function ShowWindow(asppage){
   window.open(asppage,'_blank');
}

function trimmer(untrimmed)
{
		var i;
		var startfound ="false";
		var trimmed="";
		for(i=0; i<untrimmed.length; i++) {
				if (untrimmed.charAt(i)==" ")	{
						if (startfound == "true")	trimmed += untrimmed.charAt(i);
				}
				else {
						startfound = "true";
						trimmed += untrimmed.charAt(i);
				}
		}
		var endfound ="false";
		for(i=trimmed.length-1; i>=0; i--) {
				if (trimmed.charAt(i)==" ")	{
						if (endfound == "false") {
							trimmed = trimmed.substring(0,i);
						}
				}
				else if(trimmed.charAt(i) != " ") {
						endfound = "true";
				}
		}

		return (trimmed);
}

function saveclick(abc)
{
	if (document.Form1.FName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FName.focus();
	}

	
	else if(document.Form1.LName.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.LName.focus();
	}

	
	else if(document.Form1.CompName.value == "")
	{
		alert("Please Enter Company Name");
		document.Form1.CompName.focus();
	}

	
	else if(document.Form1.Desig.value == "")
	{
		alert("Please Enter Designation");
		document.Form1.Desig.focus();
	}

	
	else if(document.Form1.phnos.value == "")
	{
		alert("Please Enter Phone Number");
		document.Form1.phnos.focus();
	}
	
	else if(document.Form1.EmailAdd.value == "")
	{
		alert("Please Enter Email Address");
		document.Form1.EmailAdd.focus();
	}
	else if(document.Form1.city.value == "")
	{
		alert("Please Enter City");
		document.Form1.city.focus();
	}
	else if(document.Form1.zip.value == "")
	{
		alert("Please Enter Zip Code");
		document.Form1.zip.focus();
	}
	else
	{
	document.Form1.action = abc;
	document.Form1.submit();
}
}


function saveclick_add(abc)
{
	//alert();
	if (document.Form1.FName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FName.focus();
	}

	
	else if(document.Form1.LName.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.LName.focus();
	}

	
	else if(document.Form1.CompName.value == "")
	{
		alert("Please Enter Company Name");
		document.Form1.CompName.focus();
	}

	
	else if(document.Form1.Desig.value == "")
	{
		alert("Please Enter Designation");
		document.Form1.Desig.focus();
	}

	
	else if(document.Form1.phnos.value == "")
	{
		alert("Please Enter Phone Number");
		document.Form1.phnos.focus();
	}
	
	else if(document.Form1.EmailAdd.value == "")
	{
		alert("Please Enter Email Address");
		document.Form1.EmailAdd.focus();
	}
	else if(document.Form1.city.value == "")
	{
		alert("Please Enter City");
		document.Form1.city.focus();
	}
	else if(document.Form1.zip.value == "")
	{
		alert("Please Enter Zip Code");
		document.Form1.zip.focus();
	}
	else
	{
	document.Form1.action = abc;
	document.Form1.submit();
}
}


function saveclick123(abc)
{
	if (document.Form1.FName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FName.focus();
	}
	else if(document.Form1.LName.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.LName.focus();
	}
	else if(document.Form1.Desig.value == "")
	{
		alert("Please Enter Designation");
		document.Form1.Desig.focus();
	}
	else if(document.Form1.phnos.value == "")
	{
		alert("Please Enter Phone Number");
		document.Form1.phnos.focus();
	}
	else if(document.Form1.EmailAdd.value == "")
	{
		alert("Please Enter Email Address");
		document.Form1.EmailAdd.focus();
	}

	else
	{
	document.Form1.action = abc;
	document.Form1.submit();
	}
}

function saveclick1()
{
	 if (document.Form1.businesstype.value == "")
	{
		alert("Please Enter Business Type");
		document.Form1.businesstype.focus();
	}
	else if (document.Form1.owner_ceo.value == "")
	{
		alert("Please Enter Owner's/CEO's Name");
		document.Form1.owner_ceo.focus();
	}
	else if (document.Form1.address1.value == "")
	{
		alert("Please Enter Address1");
		document.Form1.address1.focus();
	}
	else if (document.Form1.address2.value == "")
	{
		alert("Please Enter Address2");
		document.Form1.address2.focus();
	}
	else if (document.Form1.city.value == "")
	{
		alert("Please Enter City");
		document.Form1.city.focus();
	}
	else if (document.Form1.pincode.value == "")
	{
		alert("Please Enter Zip");
		document.Form1.pincode.focus();
	}
	else if (document.Form1.faxnos.value == "")
	{
		alert("Please Enter Fax Number");
		document.Form1.faxnos.focus();
	}
	else if (Check()==false)
	{
		document.Form1.emailaddress.focus();
	}
	else if (document.Form1.taxid.value == "")
	{
		alert("Please Enter Tax ID");
		document.Form1.taxid.focus();
	}
	else if (document.Form1.fedid.value == "")
	{
		alert("Please Enter FED ID");
		document.Form1.fedid.focus();
	}
	else if (document.Form1.salestaxid.value == "")
	{
		alert("Please Enter Sales Tax Id");
		document.Form1.salestaxid.focus();
	}
	else if (document.Form1.accadminname.value == "")
	{
		alert("Please Enter A/c Admin Name");
		document.Form1.accadminname.focus();
	}
	else if (Check1()==false)
	{
		document.Form1.accadminemail.focus();
	}
	else if ((document.Form1.accadminemail.value) == (document.Form1.emailaddress.value))
	{
		alert("Account Admins Email Address and Personal Email Address cannot be Similar.");
		document.Form1.accadminemail.focus();
	}
	else if (document.Form1.country.value == "Other")
	{
		if (document.Form1.Country1.value == "")
		{
			alert("Please Enter Other Country");
			document.Form1.Country1.focus();
		}
		else
		{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
		}
	}
	else
	{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
	}
}

function saveclick2()
{
	if (document.Form1.FirstName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FirstName.focus();
	}
	else if (document.Form1.LName.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.LName.focus();
	}
	else if (document.Form1.Designation.value == "")
	{
		alert("Please Enter Designation");
		document.Form1.Designation.focus();
	}
	else if (document.Form1.OfficePhoneNo.value == "")
	{
		alert("Please Enter Office Phone Number");
		document.Form1.OfficePhoneNo.focus();
	}
	else if (Check()==false)
	{
		document.Form1.EmailAddress.focus();
	}
	else if (document.Form1.country.value == "Other")
	{
		if (document.Form1.Country1.value == "")
		{
			alert("Please Enter Other Country");
			document.Form1.Country1.focus();
		}
		else
		{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
		}
	}
	else
	{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
	}
}

function saveclick3()
{
	
	if (document.Form1.FirstName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FirstName.focus();
	}
	else if (document.Form1.LastName.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.LastName.focus();
	}
	else if (document.Form1.PhoneNos.value == "")
	{
		alert("Please Enter Your Company's Phone Number");
		document.Form1.PhoneNos.focus();
	}
	else if (document.Form1.CheckingAccNo.value == "")
	{
		alert("Please Enter Checking Account Number");
		document.Form1.CheckingAccNo.focus();
	}
	else if (document.Form1.bankname.value == "")
	{
	
		alert("Please Enter Bank Name");
		document.Form1.bankname.focus();
	}
	else if (document.Form1.BankContPerFN.value == "")
	{
		alert("Please Enter Bank Contact Persons First Name");
		document.Form1.BankContPerFN.focus();
	}
	else if (document.Form1.BankContPerLN.value == "")
	{
		alert("Please Enter Bank Contact Persons Last Name");
		document.Form1.BankContPerLN.focus();
	}
	else if (document.Form1.BankPhoneNos.value == "")
	{
		alert("Please Enter Your Bank's Phone Number");
		document.Form1.BankPhoneNos.focus();
	}
	else if (document.Form1.country.value == "Other")
	{
		if (document.Form1.Country1.value == "")
		{
			alert("Please Enter Other Country");
			document.Form1.Country1.focus();
		}
		else
		{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
		}
	}
	else
	{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
	}
}

function saveclick4()
{

	if (document.Form1.ToShip.value == "")
	{
		alert("Please Enter To Ship");
		document.Form1.ToShip.focus();
	}
	else if (document.Form1.FirstName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FirstName.focus();
	}
	else if (document.Form1.LastName.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.LastName.focus();
	}
	else if (document.Form1.CourierAccount.value == "")
	{
		alert("Please Enter Courier Account Number");
		document.Form1.CourierAccount.focus();
	}
	else if (trimmer(document.Form1.CourierName.value) == "")
	{
		
		alert("Please Enter Courier Name");
		document.Form1.CourierName.focus();
	}
	else if (document.Form1.CourierPhoneNos.value == "")
	{
		alert("Please Enter Courier Phone Number");
		document.Form1.CourierPhoneNos.focus();
	}
	else if (document.Form1.CourierAddress1.value == "")
	{
		alert("Please Enter Courier Address1");
		document.Form1.CourierAddress1.focus();
	}
	else if (document.Form1.country.value == "Other")
	{
		//alert(0);
		if (document.Form1.Country1.value == "")
		{
			alert("Please Enter Other Country");
			document.Form1.Country1.focus();
		}
		else
		{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
		}	
	}
	else
	{
		//alert(2);
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
	}
	//alert(1);
}

function saveclick6()
{
        if (document.Form1.FirstName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FirstName.focus();
	}
	else if (document.Form1.LastName.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.LastName.focus();
	}
	else if (document.Form1.PhoneNos.value == "")
	{
		alert("Please Enter Phone Number");
		document.Form1.PhoneNos.focus();
	}
	else if (document.Form1.country.value == "Other")
	{
		if (document.Form1.Country1.value == "")
		{
			alert("Please Enter Other Country");
			document.Form1.Country1.focus();
		}
		else
		{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
		}
	}
	else
	{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
	}
}

function saveclick7()
{
	if (document.Form1.FirstName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FirstName.focus();
	}
	else if (document.Form1.LastName.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.LastName.focus();
	}
	else if (document.Form1.PhoneNos.value == "")
	{
		alert("Please Enter Phone Number");
		document.Form1.PhoneNos.focus();
	}
	else if (document.Form1.country.value == "Other")
	{
		if (document.Form1.Country1.value == "")
		{
			alert("Please Enter Other Country");
			document.Form1.Country1.focus();
		}
		else
		{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
		}
	}
	else
	{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
	}
}

function saveclick8()
{
	if (document.Form1.BusinessName.value == "")
	{
		alert("Please Enter Business Name");
		document.Form1.BusinessName.focus();
	}
	else if (document.Form1.FirstName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FirstName.focus();
	}
	else if (document.Form1.Lastname.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.Lastname.focus();
	}
	else if (document.Form1.PhoneNos.value == "")
	{
		alert("Please Enter Phone Number");
		document.Form1.PhoneNos.focus();
		
	}
	else if (document.Form1.country.value == "Other")
	{
		if (document.Form1.Country1.value == "")
		{
			alert("Please Enter Other Country");
			document.Form1.Country1.focus();
		}
		else
		{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
		}
	}
	else
	{
		document.Form1.hbutton.value = "save";
		document.Form1.submit();
	}
}

function saveclickForm1(abc)
{
	if (document.Form1.businessname.value == "")
	{
		alert("Please Enter Business Name");
		document.Form1.businessname.focus();
	}
	else if(document.Form1.mm.options[document.Form1.mm.selectedIndex].value=="mm")
	{
		alert("Enter numeric values for date of birth");
		document.Form1.mm.focus
	}	
	else if(document.Form1.dd.options[document.Form1.dd.selectedIndex].value=="dd")
	{
		alert("Enter numeric values for date of birth");
		document.Form1.dd.focus
	}
	else if(document.Form1.yy.options[document.Form1.yy.selectedIndex].value=="yyyy")
	{
		alert("Enter numeric values for date of birth");
		document.Form1.yy.focus
	}	
	else if(document.Form1.businesstype.value == "")
	{
		alert("Please select the Type of Business");
		document.Form1.businesstype.focus();
	}
	else if(document.Form1.businessnature.value == "")
	{
		alert("Please select the Nature of Business");
		document.Form1.businessnature.focus();
	}
	else if(document.Form1.owner_ceo.value == "")
	{
		alert("Please Enter Name of the OWNER or CEO of the Company");
		document.Form1.owner_ceo.focus();
	}
	else if(document.Form1.address1.value == "")
	{
		alert("Please enter the Address");
		document.Form1.address1.focus();
	}
	else if(document.Form1.address2.value == "")
	{
		alert("Please enter the Address");
		document.Form1.address2.focus();
	}
	else if(document.Form1.country.value == "")
	{
		alert("Please enter the country");
		document.Form1.country.focus();
	}
	else if(document.Form1.City.value == "")
	{
		alert("Please enter the City");
		document.Form1.City.focus();
	}
	else if(document.Form1.pincode.value == "")
	{
		alert("Please enter the pin code");
		document.Form1.pincode.focus();
	}
	else if(document.Form1.Phone1.value == "")
	{
		alert("Please enter the Phone No.");
		document.Form1.Phone1.focus();
	}
	else if(document.Form1.faxnos.value == "")
	{
		alert("Please enter the Fax No.");
		document.Form1.faxnos.focus();
	}
	else if(document.Form1.emailaddress.value == "")
	{
		alert("Please enter the Email Address");
		document.Form1.emailaddress.focus();
	}
	else if(document.Form1.taxid.value == "")
	{
		alert("Please enter the Tax ID");
		document.Form1.taxid.focus();
	}
	else if(document.Form1.fedid.value == "")
	{
		alert("Please enter the Fedex ID");
		document.Form1.fedid.focus();
	}
	else if(document.Form1.salestaxid.value == "")
	{
		alert("Please enter the Sales Tax ID");
		document.Form1.salestaxid.focus();
	}
	else if(document.Form1.accadminname.value == "")
	{
		alert("Please enter the Account Administrator's Name");
		document.Form1.accadminname.focus();
	}
	else if(document.Form1.accadminemail.value == "")
	{
		alert("Please enter the Account Administrator's Email ID");
		document.Form1.accadminemail.focus();
	}
	else if(document.Form1.FirstName.value == "")
	{
		alert("Please enter the First Name of the Owner/CEO");
		document.Form1.FirstName.focus();
	}
	else if(document.Form1.LName.value == "")
	{
		alert("Please enter the Last Name of the Owner/CEO");
		document.Form1.LName.focus();
	}
	else if(document.Form1.Designation.value == "")
	{
		alert("Please enter the Designation of the Owner/CEO");
		document.Form1.Designation.focus();
	}
	else if(document.Form1.OfficePhoneNo.value == "")
	{
		alert("Please enter the Office Phone No of the Owner/CEO");
		document.Form1.OfficePhoneNo.focus();
	}
	else if(document.Form1.owner_country.value == "")
	{
		alert("Please enter the Country");
		document.Form1.owner_country.focus();
	}
	else if(document.Form1.owner_City.value == "")
	{
		alert("Please enter the City");
		document.Form1.owner_City.focus();
	}
	else if(document.Form1.owner_pincode.value == "")
	{
		alert("Please enter the Pincode");
		document.Form1.owner_pincode.focus();
	}
	else if(document.Form1.owner_EmailAddress.value == "")
	{
		alert("Please enter the Email Address");
		document.Form1.owner_EmailAddress.focus();
	}

	else
	{
	document.Form1.action = abc;
	document.Form1.submit();
	}
}

function saveclickForm2(abc)
{
	if (document.Form1.FirstName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FirstName.focus();
	}
	else if(document.Form1.LastName.value == "")
	{
		alert("Please Enter Last Name");
		document.Form1.LastName.focus();
	}
	else if(document.Form1.PhoneNos.value == "")
	{
		alert("Please Enter Phone No");
		document.Form1.PhoneNos.focus();
	}
	else if(document.Form1.bankname.value == "")
	{
		alert("Please Enter Name of the Bank");
		document.Form1.bankname.focus();
	}
	else if(document.Form1.BankContPerFN.value == "")
	{
		alert("Please enter the name of the Contact Person of the Bank");
		document.Form1.BankContPerFN.focus();
	}
	else if(document.Form1.BankContPerLN.value == "")
	{
		alert("Please enter the name of the Contact Person of the Bank");
		document.Form1.BankContPerLN.focus();
	}
	else if(document.Form1.BankPhoneNos.value == "")
	{
		alert("Please enter the Contact Nos.");
		document.Form1.BankPhoneNos.focus();
	}
	else if(document.Form1.ToShip.value == "")
	{
		alert("Please select the 'ToShip' categories");
		document.Form1.ToShip.focus();
	}
	else if(document.Form1.FirstNameS.value == "")
	{
		alert("Please enter the First Name of Cont Person for Shipping");
		document.Form1.FirstNameS.focus();
	}
	else if(document.Form1.LastNameS.value == "")
	{
		alert("Please enter the Last Name of Cont Person for Shipping");
		document.Form1.LastNameS.focus();
	}
	else if(document.Form1.CourierName.value == "")
	{
		alert("Please enter the name of the Courier Company");
		document.Form1.CourierName.focus();
	}
	else if(document.Form1.CourierPhoneNos.value == "")
	{
		alert("Please enter the Courier Phone No.");
		document.Form1.CourierPhoneNos.focus();
	}
	else
	{
	document.Form1.action = abc;
	document.Form1.submit();
	}
}


function saveclickForm3(abc)
{
	if(document.Form1.storename.value == "")
	{
	}
	else if(document.Form1.FirstName.value == "")
	{
		alert("Please Enter First Name");
		document.Form1.FirstName.focus();
	}
	else if(document.Form1.LastName.value == "")
	{
		alert("Please Enter the Last Name");
		document.Form1.LastName.focus();
	}
	else if(document.Form1.PhoneNos.value == "")
	{
		alert("Please Enter Contact Nos. of the Store");
		document.Form1.PhoneNos.focus();
	}
	else if(document.Form1.BranchName.value == "")
	{
	}
	else if(document.Form1.FirstNameB.value == "")
	{
		alert("Please enter the First Name of the Contact Person of the Branch");
		document.Form1.FirstNameB.focus();
	}
	else if(document.Form1.LastNameB.value == "")
	{
		alert("Please enter the Last Name of the Contact Person of the Branch");
		document.Form1.LastNameB.focus();
	}
	else if(document.Form1.PhoneNosB.value == "")
	{
		alert("Please enter the Contact Nos. of the Branch");
		document.Form1.PhoneNosB.focus();
	}
	else if(document.Form1.BusinessName.value == "")
	{
	}
	else if(document.Form1.FirstNameA.value == "")
	{
		alert("Please enter the Contact Person's First Name");
		document.Form1.FirstNameA.focus();
	}
	else if(document.Form1.LastNameA.value == "")
	{
		alert("Please enter the Contact Person's Last Name");
		document.Form1.LastNameA.focus();
	}
	else if(document.Form1.PhoneNosA.value == "")
	{
		alert("Please enter the Phone No.");
		document.Form1.PhoneNosA.focus();
	}
	else
	{
	document.Form1.action = abc;
	document.Form1.submit();
	}
}







function encryptIT(form,how) {
  letters = "abcdefghijklmnopqrstuvwxyz/.1234567890~_:";
  encrypt = new Array(
  "%61","%62","c","%64","e","%66",
  "%67","%68","%69","%6a","%6b","%6c",
  "m","n","o","%70","%71","%72",
  "%73","t","%75","%76","w","%78",
  "%79","%7a","/","."
  ,"1","2","3","4","5","6","7","8",
  "9","0","~","_","!",":");
  var input = form;
  output = "";
  for(var count = 0; count < input.length; count++) {
    daChar = input.charAt(count);
    for (i = 0; i < letters.length; i++) {
      if (daChar == letters.charAt(i)) {
        output += encrypt[i];
        break;
      }
    }
  }
  javascript:window.open(output,how)	

}

 function check(str,str1) {
     var ok=true;
     for(var i=0;i<str.length;i++)
     {  var chr=str.charAt(i);
        var found=false;
        for(var j=0;j<str1.length;j++)
        {  if(chr==str1.charAt(j))  found=true;
        }
        if (!found) ok=false;
     }
     return ok;
  }
 
function emailcheck(obj){
	
var str1 = new String(eval("document.Form1." + obj+ ".value"));

    if (str1 != "")
  {
   if (!(check(str1,"abcdefghijklmnopqrstuvwxyz0123456789_-@.")))
    {
       alert(" Invalid Email Address");
       eval("document.Form1." + obj+ ".focus()");
  
    }    else
    {
    var ok = false;
    var j = 0;
    for (var i = 0 , chr='@'; i<=str1.length ; i++)
      {
        if (chr == str1.substring(i,i+1))
          {
            ok = true;
            j = i;
          }
       }

   if (ok)
     {

     ok = false;
    for (var i = j , chr='.'; i<=str1.length ; i++)
      {
        if (chr == str1.substring(i,i+1))
          {
            ok = true;
          }
       }

     }

     if (ok)
      {

       }
      else
       {

       alert("Invalid Email Address");
       eval("document.Form1." + obj+ ".focus()");
       return false;
      }
    }

  }else{
          alert("Invalid Email Address");
          eval("document.Form1." + obj+ ".value=''");
           return false;
  }


	
}

function Check()
  {

   str1 = new String(document.Form1.EmailAddress.value);
    if (str1 != "")
  {

    document.Form1.EmailAddress.value=str1;
   if (!(check(str1,"abcdefghijklmnopqrstuvwxyz0123456789_-@.")))
    {
       alert(" Invalid Email Address");
       document.Form1.EmailAddress.focus();
       document.Form1.EmailAddress.value="";
    }
    else
    {
    var ok = false;
    var j = 0;
    for (var i = 0 , chr='@'; i<=str1.length ; i++)
      {
        if (chr == str1.substring(i,i+1))
          {
            ok = true;
            j = i;
          }
       }

   if (ok)
     {

     ok = false;
    for (var i = j , chr='.'; i<=str1.length ; i++)
      {
        if (chr == str1.substring(i,i+1))
          {
            ok = true;
          }
       }

     }

     if (ok)
      {

       }
      else
       {

       alert("Invalid Email Address");
       document.Form1.EmailAddress.focus();
       document.Form1.EmailAddress.value="";
       return false;
      }

    }

  }else{
          alert("Invalid Email Address");
          Form1.EmailAddress.focus();
           return false;

  }
 }
