﻿// JScript File
/*----------------------------------------------------------------------------         
        Description			    :	 For Footer Page Validation.
        Create on			    :    
        Initial Code Created    :    Prathees Kumar. C
------------------------------------------------------------------------------*/
//Used to check valid for Contact Information.
function funContactErrMsg()  
{   
    var ErrMsg=''; var iChars = "~`!@#$%^&*()+=-_[]\\\';,/{}|\":<>?";
    var arrErr=new Array(20);          
    for(var i=0;i<5;i++)
    {   
        arrErr[i]='';
    }
    
    for (var i = 0; i < document.getElementById('txtName').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtName').value.charAt(i)) != -1)
  	    arrErr[0]='\n Name has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtName').value=='' || numericCheck(document.getElementById('txtName').value)!=false)    
        arrErr[0]='\n Enter valid Name';    
    if(document.getElementById('txtName').value.length>50)
        arrErr[0]='\n Name should not exceeds 50 Characters'; 

   /* if(document.getElementById('txtName').value=='' || numericCheck(document.getElementById('txtName').value)!=false)    
        arrErr[0]='\n Enter valid Name';    
    if(document.getElementById('txtName').value.length>50)
        arrErr[0]='\n First Name should not exceeds 50 Characters';  */
    if(document.getElementById('txtEmail').value==''||emailCheck(document.getElementById('txtEmail').value)==false)
        arrErr[1]='\n Enter Valid Email-Address';
    if(document.getElementById('txtEmail').value.length>75)
        arrErr[1]='\n Email-Address should not exceeds 75 Characters';                                     
    if(document.getElementById('txtPhone').value==''|| numericCheck(document.getElementById('txtPhone').value)==false)
        arrErr[2]='\n Enter Valid Phone No.';
    if(document.getElementById('txtPhone').value.length>15)
        arrErr[2]='\n Phone No. should not exceeds 15 Characters';    
    
    if(document.getElementById('txtDesc').value=='')
        arrErr[3]='\n Enter Your Description';
    if(document.getElementById('txtDesc').value.length>1000)
        arrErr[3]='\n Email-Address should not exceeds 1000 Characters';                                     
        
    /* if(numericCheck(document.getElementById('txtMobile').value)==false)
        arrErr[15]='\n Enter valid Mobile No..'; 
    if(document.getElementById('txtMobile').value.length>15)
        arrErr[15]='\n Mobile No. should not exceeds 15 Characters'; */
    for(var i=0;i<5;i++)
    {
        if(arrErr[i]!='')
        {
            ErrMsg=ErrMsg+arrErr[i];
        }
    }     
    if(ErrMsg!='')
    {   
        alert('Following fields are Mandatory...!\r\n------------------------------------\r' + ErrMsg);                    
        return false;            
    }
    return true;  
}

//used to reset 'Contactus.aspx' textbox infor.
function funBtnContactusReset()
{
    document.getElementById('txtName').value='';
    document.getElementById('txtEmail').value='';
    document.getElementById('txtPhone').value='';
    document.getElementById('txtMobile').value='';
    document.getElementById('txtSubject').value='';
    document.getElementById('txtDesc').value='';
    document.getElementById('ddlLearnabtus').value='Search Engines';
    document.getElementById('ddlQueryas').value='Retail Customer';
    document.getElementById('ddlQueryfor').value='Product Enquiry';
}
//Used to check valid for FeedBack Information.
function funPostQueryErrMsg()  
{   
    var ErrMsg=''; var iChars = "~`!@#$%^&*()+=-_[]\\\';,/{}|\":<>?";
    var arrErr=new Array(10);          
    for(var i=0;i<6;i++)
    {   
        arrErr[i]='';
    }
    for (var i = 0; i < document.getElementById('txtName').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtName').value.charAt(i)) != -1)
  	    arrErr[0]='\n Name has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtName').value=='' || numericCheck(document.getElementById('txtName').value)!=false)    
        arrErr[0]='\n Enter valid Name.';    
    if(document.getElementById('txtName').value.length>50)
        arrErr[0]='\n Name should not exceeds 50 Characters'; 
    for (var i = 0; i < document.getElementById('txtCity').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtCity').value.charAt(i)) != -1)
  	    arrErr[1]='\n City has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtCity').value=='' || numericCheck(document.getElementById('txtCity').value)!=false)    
        arrErr[1]='\n Enter valid City Name.';    
    if(document.getElementById('txtCity').value.length>50)
        arrErr[1]='\n City Name should not exceeds 50 Characters'; 
    for (var i = 0; i < document.getElementById('txtSubject').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtSubject').value.charAt(i)) != -1)
  	    arrErr[2]='\n Subject has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtSubject').value=='' || numericCheck(document.getElementById('txtSubject').value)!=false)    
        arrErr[2]='\n Enter valid Subject.';    
    if(document.getElementById('txtSubject').value.length>50)
        arrErr[2]='\n Subject should not exceeds 50 Characters'; 
    if(document.getElementById('txtEmailId').value==''||emailCheck(document.getElementById('txtEmailId').value)==false)
        arrErr[3]='\n Enter Valid Email-Address.';
    if(document.getElementById('txtEmailId').value.length>75)
        arrErr[3]='\n Email-Address should not exceeds 75 Characters';   
    if(document.getElementById('ddlCountry').value==''||(document.getElementById('ddlCountry').value)=='-- Select Country --' )
        arrErr[4]='\n Select a Country.';
    if(document.getElementById('txtDetails').value==''||numericCheck(document.getElementById('txtDetails').value)!==false )
        arrErr[5]='\n Enter Valid Details.';
    for (var i = 0; i < document.getElementById('txtDetails').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtDetails').value.charAt(i)) != -1)
  	    arrErr[0]='\n Details has Special Characters. These are not allowed.';}
    if(document.getElementById('txtDetails').value.length>2500)
        arrErr[5]='\n Details should not exceeds 2500 Characters';   
    for(var i=0;i<6;i++)
    {
        if(arrErr[i]!='')
        {
            ErrMsg=ErrMsg+arrErr[i];
        }
    }     
    if(ErrMsg!='')
    {   
        alert('Following fields are Mandatory...!\r\n------------------------------------\r' + ErrMsg);                    
        return false;            
    }
    return true;  
}

//Used to check validation for Refer a Friend Information.
function funTellaFriendErrMsg()  
{  
    var ErrMsg=''; var iChars = "~`!@#$%^&*()+=-_[]\\\';,/{}|\":<>?";
    var arrErr=new Array(10);          
    for(var i=0;i<8;i++)
    {   
        arrErr[i]='';
    }
    for (var i = 0; i < document.getElementById('txtYourName').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtYourName').value.charAt(i)) != -1)
  	    arrErr[0]='\n Your Name has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtYourName').value=='' || numericCheck(document.getElementById('txtYourName').value)!=false)    
        arrErr[0]='\n Enter valid Your Name';    
    if(document.getElementById('txtYourName').value.length>50)
        arrErr[0]='\n Your Name should not exceeds 50 Characters'; 

    if(document.getElementById('txtMessage').value=='' || numericCheck(document.getElementById('txtMessage').value)!=false)    
        arrErr[1]='\n Enter Your Message';    
    if(document.getElementById('txtMessage').value.length>1000)
        arrErr[1]='\n City Name should not exceeds 1000 Characters'; 
        
    for (var i = 0; i < document.getElementById('txtName1').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtName1').value.charAt(i)) != -1)
  	    arrErr[2]='\n Your Friend Name has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtName1').value=='' || numericCheck(document.getElementById('txtName1').value)!=false)    
        arrErr[2]='\n Enter Your Friend Name';    
    if(document.getElementById('txtName1').value.length>50)
        arrErr[2]='\n Your Friend Name should not exceeds 50 Characters'; 
        
    if(document.getElementById('txtYourEmailId').value==''||emailCheck(document.getElementById('txtYourEmailId').value)==false)
        arrErr[3]='\n Enter Valid Email-Address';
    if(document.getElementById('txtYourEmailId').value.length>75)
        arrErr[4]='\n Email-Address should not exceeds 75 Characters';   
                                          
    if(document.getElementById('txtEmailId1').value==''||emailCheck(document.getElementById('txtEmailId1').value)==false)
        arrErr[5]='\n Enter Valid Email-Address for Your Friend';
    if(document.getElementById('txtEmailId1').value.length>75)
        arrErr[5]='\n Email-Address should not exceeds 75 Characters';   
    if(document.getElementById('txtEmailId2').value!='')
        if(emailCheck(document.getElementById('txtEmailId2').value)==false)
            arrErr[6]='\n Your 2nd Friend EMailId is incorrect';
    if(document.getElementById('txtEmailId3').value!='')
        if(emailCheck(document.getElementById('txtEmailId3').value)==false)
            arrErr[7]='\n Your 3rd Friend EMailId is incorrect';
  
    for(var i=0;i<8;i++)
    {
        if(arrErr[i]!='')
        {
            ErrMsg=ErrMsg+arrErr[i];
        }
    }     
    if(ErrMsg!='')
    {   
        alert('Following fields are Mandatory...!\r\n------------------------------------\r' + ErrMsg);                    
        return false;            
    }
    return true;  
}
//function funMailIdCheck2()
//{
//    if(emailCheck(document.getElementById('txtEmailId2').value)==false)
//    {
//        alert('Enter your friend mailid is incorrect');
//        document.getElementById('txtEmailId2').value='';
//    }    
//}
//function funMailIdCheck3()
//{
//    if(emailCheck(document.getElementById('txtEmailId3').value)==false)
//    {
//        alert('Enter your friend mailid is incorrect');
//        document.getElementById('txtEmailId3').value='';
//    }    
//}
function funTellaFriendReset()
{
    document.getElementById('txtYourName').value='';
    document.getElementById('txtMessage').value='';
    document.getElementById('txtName1').value='';
    document.getElementById('txtName2').value='';
    document.getElementById('txtName3').value='';
    document.getElementById('txtYourEmailId').value='';
    document.getElementById('txtEmailId1').value='';
    document.getElementById('txtEmailId2').value='';
    document.getElementById('txtEmailId3').value='';
}
//Used to check validation for Request a Product Information.
function funRequestProductErrMsg()  
{   
    var ErrMsg=''; var iChars = "~`!@#$%^&*()+=-_[]\\\';,/{}|\":<>?";
    var arrErr=new Array(20);          
    for(var i=0;i<20;i++)
    {   
        arrErr[i]='';
    }
    
    for (var i = 0; i < document.getElementById('txtName').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtName').value.charAt(i)) != -1)
  	    arrErr[0]='\n Name has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtName').value=='' || numericCheck(document.getElementById('txtName').value)!=false)    
        arrErr[0]='\n Enter valid Name';    
    if(document.getElementById('txtName').value.length>50)
        arrErr[0]='\n Name should not exceeds 50 Characters'; 

    if(document.getElementById('txtAddress').value=='')    
        arrErr[1]='\n Enter Valid Address';    
    if(document.getElementById('txtAddress').value.length>50)
        arrErr[1]='\n Address should not exceeds 50 Characters'; 
        
    for (var i = 0; i < document.getElementById('txtcity1').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtcity1').value.charAt(i)) != -1)
  	    arrErr[2]='\n City has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtcity1').value=='' || numericCheck(document.getElementById('txtcity1').value)!=false)    
        arrErr[2]='\n Enter Valid City Name';    
    if(document.getElementById('txtcity1').value.length>50)
        arrErr[2]='\n City Name should not exceeds 50 Characters'; 
        
    for (var i = 0; i < document.getElementById('txtState').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtState').value.charAt(i)) != -1)
  	    arrErr[3]='\n State has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtState').value=='' || numericCheck(document.getElementById('txtState').value)!=false)    
        arrErr[3]='\n Enter Valid State Name';    
    if(document.getElementById('txtState').value.length>50)
        arrErr[3]='\n State Name should not exceeds 50 Characters';
        
    if((document.getElementById('ddlCountry1').value=='') || (document.getElementById('ddlCountry1').value=='-- Select Country --'))    
        arrErr[4]='\n Select a Country';    
       
    if(document.getElementById('txtPhone1').value==''|| numericCheck(document.getElementById('txtPhone1').value)==false)
        arrErr[5]='\n Enter Valid Phone No.';
    if(document.getElementById('txtPhone1').value.length>15)
        arrErr[5]='\n Phone No. should not exceeds 15 Characters';     
        
    if(document.getElementById('txtEmail').value==''||emailCheck(document.getElementById('txtEmail').value)==false)
        arrErr[6]='\n Enter Valid Email-Address';
    if(document.getElementById('txtEmail').value.length>75)
        arrErr[6]='\n Email-Address should not exceeds 75 Characters';   
    
     if(document.getElementById('txtReqProduct').value=='')
        arrErr[7]='\n Enter Required Product';
//    if(document.getElementById('txtReqProduct').value.length>15)
//        arrErr[7]='\n Required Product should not exceeds 15 Characters';             
                
    if(document.getElementById('ddlPriceRange').value=='' || document.getElementById('ddlPriceRange').value=='Select Price Range')    
        arrErr[8]='\n Select the Price Range';    
                                  
    for (var i = 0; i < document.getElementById('txtShipmentCity').value.length; i++) {
  	if (iChars.indexOf(document.getElementById('txtShipmentCity').value.charAt(i)) != -1)
  	    arrErr[9]='\n Shipment City Name has Special Characters. These are not allowed.';}
  	if(document.getElementById('txtShipmentCity').value=='' || numericCheck(document.getElementById('txtShipmentCity').value)!=false)    
        arrErr[9]='\n Enter Valid Shipment City Name';    
    if(document.getElementById('txtShipmentCity').value.length>50)
        arrErr[9]='\n Shipment City Name should not exceeds 50 Characters';                           
                                  
    if((document.getElementById('ddShipmentCoun').value=='')|| (document.getElementById('ddShipmentCoun').value=='-- Select Country --'))
        arrErr[10]='\n Select a Shipment Country';    
   
    for(var i=0;i<20;i++)
    {
        if(arrErr[i]!='')
        {
            ErrMsg=ErrMsg+arrErr[i];
        }
    }     
    if(ErrMsg!='')
    {   
        alert('Following fields are Mandatory...!\r\n------------------------------------\r' + ErrMsg);                    
        return false;            
    }
    return true;  
}
function funBtnPQReset()
{
    document.getElementById('txtName').value='';
    document.getElementById('txtEmailId').value='';
    document.getElementById('txtCity').value='';
    document.getElementById('txtSubject').value='';
    document.getElementById('txtDetails').value='';
    document.getElementById('ddlCountry').value='-- Select Country --';
}