// JavaScript Document
function trim(str){ //删除左右两端的空格
　　     return str.replace(/(^\s*)|(\s*$)/g, "");
　　 }
　　 function ltrim(str){ //删除左边的空格
　　     return str.replace(/(^\s*)/g,"");
　　 }
　　 function rtrim(str){ //删除右边的空格
　　     return str.replace(/(\s*$)/g,"");
　　 }

function getXmlhttp(){
	var xmlhttp;
	try{
			xmlhttp=new ActiveXObject('Msxml2.XMLHTTP');
		}catch(e){
			try{
				xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
			}catch(e){
				try{
					xmlhttp=new XMLHttpRequest();
				}catch(e){}
			}
		}
		return xmlhttp;
}
function getValidateCode(){
	var theRndNum=Math.random();
	return(theRndNum.toString().substring(theRndNum.toString().length-4,theRndNum.toString().length));
}
function showSingerDiv(theNum){
for (var i=1;i<6;i++){
	if (theNum==0){
		document.getElementById("singer_type_"+i).style.display="block";
	}else if (i==theNum){
		document.getElementById("singer_type_"+i).style.display="block";
	}else{
		document.getElementById("singer_type_"+i).style.display="none";
	}
}

}
function showSearchDiv(theDiv){
	if (theDiv=="pic"){
		document.getElementById("search_pic").style.display="block";
		document.getElementById("search_gtp").style.display="none";
		document.getElementById("search_txt").style.display="none";
	}else if (theDiv=="gtp"){
		document.getElementById("search_pic").style.display="none";
		document.getElementById("search_gtp").style.display="block";
		document.getElementById("search_txt").style.display="none";
	}else if (theDiv=="txt"){
		document.getElementById("search_pic").style.display="none";
		document.getElementById("search_gtp").style.display="none";
		document.getElementById("search_txt").style.display="block";
	}else{
		document.getElementById("search_pic").style.display="block";
		document.getElementById("search_gtp").style.display="block";
		document.getElementById("search_txt").style.display="block";
	}
}
function submit_Pro_Comment(){
	if (document.getElementById("validatecode").value!=document.getElementById("validatecode1").innerHTML){
		alert("验证码输入有误!");
	}else if (document.getElementById("form_comment").value.length<5){
		alert("输入内容不得少于5字节!");
	}else{
		document.getElementById("form1").submit();
	}
}
function submit_Comment(content,gtptype,gtp_id){
	var xmlhttp;
	if (document.getElementById("validatecode").value!=document.getElementById("validatecode1").innerHTML){
		alert("验证码输入有误!");
	}else if (document.getElementById("form_comment").value.length<5){
		alert("输入内容不得少于5字节!");
	}else{
		/*Ajax*/
		/*xmlhttp=getXmlhttp();		
		xmlhttp.open ("get","../ajax_comment.asp?comment="+escape(content)+"&type="+escape(gtptype)+"&gtp_id="+gtp_id);	
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4){
				if (xmlhttp.status==200){
					showComment(xmlhttp.responseText);
				}
				else{
					alert("网络连接失败!")
				}
			}
		}
		xmlhttp.send(null);*/
		/*非Ajax*/
		window.open ("../submit_comment.asp?comment="+escape(content)+"&type="+escape(gtptype)+"&gtp_id="+gtp_id);
		showComment("done");
	}
}
function submit_Comment1(content,gtptype,gtp_id){
	var xmlhttp;
	if (document.getElementById("validatecode").value!=document.getElementById("validatecode1").innerHTML){
		alert("验证码输入有误!");
	}else if (document.getElementById("form_comment").value.length<5){
		alert("输入内容不得少于5字节!");
	}else{
		/*Ajax*/
		/*xmlhttp=getXmlhttp();		
		xmlhttp.open ("get","../ajax_comment.asp?comment="+escape(content)+"&type="+escape(gtptype)+"&gtp_id="+gtp_id);	
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4){
				if (xmlhttp.status==200){
					showComment(xmlhttp.responseText);
				}
				else{
					alert("网络连接失败!")
				}
			}
		}
		xmlhttp.send(null);*/
		/*非Ajax*/
		window.open ("submit_comment.asp?comment="+escape(content)+"&type="+escape(gtptype)+"&gtp_id="+gtp_id);
		showComment("done");
	}
}
function showComment(theStr){
	var theMsgContent;
	var date;
	if (theStr=="done"){
	var today = new Date();  //获取系统日期，即Sat Jul 29 08:24:48 UTC+0800 2006
	date=(today.getYear())+"-"+(today.getMonth()+1)+"-"+today.getDate(); 
	var yy = today.getYear(); //截取年，即2006 
	var mm = today.getMonth(); //截取月，即07 
	var dd = today.getDay(); //截取日，即29 
	var hh = today.getHours(); //截取小时，即8 
	var mm = today.getMinutes(); //截取分钟，即34 
	var ss = today.getTime() % 60000; //获取时间，因为系统中时间是以毫秒计算的， 
	ss = (ss - (ss % 1000)) / 1000; //然后，将得到的毫秒数再处理成秒 
	var clock = hh+':'; //将得到的各个部分连接成一个日期时间 
	if (mm < 10) clock += '0'; //字符串 
	clock += mm+':';  
	if (ss < 10) clock += '0';  
	clock += ss; 
	theMsgContent="<a id='current_comment' name='current_comment'></a><div class='graya12' id='comment_title1' align='left'><span style='float:left; width:150px;'><img src='../images/icon_01.gif' width='11' height='11' />"+document.getElementById("localip").value+"</span><span style='float:left; width:150px;'>"+date+" "+clock+"</span>  </div><div class='graya12' id='comment_detail' align='left'><pre>"+document.getElementById("form_comment").value+"</pre></div>";
	document.getElementById("comment_panel").innerHTML=theMsgContent+document.getElementById("comment_panel").innerHTML;
	document.getElementById("validatecode").value="";
	document.getElementById("form_comment").value="";
	location.href="#current_comment";
	}
}
function showType(theNum){
	if (document.getElementById("type1_"+theNum).style.display=="none"){
		document.getElementById("type1_"+theNum).style.display="block";
	}else if (document.getElementById("type1_"+theNum).style.display=="block"){
		document.getElementById("type1_"+theNum).style.display="none";
	}
}
function SetProHeight(obj) 
{ 
 var search_pic=obj; 
 if (document.getElementById) 
 { 
  if (search_pic && !window.opera) 
  { 
   if (search_pic.contentDocument && search_pic.contentDocument.body.offsetHeight)  

    search_pic.height = search_pic.contentDocument.body.offsetHeight;  
   else if(search_pic.Document && search_pic.Document.body.scrollHeight) 
    search_pic.height = search_pic.Document.body.scrollHeight; 
  } 
 } 
} 
function doZoom(size){ 
document.getElementById("study_content1").style.fontSize=size+"px"; 
} 
function checkUser(){
	var kk1,kk2,kk3,kk4;
	var len=document.getElementById("email").value.length;
	if (document.getElementById("yueshou").value.length<3 | document.getElementById("yueshou").value.length>18){
		alert("注册乐手名长度限制为3-18字节");
		document.getElementById("yueshou").focus();
		document.getElementById("yueshou").style.backgroundColor="#FF9999";
		return false;
	}else{
		document.getElementById("yueshou").style.backgroundColor="#EAEAEA";
	}
	if (document.getElementById("password1").value.length<6){
		alert("密码至少6位");
		document.getElementById("password1").focus();
		document.getElementById("password1").style.backgroundColor="#FF9999";
		return false;
	}else{
		document.getElementById("password1").style.backgroundColor="#EAEAEA";
	}
	if (document.getElementById("password1").value!=document.getElementById("password2").value){
		alert("两次密码输入不正确");
		document.getElementById("password1").focus();
		document.getElementById("password1").style.backgroundColor="#FF9999";
		document.getElementById("password2").style.backgroundColor="#FF9999";
		return false;
	}else{
		document.getElementById("password1").style.backgroundColor="#EAEAEA";
		document.getElementById("password2").style.backgroundColor="#EAEAEA";
	}
	kk1=document.getElementById("email").value.indexOf("@");
	kk2=document.getElementById("email").value.indexOf(".");
	kk3=document.getElementById("email").value.lastIndexOf("@");
	kk4=document.getElementById("email").value.lastIndexOf(".");
	if((kk1<=0)||(kk2<=0)||(kk1==len-1)||(kk2==len-1)){
		alert("请正确输入Email地址!");
		document.getElementById("email").focus();
		document.getElementById("email").style.backgroundColor="#FF9999";
		document.getElementById("email").style.backgroundColor="#FF9999";
		return false;
	}else if((kk1!=kk3)||(kk1==kk2+1)||(kk2==kk1+1)||(kk3>kk4)){
		alert("请正确输入Email地址!");
		document.getElementById("email").focus();
		document.getElementById("email").style.backgroundColor="#FF9999";
		document.getElementById("email").style.backgroundColor="#FF9999";
		return false;
	}else{
		document.getElementById("email").style.backgroundColor="#EAEAEA";
		document.getElementById("email").style.backgroundColor="#EAEAEA";
	}
	if (document.getElementById("validate").value!=document.getElementById("validate1").value){
		alert("验证码输入不正确");
		document.getElementById("validate").focus();
		document.getElementById("validate").style.backgroundColor="#FF9999";
		return false;
	}else{
		document.getElementById("validate").style.backgroundColor="#EAEAEA";
	}
	document.getElementById("form_reg").submit();
}
function checkOrderLogin(){

	if (document.getElementById("username").value.length<3 | document.getElementById("username").value.length>18){
		alert("请正确输入乐手名");
		document.getElementById("username").focus();
		document.getElementById("username").style.backgroundColor="#FF9999";
		return false;
	}else{
		document.getElementById("username").style.backgroundColor="#EAEAEA";
	}
	if (document.getElementById("password").value.length<6){
		alert("请正确输入密码");
		document.getElementById("password").focus();
		document.getElementById("password").style.backgroundColor="#FF9999";
		return false;
	}else{
		document.getElementById("password").style.backgroundColor="#EAEAEA";
	}
	document.getElementById("form_reg").submit();
}

function showChk(theAnswer){
	if (theAnswer=="Yes"){
		document.getElementById("chk_msg").innerHTML="<img src='http://www.52jt.net/images/check_error.gif' /><span class='reda12'>乐手名已存在!</span>";
	}else if (theAnswer=="No"){
		document.getElementById("chk_msg").innerHTML="<img src='http://www.52jt.net/images/check_right.gif' />";
	}
}
function chkUsername(){	
	var xmlhttp;
	xmlhttp=getXmlhttp();
	xmlhttp.open ("get","reg_chk.asp?username="+document.getElementById("yueshou").value);																													  	xmlhttp.onreadystatechange=function(){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			showChk(xmlhttp.responseText);
		}
		else{
			alert("网络连接失败!")
		}
	}
	}
	xmlhttp.send(null);
}
function saveMobile(){	
	var xmlhttp;
	xmlhttp=getXmlhttp();
	xmlhttp.open ("get","ajax_mobile.asp?mobile="+document.getElementById("mobile").value);																													
	xmlhttp.send(null);
}
function chkOrderUsername(){	
	var xmlhttp;
	xmlhttp=getXmlhttp();
	xmlhttp.open ("get","../reg_chk.asp?username="+document.getElementById("yueshou").value);																													  	xmlhttp.onreadystatechange=function(){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			showChk(xmlhttp.responseText);
		}
		else{
			alert("网络连接失败!")
		}
	}
	}
	xmlhttp.send(null);
}
function isEmail(strEmail)
{
    if (strEmail == null) return false;
    strEmail += "";
    
    //检查Email的长度
    var iLen;
    iLen = strEmail.length;
    //alert("iLen: " + iLen);
    if (iLen < 5)
    {
        alert("Email格式长度不足");
        return false;
    }

    //检查Email的字符组成
    var strRngAll;
    var strRng1, strRng2, strRng3, strRng4;

    strRng1    = "0123456789";
    strRng2    = "abcdefghijklmnopqrstuvwxyz";
    strRng3    = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    strRng4    = "_@.";
    strRngAll    = strRng1 + strRng2 + strRng3 + strRng4;
    
    var iCount;
    var iChrIdx;

    //-- 是否含有非法字符
    for (iCount = 0; iCount < iLen; iCount ++)
    {
        iChrIdx = strRngAll.indexOf(strEmail.charAt(iCount));
        if (iChrIdx == -1)
        {
            alert("invalid char ..\niChrIdx: " + iChrIdx + "\nchar: " + strEmail.charAt(iCount));
            return false;
        }
    }
    
   
    //检查@字符
    var iAtIdx, iAtIdx1;
    
    iAtIdx        = strEmail.indexOf("@");
    iAtIdx1    = strEmail.lastIndexOf("@");
    //alert("iAtIdx: " + iAtIdx + "\niAtIdx1: " + iAtIdx1);

    //-- 是否存在@字符
    if (iAtIdx < 0)
    {
        alert("没有@符号");
        return false;
    }
    
    //-- 是否有2个以上的@字符
    if (iAtIdx != iAtIdx1)
    {
        alert("@符号多于2个");
        return false;
    }
    
    //-- 是否@字符在首位上
    if (iAtIdx == 0)
    {
        alert("@符号位置不正确");
        return false;
    }
    
    //检查.字符
    var iDotIdx, iDotIdx1;
    
    iDotIdx    = strEmail.indexOf(".");
    iDotIdx1    = strEmail.lastIndexOf(".");
    //alert("iDotIdx: " + iDotIdx + "\niDotIdx1: " + iDotIdx1);
    
    //-- 是否存在.字符
    if (iDotIdx < 0)
    {
        alert("没有.");
        return false;
    }
    
    //-- 是否@字符在末位上
    if (iDotIdx1 == iLen - 1) 
    {
        alert(".位置不正确");
        return false;
    }
    return true;
}

function isNumber(name) {
	if(name.length == 0) return false;
	for(i = 0; i < name.length; i++) { 
		if (name.charAt(i) < "0" || name.charAt(i) > "9") return false; 
	} return true; 
}

function submitCOD(){
	document.getElementById("text_shr").style.display="none"; 
	document.getElementById("text_area").style.display="none"; 
	document.getElementById("text_dizhi").style.display="none"; 
	document.getElementById("text_tel").style.display="none"; 
	if(document.getElementById("shr").value.length<2 | document.getElementById("shr").value.length>10) {
		document.getElementById("text_shr").style.display="block"; 
		document.getElementById("shr").focus(); 
		return false; 
	}
	else if(document.getElementById("PerRes_HuKou_Lst1").value==0) {
		document.getElementById("text_area").style.display="block"; 
		document.getElementById("PerRes_HuKou_Lst1").focus(); 
		return false; 
	}
	else if(document.getElementById("dizhi").value.length<3) {
		document.getElementById("text_dizhi").style.display="block"; 
		document.getElementById("dizhi").focus(); 
		return false; 
	}
	else if(document.getElementById("tel").value.length<3) {
		document.getElementById("text_tel").style.display="block"; 
		document.getElementById("tel").focus(); 
		return false; 
	}
	document.getElementById("form1").submit();
}

function checkAddress() {
	document.getElementById("text_shouhuoren").style.display="none"; 
	document.getElementById("text_area").style.display="none"; 
	document.getElementById("text_address").style.display="none"; 
	document.getElementById("text_mobile").style.display="none"; 
	document.getElementById("text_phone").style.display="none"; 
	
	if(document.getElementById("shouhuoren").value.length<2 | document.getElementById("shouhuoren").value.length>10) {
		document.getElementById("text_shouhuoren").style.display="block"; 
		document.getElementById("shouhuoren").focus(); 
		return false; 
	}
	else if(document.getElementById("PerRes_HuKou_Lst1").value==0) {
		document.getElementById("text_area").style.display="block"; 
		document.getElementById("PerRes_HuKou_Lst1").focus(); 
		return false; 
	}
	else if(document.getElementById("address").value.length<3) {
		document.getElementById("text_address").style.display="block"; 
		document.getElementById("address").focus(); 
		return false; 
	}
	else if(isNumber(document.getElementById("mobile").value)==false) {
		document.getElementById("text_mobile").style.display="block"; 
		document.getElementById("mobile").focus(); 
		return false; 
	}
	else if(document.getElementById("phone").value.length<3) {
		document.getElementById("text_phone").style.display="block"; 
		document.getElementById("phone").focus(); 
		return false; 
	}
	document.getElementById("form1").submit();
}

function checkPay() {
	document.getElementById("text_pay").style.display="none"; 
	var thePayMode;
	var chkObjs = document.getElementsByName("pay_mode");
	for(var i=0;i<chkObjs.length;i++){
		if(chkObjs[i].checked){
			thePayMode=chkObjs[i].value;
		}
	}
	if(thePayMode==null){
		document.getElementById("text_pay").style.display="block"; 
	}
	document.getElementById("form1").submit();
}

function checkBankSubmit() {
	cflag=false;
	
	for(var i=0;i<document.getElementsByName("bank_type").length;i++) {
		if(document.getElementsByName("bank_type")[i].checked==true){
			cflag=true ;
		} 
	}
   
	if (cflag==false) {
		document.getElementById("text_banktype").style.display="block"; 
   }
   else if(cflag==true){
		document.getElementById("formbank").submit();
	}
   
}
function paraSelect(theParaNum,theTotalPara,theParaValue){
		document.getElementById("msg_para").style.display="none";
		document.getElementById("div_para").style.borderColor="#FFFFFF";
		for(i = 0; i <= theTotalPara; i++){
			document.getElementById("product_para"+i).style.borderColor="#CCCCCC"; 
			document.getElementById("product_para"+i).style.color="#333333"; 
		}
			document.getElementById("product_para"+theParaNum).style.borderColor="#FF0000";
			document.getElementById("product_para"+theParaNum).style.color="#FF0000";
			document.getElementById("product_para").value=theParaValue;
}
function checkProductMsg(){
	document.getElementById("msg_title").style.display="none"; 
	document.getElementById("msg_content").style.display="none"; 
	if (document.getElementById("title").value.length<5){
		document.getElementById("msg_title").style.display="block";
		document.getElementById("title").focus();
		return false; 
	}else if (document.getElementById("content").value.length<16){
		document.getElementById("msg_content").style.display="block";
		document.getElementById("content").focus();
		return false; 
	}else{
		document.getElementById("form1").submit();
	}
}

function submitEmailRecord()
{
	if (isEmail(document.getElementById("email_input").value)==true){
		document.getElementById("form_email").submit();
	}
	
}
function changeExpressPrice(){
	document.getElementById("msg_express_price").innerHTML=document.getElementById("express_price").value;
}
