//随机背景音乐

//var bgmtype=1;
//var themid;
function runbgmusic(str){
	//var bgmtype=getCookie("bgmusic");
	bgmusic = new Array(6);
	bgmusic[0] = "media/bg0.mid";
	bgmusic[1] = "media/bg1.mid";
	bgmusic[2] = "media/bg2.mid";
	bgmusic[3] = "media/bg3.mid";
	bgmusic[4] = "media/bg4.mid";
	bgmusic[5] = "media/bg5.mid";
	bgmusic[6] = "media/bg6.mid";
	index = Math.floor(Math.random() * bgmusic.length);
	if(str){
		if(getCookie("bgmusic")!=0){
			$("bgm").src=bgmusic[index];
		}
		else{
			$("bgm").src="none";
		}
	}
	else{
		$("bgm").src="media/none.mid";
		setCookie("bgmusic",0)
	}
	this.mid = function(){
		//alert(bgmtype);
		if(bgmtype){
			$("bgm").src=bgmusic[index];
			bgmtype=0;
		}
		else{
			$("bgm").src="media/none.mid";
			bgmtype=1;
		}
	}
}

//显示我的信息
function ShowDialog(){
  return showModalDialog("about/about.htm", parent.dialogArguments, "dialogWidth:400px;dialogHeight:170px;help:no;scroll:no;status:no");
}

function SaveAs(href,name){   //下载
	var a = window.open(href)
	a.document.execCommand("Saveas",true,name)
	a.window.close()
	return false
}

//TOP广告
function divdown(){
	//var n=$("ad_topop").style.marginTop.replace("px","");	
	//n++;
	//$("ad_topop").style.marginTop = n+"px";
	//if(n <= 0){
	//	var divMove=setTimeout("divdown()",0);
	//}
	//else{
	//	var divMove=setTimeout("divup()",6000);
	//}
}
function divup(){
	var n=$("ad_topop").style.marginTop.replace("px","");
	n--;
	$("ad_topop").style.marginTop = n+"px";
	if(n >= -60){
		var divMove=setTimeout("divup()",0);
	}
	else{
		clearTimeout(divMove);
	}
}

//留言提示
var rate = 20;
var elmH = 0;
var elmS = 128;
var elmV = 255;
var TimerID="";
function ChangeColor(){
	$("gbooktip").style.borderColor = makeColor();
}

function makeColor(){
	if(elmS == 0) {lmR = elmV;elmG = elmV;elmB = elmV;}
	else{
		t1 = elmV;t2 = (255 - elmS) * elmV / 255;t3 = elmH % 60;t3 = (t1 - t2) * t3 / 60;
		if(elmH < 60) {elmR = t1;elmB = t2;elmG = t2 + t3;}
		else{
			if(elmH < 120) {elmG = t1;elmB = t2;elmR = t1 - t3;}
			else{
				if(elmH < 180) {elmG = t1;elmR = t2;elmB = t2 + t3;}
				else{
					if(elmH < 240) {elmB = t1;elmR = t2;elmG = t1 - t3;}
					else{
						if(elmH < 300) {elmB = t1;elmG = t2;elmR = t2 + t3;}
						else{
							if(elmH < 360) {elmR = t1;elmG = t2;elmB = t1 - t3;}
							else{
								elmR = 0;elmG = 0;elmB = 0;
							}
						}
					}
				}
			}
		}
	}
	elmR = Math.floor(elmR);
	elmG = Math.floor(elmG);
	elmB = Math.floor(elmB);
	clrRGB = '#' + elmR.toString(16) + elmG.toString(16) + elmB.toString(16);elmH = elmH + rate;if (elmH >= 360)elmH = 0;return clrRGB;
}

function showGbookTip(){
	$("gbooktip").style.display="";
	$("gbooktip").filters.alpha.opacity+=10;
	if($("gbooktip").filters.alpha.opacity < 100){
		setTimeout("showGbookTip()",100);
	}
}
function hiddenGbookTip(){
	$("gbooktip").filters.alpha.opacity-=10;
	if($("gbooktip").filters.alpha.opacity > 0){
		setTimeout("hiddenGbookTip()",100);
	}
	else{
		$("gbooktip").style.display="none";
	}
}

//图片加载提示
function loadPic(){
	eval("window.imgtype=document.getElementById(\"adpic\");");
  //imgtype.src="img/serverup.jpg";
  if(imgtype!=null){
   if(!imgtype.complete) return;
   $("picLoading").style.display="none";
   imgtype.style.display="";
   setTimeout("hiddenGbookTip()",10000);
   clearInterval(picload);
 }
}
//COOKIE
function checkcookie(){
	if(getCookie("KFtype")!="ok" && getCookie("KFtype")!="no"){
		if(getCookie("KFtype")=="close"){
			onno();
		}
	}
	else{
		onno();
	}

	if(getCookie("topop") != "showed"){
		$("ad_topop").style.display="";
		divdown();
	}
}

function $(id){
	return document.getElementById(id);
}

function bodyonload(){
	LoadImages("images/a_10_03_a.gif","images/a_10_05_a.gif","images/a_10_07_a.gif");
	runbgmusic(true);
	$("loadiv").style.display="none";
	initAd();
	checkcookie();
	//setTimeout("showGbookTip()",2000);
}