﻿// JScript File


 
   function ValidateMailToUsN1(txtName,SelectInt,txtEmail, txtCity,txtCountry,txtZip, txtTel)
  {
 

//for(var i=0; i<CountryA.length; i++) 

 
//  var myC=new Boolean(false);  
//   //debugger;
// for(i=0; i<CountryA.length; i++)
// { 
//  if(txtCountry.value==CountryA[i])
//     {
//      myC=true;
//     
//     }
// }
// if(myC==false)
// {
//  alert("txtCountry Can Not Be Match.");
//  txtCountry.style.borderColor='red';
//    txtCountry.style.borderWidth='2px';
//    return false;
// }
// else
//{
//    txtCountry.style.borderColor='#68c417';
//    txtCountry.style.borderWidth='1px';
//}
  
 
 var myBoolean=new Boolean(true);  

//




//Name 
myBoolean=blankCheck(txtName,'Name');    
if(myBoolean==false)
{   
  //  txtName.style.borderColor='red';
  //  txtName.style.borderWidth='2px';
    return false;
} 
else
{
  //  txtName.style.borderColor='#68c417';
   // txtName.style.borderWidth='1px';
}


 myBoolean=CheckCH(txtName);  
if(myBoolean==false)
{   
  //  txtName.style.borderColor='red';
   // txtName.style.borderWidth='2px';
    return false;
} 
else
{
  //  txtName.style.borderColor='#68c417';
  //  txtName.style.borderWidth='1px';
}


//txtEmail
myBoolean=blankCheck(txtEmail,'Email');    
if(myBoolean==false)
{   
   // txtEmail.style.borderColor='red';
   // txtEmail.style.borderWidth='2px';
    return false;
} 
else
{
   // txtEmail.style.borderColor='#68c417';
   // txtEmail.style.borderWidth='1px';
} 


//Email
var  status=validateEmails(txtEmail);
if (status=="1")
{
  //  txtEmail.style.borderColor='red';
   // txtEmail.style.borderWidth='2px';
    return false;
} 
else
{
  //  txtEmail.style.borderColor='#68c417';
   // txtEmail.style.borderWidth='1px';
}
 

//var chkOpt=document.getElementsByName(chkMaleFemale);

//myBoolean=checkBoxSelection(chkOpt,'Gender');    
//if(myBoolean==false)
//{   
//    return false;
//}    
  
 


//City
myBoolean=blankCheck(txtCity,'City');    
if(myBoolean==false)
{   
   // txtCity.style.borderColor='red';
   // txtCity.style.borderWidth='2px';
    return false;
} 
else
{
  //  txtCity.style.borderColor='#68c417';
   // txtCity.style.borderWidth='1px';
}

 myBoolean=CheckCH(txtCity);  
if(myBoolean==false)
{   
  //  txtCity.style.borderColor='red';
   // txtCity.style.borderWidth='2px';
    return false;
} 
else
{
   // txtCity.style.borderColor='#68c417';
  //  txtCity.style.borderWidth='1px';
}


//Country
myBoolean=blankCheck(txtCountry,'Country');    
if(myBoolean==false)
{   
   // txtCountry.style.borderColor='red';
  //  txtCountry.style.borderWidth='2px';
    return false;
} 
else
{
    txtCountry.style.borderColor='#68c417';
  //  txtCountry.style.borderWidth='1px';
}


 myBoolean=CheckCH(txtCountry);  
if(myBoolean==false)
{   
  //  txtCountry.style.borderColor='red';
   // txtCountry.style.borderWidth='2px';
    return false;
} 
else
{
   // txtCountry.style.borderColor='#68c417';
  //  txtCountry.style.borderWidth='1px';
}





myBoolean=CountryCheck(txtCountry,'Country');    
if(myBoolean==false)
{   
    //txtCountry.style.borderColor='red';
   // txtCountry.style.borderWidth='2px';
    return false;
} 
else
{
   // txtCountry.style.borderColor='#68c417';
  //  txtCountry.style.borderWidth='1px';
}



//Zip
myBoolean=blankCheck(txtZip,'Pin Code');
if(myBoolean==false)
{   
   // txtZip.style.borderColor='red';
  //  txtZip.style.borderWidth='2px';
    return false;
} 
else
{
   // txtZip.style.borderColor='#68c417';
   // txtZip.style.borderWidth='1px';
}
 
myBoolean=integerCheck(txtZip,'Zip Code');   
if(myBoolean==false)
{   
   // txtZip.style.borderColor='red';
  //  txtZip.style.borderWidth='2px';
    return false;
}
else
{
   // txtZip.style.borderColor='#68c417';
   // txtZip.style.borderWidth='1px';
}

    if(txtZip.value.length!=6)
    {
    alert('Please Enter Six Digit PinCode.');
    txtZip.focus();
   //  txtZip.style.borderColor='red';
  //  txtZip.style.borderWidth='2px';
    return false;
    
    }


//Phone
if (txtTel.value=='Phone')
{
txtTel.value='';
} 

myBoolean=blankCheck(txtTel,'Phone');    
if(myBoolean==false)
{   
   // txtTel.style.borderColor='red';
  //  txtTel.style.borderWidth='2px';
    return false;
} 
else
{
  //  txtTel.style.borderColor='#68c417';
  //  txtTel.style.borderWidth='1px';
} 
myBoolean=integerCheck(txtTel,'Phone'); 
 
if(myBoolean==false)
{   
  //  txtTel.style.borderColor='red';
  //  txtTel.style.borderWidth='2px';
    return false;
} 
else
{
   // txtTel.style.borderColor='#68c417';
  //  txtTel.style.borderWidth='1px';
} 

if (txtTel.value.length<5)
{
    alert("Phone Number Can Not Be Less Than 5 Digits.");
  //  txtTel.style.borderColor='red';
  //  txtTel.style.borderWidth='2px';
    return false;
} 
else
{
  //  txtTel.style.borderColor='#68c417';
  //  txtTel.style.borderWidth='1px';
} 
 


 var chosenoption=SelectInt.options[SelectInt.selectedIndex]  
 if (chosenoption.value=="- Please Select -")
 {
 alert('Please Select Interest In');
 SelectInt.focus();
   return false;
 
 }
  

 

//myBoolean=integerCheck(txtMobile,'Mobile'); 

//if(myBoolean==false)
//{   
//    txtMobile.style.borderColor='red';
//    txtMobile.style.borderWidth='2px';
//    return false;
//} 
//else
//{
//    txtMobile.style.borderColor='#68c417';
//    txtMobile.style.borderWidth='1px';
//} 
//if (txtMobile.value.length!=10)
//{
//    alert("Mobile Number Should Be of 10 Digits.");
//    txtMobile.style.borderColor='red';
//    txtMobile.style.borderWidth='2px';
//    return false;
//} 
//else
//{
//    txtMobile.style.borderColor='#68c417';
//    txtMobile.style.borderWidth='1px';
//} 

 


   document.forms[0].action="MailToUsThanks.aspx";

}

function  blankCheck(control,message)
{
    if (control.value=='')
    {
        alert('Please Enter The '+message);
        control.focus();
        return false;
    }
}

function redirect(redrFirm)
{
    window.location.href=redrFirm;
}

function  integerCheck(control,message)
{
    var digits='0123456789';
    var temp;
    for (var i=0;i<control.value.length;i++)
        {
            temp=control.value.substring(i,i+1);
            if (digits.indexOf(temp)==-1)
            {
                alert("'"+temp+"'" +" character in Your "+ message +" seems incorrect. Please try again.");
                control.focus();
                return false;
            }        
        }      
}


function validateEmails(field, delimiter) {
 var delimiter = delimiter || ';';
 var filter  = /([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+>?$/; 
 var error = 0;

 // Create an array by splitting the field along the delimiter
 var aEmails = field.value.split(';');
 
 // For each of the emails
 for(index = 0; index < aEmails.length; index++) {
  // Trim spaces from the ends
  aEmails[index] = (aEmails[index].replace(/^\s+/,'')).replace(/\s+$/,'');
  // Check whether an email is present
  if(aEmails[index] != '' && aEmails[index].search(filter) == -1)
  {
   error = 1;
   alert('Your Email Id Is Not Valid');
   }
 }
 return error
 
 // Update the value of the field
 field.style.backgroundColor = (error == 1) ? 'FFFFCC' : 'FFFFFF';
}


function ValidateDung(txtName,txtAddress,txtContactNo,txtEmail,txtMessage)
{
var txtName=document.getElementById(txtName);
var txtAddress=document.getElementById(txtAddress);
var txtContactNo=document.getElementById(txtContactNo);
var txtEmail=document.getElementById(txtEmail);
var txtMessage=document.getElementById(txtMessage);

 var myBoolean=new Boolean(true);  


//Name 
myBoolean=blankCheck(txtName,'Name');    
if(myBoolean==false)
{   
    return false;
} 



//Address
myBoolean=blankCheck(txtAddress,'Address');    
if(myBoolean==false)
{   
    return false;
} 

//Contact No.
myBoolean=blankCheck(txtContactNo,'Contact No.');    
if(myBoolean==false)
{   
    return false;
} 


  myBoolean=integerCheck(txtContactNo,'Contact No.');
if(myBoolean==false)
{   
    return false;
} 

if(txtContactNo.value.length<5 || txtContactNo.value.length>12)
{
alert('Contact No. can not be less then 5 or greater then 12 ');
txtContactNo.focus();
return false;
}


//Email
myBoolean=blankCheck(txtEmail,'Email');    
if(myBoolean==false)
{   
    return false;
} 




//Email
var  status=validateEmails(txtEmail);
if (status=="1")
{
    txtEmail.focus();
    return false; 
} 


//txtMessage
myBoolean=blankCheck(txtMessage,'Message');    
if(myBoolean==false)
{   
    return false;
} 


}


function greenbtnmover(item)
{
    //alert('');
    if (item.disabled==false)
    {
        item.style.color='white';
        item.style.fontSize='13px'; 

    }

}
function greenbtnmout(item)
{

    if ((item.value!='Processing...')&&(item.value!='Searching...'))
    { 
        item.style.color='#0033CC';
        item.style.fontSize='12px'; 
    }
}  

function assLinksOver(it1,it2)
{
//debugger;
var it1=document.getElementById(it1);
var it2=document.getElementById(it2);



it1.style.color='red';
it1.style.fontWeight='bold';
it2.style.color='red';
it2.style.fontWeight='bold';


}

function assLinksOut(it1,it2)
{

var it1=document.getElementById(it1);
var it2=document.getElementById(it2);
 
it1.style.color='#790507';
it1.style.fontWeight='bold';
it2.style.color='#790507';
it2.style.fontWeight='bold';

}






