﻿// JScript File
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';

}





