$(document).ready(function(){
	//注册页面的提交
	$('#hcregsubmit').click(function(){
			if ($("#txtarg2").val()=="2"){
				submitloginform();
			}else{
			   submitdata();
               }
			return false;
            
	 });
	//注册页面的reset 
	$('#hcregreset').click(function(){
		location.href="index-"+$("#txtlangsnum").val()+".htm";
	 });
     
	//在线留言提交
	$('#onlinesubmit').click(function(){
        if ($('#txt_email').val()==""){
            alert("Email必须填写！");
            $('#txt_email').focus();
            return false;
        }
        if ($('#txt_content').val()==""){
            alert("请填写留言内容！");
            $('#txt_content').focus();
            return false;
        }
        if ($('#auth').val()==""){
            alert("请填写校验码！");
            $('#auth').focus();
            return false;
        }        
	   if (chkemail($("#txt_email").val())==false){
				   alert("Email格式不正确！");
					$("#txt_email").focus();
					return false;
				   }        
	    document.hconline.submit();
    	 });
	
	
});

function submitdata(){
	if ($('#email').val()==""){
		alert("Email必须填写！");
		$('#email').focus();
		return false;
	}
	if ($('#auth').val()==""){
		alert("请填写校验码！");
		$('#auth').focus();
		return false;
	}	
	if ($('#pwd').val()==""){
		alert("请输入密码！");
		$('#pwd').focus();
		return false;
	}		
	if ($('#confirmpwd').val()==""){
		alert("请输入确认密码！");
		$('#confirmpwd').focus();
		return false;
	}	
	if ($('#pwd').val()!=$('#confirmpwd').val()){
					   alert("两次输入的密码不相同！");
						$("#confirmpwd").focus();
						return false;	
		}

   //*****************************************************************************************
   //vertify Email 
   //*****************************************************************************************
   if (chkemail($("#txt_email").val())==false){
				   alert("Email格式不正确！");
					$("#txt_email").focus();
					return false;
				   }
 	document.hcreg.submit();
	
}

function submitloginform(){


	if ($('#email').val()==""){
		alert("Email必须填写！");
		$('#email').focus();
		return false;
	}
	if ($('#auth').val()==""){
		alert("请填写校验码！");
		$('#auth').focus();
		return false;
	}	
	if ($('#pwd').val()==""){
		alert("请输入密码！");
		$('#pwd').focus();
		return false;
	}		
	
   if (chkemail($("#email").val())==false){
				   alert("Email格式不正确！");
					$("#txt_email").focus();
					return false;
				   }
 	document.hcreg.submit();
	
}


function chkemail(i){
 d= i.match(/^\S+@\S+\.\S+$/);
 if(!d||!i)return false;
 return true;
} 

function showslide(){
			//定义左联图片的所在位置及其链接目标的地址
			var leftsrc = "left.gif";
			var leftlink = "#";
			//定义右联图片的所在位置及其链接目标的地址
			var rightsrc =  "right.gif";
			var rightlink = "#";
			//定义“关闭”按钮图片的所在位置
			var closesrc ="/images/icon_list_close.gif";
			////  以下代码无需改动  ////
			lastScrollY=0;
			
	str_html="<div style=\"border-style:groove; border-width:thin; border-color:#000000 ; width:150px\" >";
	str_html=str_html+"<div style=\"background-color:#6699CC; width:150px; font-size:10px; text-align:center\">HOPCOM在线客服<div style=\"float:right;vertical-align:middle\"  onclick=\"document.getElementById('dy2').style.display = 'none'; document.getElementById('dy2').style.display = 'none';\" style='text-align:center;'><img src=\" + closesrc +\" /></div></div>";
    str_html=str_html+"<div style=\"font-weight:bold; font-size:10px; text-align:center\">服务热线</div>";
    str_html=str_html+"<div style=\"text-align:center;\">0755-26453924</div>";
    
    str_html=str_html+"<div style=\"font-weight:bold; font-size:10px; \"><span style=\"text-align:left;\">QQ</span><span style=\"text-align:right; width:60px;\"> <a class='qqa' target=blank href='http://wpa.qq.com/msgrd?V=1&Uin=471133041&Site=在线咨询& Menu= no' title='在线即时交谈'>客&nbsp;&nbsp;服</a></span></div>";
	str_html=str_html+"<div style=\"font-weight:bold; font-size:10px; \"><span style=\"text-align:left;\">MSN</span><span style=\"text-align:right; width:60px;\"> 在线客服</span></div>";
	str_html=str_html+"</div>";

			
			suspendcode2="<div id=\"dy2\" style='right:50px;position:absolute;top:100px; cursor:pointer;'>"+str_html+"</div>"
//			document.write(suspendcode1);
			document.write(suspendcode2);
			 
			window.setInterval("heartBeat()",1);
			
				
}
function heartBeat(){
		var diffY;
		if (document.documentElement && document.documentElement.scrollTop)
		 diffY = document.documentElement.scrollTop;
		else if (document.body)
		 diffY = document.body.scrollTop
		else
		 {/*Netscape stuff*/}
		//alert(diffY);
		percent=.1*(diffY-lastScrollY);
		if(percent>0)percent=Math.ceil(percent);
		else percent=Math.floor(percent);
		//document.getElementById("dy1").style.top=parseInt(document.getElementById
//		("dy1").style.top)+percent+"px";
		document.getElementById("dy2").style.top=parseInt(document.getElementById("dy2").style.top)+percent+"px";
		lastScrollY=lastScrollY+percent;
		//alert(lastScrollY);
}

function alertinfo(action,langs){
	$.post('/alert_text.php',{'action': action,'langs': langs},function(data){
		if(data){
			alert(data);			
		}
	});		
}

function openwindow(url,width,height,resizable){
	var xposition=0; 
	var yposition=0;
	if(parseInt(navigator.appVersion) >= 4 ){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height-25) / 2;
	}
	var Win = window.open(url,'','width=' + width + ',height=' + height + ',left=' + xposition + ',top=' + yposition + ',toolbar=no,scrollbars='+resizable+',resizable='+resizable);
}
