
var defaultTheme=1;

function changeTheme(selectedID) {

	themeID=selectedID;
  	var objLinkThemeGlobal=document.getElementById('linkThemeGlobal');
  	var objLinkThemeIndex=document.getElementById('linkThemeIndex');
  	var objLinkThemeArticle=document.getElementById('linkThemeArticle');
  	var objLinkThemeList=document.getElementById('linkThemeList');
  	var objLinkThemeMenu=document.getElementById('linkThemeMenu');
  	
  	if(objLinkThemeMenu!=null){
  		objLinkThemeMenu.href='./styles/theme' + themeID + '/front/jqueryslidemenu.css';
  	}
  	if(objLinkThemeGlobal!=null){
  		objLinkThemeGlobal.href='./styles/theme' + themeID + '/front/blue.css';
  	}
  	if(objLinkThemeIndex!=null){
  		objLinkThemeIndex.href='/skin/' + themeID + '/style.css';
  	}
  	if(objLinkThemeArticle!=null){
  		objLinkThemeArticle.href='./styles/theme' + themeID + '/front/Article.css';
  	}
  	if(objLinkThemeList!=null){
  		objLinkThemeList.href='./styles/theme' + themeID + '/front/list.css';
  	}
  	
  	oldTheme=getThemeID();
  	document.getElementById('img_theme_'+oldTheme).src='/images/skin_'+oldTheme+'_0.jpg';
  	document.getElementById('img_theme_'+themeID).src='/images/skin_'+themeID+'_1.jpg';
  	delCookie('myHntTheme');
  	SetCookie('myHntTheme',themeID);
	//writeHeaderFlash();
	//writeBannerFlash();
}

function getThemeID(){
	var tid=getCookie('myHntTheme');
	if(tid==null || tid==''){
		tid=defaultTheme;
	}
	return tid;
}

function writeStylesheetLinks(_links){
	themeID = getThemeID();

	for (var i = 0; i < _links.length; i++) {
		var link = _links[i];
		switch (link)
		{
			case 'linkThemeGlobal':
				document.writeln("<link id='linkThemeGlobal' href='./styles/theme" + themeID + "/front/blue.css' type='text/css' rel='stylesheet' />");
				break;
			case 'linkThemeIndex':
				document.writeln("<link id='linkThemeIndex' href='/css/index_" + themeID + ".css' type='text/css' rel='stylesheet' />");
				break;
			case 'linkThemeArticle':
				document.writeln("<link id='linkThemeArticle' href='./styles/theme" + themeID + "/front/Article.css' type='text/css' rel='stylesheet' />");
				break;
			case 'linkThemeList':
				document.writeln("<link id='linkThemeList' href='./styles/theme" + themeID + "/front/list.css' type='text/css' rel='stylesheet' />");
				break;
			case 'linkThemeMenu':
				document.writeln("<link id='linkThemeMenu' href='./styles/theme" + themeID + "/front/jqueryslidemenu.css' type='text/css' rel='stylesheet' />");
				break;
		};
	}
}
function writeHeaderFlash(onload){
	themeID = getThemeID();
	var flash = '\
    <object id="HeaderFlashObject" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="1002px" height="145px">\
    <param name="allowScriptAccess" value="sameDomain"><param name="movie" value="../images/theme' + themeID + '/front/headbanner.swf"><param name="quality" value="high">\
    <param name="menu" value="false"><param name=wmode value="opaque">\
    <embed src="../images/theme' + themeID + '/front/headbanner.swf" wmode="opaque" menu="false" quality="high" width ="1002px" height="145px" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\
    </object>';
	if (onload) {
		document.write(flash);
	} else {
		jQuery("#headbanner").empty()
		if (jQuery.browser.msie && parseInt(jQuery.browser.version) > 7){
			return;
		}else{
			jQuery("#headbanner").html(flash);
		}	
	}
}

function writeBannerFlash(onload){
	themeID = getThemeID();
	var flash = '\
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="615px" height="90px">\
    <param name="allowScriptAccess" value="sameDomain"><param name="movie" value="../images/theme' + themeID + '/front/banner01.swf"><param name="quality" value="high">\
    <param name="menu" value="false"><param name=wmode value="opaque">\
    <embed src="../images/theme' + themeID + '/front/banner01.swf" wmode="opaque" menu="false" quality="high" width ="615px" height="90px" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\
    </object>';
	if (onload) {
		document.write(flash);
	} else {
		if (jQuery.browser.msie && parseInt(jQuery.browser.version) > 7)
			return;
		else
			jQuery("#dianxin-banner").empty().html(flash);
	}
}

//将主题的图片改为“选中”
window.onload = function(){
	var themeID=getThemeID();
	document.getElementById('img_theme_'+themeID).src='/images/skin_'+themeID+'_1.jpg';
	
// 图片幻灯JS,来自img_sli.js,因两个window.onload冲突，所以合并函数	
var interv=5000; //切换间隔时间
var interv2=10; //切换速速
var opac1=60; //文字背景的透明度
var source="fade_focus" //图片容器id
//获取对象
function getTag(tag,obj){if(obj==null){return document.getElementsByTagName(tag)}else{return obj.getElementsByTagName(tag)}}
function getid(id){return document.getElementById(id)};
var opac=0,j=0,t=63,num,scton=0,timer,timer2,timer3;var id=getid(source);id.removeChild(getTag("div",id)[0]);var li=getTag("li",id);var div=document.createElement("div");var title=document.createElement("div");var span=document.createElement("span");var button=document.createElement("div");button.className="button";for(var i=0;i<li.length;i++){var a=document.createElement("a");a.innerHTML=i+1;a.onclick=function(){clearTimeout(timer);clearTimeout(timer2);clearTimeout(timer3);j=parseInt(this.innerHTML)-1;scton=0;t=63;opac=0;fadeon();};a.className="b1";a.onmouseover=function(){this.className="b2"};a.onmouseout=function(){this.className="b1";sc(j)};button.appendChild(a);}
//控制透明度
function alpha(obj,n){if(document.all){obj.style.filter="alpha(opacity="+n+")";}else{obj.style.opacity=(n/100);}}
//控制焦点按钮
function sc(n){for(var i=0;i<li.length;i++){button.childNodes[i].className="b1"};button.childNodes[n].className="b2";}
title.className="num_list";title.appendChild(span);alpha(title,opac1);id.className="d1";div.className="d2";id.appendChild(div);id.appendChild(title);id.appendChild(button);
//渐显
var fadeon=function(){opac+=5;div.innerHTML=li[j].innerHTML;span.innerHTML=getTag("img",li[j])[0].alt;alpha(div,opac);if(scton==0){sc(j);num=-2;scrolltxt();scton=1};if(opac<100){timer=setTimeout(fadeon,interv2)}else{timer2=setTimeout(fadeout,interv);};}
//渐隐
var fadeout=function(){opac-=5;div.innerHTML=li[j].innerHTML;alpha(div,opac);if(scton==0){num=2;scrolltxt();scton=1};if(opac>0){timer=setTimeout(fadeout,interv2)}else{if(j<li.length-1){j++}else{j=0};fadeon()};}
//滚动文字
var scrolltxt=function(){t+=num;span.style.marginTop=t+"px";if(num<0&&t>3){timer3=setTimeout(scrolltxt,interv2)}else if(num>0&&t<62){timer3=setTimeout(scrolltxt,interv2)}else{scton=0}};
fadeon();	

}
