
var NUMBER_OF_REPETITIONS = 40;
var g_oTimer = null;
var xmlHttp = false;
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MenuChange(value){
var OnClass="selectedTranType";
var OffClass="tranType";
var OffClass1="tranType_left";
	if(value=='hot'){
		document.getElementById("Smenu1").className=OnClass;
		document.getElementById("Hotmessage").style.display='block';
		document.getElementById("TextMessage").style.display='none';
		document.getElementById("TapeMessage").style.display='none';
		document.getElementById("messageType").value=0;
		}
		else{document.getElementById("Smenu1").className=OffClass1;}
	if(value=='zdy'){
		document.getElementById("Smenu2").className=OnClass;
		document.getElementById("Hotmessage").style.display='none';
		document.getElementById("TextMessage").style.display='block';
		document.getElementById("TapeMessage").style.display='none';
		document.getElementById("messageType").value=1;
		}
		else{
			if(value=='ly'){
			document.getElementById("Smenu2").className=OffClass1;
			}else{document.getElementById("Smenu2").className=OffClass;}
			}	
	if(value=='ly'){
		document.getElementById("Smenu3").className=OnClass;
		document.getElementById("Hotmessage").style.display='none';
		document.getElementById("TextMessage").style.display='none';
		document.getElementById("TapeMessage").style.display='block';
		document.getElementById("messageType").value=2;
		}
		else{document.getElementById("Smenu3").className=OffClass;}		
}




//开启遮罩函数
function startLongProcess(){  
  //document.getElementById("divhide_content").innerHTML= "";
  document.getElementById("divhide").style.display="block";
  document.getElementById("divhide_title").innerHTML= "选择其他歌曲";
  document.getElementById("divhide_content").innerHTML= "<IFRAME ID=\"changemusic\" frameborder=\"0\" width=\"100%\" height=\"455px\" FRAMEBORDER=0 SCROLLING=NO SRC=\"http://www.afu365.com/subject/musicList.asp\"></IFRAME>"
  document.getElementById("divhide").style.width="700px";
  document.getElementById("divhide").style.height="400px";
   makediv("divModal","#fafafa","wait",75);  
   resizeModal();
  window.onresize = resizeModal;
  document.getElementById("divhide_title").focus();
}

//关闭遮罩函数
function stopLongProcess(){
	document.getElementById("divhide_content").innerHTML="";
    document.getElementById("divhide").style.display="none";
   if (g_oTimer != null)
   {
      window.clearTimeout(g_oTimer);
      g_oTimer = null;
   }
    document.getElementById("divModal").style.display="none";
    document.getElementById("divModal").style.width ="0px"
    document.getElementById("divModal").style.height ="0px"
   	window.onresize = null;
   	window.onbeforeunload = null;
	document.getElementById("divhide_content").innerHTML= "";
}
//重至遮罩层宽和高
function resizeModal(){
    document.getElementById("divModal").style.width = document.body.scrollWidth;
   	document.getElementById("divModal").style.height = document.body.scrollHeight+10;
	document.getElementById("divhide").style.left=(parseInt(screen.width)-parseInt(document.getElementById("divhide").style.width))/2-window.screenLeft;
	document.getElementById("divhide").style.top=(parseInt(screen.height)-parseInt(document.getElementById("divhide").style.height))/2-window.screenTop;
	document.getElementById("divModal").style.display="block"; 
	
}
//输出一个层
function makediv(myid,mycolor,mycursor,myopacity){
 var bb=1;
 if(!document.getElementById(myid)){ 
 if(bb==2)
 {
 window.parent.document.getElementsByTagName("body")[0].innerHTML+="<div id=\""+myid+"\" style=\" "/*BACKGROUND-COLOR: "+mycolor+";-moz-opacity:0.8;"*/+"width:100%;height:100%; LEFT: 0px; POSITION:absolute; TOP: 0px; Z-INDEX: 30;\" onclick=\"window.event.cancelBubble=true;window.event.returnValue=false;\"><img src=\"http://www.afu365.com/images/place.gif\" width=\"100%\" height=\"100%\"></DIV>";
 }
 else
 {
  window.parent.document.getElementsByTagName("body")[0].innerHTML+="<div id=\""+myid+"\" style=\"BACKGROUND-COLOR: "+mycolor+"; FILTER: alpha(opacity="+myopacity+"); LEFT: 0px; POSITION:absolute; TOP: 0px; Z-INDEX: 30;cursor:"+mycursor+";\" onclick=\"window.event.cancelBubble=true;window.event.returnValue=false;\"><IFRAME id=\"frTest\" style=\"filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';visibility:inherit;width:100%;height:10000px;position:absolute;top:0;left:0;\" frameborder=0 scrolling=no marginwidth=0 src=\"http://www.afu365.com/divzz.shtml\" marginheight=0></iframe></DIV>";
 }
 }
}
//试听
function MessageProcess(no,id){  
  document.getElementById("divhide").style.display="block";
  document.getElementById("divhide_title").innerHTML= "试听";
  document.getElementById("divhide_content").innerHTML= "<IFRAME ID=\"changemusic\" frameborder=\"0\" width=\"100%\" FRAMEBORDER=0 SCROLLING=NO SRC=\"http://www.afu365.com/subject/tryMessage.asp?no="+no+"&id="+id+"\"></IFRAME>"
  document.getElementById("divhide").style.width="400px";
  document.getElementById("divhide").style.height="160px";
   makediv("divModal","#fafafa","wait",75);  
   resizeModal();
  window.onresize = resizeModal;
  document.getElementById("divhide_title").focus();
}
function readCookie(name){
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0){ 
    offset = document.cookie.indexOf(search);
    if (offset != -1){ 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function radiovalue(name){
  var obj=document.getElementsByName(name);
  for (i=0;i<obj.length;i++)
     {
         if (obj[i].checked==true){var radiotext=obj[i].value;}
  } 
  return radiotext;  
}

//提交验证
function nextstep(){
	 var nickName=document.getElementById("textfield").value;
	 var messageType=document.getElementById("messageType").value;
	 var message
	 if(messageType==0){
		 message=radiovalue("Meradio");
		 }
	 else{
		 message=document.getElementById("messageurl").value;
	 }
	 if(nickName.length<1||nickName=="请输入您的名字"){
	 alert("请输入您的名字！")
	 return false;
	 }
	 if(message.length<1){
	 alert("请选择您要发送的留言！")
	 return false;
	 }
}



function soundcreate(){
	closefile();
	var text=document.getElementById("soundtext").value;
	var speed="";
	var playmode;
	for (i=0;i<document.all.vocietype.length;i++){
         if (document.all.vocietype[i].checked){
			 playmode = document.all.vocietype[i].value;}
        }
	if(playmode==0){
		var speed=document.getElementById("select_1").value;
	    var url="http://www.afu365.com/afu_asp/create.asp?text="+text+"&playmode="+playmode+"&speed="+speed;
	}
	else if(playmode==1){
		var speed=document.getElementById("select_2").value;
	    var url="http://www.afu365.com/afu_asp/create.asp?text="+text+"&playmode="+playmode+"&speed="+speed;
	}
	else if(playmode==2){
		var speed=document.getElementById("select_3").value;
	    var url="http://www.afu365.com/afu_asp/create.asp?text="+text+speed;
	}
	xmlHttp.open("GET", url+"&fixed=0", true);
	xmlHttp.onreadystatechange =function (){
		if (xmlHttp.readyState < 4)
		    {trymusic.innerHTML="<img src=\"http://www.afu365.com/images/spinner.gif\" height=\"15\" width=\"15\" align=\"absmiddle\" />";}	
        if (xmlHttp.readyState == 4)
            {
		    response =unescape(xmlHttp.responseText);
			if (response=="false")
			  {trymusic.innerHTML="生成失败!请重试"}
			 else 
			 {
				trymusic.innerHTML="";
				openfile(response,11)
			  }
			}
		}
    xmlHttp.send(null);
}
function message_checked(){
	closefile();
	var text=document.getElementById("soundtext").value;
	if(text=="请输入您的祝福文字,我们将会把文字祝福转换为语音祝福,为您的朋友送出!赶紧试试吧!(限制80个字)")
	{
		document.getElementById("textwarm").innerHTML="<img src=\"http://www.afu365.com/images/red_error.gif\" height=\"15\" width=\"15\" align=\"absmiddle\" />请先输入祝福语！";
		return false;
		}
	else
	{
		document.getElementById("textwarm").innerHTML="";
	}
	var speed="";
	var playmode;
	     for (i=0;i<document.all.vocietype.length;i++)
       {
         if (document.all.vocietype[i].checked)
            {playmode = document.all.vocietype[i].value;}
        }
	if(playmode==0)
	{
		var speed=document.getElementById("select_1").value;
	    var url="http://www.afu365.com/afu_asp/create.asp?text="+text+"&playmode="+playmode+"&speed="+speed;
	}
	else if(playmode==1)
	{
		var speed=document.getElementById("select_2").value;
	    var url="http://www.afu365.com/afu_asp/create.asp?text="+text+"&playmode="+playmode+"&speed="+speed;
	}
	else if(playmode==2)
	{
		var speed=document.getElementById("select_3").value;
	    var url="http://www.afu365.com/afu_asp/create.asp?text="+text+speed;
	}
	xmlHttp.open("GET", url+"&fixed=2", true);
	xmlHttp.onreadystatechange =function (){
		if (xmlHttp.readyState < 4)
		    {trymusic.innerHTML="<img src=\"http://www.afu365.com/images/spinner.gif\" height=\"15\" width=\"15\" align=\"absmiddle\" />";}	
        if (xmlHttp.readyState == 4)
            {
		    response =unescape(xmlHttp.responseText);
			if (response=="false")
			  {trymusic.innerHTML="生成失败!请重试"}
			 else 
			 {
				trymusic.innerHTML="";
				document.getElementById("messageurl").value=response;
				document.getElementById("messagetext").value=text;
				alert("留言提交成功！")
			  }
			}
		}
    xmlHttp.send(null);
}

function UrlPost(value){
	var nick=document.getElementById("textfield").value;	
	switch  (value)  
	{  
			   case  1:  
					window.location.href='default.shtml?nick='+nick;
					break;  
			   case  2:  
					window.location.href='toparent.shtml?nick='+nick;
					break;  
			   case  3:  
					window.location.href='tofriend.shtml?nick='+nick;
					break;  
			   case  4:  
					window.location.href='toclient.shtml?nick='+nick;
					break;  
			   case  5:  
					window.location.href='toother.shtml?nick='+nick;
					break;  
			   case  6:  
					window.location.href='tobrith.shtml?nick='+nick;
					break;  
			 default:  return false; 
	}
}

function toPage(value){
	var nick=document.getElementById("textfield").value;	
	switch  (value)  
	{  
			   case  1:  
					window.location.href='toother.shtml?nick='+nick;
					break;  
			   case  2:  
					window.location.href='toother_2.shtml?nick='+nick;
					break;  
			   case  3:  
					window.location.href='toother_3.shtml?nick='+nick;
					break;  
			   case  4:  
					window.location.href='toother_4.shtml?nick='+nick;
					break;  
			   case  5:  
					window.location.href='toother_5.shtml?nick='+nick;
					break;  
			   case  6:  
					window.location.href='toother_6.shtml?nick='+nick;
					break; 
			   case  7:  
					window.location.href='toother_7.shtml?nick='+nick;
					break; 		
			   case  8:  
					window.location.href='toother_8.shtml?nick='+nick;
					break; 		
			 default:  return false; 
	}
}


function   QueryString(sName)   
  {   
  var sSource=String(window.document.location);   
  var sReturn= "";   
  var sQUS="?";   
  var sAMP="&";   
  var sEQ="=";   
  var iPos;   
  iPos =sSource.indexOf(sQUS);   
  var strQuery=sSource.substr(iPos,sSource.length-iPos);   
  var strLCQuery=strQuery.toLowerCase();   
  var strLCName=sName.toLowerCase();   
  iPos=strLCQuery.indexOf(sQUS+strLCName+sEQ);   
  if (iPos==-1)   
   {
    iPos=strLCQuery.indexOf(sAMP+strLCName+sEQ);   
      if(iPos==-1)   
      return  "";
   }   
  sReturn=strQuery.substr(iPos+sName.length+2,strQuery.length-(iPos+sName.length+2));   
  var iPosAMP=sReturn.indexOf(sAMP);   
  if(iPosAMP==-1)   
  return sReturn;   
  else{sReturn=sReturn.substr(0,iPosAMP);}   
  return sReturn;   
  }  


function getNick(){
	var nick=QueryString("nick")
	var nickthis=document.getElementById("textfield").value
	if(nick.length<1){nick="请输入您的名字"}
	if(nickthis.length<1){
	document.getElementById("textfield").value=nick;}
}