var ccErrorNo = 0;
var ccErrors = new Array ()

ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function checkCreditCard (cardnumber, cardname) {
     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.
  
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  cards [0] = {name: "VISA", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "MC", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
  cards [2] = {name: "DinersClub", 
               length: "14,16", 
               prefixes: "305, 36, 38, 54,55",
               checkdigit: true};
  cards [3] = {name: "CarteBlanche", 
               length: "14", 
               prefixes: "300,301,302,303,304,305",
               checkdigit: true};
  cards [4] = {name: "AmEx", 
               length: "15", 
               prefixes: "34,37",
               checkdigit: true};
  cards [5] = {name: "Discover", 
               length: "16", 
               prefixes: "6011,622,64,65",
               checkdigit: true};
  cards [6] = {name: "JCB", 
               length: "16", 
               prefixes: "35",
               checkdigit: true};
  cards [7] = {name: "enRoute", 
               length: "15", 
               prefixes: "2014,2149",
               checkdigit: true};
  cards [8] = {name: "Solo", 
               length: "16,18,19", 
               prefixes: "6334, 6767",
               checkdigit: true};
  cards [9] = {name: "Switch", 
               length: "16,18,19", 
               prefixes: "4903,4905,4911,4936,564182,633110,6333,6759",
               checkdigit: true};
  cards [10] = {name: "Maestro", 
               length: "12,13,14,15,16,18,19", 
               prefixes: "5018,5020,5038,6304,6759,6761",
               checkdigit: true};
  cards [11] = {name: "VisaElectron", 
               length: "16", 
               prefixes: "417500,4917,4913,4508,4844",
               checkdigit: true};
  cards [12] = {name: "LaserCard", 
               length: "16,17,18,19", 
               prefixes: "6304,6706,6771,6709",
               checkdigit: true};
               
  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++) {

    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }
  
  // If card type not found, report an error
  if (cardType == -1) {
     ccErrorNo = 0;
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false; 
  }
    
  // Now remove any spaces from the credit card number
  cardnumber = cardnumber.replace (/\s/g, "");
  
  // Check that the number is numeric
  var cardNo = cardnumber
  var cardexp = /^[0-9]{13,19}$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
     return false; 
  }
       
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2
  
    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {
    
      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;
    
      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }
    
      // Add the units element to the checksum total
      checksum = checksum + calc;
    
      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    } 
  
    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
     return false; 
    }
  }  

  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false; 
  var undefined; 

  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
    
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
      
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }
      
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
     return false; 
  }
    
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the 
  // length if all else was hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
     return false; 
  };   
  
  // The credit card is in the required format.
  return true;
}

///////////////////////////////

function Trim(str)
{

  return LTrim(RTrim(str));

}


function LTrim(str)
{

  for (var i=0; str.charAt(i)==" "; i++)
  {
    str =  str.substring(i,str.length-1);
  }
  return str;
}


function RTrim(str)
{

  for (var i=str.length-1; str.charAt(i)==" "; i--)
  {  
    str = str.substring(0,i);
  }
  return str;
}


function enterRTrim(str)
{
var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;

}
function enterLTrim(str)
{
 var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;

}
function enterTrim(str)
{
return enterRTrim(enterLTrim(str));

}


function isNum(phone)
{
 var reNum=/^[0-9\-]+$/;
	if(!reNum.test(phone))
	{
		return false;
	}
		return true;
}
function isNumeric(elem){
	var reNum=/^[0-9]+$/;
	if(!reNum.test(elem))
	{
		return false;
	}
		return true;
}
function isqty(elem){
	var reNum=/^[1-9]+$/;
	if(!reNum.test(elem))
	{
		return false;
	}
		return true;
}
function isusername(usename)
{
 var reNum=/^[a-zA-Z0-9\._@]+$/;
	if(!reNum.test(usename))
	{
		return false;
	}
		return true;
}
function isAlphabet(elem){
	var alphaExp = /^[a-zA-Z]+$/;
	
	if(!alphaExp.test(elem))
	{
	    return false;
		
	}
		return true;
	
}

function ismaxlength_textarea(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function numbersonly(myfield, e, dec)
{
   var unicode=e.charCode? e.charCode : e.keyCode    
    if (unicode!=8 && unicode!=9)
    { //if the key isn't the backspace key (which we should allow)
   
        if (unicode<48||unicode>57)  //if not a number
        return false //disable key press
    } 
    return true;   
}

function validatePwd(fieldname) {
      //Initialise variables
        var errorMsg = "";
        var space = " ";
        //fieldname = document.myform.password;
        fieldvalue = fieldname;
        fieldlength = fieldvalue.length;

        //It must not contain a space
        if (fieldvalue.indexOf(space) > -1) {
            errorMsg += "\nPasswords cannot include a space.\n";
        }
        //It must contain at least one character     
        if (!((fieldvalue.match(/[A-Z]/)) || (fieldvalue.match(/[a-z]/)))) {
            errorMsg += "\nStrong passwords must include at least one character.\n";
        }
        //It must contain at least one number
        if (!(fieldvalue.match(/\d/))) {
            errorMsg += "\nStrong passwords must include at least one number.\n";
        }
        //It must be at least 7 characters long.
        if (!((fieldlength >= 7) && (fieldlength <= 16))) {
            errorMsg += "\nStrong passwords must be between 7-16 characters long.\n";
        }
        //If there is aproblem with the form then display an error
        if (errorMsg != "") {
           // msg="";
           // msg = "______________________________________________________\n\n";
           // msg += "Please correct the problem(s) with your trial password test it again.\n";
          //  msg += "______________________________________________________\n";
           // errorMsg += alert(msg + errorMsg + "\n\n");
           errorMsg += alert(errorMsg);
            return false;
        }
        return true;
    }

function productqty_validate(pid)
{
    var field_name="cart_qty_"+pid;
    var L=document.getElementById(field_name).value.length;
    if(RTrim(document.getElementById(field_name).value)=="")
    {
            alert("Please enter product qty");
            document.frm_cart.field_name.focus();
            document.frm_cart.field_name.value=1;
            return false;
    }
    if(L<=2){
        if(!isqty(document.getElementById(field_name).value))
	    {
		    alert("Please enter correct product qty");
		    document.frm_cart.field_name.focus();
		    return false;
	     }
	}       
	return true;
}
	
function cust_accounteditvalid()
{
        invalid =" ";
        var radio_choice = false;
        for (counter = 0; counter < document.frm_accountedit.customer_gender.length; counter++)
        {
        if (document.frm_accountedit.customer_gender[counter].checked)
        radio_choice = true; 
        }

        if (!radio_choice)
        {
        alert("Please choose a gender type.")
        return (false);
        }
              

    if(RTrim(document.frm_accountedit.customer_fname.value)=="")
        {
            alert("Please enter first name");
            document.frm_accountedit.customer_fname.focus();
            return false;
        }
      if(RTrim(document.frm_accountedit.customer_lname.value)=="")
        {
            alert("Please enter last name");
            document.frm_accountedit.customer_lname.focus();
            return false;
        }
       if(RTrim(document.frm_accountedit.customer_phoneno.value)=="")
        {
            alert("Please enter phone number");
            document.frm_accountedit.customer_phoneno.focus();
            return false;
        }
      if(RTrim(document.frm_accountedit.customer_phoneno.value)!="")
        {
            if(!isNum(document.frm_accountedit.customer_phoneno.value))
			  {
				alert("Please enter correct phone number");
				document.frm_accountedit.customer_phoneno.focus();
				return false;
			 }
        }
        if(RTrim(document.frm_accountedit.customer_faxno.value)!="")
        {
            if(!isNum(document.frm_accountedit.customer_faxno.value))
			  {
				alert("Please enter correct fax number");
				document.frm_accountedit.customer_faxno.focus();
				return false;
			 }
        }
       return true;
}

function addressbook_validate()
{
  
      var radio_choice = false;
       var invalid =" ";
       var counter;
        // Loop from zero to the one minus the number of radio button selections
        for (counter = 0; counter < document.frm_addbook.c_gender.length; counter++)
        {
          // If a radio button has been selected it will return true
        // (If not it will return false)
        if (document.frm_addbook.c_gender[counter].checked)
        radio_choice = true; 
        }

        if (!radio_choice)
        {
        // If there were no selections made display an alert box 
        alert("Please choose a gender type.")
        return false;
        }
              

    if(RTrim(document.frm_addbook.c_fname.value)=="")
        {
            alert("Please enter first name");
            document.frm_addbook.c_fname.focus();
            return false;
        }
      if(RTrim(document.frm_addbook.c_lname.value)=="")
        {
            alert("Please enter last name");
            document.frm_addbook.c_lname.focus();
            return false;
        }
        if(RTrim(document.frm_addbook.c_address1.value)=="")
        {
            alert("Please enter Address 1");
            document.frm_addbook.c_address1.focus();
            return false;
        }
       if(RTrim(document.frm_addbook.c_country.value)=="")
        {
            alert("Please select country name");
            document.frm_addbook.c_country.focus();
            return false;
        }
      
    return true;
}

function validate_password()
{
    var invalid = " ";
		if(RTrim(document.frm_pass.current_password.value)=="")
        {
            alert("Please enter the current password.");
            document.frm_pass.current_password.value="";
            document.frm_pass.current_password.focus();
            return false;
        }
        if(RTrim(document.frm_pass.current_password.value)!=RTrim(document.frm_pass.oldpassword.value))
		{
		alert("Please enter the correct current password.");
		document.frm_pass.current_password.focus();
		return false;
		}	
        
        
       if(RTrim(document.frm_pass.new_password.value)=="")
        {
            alert("Please enter the new password ");
            document.frm_pass.new_password.value="";
            document.frm_pass.new_password.focus();
            return false;
        }
        if (document.frm_pass.new_password.value.indexOf(invalid) > -1) {
			 alert( "Please enter valid password. Password should not contain white spaces at any place." );
			 document.frm_pass.new_password.focus();
             return false;
		 }
		 
		if(document.frm_pass.new_password.value!="")
        {
            if(!validatePwd(document.frm_pass.new_password.value))
            {
                 return false;
            }
        }
      if(RTrim(document.frm_pass.new_confpassword.value)=="")
        {
            alert("Please enter the confirm password");
            document.frm_pass.new_confpassword.value="";
            document.frm_pass.new_confpassword.focus();
            return false;
        }
       if(RTrim(document.frm_pass.new_password.value)!=RTrim(document.frm_pass.new_confpassword.value))
		{
		    alert("Password and confirm password do not match. \n Please re-enter the passwords.!");
		    document.frm_pass.new_confpassword.value="";
		    document.frm_pass.new_confpassword.focus();
		    return false;
		}	
	  return true;
}


	function create_account_validation()
{

        invalid =" ";
        var radio_choice = false;
        for (counter = 0; counter < document.frm_create_account.gender.length; counter++)
        {
       if (document.frm_create_account.gender[counter].checked)
        radio_choice = true; 
        }

        if (!radio_choice)
        {
        alert("Please choose a gender.")
        return (false);
        }
            

    if(RTrim(document.frm_create_account.firstname.value)=="")
        {
            alert("Please enter first name");
            document.frm_create_account.firstname.focus();
            return false;
        }
      if(RTrim(document.frm_create_account.lastname.value)=="")
        {
            alert("Please enter last name");
            document.frm_create_account.lastname.focus();
            return false;
        }
        if(RTrim(document.frm_create_account.email_address.value)=="")
        {
            alert("Please enter Email Id");
            document.frm_create_account.email_address.focus();
            return false;
        }
        if (document.frm_create_account.email_address.value != "")
		{
		        re=/\w{1,}/;
		        emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
		        if(!(emailExp.test(document.frm_create_account.email_address.value)))
		        {
		        alert("Please Enter Correct Email Id");
		        document.frm_create_account.email_address.focus();
		        return false;
		        }
		}
        
        
        if(RTrim(document.frm_create_account.address1.value)=="")
        {
            alert("Please enter address1");
            document.frm_create_account.address1.focus();
            return false;
        } 
        
        if(RTrim(document.frm_create_account.country_create_account.value)=="")
        {
            alert("Please select country");
            document.frm_create_account.country_create_account.focus();
            return false;
        } 
        if(RTrim(document.frm_create_account.postcode.value)=="")
        {
            alert("Please enter post code");
            document.frm_create_account.postcode.focus();
            return false;
        }
      if(RTrim(document.frm_create_account.postcode.value)!="")
        {
            if(!isNum(document.frm_create_account.postcode.value))
			  {
				alert("Please enter correct post code");
				document.frm_create_account.postcode.focus();
				return false;
			 }
        }
        
        
      if(RTrim(document.frm_create_account.telephone.value)=="")
        {
            alert("Please enter phone number");
            document.frm_create_account.telephone.focus();
            return false;
        }
      if(RTrim(document.frm_create_account.telephone.value)!="")
        {
            if(!isNum(document.frm_create_account.telephone.value))
			  {
				alert("Please enter correct phone number");
				document.frm_create_account.telephone.focus();
				return false;
			 }
        }
        
        
        if(RTrim(document.frm_create_account.fax.value)!="")
        {
            if(!isNum(document.frm_create_account.fax.value))
			  {
				alert("Please enter correct fax number");
				document.frm_create_account.fax.focus();
				return false;
			 }
        }
                        
        if(RTrim(document.frm_create_account.password.value)=="")
        {
            alert("Please enter password ");
            document.frm_create_account.password.focus();
            return false;
        }
        if (document.frm_create_account.password.value.indexOf(invalid) > -1) {
			 alert( "Please enter valid password. Password should not contain white spaces at any place." );
			 document.frm_create_account.password.focus();
            return false;
		 }
		 
		if(RTrim(document.frm_create_account.password.value) !="")
        {
             if(!validatePwd(document.frm_create_account.password.value))
            {
                 return false;
            }
        }
      if(RTrim(document.frm_create_account.conf_password.value)=="")
        {
            alert("Please enter the password confirmation");
            document.frm_create_account.conf_password.focus();
            return false;
        }
       if(RTrim(document.frm_create_account.password.value)!=RTrim(document.frm_create_account.conf_password.value))
		{
		alert("Password and password confirmation do not match. \n Please re-enter the password confirmation.!");
		document.frm_create_account.conf_password.value="";
		document.frm_create_account.conf_password.focus();
		return false;
		}	
        
        /*
         if(document.getElementById("customer_count").value == '1')
                {           
                
                alert("Only one product can be featured.To make this product featured please make the previous product unfeatured");
                return false;
                }
        */
         
    return true;
}

function productqtyspecial_validate(speid)
	{
	        var field_name_spe="products_qty_"+speid;
	        if(RTrim(document.getElementById(field_name_spe).value)=="")
                {
                    alert("Please enter product qty");
                    document.getElementById(field_name_spe).focus();
                    document.getElementById(field_name_spe).value="";
                    return false;
                }
              if(!isqty(document.getElementById(field_name_spe).value))
			  {
				alert("Please enter correct product qty");
				document.getElementById(field_name_spe).focus();
				return false;
			 }
                
                
	return true;
	}
	
function validate_shipping() {
        var radio_choice = false;
        for (var counter = 0; counter < document.frm_shipping.shipping.length; counter++)
        {
           if (document.frm_shipping.shipping[counter].checked)
            radio_choice = true; 
            }

        if (!radio_choice)
        {
        alert("Please choose shipping method.")
        return (false);
        }
                      
	return true;  
        
}
	
function contactus_validation()
{

        

    if(RTrim(document.contact.fullname.value)=="")
        {
            alert("Please enter full name");
            document.contact.fullname.focus();
            return false;
        }
     
        if(RTrim(document.contact.emailadd.value)=="")
        {
            alert("Please enter Email Id");
            document.contact.emailadd.focus();
            return false;
        }
        if (document.contact.emailadd.value != "")
		{
		        re=/\w{1,}/;
		        emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
		        if(!(emailExp.test(document.contact.emailadd.value)))
		        {
		        alert("Please Enter Correct Email Id");
		        document.contact.emailadd.focus();
		        return false;
		        }
		}
        
             
      if(RTrim(document.contact.contactno.value)!="")
        {
            if(!isNum(document.contact.contactno.value))
			  {
				alert("Please enter correct contact number");
				document.contact.contactno.focus();
				return false;
			 }
        }
        
         if(enterTrim(document.contact.enquiry.value)=="")
        {
            alert("Please enter enquiry detail.");
            document.contact.enquiry.focus();
            return false;
        }
      	
    return true;
}


function search_validation()
{
   if(RTrim(document.frm_seach.prodkey.value)=="")
        {
            alert("Please product name");
            document.frm_seach.prodkey.focus();
            return false;
        }
       return true;
}
		
		function emailfriend_validation()
{

        

    if(RTrim(document.emailtofriend.y_name.value)=="")
        {
            alert("Please enter your name");
            document.emailtofriend.y_name.focus();
            return false;
        }
     
        if(RTrim(document.emailtofriend.y_email_id.value)=="")
        {
            alert("Please enter your Email Id");
            document.emailtofriend.y_email_id.focus();
            return false;
        }
        if (document.emailtofriend.y_email_id.value != "")
		{
		        re=/\w{1,}/;
		        emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
		        if(!(emailExp.test(document.emailtofriend.y_email_id.value)))
		        {
		        alert("Please Enter Correct Email Id");
		        document.emailtofriend.y_email_id.focus();
		        return false;
		        }
		}
        
             
       if(RTrim(document.emailtofriend.f_name.value)=="")
        {
            alert("Please enter your friend name");
            document.emailtofriend.f_name.focus();
            return false;
        }
     
        if(RTrim(document.emailtofriend.f_email_id.value)=="")
        {
            alert("Please enter your friend Email Id");
            document.emailtofriend.f_email_id.focus();
            return false;
        }
        if (document.emailtofriend.f_email_id.value != "")
		{
		        re=/\w{1,}/;
		        emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
		        if(!(emailExp.test(document.emailtofriend.f_email_id.value)))
		        {
		        alert("Please Enter Correct Email Id");
		        document.emailtofriend.f_email_id.focus();
		        return false;
		        }
		}
      	
    return true;
}

function ValidateCard()
{

    var m_names = new Array("1", "2", "3", 
    "4", "5", "6", "7", "8", "9", 
    "10", "11", "12");

    var d = new Date();
    var curr_month = d.getMonth();
    var curr_year = d.getFullYear();
    
   curYear = curr_year.toString().slice(2);

   if(document.frm_payment.card_type.value=="")
    {
        alert("Please select card type");
        document.frm_payment.card_type.focus();
        return false;
    }
    if(RTrim(document.frm_payment.holder_name.value)=="")
        {
            alert("Please enter card holder name");
            document.frm_payment.holder_name.focus();
            return false;
        }
        if(RTrim(document.frm_payment.card_no.value)=="")
        {
            alert("Please enter card number");
            document.frm_payment.card_no.focus();
            return false;
        }
        myCardNo = document.getElementById('card_no').value;
        myCardType = document.frm_payment.card_type.value;
        if (!checkCreditCard(myCardNo,myCardType)) {
            alert (ccErrors[ccErrorNo])
            document.frm_payment.card_no.focus();
            return false;
        }
                
       if(RTrim(document.frm_payment.expirymonth.value)=="")
        {
            alert("Please enter expiry month");
            document.frm_payment.expirymonth.focus();
            return false;
        }
        if(RTrim(document.frm_payment.expiryyear.value)=="")
        {
            alert("Please enter expiry year");
            document.frm_payment.expiryyear.focus();
            return false;
        }
        if((document.frm_payment.expirymonth.value!="") && (document.frm_payment.expiryyear.value!=""))
        {
    
            if ((document.frm_payment.expiryyear.value == curYear) && parseInt(m_names[curr_month]) > parseInt(document.frm_payment.expirymonth.value))
            {
                alert("Expiry month should be greater than current month");
                return false;
            }
        }
        
       
       return true;
}
function set_jumppage(obj)
{
   // document.getElementById("jump_page").value=obj.value;
   document.getElementsByName("jump_page")[0].value=obj.value;
   document.getElementsByName("jump_page")[1].value=obj.value;
   
}

function client_validation()
{

       if(RTrim(document.frm_client.client_firstname.value)=="")
        {
            alert("Please enter your first name");
            document.frm_client.client_firstname.value="";
            document.frm_client.client_firstname.focus();
            return false;
        } 
        if(RTrim(document.frm_client.client_lastname.value)=="")
        {
            alert("Please enter your last name");
            document.frm_client.client_lastname.value="";
            document.frm_client.client_lastname.focus();
            return false;
        }
         if(RTrim(document.frm_client.client_email.value)=="")
        {
            alert("Please enter your email address");
            document.frm_client.client_email.value="";
            document.frm_client.client_email.focus();
            return false;
        }
        if (document.frm_client.client_email.value != "")
		{
		        re=/\w{1,}/;
		        emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
		        if(!(emailExp.test(document.frm_client.client_email.value)))
		        {
		        alert("Please enter correct email address");
		        document.frm_client.client_email.focus();
		        return false;
		        }
		}
		 if(RTrim(document.frm_client.EVALUE.value)==1)
        {
            alert("Specified Email address already exit!");
            document.frm_client.client_email.focus();
            return false;
        }
        
         
        if(RTrim(document.frm_client.client_pno.value)=="")
        {
            alert("Please enter your phone no.");
            document.frm_client.client_pno.value="";
            document.frm_client.client_pno.focus();
            return false;
        }
        
        
      if(RTrim(document.frm_client.client_country.value)=="")
        {
            alert("Please enter your country");
            document.frm_client.client_country.value="";
            document.frm_client.client_country.focus();
            return false;
        }
        if(RTrim(document.frm_client.client_address.value)=="")
        {
            alert("Please enter your address");
            document.frm_client.client_address.value="";
            document.frm_client.client_address.focus();
            return false;
        }
    return true;
}
function document_validation()
{

    if(RTrim(document.frm_document.project_name.value)=="")
    {
        alert("Please select project name");
        document.frm_document.project_name.value="";
        document.frm_document.project_name.focus();
        return false;
    }
            
    if(RTrim(document.frm_document.document.value)=="")
    {
        alert("Please enter document name");
        document.frm_document.document.value="";
        document.frm_document.document.focus();
        return false;
    }


    if(RTrim(document.getElementById('attach').value) !="") 
    {
    			
        var attachfileNamedocument = document.getElementById('attach').value;               
        var attachfileextdocument = attachfileNamedocument.substring(attachfileNamedocument.lastIndexOf('.') + 1);
        if((attachfileextdocument!="doc") && (attachfileextdocument!="docx") && (attachfileextdocument!="xls") && (attachfileextdocument!="pdf"))
        {
            alert("supports .DOC, .DOCX, .XLS and .PDF document formats. Your file-type is " + attachfileextdocument + ".\n It is not supported file");
            document.getElementById('attach').focus();
            return false;
        }                

    } 
return true;
}

function contactus_validation()
{

    if(RTrim(document.contact.fullname.value)=="")
        {
            alert("Please enter your name");
            document.contact.fullname.focus();
            return false;
        }
     
        if(RTrim(document.contact.emailadd.value)=="")
        {
            alert("Please enter your email address");
            document.contact.emailadd.focus();
            return false;
        }
        if (document.contact.emailadd.value != "")
		{
		        re=/\w{1,}/;
		        emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
		        if(!(emailExp.test(document.contact.emailadd.value)))
		        {
		        alert("Please enter correct email address");
		        document.contact.emailadd.focus();
		        return false;
		        }
		}

		if(RTrim(document.contact.phone.value)=="")
        {
            alert("Please enter your phone number");
            document.contact.phone.focus();
            return false;
        }

     
      if(RTrim(document.contact.phone.value)!="")
        {
            if(!isNum(document.contact.phone.value))
			  {
				alert("Please enter correct contact number");
				document.contact.phone.focus();
				return false;
			 }
        }
        
         if(enterTrim(document.contact.industry.value)=="")
        {
            alert("Please select industry.");
            document.contact.industry.focus();
            return false;
        }
      	
    return true;
}
