// JavaScript Document
	function scr_change(){
		document.getElementById("scrr").style.top = document.documentElement.scrollTop + 210 + "px";
	}
	window.onscroll = scr_change;
	function exit(){
		document.getElementById("scrr").style.visibility = "hidden";
	}
	
//Creat XHR Object
function createxmlhttp(){
    var xmlhttpobj;
    if (window.ActiveXObject){
    try {
        xmlhttpobj=new window.ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttpobj=new window.ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            alert("Cannot Creat XMLHttpRequest!");
            return false;
        }      
    }     
    } else if(window.XMLHttpRequest){
        xmlhttpobj=new window.XMLHttpRequest();
        if (xmlhttpobj.overrideMimeType){
            xmlhttpobj.overrideMimeType("text/xml");
        }
    } 
    return xmlhttpobj;
}
//check code
function CheckForm(){
	document.getElementById('submits').disabled=true;
	if(document.getElementById("cname").value==""){
		alert('Your Name Can NOT Be Empty!');
		document.getElementById('submits').disabled=false;
		return false;
	}
	if(document.getElementById("email").value.length!=0){
		if(document.ctt.email.value.charAt(0)=="."||document.ctt.email.value.charAt=="@"||document.ctt.email.value.indexOf('@',0)==-1||document.ctt.email.value.indexOf('.',0)==-1||document.ctt.email.value.lastIndexOf("@")==document.ctt.email.value.length-1||document.ctt.email.value.lastIndexOf(".")==document.ctt.email.value.length-1){
			alert('Your E-mail Address Format Error!');
			document.getElementById('submits').disabled=false;
			return false;
		}
	}else{
			alert("E_mail Address Can NOT Be Empty!");
			document.ctt.email.focus();
			return false;
	}
	if(document.getElementById("CheckCodeStatus").value=="0"){
		alert("Error Verification Code,Please Check and Enter Again!");
		RefreshImage('imgCaptcha');
		document.getElementById('submits').disabled=false;
		return false;
	}
	return true;
}
function CheckCodes(){
	var code=document.getElementById("CheckCode").value;
	var now=new Date();
	var url="../Ajax/Ajax_CheckCode.asp?Str="+code+"&n="+Math.random();
	var xmlhttp=createxmlhttp();
	if(xmlhttp){
		xmlhttp.open("GET",url,true);
		xmlhttp.onreadystatechange=function(){f_getCheckCodes(xmlhttp);}
		xmlhttp.send();
	}
}
function f_getCheckCodes(xmlhttp){
	if(xmlhttp.readyState==4){
		if(xmlhttp.status==200){
			var resStr=xmlhttp.responseText;
			if(resStr==1){
				document.getElementById("CheckCodeStatus").value="1";
			}else if(resStr==0){
				document.getElementById("CheckCodeStatus").value="0";
			}
			if(CheckForm()){
				if(confirm('Are you sure your message?')){
					document.getElementById('submits').disabled=false;
					document.getElementById("ctt").submit();	
				}
			}
		}else{alert('Error Code：'+xmlhttp.status);}
	}
}
//refresh the Image
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

//*****Check the content.
function checknum(obj,iputName){
	var sl;
	sl=obj.value;
	if(!isValidNumber(sl)){
		obj.value='0';
		alert('"'+iputName+'" InValid! Please Enter Again!');
		window.setTimeout(function(){obj.focus();},0);//for the FireFox
		obj.select();//if IE,then select the content.invalid in FireFox
	}
}	
function isValidNumber(sl){
	var i,j;
	var strTemp="0123456789";
	if (sl=='' || sl==null)
		return false;
	    var bRet = true;
	    for (i=0;i<sl.length;i++){
		    j=strTemp.indexOf(sl.charAt(i)); 
		    if (j==-1){
			     bRet = false;
			    break;
		     }
	    }	
	return bRet;
}
