function Trim(str) {
    if (str.charAt(0) == " ") {
        str = str.slice(1);
        str = Trim(str);
    }

    if (str.charAt(0) == "　") {
        str = str.slice(1);
        str = Trim(str);
    }
    if (str.charAt(str.length - 1) == " ") {
        str = str.substring(0, str.length - 1);
        str = Trim(str);
    }
    if (str.charAt(str.length - 1) == "　") {
        str = str.substring(0, str.length - 1);
        str = Trim(str);
    }

    return str;
}



function submitForm()
{	 

    var svalue;
    
    svalue = document.getElementById("txtName").value ; 

       if (!checkEmail(svalue))
       {
			alert("请输入正确的Email地址！");
			document.getElementById("txtName").value="";	
			document.getElementById("txtName").focus();	
			return false;
       }
   
	return true ; 


}


function submitForm2()
{	 

    var svalue;
    
    svalue = document.getElementById("txtName2").value ; 

       if (!checkEmail(svalue))
       {
			alert("请输入正确的Email地址！");
			document.getElementById("txtName2").value="";	
			document.getElementById("txtName2").focus();	
			return false;
       }
   
	return true ; 


}

//检查email的合法性
function checkEmail(emailAddr)
{

	var checkStr = emailAddr;
	var emailtag = false;
	var emaildot=0;//.位置
	var emailat=0;//@位置
	var a_count=0;//@个数
   
   
  
	// var Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789><,[]{}?/+=|\'\":;~!#$%()'@.";
   var Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789>.<,[]{}?/+=|\'\":;~_-!#$%()'@.";
	if(/[\u4e00-\u9fa5]|[\ufe30-\uffa0]/gi.test(emailAddr)) return false; //检查汉字
	if ((checkStr == null) || (checkStr.length < 5)) return false ;//1@1.1 
   
    for (var i=0;i<checkStr.length;i++)
    {
		ch=checkStr.charAt(i);
      
		if (Chars.indexOf(ch) == -1) return false;
       
		if (ch=='@')
		{
			emailat=i;
			a_count++;
		}
		if(ch=='.'  && a_count>0)    
		{ 
			emaildot=i;
			if ((emailat+1)==emaildot) return false; //44@.1
		}
    }
    
    if (a_count!=1) return false;
    if (emailat>emaildot) return false; //44.6@1
    if ((emailat+1)==emaildot) return false; //44@.1
    if (emailat==0) return false;//@123
    if (checkStr.charAt(checkStr.length-1)=='.') return false;//1@1.
    
    return true;



//if (emailAddr.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) return true;

return false;


}


var BrowseID = getOs();

function getOs()
{
   if(navigator.userAgent.indexOf("MSIE")>0) return 1;
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0) return 2;
   if(isSafari=navigator.userAgent.indexOf("Safari")>0) return 3;   
   if(isCamino=navigator.userAgent.indexOf("Camino")>0) return 4;
   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0) return 5;
   return 0;
}
//限制后退
function  forbidback() 
{ 
	if ( BrowseID != 1)//! IE
	{
		if(window.event.keyCode==0)
		{ 
			location.replace(this.location.href);       
		}  
      }          
              
 }   
 
 function Quickpick() 
{ 
  
  for( var i = 1; i < adcount; i++) 
  { 
    this[i] = parseInt(Math.random() * counts + 1); 
    for(var list = 0; list < i; list++) 
    { 
      if(this[list] == this[i]) 
      {        
        list = i; 
        i--; 
      } 
    } 
  } 
  return this; 
}
function init() {

   
    if (window.location.href.split("?").length == 1) {
        document.getElementById("txtName").value = "";
    }
    if (document.getElementById("txtName").value != "") {
        if (!checkEmail(document.getElementById("txtName").value)) {
            document.getElementById("loginTitle").style.display = "";
            document.getElementById("loginInput").style.display = "";
            document.getElementById("txtName").value = "";
        }
        else
            document.getElementById("loginNext").style.display = "";

    }
    else {
        document.getElementById("loginTitle").style.display = "";
        document.getElementById("loginInput").style.display = "";
    }
    if (document.getElementById("txtName").value == "") {
        document.getElementById("txtName").focus();
    }
    window.history.forward();   
}

    



