
function validate(val){

 var fName = val.FName.value;
 var lName = val.LName.value;
 var compName = val.Comp_Name.value;
 var design = val.Designation.value;
 var email = val.Email_Id.value;
 var vemail = val.VEmail_Id.value;
 var pass = val.P_Password.value;
 var cpass =val.Cp_Password.value;
 var add1 = val.Add_1.value;
 var add2 = val.Add_2.value;
 var city = val.City.value;
 var zip = val.Num_Zip_Code.value;
 var phone = val.Phone_No.value;

 var fNameInt = charCheck(fName);
 var lNameInt = charCheck(lName);
 var emailInt = isWhiteSpace(email);
 var passInt = isWhiteSpace(pass);
 var zipNum = numCheck(zip);
 var phoneNum = numCheckTel(phone);

 if(fName == ""){
  alert("Please enter your First Name");
  val.FName.focus();
 }
 else if(fName.length > 30){
  alert("Please enter maximun of 30 characters in the First Name field");
  val.FName.focus();
 }
 else if(fNameInt == 0){
  alert("Please enter letter characters in the First Name field.");
  val.FName.focus();
 }
 else if (lName == ""){
  alert("Please enter your Last Name");
  val.LName.focus();
 }
 else if (lName.length > 30){
  alert("Please enter maximum of 30 characters in the Last Name field.");
  val.LName.focus();
 }
 else if(lNameInt == 0){
  alert("Please enter letter characters in the Last Name field.");
  val.LName.focus();
 }
 else if(compName == ""){
  alert("Please enter your Company Name");
  val.Comp_Name.focus();
 }
 else if(compName.length > 100){
  alert("Please enter maximum of 100 characters in the Company Name field.");
  val.Comp_Name.focus();
 }
 else if(design == ""){
  alert("Please enter your Designation");
  val.Designation.focus();
 }
 else if(design.length > 60){
  alert("Please enter maximum of 60 characters in the Designation field.");
  val.Designation.focus();
 }
 else if(email  == "" ){
  alert("Email field cannot be empty.");
  val.Email_Id.focus();
 }
 else if(email.length > 60 ){
  alert("Please enter maximum of 60 characters in the Email Id field.");
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") == -1 || email.indexOf("@") == 0 || (email.indexOf("@") == (email.length-1))){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf(".") == -1 || (email.lastIndexOf(".") == (email.length-1))){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") > email.lastIndexOf(".")){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") ==  (email.lastIndexOf(".")-1)){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") !=  email.lastIndexOf("@")){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(emailInt == 1){
  alert("Please do not use any white space in the Email field.");
  val.Email_Id.focus();
 }
 else if(vemail  == "" ){
  alert("Please Verify Your Email Id.");
  val.VEmail_Id.focus();
 }
 else if(vemail != email){
  alert("Your Email and verify Email field does not Match ");
  val.Email_Id.focus();
 }
 else if(pass == email){
  alert("Your password and email cannot be same.");
  val.P_Password.focus();
 }
 else if(pass.length == 0){
  alert("Your password should be minimum of 5 character and maximum of 10 character.");
  val.P_Password.focus();
 }
 else if(pass.length < 5){
  alert("Your password should be minimum of 5 character and maximum of 10 character.");
  val.P_Password.focus();
 }
 else if(pass.length > 10){
  alert("Your password should be minimum of 5 character and maximum of 10 character.");
  val.P_Password.focus();
 }
 else if(pass != cpass){
  alert("Your password and confirm password field does not match. Please re-enter.");
  val.P_Password.focus();
 }
 else if(passInt == 1){
  alert("Please do not use any white space in the password field.");
  val.P_Password.focus();
 }
 else if(add1 == ""){
  alert("Please enter your current address.");
  val.Add_1.focus();
 }
 else if(add1.length > 255){
  alert("Please enter maximum of 255 characters in the Address field.");
  val.Add_1.focus();
 }
 else if(add2.length > 255){
  alert("Please enter maximum of 255 characters in the Address field.");
  val.Add_2.focus();
 }
 else if(city == ""){
  alert("Please enter the city.");
  val.City.focus();
 }
 else if(city.length > 100){
  alert("Please enter at most 100 characters in the City field.");
  val.City.focus();
 }
 else if(zip == ""){
  alert("Please enter your Pin Code.");
  val.Num_Zip_Code.focus();
 }
 else if(zip.length > 9){
  alert("Please enter at most 9 characters in the Pin Code field.");
  val.Num_Zip_Code.focus();
 }
 else if(zipNum == 0){
  alert("Please enter any number between 0 to 9(without any space) in the Pin Code field.");
  val.Num_Zip_Code.focus();
 }
 else if(val.State.selectedIndex == 0){
  alert("The first \"Select State\" option is not a valid selection. Please choose one of the other options.");
  val.State.focus();
 }
 else if(phone.length < 6){
  alert("Please enter minimum of 6 digits in the Phone No. field.");
  val.Phone_No.focus();
 }
 else if(phone.length > 50){
  alert("Please enter at most 50 digits in the Phone No. field.");
  val.Phone_No.focus();
 }
 else if(phoneNum == 0){
  alert("Please enter any number between 0 and 9 in the Phone No field. Use comma for two or more Phone Nos.");
  val.Phone_No.focus();
 }
 else if(val.InfoAboutUs.selectedIndex == 0){
  alert("The \"Please select one...\" option is not a valid selection. Please choose one of the other options.");
  val.InfoAboutUs.focus();
 }
 else{
  val.submit();
 }
}

function validateReseller(val){

 var fName = val.FName.value;
 var lName = val.LName.value;
 var compName = val.Comp_Name.value;
 var design = val.Designation.value;
 var email = val.Email_Id.value;
 var vemail = val.VEmail_Id.value;
 var add1 = val.Add_1.value;
 var add2 = val.Add_2.value;
 var city = val.City.value;
 var zip = val.Num_Zip_Code.value;
 var phone = val.Phone_No.value;
 var fax = val.Fax_No.value;
 var noofPC = val.Num_No_of_PC.value;
 var salesTax = val.Hid_Res_Sales_Tax_No.value;
 var turnOver = val.Hid_Res_TurnOver.value;
 var softSales = val.Hid_Res_Soft_Sales.value;
 var top5Prod = val.Hid_Res_Top5Prod.value;
 var noofEmp = val.Hid_Res_Num_No_of_Emp.value;
 var name1 = val.Hid_Res_Ref1_Name.value;
 var company1 = val.Hid_Res_Ref1_Company.value;
 var email1 = val.Hid_Res_Ref1_Email_Id.value;
 var name2 = val.Hid_Res_Ref2_Name.value;
 var company2 = val.Hid_Res_Ref2_Company.value;
 var email2 = val.Hid_Res_Ref2_Email_Id.value;
 var name3 = val.Hid_Res_Ref3_Name.value;
 var company3 = val.Hid_Res_Ref3_Company.value;
 var email3 = val.Hid_Res_Ref3_Email_Id.value;

 var fNameInt = charCheck(fName);
 var lNameInt = charCheck(lName);
 var emailInt = isWhiteSpace(email);
 var zipNum = numCheck(zip);
 var phoneNum = numCheckTel(phone);
 var faxNum = numCheckTel(fax);
 var noofPCNum = numCheck(noofPC);
 var noofEmpNum = numCheck(noofEmp);
 var email1Int = isWhiteSpace(email1);
 var email2Int = isWhiteSpace(email2);
 var email3Int = isWhiteSpace(email3);

 if(fName == ""){
  alert("Please enter your First Name");
  val.FName.focus();
 }
 else if(fName.length > 30){
  alert("Please enter maximun of 30 characters in the First Name field");
  val.FName.focus();
 }
 else if(fNameInt == 0){
  alert("Please enter letter characters in the First Name field.");
  val.FName.focus();
 }
 else if (lName == ""){
  alert("Please enter your Last Name");
  val.LName.focus();
 }
 else if (lName.length > 30){
  alert("Please enter maximum of 30 characters in the Last Name field.");
  val.LName.focus();
 }
 else if(lNameInt == 0){
  alert("Please enter letter characters in the Last Name field.");
  val.LName.focus();
 }
 else if(compName == ""){
  alert("Please enter your Company Name");
  val.Comp_Name.focus();
 }
 else if(compName.length > 100){
  alert("Please enter maximum of 100 characters in the Company Name field.");
  val.Comp_Name.focus();
 }
 else if(design == ""){
  alert("Please enter your Designation");
  val.Designation.focus();
 }
 else if(design.length > 60){
  alert("Please enter maximum of 60 characters in the Designation field.");
  val.Designation.focus();
 }
 else if(email  == "" ){
  alert("Email field cannot be empty.");
  val.Email_Id.focus();
 }
 else if(email.length > 60 ){
  alert("Please enter maximum of 60 characters in the Email Id field.");
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") == -1 || email.indexOf("@") == 0 || (email.indexOf("@") == (email.length-1))){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf(".") == -1 || (email.lastIndexOf(".") == (email.length-1))){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") > email.lastIndexOf(".")){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") ==  (email.lastIndexOf(".")-1)){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") !=  email.lastIndexOf("@")){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(emailInt == 1){
  alert("Please do not use any white space in the Email field.");
  val.Email_Id.focus();
 }
 else if(vemail  == "" ){
  alert("Please Verify Your Email Id.");
  val.VEmail_Id.focus();
 }
 else if(vemail != email){
  alert("Your Email and verify Email field does not Match ");
  val.Email_Id.focus();
 }
 else if(add1 == ""){
  alert("Please enter your current address.");
  val.Add_1.focus();
 }
 else if(add1.length > 255){
  alert("Please enter maximum of 255 characters in the Address field.");
  val.Add_1.focus();
 }
 else if(add2.length > 255){
  alert("Please enter maximum of 255 characters in the Address field.");
  val.Add_2.focus();
 }
 else if(city == ""){
  alert("Please enter the city.");
  val.City.focus();
 }
 else if(city.length > 100){
  alert("Please enter at most 100 characters in the City field.");
  val.City.focus();
 }
 else if(zip == ""){
  alert("Please enter your Pin Code.");
  val.Num_Zip_Code.focus();
 }
 else if(zip.length > 9){
  alert("Please enter at most 9 characters in the Pin Code field.");
  val.Num_Zip_Code.focus();
 }
 else if(zipNum ==0){
  alert("Please enter any number between 0 to 9(without any space) in the Pin Code field.");
  val.Num_Zip_Code.focus();
 }
 else if(val.State.selectedIndex == 0){
  alert("The first \"Select State\" option is not a valid selection. Please choose one of the other options.");
  val.State.focus();
 }
 else if(phone.length < 6){
  alert("Please enter minimum of 6 digits in the Phone No. field.");
  val.Phone_No.focus();
 }
 else if(phone.length > 50){
  alert("Please enter at most 50 digits in the Phone No. field.");
  val.Phone_No.focus();
 }
 else if(phoneNum == 0){
  alert("Please enter any number between 0 and 9 in the Phone No field. Use comma for two or more Phone Nos.");
  val.Phone_No.focus();
 }
 else if(val.InfoAboutUs.selectedIndex == 0){
  alert("The \"Please select one...\" option is not a valid selection. Please choose one of the other options.");
  val.InfoAboutUs.focus();
 }
 else if(fax.length !=0 && fax.length < 6){
  alert("Please enter minimum of 6 digits in the Fax No. field.");
  val.Fax_No.focus();
 }
 else if(fax.length > 50){
  alert("Please enter at most 50 digits in the Fax No. field.");
  val.Fax_No.focus();
 }
 else if(faxNum == 0){
  alert("Please enter any number between 0 and 9 in the Fax No field.Use comma for two or more Fax Nos.");
  val.Fax_No.focus();
 }
 else if(noofPC.length > 9){
  alert("Please enter at most 9 digits in the No of PCs in your company field.");
  val.Num_No_of_PC.focus();
 }
 else if(noofPCNum == 0){
  alert("Please enter any number between 0 and 9 (without any space) in the No of PCs in your company field.");
  val.Num_No_of_PC.focus();
 }
 else if(salesTax.length > 255){
  alert("Please enter at most 255 characters in the Sales Tax field.");
  val.Hid_Res_Sales_Tax_No.focus();
 }
 else if(turnOver.length > 255){
  alert("Please enter at most 255 characters in the Turnover field.");
  val.Hid_Res_TurnOver.focus();
 }
 else if(softSales.length > 255){
  alert("Please enter at most 255 characters in the Software sales field.");
  val.Hid_Res_Soft_Sales.focus();
 }
 else if(top5Prod.length > 255){
  alert("Please enter at most 255 characters in the Top 5 Products sold.");
  val.Hid_Res_Soft_Sales.focus();
 }
 else if(noofEmp.length >9){
  alert("Please enter at most 9 digits in the No of Employee field.");
  val.Hid_Res_Num_No_of_Emp.focus();
 }
 else if(noofEmpNum == 0){
  alert("Please enter any number between 0 and 9 (without any space) in the No of Employee field.");
  val.Hid_Res_Num_No_of_Emp.focus();
 }
 else if(name1.length > 30){
  alert("Please enter at most 30 characters in the References - 1 Name field.");
  val.Hid_Res_Ref1_Name.focus();
 }
 else if(company1.length > 255){
  alert("Please enter at most 255 characters in the References - 1 Company field.");
  val.Hid_Res_Ref1_Company.focus();
 }
 else if(email1.length > 60){
  alert("Please enter at most 60 characters in the References - 1 Email field.");
  val.Hid_Res_Ref1_Email_Id.focus();
 }
 else if(email1.length != 0 && (email1.indexOf("@") == -1 || email1.indexOf("@") == 0 || (email1.indexOf("@") == (email1.length-1)))){
  alert("You have not entered valid References - 1 Email address.")
  val.Hid_Res_Ref1_Email_Id.focus();
 }
 else if(email1.length != 0 && (email1.indexOf(".") == -1 || (email1.lastIndexOf(".") == (email1.length-1)))){
  alert("You have not entered valid References - 1 Email address.")
  val.Hid_Res_Ref1_Email_Id.focus();
 }
 else if(email1.length != 0 && (email1.indexOf("@") > email1.lastIndexOf("."))){
  alert("You have not entered valid References - 1 Email address.")
  val.Hid_Res_Ref1_Email_Id.focus();
 }
 else if(email1.length != 0 && (email1.indexOf("@") ==  (email1.lastIndexOf(".")-1))){
  alert("You have not entered valid Email address.")
  val.Hid_Res_Ref1_Email_Id.focus();
 }
 else if(email1.length != 0 && (email1.indexOf("@") !=  email1.lastIndexOf("@"))){
  alert("You have not entered valid References - 1 Email address.")
  val.Hid_Res_Ref1_Email_Id.focus();
 }
 else if(email1.length != 0 && email1Int == 1){
  alert("Please do not use any white space in the References - 1 Email field.");
  val.Hid_Res_Ref1_Email_Id.focus();
 }
 else if(name2.length > 30){
  alert("Please enter at most 30 characters in the References - 2 Name field.");
  val.Hid_Res_Ref2_Name.focus();
 }
 else if(company2.length > 255){
  alert("Please enter at most 255 characters in the References - 2 Company field.");
  val.Hid_Res_Ref2_Company.focus();
 }
 else if(email2.length > 60){
  alert("Please enter at most 60 characters in the References -2 Email field.");
  val.Hid_Res_Ref2_Email_Id.focus();
 }
 else if(email2.length != 0 && (email2.indexOf("@") == -1 || email2.indexOf("@") == 0 || (email2.indexOf("@") == (email2.length-1)))){
  alert("You have not entered valid References - 2 Email address.")
  val.Hid_Res_Ref2_Email_Id.focus();
 }
 else if(email2.length != 0 && (email2.indexOf(".") == -1 || (email2.lastIndexOf(".") == (email2.length-1)))){
  alert("You have not entered valid References - 2 Email address.")
  val.Hid_Res_Ref2_Email_Id.focus();
 }
 else if(email2.length != 0 && (email2.indexOf("@") > email2.lastIndexOf("."))){
  alert("You have not entered valid References - 2 Email address.")
  val.Hid_Res_Ref2_Email_Id.focus();
 }
 else if(email2.length != 0 && (email2.indexOf("@") ==  (email2.lastIndexOf(".")-1))){
  alert("You have not entered valid Email address.")
  val.Hid_Res_Ref2_Email_Id.focus();
 }
 else if(email2.length != 0 && (email2.indexOf("@") !=  email2.lastIndexOf("@"))){
  alert("You have not entered valid References - 2 Email address.")
  val.Hid_Res_Ref2_Email_Id.focus();
 }
 else if(email2.length != 0 && email2Int == 1){
  alert("Please do not use any white space in the References - 2 Email field.");
  val.Hid_Res_Ref2_Email_Id.focus();
 }
 else if(name3.length > 30){
  alert("Please enter at most 30 characters in the References - 3 Name field.");
  val.Hid_Res_Ref3_Name.focus();
 }
 else if(company3.length > 255){
  alert("Please enter at most 255 characters in the References - 3 Company field.");
  val.Hid_Res_Ref3_Company.focus();
 }
 else if(email3.length > 60){
  alert("Please enter at most 60 characters in the References - 3 Email field.");
  val.Hid_Res_Ref3_Email_Id.focus();
 }
 else if(email3.length != 0 && (email3.indexOf("@") == -1 || email3.indexOf("@") == 0 || (email3.indexOf("@") == (email3.length-1)))){
  alert("You have not entered valid References - 3 Email address.")
  val.Hid_Res_Ref3_Email_Id.focus();
 }
 else if(email3.length != 0 && (email3.indexOf(".") == -1 || (email3.lastIndexOf(".") == (email3.length-1)))){
  alert("You have not entered valid References - 3 Email address.")
  val.Hid_Res_Ref3_Email_Id.focus();
 }
 else if(email3.length != 0 && (email3.indexOf("@") > email3.lastIndexOf("."))){
  alert("You have not entered valid References - 3 Email address.")
  val.Hid_Res_Ref3_Email_Id.focus();
 }
 else if(email3.length != 0 && (email3.indexOf("@") ==  (email3.lastIndexOf(".")-1))){
  alert("You have not entered valid Email address.")
  val.Hid_Res_Ref3_Email_Id.focus();
 }
 else if(email3.length != 0 && (email3.indexOf("@") !=  email3.lastIndexOf("@"))){
  alert("You have not entered valid References - 3 Email address.")
  val.Hid_Res_Ref3_Email_Id.focus();
 }
 else if(email3.length != 0 && email3Int == 1){
  alert("Please do not use any white space in the References - 3 Email field.");
  val.Hid_Res_Ref3_Email_Id.focus();
 }

 else{
  val.submit();
 }
}

function changeProfile(val){

 var fName = val.FName.value;
 var lName = val.LName.value;
 var compName = val.Comp_Name.value;
 var design = val.Designation.value;
 var add1 = val.Add_1.value;
 var add2 = val.Add_2.value;
 var city = val.City.value;
 var zip = val.Num_Zip_Code.value;
 var phone = val.Phone_No.value;

 var fNameInt = charCheck(fName);
 var lNameInt = charCheck(lName);
 var zipNum = numCheck(zip);
 var phoneNum = numCheckTel(phone);

 if(fName == ""){
  alert("Please enter your First Name");
  val.FName.focus();
 }
 else if(fName.length > 30){
  alert("Please enter maximun of 30 characters in the First Name field");
  val.FName.focus();
 }
 else if(fNameInt == 0){
  alert("Please enter letter characters in the First Name field.");
  val.FName.focus();
 }
 else if (lName == ""){
  alert("Please enter your Last Name");
  val.LName.focus();
 }
 else if (lName.length > 30){
  alert("Please enter maximum of 30 characters in the Last Name field.");
  val.LName.focus();
 }
 else if(lNameInt == 0){
  alert("Please enter letter characters in the Last Name field.");
  val.LName.focus();
 }
 else if(compName == ""){
  alert("Please enter your Company Name");
  val.Comp_Name.focus();
 }
 else if(compName.length > 100){
  alert("Please enter maximum of 100 characters in the Company Name field.");
  val.Comp_Name.focus();
 }
 else if(design == ""){
  alert("Please enter your Designation");
  val.Designation.focus();
 }
 else if(design.length > 60){
  alert("Please enter maximum of 60 characters in the Designation field.");
  val.Designation.focus();
 }
 else if(add1 == ""){
  alert("Please enter your current address.");
  val.Add_1.focus();
 }
 else if(add1.length > 255){
  alert("Please enter maximum of 255 characters in the Address field.");
  val.Add_1.focus();
 }
 else if(add2.length > 255){
  alert("Please enter maximum of 255 characters in the Address field.");
  val.Add_2.focus();
 }
 else if(city == ""){
  alert("Please enter the city.");
  val.City.focus();
 }
 else if(city.length > 100){
  alert("Please enter at most 100 characters in the City field.");
  val.City.focus();
 }
 else if(zip == ""){
  alert("Please enter your Pin Code.");
  val.Num_Zip_Code.focus();
 }
 else if(zip.length > 9){
  alert("Please enter at most 9 characters in the Pin Code field.");
  val.Num_Zip_Code.focus();
 }
 else if(zipNum ==0){
  alert("Please enter any number between 0 to 9(without any space) in the Pin Code field.");
  val.Num_Zip_Code.focus();
 }
 else if(val.State.selectedIndex == 0){
  alert("The first \"Select State\" option is not a valid selection. Please choose one of the other options.");
  val.State.focus();
 }
 else if(phone.length < 6){
  alert("Please enter minimum of 6 digits in the Phone No. field.");
  val.Phone_No.focus();
 }
 else if(phone.length > 50){
  alert("Please enter at most 50 digits in the Phone No. field.");
  val.Phone_No.focus();
 }
 else if(phoneNum == 0){
  alert("Please enter any number between 0 and 9 in the Phone No field. Use comma for two or more Phone Nos.");
  val.Phone_No.focus();
 }
 else{
  val.submit();
 }
}

function numCheck(val){

 var numberCheck = "0123456789";
 var notNum = 1;
 
 outer:for(i=0; i<val.length; i++){
  var index = val.charAt(i);
  inner:for(j=0; j<numberCheck.length; j++){
   if(index == numberCheck.charAt(j))
    break inner;
   if(j == numberCheck.length-1){
    notNum = 0;
    break outer;
   }
  }
 }
 return(notNum);
}


function numCheckTel(val){

 var numberCheck = "0123456789 ,";
 var notNum = 1;
 
 outer:for(i=0; i<val.length; i++){
  var index = val.charAt(i);
  inner:for(j=0; j<numberCheck.length; j++){
   if(index == numberCheck.charAt(j))
    break inner;
   if(j == numberCheck.length-1){
    notNum = 0;
    break outer;
   }
  }
 }
 return(notNum);
}


function charCheck(val){

 var characterCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ' ";

 var notChar = 1;
 
 outer:for(i=0; i<val.length; i++){
  var index = val.charAt(i);
  inner:for(j=0; j<characterCheck.length; j++){
   if(index == characterCheck.charAt(j))
    break inner;
   if(j == characterCheck.length-1){
    notChar = 0;
    break outer;
   }
  }
 }
 return(notChar);
}


function changePassword(val){

 var pass = val.P_Password.value;
 var cpass =document.ChPassForm.Cp_Password.value;
 var user = val.User.value;

 var passInt = isWhiteSpace(pass);

 if(pass.length == 0){
  alert("Your password should be minimum of 5 character and maximum of 10 character.");
  val.P_Password.focus();
 }
 else if(pass == user){
  alert("Your password and email cannot be same.");
  val.P_Password.focus();
 }
 else if(pass.length < 5){
  alert("Your password should be minimum of 5 character and maximum of 10 character.");
  val.P_Password.focus();
 }
 else if(pass.length > 10){
  alert("Your password should be minimum of 5 character and maximum of 10 character.");
  val.P_Password.focus();
 }
 else if(pass != cpass){
  alert("Your password and confirm password field does not match. Please re-enter.");
  val.P_Password.focus();
 }
 else if(passInt == 1){
  alert("Please do not use any white space in the password field.");
  val.P_Password.focus();
 }
 else{
  val.submit();
 }
}


function checkEmail(val){

 var email = val.Email_Id.value;
 var vemail = val.VEmail_Id.value;
 var emailInt = isWhiteSpace(email);

 if(email  == "" ){
  alert("Email field cannot be empty.");
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") == -1 || email.indexOf("@") == 0 || (email.indexOf("@") == (email.length-1))){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf(".") == -1 || (email.lastIndexOf(".") == (email.length-1))){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") > email.lastIndexOf(".")){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") ==  (email.lastIndexOf(".")-1)){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(email.indexOf("@") !=  email.lastIndexOf("@")){
  alert("You have not entered valid Email address.")
  val.Email_Id.focus();
 }
 else if(emailInt == 1){
  alert("Please do not use any white space in the Email field.");
  val.Email_Id.focus();
 }
 else if(vemail  == "" ){
  alert("Please Verify Your Email Id.");
  val.VEmail_Id.focus();
 }
 else if(vemail != email){
  alert("Your entries in Email field and verify Email field does not Match ");
  val.VEmail_Id.focus();
 }
 else{
  val.submit();
 }
}

function contactCheck(val){

 var email = val.from.value;
 var emailInt = isWhiteSpace(email);

 if(email  == "" ){
  alert("Email field cannot be empty.");
  val.from.focus();
 }
 else if(email.indexOf("@") == -1 || email.indexOf("@") == 0 || (email.indexOf("@") == (email.length-1))){
  alert("You have not entered valid Email address.")
  val.from.focus();
 }
 else if(email.indexOf(".") == -1 || (email.lastIndexOf(".") == (email.length-1))){
  alert("You have not entered valid Email address.")
  val.from.focus();
 }
 else if(email.indexOf("@") > email.lastIndexOf(".")){
  alert("You have not entered valid Email address.")
  val.from.focus();
 }
 else if(email.indexOf("@") ==  (email.lastIndexOf(".")-1)){
  alert("You have not entered valid Email address.")
  val.from.focus();
 }
 else if(email.indexOf("@") !=  email.lastIndexOf("@")){
  alert("You have not entered valid Email address.")
  val.from.focus();
 }
 else if(emailInt == 1){
  alert("Please do not use any white space in the Email field.");
  val.from.focus();
 }
 else{
  val.submit();
 }
}

function isWhiteSpace(val){

 var whiteSpace=0;

 for(i=0; i<val.length; i++){
  var index = val.charCodeAt(i);
  if(index == 32 || index == 255){
   whiteSpace = 1;   
   break;
  }
 }
 return (whiteSpace);
}


function changeColor_MouseOver(textColor){
 textColor.style.color = "red";
}


function changeColor_MouseOut(textColor){
 textColor.style.color = "#2F73AF";
}


function changeColor(textColor){
 textColor.style.color = "#FFFFFF";
}


function resumeColor(textColor){
 textColor.style.color = "#ffcc00";
}


function changeColor1(textColor){
 textColor.style.color = "navy";
}


function resumeColor1(textColor){
 textColor.style.color = "#c71585";
}


function querySearch(val){
 if(val.QuerySearch.value.length < 3){
  alert("Your search is too general, Enter atleast three characters");
  val.QuerySearch.focus();
 }
 else{
  val.submit();
 }
}


function login(val){
 if(val.Email_Id.value.length == 0){
  alert("Please enter your username to login");
  val.Email_Id.focus();
 }
 else if(val.P_Password.value.length == 0){
  alert("Please enter your password to login");
  val.P_Password.focus();
 }
 else{
  val.submit();
 }
}


function currentDate(){
 months = new Array(12);
 months[0] = "Jan";
 months[1] = "Feb";
 months[2] = "Mar";
 months[3] = "Apr";
 months[4] = "May";
 months[5] = "Jun";
 months[6] = "Jul";
 months[7] = "Aug";
 months[8] = "Sep";
 months[9] = "Oct";
 months[10] = "Nov";
 months[11] = "Dec";
 currDate = new Date();
 var todayDate = months[currDate.getMonth()] + " " + currDate.getDate() + ", "+ currDate.getFullYear();
 document.write(todayDate);
}


function submitForm(val){

  val.submit();
}


function registeredUser(fname){

 var register = window.confirm("You are logged in as "+fname+". If You continue you will be logged out as "+fname+" and logged in as new user.  Click Ok to continue, Cancel to go back to previous page.");

 if(register){
 } 
 else{
  window.history.go(-2);
 }
}


function windowNew(url){
 window.open(url,"Priority","toolbar=no,location=0,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=400");
}


function categorySearch(){
 
 var categoryFormValue = document.ProdSearchForm.Category;
 var categoryValue = categoryFormValue.options[categoryFormValue.selectedIndex].value;
 while(true){
  if(categoryValue.indexOf(" ") != -1){
   categoryValue = categoryValue.replace(" ", "%");
  }
  else{
   break;
  }
 }
 var categoryUrl = "/servlet/softmart.ProductDisplay?ProductSearch='";

 if(document.ProdSearchForm.Category.selectedIndex == 0){

  alert("\"Select by Manufacture\" is not a valid selection. Please choose one of the other options.");
  document.ProdSearchForm.Category.focus();
 }
 else{
  categoryUrl = categoryUrl+ "" +categoryValue+ "-Manufacturer'";
  document.ProdSearchForm.action = categoryUrl;
  document.ProdSearchForm.submit();
 }
}


function mailCheck(mailVal){

 var fName = mailVal.FName.value;
 var compName = mailVal.Comp_Name.value;
 var phone = mailVal.Phone_No.value;
 var email = mailVal.recipient.value;

 var fNameInt = charCheck(fName);
 var emailInt = isWhiteSpace(email);
 var phoneNum = numCheckTel(phone);

 if(fName == ""){
  alert("Please enter your First Name");
  mailVal.FName.focus();
 }
 else if(fName.length > 30){
  alert("Please enter maximun of 30 characters in the First Name field");
  mailVal.FName.focus();
 }
 else if(fNameInt == 0){
   alert("Please enter letter characters in the First Name field.");
   mailVal.FName.focus();
 }
 else if(compName == ""){
  alert("Please enter your Company Name");
  mailVal.Comp_Name.focus();
 }
 else if(compName.length > 100){
  alert("Please enter maximum of 100 characters in the Company Name field.");
  mailVal.Comp_Name.focus();
 }
 else if(phone.length < 6){
  alert("Please enter minimum of 6 digits in the Phone No. field.");
  mailVal.Phone_No.focus();
 }
 else if(phoneNum == 0){
  alert("Please enter any number between 0 and 9 in the Phone No field. Use Comma for two or more Phone Nos.");
  mailVal.Phone_No.focus();
 }
 else if(email  == "" ){
  alert("Email field cannot be empty.");
  mailVal.recipient.focus();
 }
 else if(email.indexOf("@") == -1 || email.indexOf("@") == 0 || (email.indexOf("@") == (email.length-1))){
  alert("You have not entered valid Email address.")
  mailVal.recipient.focus();
 }
 else if(email.indexOf(".") == -1 || (email.lastIndexOf(".") == (email.length-1))){
  alert("You have not entered valid Email address.")
  mailVal.recipient.focus();
 }
 else if(email.indexOf("@") > email.lastIndexOf(".")){
  alert("You have not entered valid Email address.")
  mailVal.recipient.focus();
 }
 else if(email.indexOf("@") ==  (email.lastIndexOf(".")-1)){
  alert("You have not entered valid Email address.")
  mailVal.recipient.focus();
 }
 else if(email.indexOf("@") !=  email.lastIndexOf("@")){
  alert("You have not entered valid Email address.")
  mailVal.recipient.focus();
 }
 else if(emailInt == 1){
  alert("Please do not use any white space in the Email field.");
  mailVal.recipient.focus();
 }
 else if(email.indexOf(",") != -1){
  alert("Please do not use comma, use semi-colon to seperate email address.")
  mailVal.recipient.focus();
 }
 else{
  document.plform.submit();
 }
}