﻿// JScript 文件

//用户名和密码验证
var HavingNameObj;
function isHavingName(obj)
{	       
        HavingNameObj=obj;
		var getName=obj.value;		
		if(getName!='')
		{
			AjaxMethod.CheckRegName(getName,LoadisHavingName_CallBack);			
		}
		
}
	function LoadisHavingName_CallBack(response)	
	{		   
		  if (response.error != null)
				{    	
					//alert(response.error); 
					return;
				} 
	   
				var returnStr = response.value;		
				    	
				if(returnStr==1)				
				{   
				   
                   document.getElementById('UserNameEr').innerHTML="<font color=red> *Your E-Mail Address already exists in our records!</font>";
 	               document.getElementById('UserNameEr').style.display="inline";
					
				    HavingNameObj.value="";
				}				
			   else
			    {
			 
					document.getElementById('UserNameEr').style.display="none";
				}
	}   
	
	
  function RegLoginCheck()
  {       
         var EmailReg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
         var userName=document.getElementById('UserRegs1_txt_username').value;
         var pass1=document.getElementById('UserRegs1_txt_password1').value;
         var pass2=document.getElementById('UserRegs1_txt_password2').value;
        
      
//         var ErrorMsg=document.removeelement('DIV');
//         var ErrorMsg=document.createElement('DIV');
//          
          
        if(document.getElementById('UserRegs1_txt_username').value=="")
        {
          
         
            document.getElementById('UserNameEr').innerHTML="<font color=red> *Please input E-mail address!</font>";
 	        document.getElementById('UserNameEr').style.display="inline";
          
        
            return false;   
        }
        
        else if(!EmailReg.test(userName))
        {
            document.getElementById('UserNameEr').innerHTML="<font color=red> *Your E-Mail Address does not appear to be valid!</font>";
 	        document.getElementById('UserNameEr').style.display="inline";
          
            return false;
         
        }
      
        
        
        else if(pass1=="")
        { 
        
//          ErrorMsg.innerHTML="<font color=red> *Please input Login Password!</font>";
//          var parent=document.getElementById('Userreg1_txt_password1').parentNode.nextSibling;
//          parent.appendChild(ErrorMsg);
          document.getElementById('Pass1Er').innerHTML="<font color=red> *Please input Login Password!</font>";
 	      document.getElementById('Pass1Er').style.display="inline";
            return false;
        }
        else if(pass2!=pass1)
        { 
         
		   document.getElementById('Pass2Er').innerHTML="<font color=red>*Login Password check error!</font>";
 	       document.getElementById('Pass2Er').style.display="inline";
		
          return false;
         
        }
        
        else{
        	
            return true;
        }
  } 
  
   function addFav(url, title)
    {
        try 
        {
            window.external.AddFavorite(url, title);
        }
        catch (ex)
        {
            if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))
                 window.sidebar.addPanel (title, url,'');
        }
    }
    
function getCouponCode()
{
    var CouponCode = document.getElementById("UserRegs1_txt_CouponCode").value;
    var Price = document.getElementById("UserRegs1_Lab_Price").innerHTML;
    if(CouponCode != '' && Price != null)
    {
        AjaxMethod.CouponPrice(CouponCode,Price,getCouponCode_CallBack);
    }
    else
    {
        document.getElementById("UserRegs1_lab_CouponPrice").innerHTML = "";
        document.getElementById("UserRegs1_Lab_Paytype").style.textDecoration = "none";
        document.getElementById("UserRegs1_Lab_Price").style.textDecoration = "none";
    }
}

function getCouponCode_CallBack(response)
{
    if (response.error != null)
	{    	
		return;
	}
	var returnStr = response.value;
	if(returnStr != null && returnStr != '' && returnStr != '0')
	{
        document.getElementById("UserRegs1_lab_CouponPrice").innerHTML = document.getElementById("UserRegs1_Lab_Paytype").innerHTML + " "+ returnStr;
        document.getElementById("UserRegs1_Lab_Paytype").style.textDecoration = "line-through";
        document.getElementById("UserRegs1_Lab_Price").style.textDecoration = "line-through";
        
    }
    else
    {
        document.getElementById("UserRegs1_lab_CouponPrice").innerHTML = "invalid code";
        document.getElementById("UserRegs1_Lab_Paytype").style.textDecoration = "none";
        document.getElementById("UserRegs1_Lab_Price").style.textDecoration = "none";
    }
}
  