﻿// JScript File
var result;


//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    CreateXMLHttpRequest()
//        '        'Author        :    Mohan Deval 
//        '        'Date          :    04/13/2008  
//        '        'Purpose       :    To send request to the aspx page(Server) using Azax and get some result according to the request.
//        '        'Input(s)      :    strUserName: User Name
//        '        '                   
//        '        'Output        :    String
//        '        'Message       :    Message with alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

//To create an XMLHttpRequest Function Which will return an ActiveX Object
function CreateXMLHttpRequest()
{
    var http_request;
    try
    {
        http_request=new ActiveXObject("MsXML2.XMLHTTP");
    }
    catch(e)
    {
        var http_request=new ActiveXObject("Microsoft.XMLHTTP");
    }
    return http_request;
}

//---------------------------------------End Function---------------------------------------------------------------


//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    IsUserNameExist()
//        '        'Author        :    Mohan Deval 
//        '        'Date          :    04/13/2008  
//        '        'Purpose       :    To verify the user name is already Exist in the database using Ajax.
//        '        'Input(s)      :    strUserName: User Name
//        '        '                   
//        '        'Output        :    String
//        '        'Message       :    Message with alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

function IsUserNameExist()
{
    
     var UserName=document.getElementById("txtUserName").value;
     if(UserName.trim()=="")
     {
            alert("User Name is required");
            return false;
     }
     //To Create a XMLHttpRequest Object
     var http_request=CreateXMLHttpRequest();
     //To request a page using Query string
	 http_request.open('POST','UserManagement/ExecuteAjaxServerScript.aspx?Mode=IsExistUserName&UserName='+UserName.trim(),false);
	 //http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
     http_request.onReadyStateChange=function()
     {
        if(http_request.readyState==4)
        {
	        result=http_request.responseText.split("|");	        
	        if(result[0]=='1')	
	        {			           
	               alert('User name is not available ');
	               return false; 
	        }
	        else if(result[0]=='0')
	        {
	               alert('User name is available ');
	               return false;
	        }
	        else if(result[0]=='2')
	        {
	               alert('Could not complete the request ');
	               return false;
	        }	           
        }				        
        
     }
	 http_request.send(null);
    return false
}
//---------------------------------------End Function---------------------------------------------------------------




//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    VerifyUser()
//        '        'Author        :    Mohan Deval 
//        '        'Date          :    04/21/2008  
//        '        'Purpose       :    To verify the user is already Exist using Ajax.
//        '        'Input(s)      :    strUserName: User Name
//        '        '                   
//        '        'Output        :    String
//        '        'Message       :    Message with alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

//Verify UserName  Exist or not
function VerifyUser()
{

    //To check UserName is not Blank 
//    if(!RequirefieldValidation(document.getElementById('txtUserName').value))
//    {
//         alert('Please enter your User Name.');
//          return false; 
//    }
//    
//    //To check Password is not Blank
//    if(!RequirefieldValidation(document.getElementById('txtPassword').value))
//    {
//         alert('Please enter your Password.');
//          return false; 
//    }
    var result1;
    //To Create a XMLHttpRequest Object
    var http_request=CreateXMLHttpRequest();
    //To request a page using Query string
    http_request.open('POST','UserManagement/ExecuteAjaxServerScript.aspx?Mode=IsExistUserName&UserName='+document.getElementById('txtUserName').value.trim(),false);
    //http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    result1=false;    
    http_request.onReadyStateChange=function()
    {
       
        if(http_request.readyState==4)
        {
                
	            result=http_request.responseText.split("|");	        
	            if(result[0]=='1')	
	            {	   //If User is exist in the database then it will return boolean value true.
	                   //result1=true; 
	                   if(IsUserLock(document.getElementById('txtUserName').value.trim()))
	                        result1= true;
	                   else
	                   return false;
	            }
	            else if(result[0]=='0')
	            {
	                   //If User is not exist in the database then it will return boolean value false and an alert message.
	                   alert('User Name/Passwrd does not match. Please Try again ');
	                   return false;	                   
	            }
	            else if(result[0]=='2')
	            {
	                   alert('Could not complete the request ');
	                   return false;
	            }		
        }					        
        else
        {
            result1=false;            
        }
    }
     http_request.send(null);
     if(result1==true)
        return true;
        else if(result1==false && result[0]!='2' && result[0]!='0')
        {
	        alert('Could not complete the request ');
	        return false;
	    }
	    else
	        return false;	
     //return result1;   
 
}
//---------------------------------------End Function---------------------------------------------------------------





//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    IsUserLock()
//        '        'Author        :    Mohan Deval 
//        '        'Date          :    04/22/2008  
//        '        'Purpose       :    To verify the user Locked or not using Ajax.
//        '        'Input(s)      :    strUserName: User Name
//        '        '                   
//        '        'Output        :    String
//        '        'Message       :    Message with alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

//Verify User is Locked or not
function IsUserLock(UserName)
{

    
    var result1;
    //To Create a XMLHttpRequest Object
    var http_request=CreateXMLHttpRequest();
    //To request a page using Query string
    http_request.open('POST','UserManagement/ExecuteAjaxServerScript.aspx?Mode=IsLockUser&UserName='+UserName,false);
    //http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    result1=false;
    http_request.onReadyStateChange=function()
    {
       
        if(http_request.readyState==4)
        {
                
	            result=http_request.responseText.split("|");	        
	            if(result[0]=='1')	
	            {	   //If User is exist in the database then it will return boolean value true.
	                   result1=true; 
	            }
	            else if(result[0]=='0')
	            {
	                   //If User is Locked then it will return boolean value false and show an alert message.
	                   alert('You are Inactive user so you can not use Login form. Please contact to your Admin.');
	                   return false;
	            }
	            else if(result[0]=='2')
	            {
	                   //If User is Locked then it will return boolean value false and show an alert message.
	                   alert('You are in Hold user so you can not use Login form. Please contact to your Admin.');
	                   return false;
	            }
	             else if(result[0]=='3')
	            {
	                   //If User is Locked then it will return boolean value false and show an alert message.
	                   alert('You are Locked user so you can not use Login form. Please click ForgetPassword link for unlock the password.');
	                   return false;
	            }
	            else 
	            {
	                   alert('Could not complete the request ');
	                   return false;
	            }		
        }					        
        else
        return false
    }
     http_request.send(null);
     return result1;   
 
}
//---------------------------------------End Function---------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    IsAlphaNumeric()
//        '        'Author        :    Mohan Deval
//        '        'Date          :    04/24/2008  
//        '        'Purpose       :    To valid only alpha numeric
//        '        'Input(s)      :    Value: Enter the Value             
//        '        'Output        :    Boolean value
//        '        'Message       :    No alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

function IsAlphaNumeric(sText)
{
           
    var InValidChars =  "!@#$%^&*()+=-[]\\\';/{}|\":<>?";
    var Char;
    
    for (i = 0; i < sText.length; i++) 
         { 
            Char = sText.charAt(i); 
            if (InValidChars.indexOf(Char) != -1) 
             {
                return false;
             }
          }
          return true;
} 
//---------------------------------------End Function---------------------------------------------------------------

//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    VerifyUserDetalsForForgetPassword()
//        '        'Author        :    Mohan Deval 
//        '        'Date          :    04/23/2008  
//        '        'Purpose       :    To verify the user's first Name and Last name for Forget password 
//        '        '              :    verification
//        '        'Input(s)      :    FirstName: First Name
//        '        '                   FirstName: Last Name
//        '        'Output        :    String
//        '        'Message       :    Message with alert.
//        '        'Revised       :    None
//        '        'Notes         :    None

//Verify UserName  Exist or not
function VerifyUserDetalsForForgetPassword()
{

    //To check UserName is not Blank 
    if(!RequirefieldValidation(document.getElementById('txtFirstName').value))
    {
         alert('Please enter your First Name.');
          return false; 
    }
    
    //To check Password is not Blank
    if(!RequirefieldValidation(document.getElementById('txtLastName').value))
    {
         alert('Please enter your Last Name.');
          return false; 
    }   
    if(!RequirefieldValidation(document.getElementById('txtVerificationNo').value))
    {
         alert('Please enter Verification No.');
          return false; 
    }
   //-----------------------------------------Check Alpha Numeric Character---------------------------------------------------- 
   
  if(!IsAlphaNumeric(document.getElementById('txtFirstName').value))
    {
       alert("First Name must be alpha numeric value.");
        return false;
    }
    if(!IsAlphaNumeric(document.getElementById('txtLastName').value))
    {
       alert("Last Name must be alpha numeric value.");
        return false;
    }
     if(!IsAlphaNumeric(document.getElementById('txtVerificationNo').value))
    {
       alert("Verification Numner must be alpha numeric value.");
        return false;
    }
    //-------------------------------------------------------------------------------------------------------------------------
    var result1;
    //To Create a XMLHttpRequest Object
    var http_request=CreateXMLHttpRequest();
    //To request a page using Query string
    
    http_request.open('POST','UserManagement/ExecuteAjaxServerScript.aspx?Mode=UserDetailsForgetPassword&FirstName='+document.getElementById('txtFirstName').value+'&LastName='+document.getElementById('txtLastName').value+'&EmailID='+document.getElementById('txtEmail').value,false);
    //http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    result1=false;
    
    http_request.onReadyStateChange=function()
    {
   
        if(http_request.readyState==4)
        {
              
	            result=http_request.responseText.split("|");	        
	            if(result[0]=='1')	
	            {	   //If User Details is correct in the database then it will return boolean value true.
	                                      
	                        result1= true;
	            }
	            else if(result[0]=='0')
	            {
	                   //If User is not exist in the database then it will return boolean value false and an alert message.
	                   alert('First Name, Last Name and EmailID does not match. ');
	                   return false;
	            }
	            else if(result[0]=='2')
	            {
	                   alert('Email address does not match. ');
	                   return false;
	            }	
	            else if(result[0]=='3')
	            {
	                   alert('First or Last Name does not match.');
	                   result1= false;
	            }	
	            else 
	            {
	                   alert('Could  not complete the request ');
	                   return false;
	            }		
        }					        
        else
        return false
    }
     http_request.send(null);
     return result1;   
 
}
//---------------------------------------End Function---------------------------------------------------------------




//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    CancelProcess()
//        '        'Author        :    Mohan Deval 
//        '        'Date          :    05/13/2008  
//        '        'Purpose       :    To cancel the registration as well as Verification Email.
//        '        '              :    Redirect to Login Page 
//        '        'Input(s)      :    None
//        '        '                   
//        '        'Output        :    
//        '        'Message       :    None
//        '        'Revised       :    None
//        '        'Notes         :    None

function CancelProcess(Mode)
{
    var Result;
    var Message;
    if(Mode=='VerificatioEmail')
        Message='Do you want to cancel the Verification for forget password?';
    else if(Mode=='Registration')
        Message='Do you want to cancel the registration?';
    Result=confirm(Message);
    if(Result==true)
    {
        window.location ="Login.aspx";        
        return false;
    }
    else
        return false;
    
}


//---------------------------------------End Function---------------------------------------------------------------



//------------------------------------------------------------------------------------------------------------------
//        '        'Function Name :    CancelChangePassword()
//        '        'Author        :    Mohan Deval 
//        '        'Date          :    05/22/2008  
//        '        'Purpose       :    To cancel the Change Password Process.
//        '        '              :    Redirect to Home Page 
//        '        'Input(s)      :    None
//        '        '                   
//        '        'Output        :    
//        '        'Message       :    None
//        '        'Revised       :    None
//        '        'Notes         :    None

function CancelChangePassword()
{
    var Result;
    var Message; 
    Result=confirm('Do you want to cancel the Changing Password Process?');
    if(Result==true)
    {
        window.location ="../SpacenetPortal/Default.aspx";        
        return false;
    }
    else
        return false;
    
}


//---------------------------------------End Function---------------------------------------------------------------

function LogoutUser()
{
     var result1;
    var http_request=CreateXMLHttpRequest();
    http_request.open('POST','../UserManagement/ExecuteAjaxServerScript.aspx?Mode=LogoutUser',false);
    result1=false;    
    http_request.onReadyStateChange=function()
    { 
         if(http_request.readyState==4)
         {        
         }
    }
    http_request.send(null);
    
}
 
	    function ShowCustomerUserForm(groupby)
        {
           //var qString = "SurveyId=" + document.getElementById('ctl00_ContentPlaceHolderMain_ddlSurvey').value
           //alert(qString ); 
           window.radopen("GroupByCustomer_User.aspx?groupby="+groupby, "UserListDialog");
           return false;
        }	
        function OnclickChkBxNova1000()
        {
                    //alert('chkBxNova1000  Selected')
                    document.getElementById("ChkBxNova1500").checked   = false;
        }
        
        function OnclickChkBxNova1500()
        {
                   // alert('chkBxNova1500  Selected')
                    document.getElementById("ChkBxNova1000").checked  = false;
        }
        function OnclickRdBtnStaticIPYes()
        {
              // alert('RdobtnStaticIPYes Selected')
              // document.getElementById("RdobtnStaticIPYes").value  = true;
                document.getElementById("RdobtnStaticIPNo").checked  = false;
        }
        
        function OnclickRdBtnStaticIPNo()
        {
               //alert('RdobtnStaticIPNO  Selected')
              // document.getElementById("RdobtnStaticIPNo").value  = true;
              document.getElementById("RdobtnStaticIPYes").checked  = false;
        
        }
        function OnclickChkBxRoofMount()
        {
         document.getElementById("ChkbxWallMount").checked  = false;
          document.getElementById("ChkbxNoMount").checked  = false;
        
        }
        function OnclickChkBxWallMount()
        {
         document.getElementById("ChkbxRoofMount").checked  = false;
          document.getElementById("ChkbxNoMount").checked  = false;
        }
        function OnclickChkBxNoMount()
        {
         document.getElementById("ChkbxRoofMount").checked  = false;
         document.getElementById("ChkbxWallMount").checked  = false;
        }
        function OnclickRdoBtnOption1For12Months()
        {
         document.getElementById("RdobtnOption2_24Months").checked  = false;
        }
        function OnclickRdBtnOption1For24Months()
        {
         document.getElementById("RdobtnOption1_12Months").checked  = false;
        }
         
         function OnclickChkboxCCInvoice()
         {
               
             document.getElementById("ChkboxPaperInvoice").checked  = false;
             document.getElementById("TblMRCCreditCardInfo").visible = true;
         }
         function  OnclickChkboxPaperInvoice()
         {
             document.getElementById("ChkboxCCInvoice").checked  = false;
             document.getElementById("TblMRCCreditCardInfo").visible = false;
         }
         
    
    
    function OnclickRdBtnShipToInstallAddrYes()
        {
              // alert('RdobtnShipToInstallAddrNo Selected')
            
                document.getElementById("RdobtnShipToInstallAddrNo").checked  = false;
  

        }
        
        function OnclickRdBtnShipToInstallAddrNo()
        {
               //alert('RdobtnShipToInstallAddrYes  Selected')
              // document.getElementById("RdobtnShipToInstallAddrYes").value  = true;
              document.getElementById("RdobtnShipToInstallAddrYes").checked  = false;
        
        }
        
        function OnclickChkBxShippingStandard()
        {

         document.getElementById("ChkbxShippingExpress").checked  = false;        
        }
        function OnclickChkBxShippingExpress()
        {
        
         document.getElementById("ChkbxShippingStandard").checked  = false;
        }
       