function replaceChars(entry) {
out = "-"; // replace this
add = ""; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
//document.subform.text.value = temp;
return temp;
}
function send_va(gva){
eval("var name = document.form1.name"+gva+".value");
document.form1.description.value=name
eval("var amount = document.form1.amount"+gva+".value");
document.form1.amount.value=amount
eval("var cur_abbr = document.form1.cur_abbr"+gva+".value");
document.form1.cur_abbr.value=cur_abbr

}
function chk_empty()
{ 
//var description=document.form1.description.value + ':' + document.form1.palm_model.value + ':' + document.form1.palm_id.value + ':' + document.form1.hotsync_name.value + ':' + document.form1.cust_fname.value + ':' + document.form1.cust_lname.value;
document.form1.description.value += ', ' + document.form1.palm_id.value + ', ' + document.form1.hotsync_name.value + ', ' + document.form1.cust_email.value + ', ' + document.form1.palm_model.value + ', ' + document.form1.cust_fname.value + ', ' + document.form1.cust_lname.value;
var amount=document.form1.amount.value;
var cur_abbr=document.form1.cur_abbr.value;
var mid_s=document.form1.mid.value;
var terminal_s=document.form1.terminal.value;
var nowdatetime_s=document.form1.nowdatetime_s.value;

 var palm_model=document.form1.palm_model.value;
 var palm_id=document.form1.palm_id.value;
 var hotsync_name=document.form1.hotsync_name.value;
 var cust_fname=document.form1.cust_fname.value;
 var cust_lname=document.form1.cust_lname.value;
 var cust_address1=document.form1.cust_address1.value;
 var cust_address2=document.form1.cust_address2.value;
 var cust_city=document.form1.cust_city.value;
 var cust_province=document.form1.cust_province.value;
 var cust_zip=document.form1.cust_zip.value;
 var cust_country=document.form1.cust_country.value;
 var cust_email=document.form1.cust_email.value;


//check radio
	x=0;
	for(i=0;i<form1.Num.length;i++)
	if(form1.Num[i].checked==true)
	 
	x=x+1;
	if (x==0) 
	{
	   alert ("Please Choose a Product");
       return false;
    }
if (palm_model==""){
	   alert("Please Add :  your Palm Model");
	   return false;}
	  else{
		  palm_model=replaceChars(palm_model);
		  document.form1.palm_model.value=palm_model;
		  document.form1.usrdat1.value=palm_model;
		  }                                
if (palm_id==""){
	   alert("Please Add :  your Palm ID");
	   return false;}	
	   else{
            palm_id=replaceChars(palm_id);
			document.form1.palm_id.value=palm_id;
		   document.form1.usrdat2.value=palm_id;}
if (cust_fname==""){
	   alert("Please Add :  First Name");
	   return false;}	
	    else{
			cust_fname=replaceChars(cust_fname);
			document.form1.cust_fname.value=cust_fname;
			document.form1.usrdat4.value=cust_fname;
			}
if (cust_lname==""){
	   alert("Please Add :  Last Name");
	   return false;}
	   else{
		   cust_lname=replaceChars(cust_lname);
		   document.form1.cust_lname.value=cust_lname;
		   document.form1.usrdat5.value=cust_lname;}
if (cust_address1==""){
	   alert("Please Add :  Address1");
	   return false;}	
	    else{
			cust_address1=replaceChars(cust_address1);
			cust_address2=replaceChars(cust_address2);
			 document.form1.cust_address1.value=cust_address1;
			 document.form1.cust_address2.value=cust_address2;
			document.form1.usrdat6.value=cust_address1+"  "+cust_address2;}
if (cust_city==""){
	   alert("Please Add :  City");
	   return false;}	
	   else{
		   cust_city=replaceChars(cust_city);
		    document.form1.cust_city.value=cust_city;
		   document.form1.usrdat7.value=cust_city;
		   }
if (cust_province==""){
	   alert("Please Add :  State");
	   return false;}	
	  else{
		  cust_province=replaceChars(cust_province);
		  document.form1.cust_province.value=cust_province;
		  document.form1.usrdat7.value +=cust_province;}
if (cust_zip==""){
	   alert("Please Add :  Postal Code");
	   return false;}	
	    else{
			cust_zip=replaceChars(cust_zip);
			document.form1.cust_zip.value=cust_zip;
			document.form1.usrdat8.value=cust_zip;}
if (cust_country==""){
	   alert("Please Add :  Contry");
	   return false;}	
	     else{
			 cust_country=replaceChars(cust_country);
			 document.form1.cust_country.value=cust_country;
			 document.form1.usrdat9.value=cust_country;}
if (cust_email==""){
	   alert("Please Add :  Email Address");
	   return false;}	
	   else
	{	
		emailObj=form1.cust_email;
		emailStr = emailObj.value; 
		var checkTLD=0; 
		var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/; 
		var emailPat=/^(.+)@(.+)$/; 
		var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; 
		var validChars="\[^\\s" + specialChars + "\]"; 
		var quotedUser="(\"[^\"]*\")"; 
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; 
		var atom=validChars + '+'; 
		var word="(" + atom + "|" + quotedUser + ")"; 
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); 
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); 
		var matchArray=emailStr.match(emailPat); 
		if (matchArray==null) { 
		alert("Please Check :  Email Address"); 
		   return false;
		}
	}//end else
	var user=matchArray[1]; 
var domain=matchArray[2]; 
for (i=0; i<user.length; i++) { 
if (user.charCodeAt(i)>127) { 
alert("Please Check :  Email Address"); 
return false; 
} 
} 
for (i=0; i<domain.length; i++) { 
if (domain.charCodeAt(i)>127) { 
alert("Please Check :  Email Address"); 
return false; 
} 
} 
if (user.match(userPat)==null) { 
alert("Please Check :  Email Address"); 
return false; 
} 
var IPArray=domain.match(ipDomainPat); 
if (IPArray!=null) { 
for (var i=1;i<=4;i++) { 
if (IPArray[i]>255) { 
alert("Please Check :  Email Address"); 
return false; 
} 
} 
//return true; 
} 
var atomPat=new RegExp("^" + atom + "$"); 
var domArr=domain.split("."); 
var len=domArr.length; 
for (i=0;i<len;i++) { 
if (domArr[i].search(atomPat)==-1) { 
alert("Please Check :  Email Address"); 
return false; 
} 
} 
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) { 
alert("Please Check :  Email Address"); 
return false; 
} 
if (len<2) { 
alert("Please Check :  Email Address"); 
return false; 
} 
document.form1.usrdat10.value=cust_email;
hotsync_name=replaceChars(hotsync_name);
document.form1.hotsync_name.value=hotsync_name;
document.form1.usrdat3.value=hotsync_name;
//document.form1.backURL.value="http://www.kktechnologies.com/payment/return.php?mid="+mid_s+"&nowdatetime="+nowdatetime_s+"&cur_abbr="+cur_abbr+"&amount="+amount+"&description="+description+"&palm_model="+palm_model+"&palm_id="+palm_id+"&hotsync_name="+hotsync_name+"&cust_fname="+cust_fname+"&cust_lname="+cust_lname+"&cust_address1="+cust_address1+"&cust_city="+cust_city+"&cust_province="+cust_province+"&cust_zip="+cust_zip+"&cust_country="+cust_country+"&cust_email="+cust_email+"";
document.form1.backURL.value="http://www.kktechnologies.com/payment/return.php?mid="+mid_s+"&terminal="+terminal_s;
document.form1.cust_id.value=document.form1.cust_email.value;
}//end fucn

function chk_product_empty()
{ 
 var product_name=document.form1.product_name.value;
 var product_price=document.form1.product_price.value;

//check radio
	x=0;
	for(i=0;i<form1.type_price.length;i++)
	if(form1.type_price[i].checked==true)
	x=x+1;
	if (x==0) 
	{
	    alert("Please  Choose : Type price");
       return false;
    }

if (product_name==""){
	   alert("Please Add : Product name");
	   return false;}	
if (product_price==""){
	   alert("Please Add : Product price");
	   return false;}	
}//end fucn
function check_number() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k != 13 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("Please Add : Number Only");
}
}//end func
function chk_email_empty()
{ 
 var mainemail=document.form3.mainemail.value;
if ( mainemail==""){
	   alert("Please Add : Main E-mail ");
	   return false;}	
}///end func
function chk_info_empty()
{ 
 var mid=document.form4.mid.value;
 var terminal=document.form4.terminal.value;
if (mid==""){
	   alert("Please Add : Merchant ID ");
	   return false;}	
if (terminal==""){
	   alert("Please Add : Terminal ID");
	   return false;}	
}///end func


