var img;function regImg(elem){img=elem;}

function HideSubmit(){
	var obj2 = MM_findObj("trWarning");
	var obj = MM_findObj("imgSubmit");
	eval("obj.style.display='none'");
	eval("obj2.style.display=''");
}
function callValidate(){
	
	if(document.affForm.Aff_SiteName.value==''){
		alert("Please enter your Site Name");
		return false;
	}
	
	if(document.affForm.Aff_SiteURL.value==''){
		alert("Please enter your Site URL");
		return false;
	}
	
	if(document.affForm.Aff_Fname.value==''){
		alert("Please enter your First name");
		return false;
	}
	
	if(document.affForm.Aff_Lname.value==''){
		alert("Please enter your last name");
		return false;
	}
	
	if(document.affForm.Aff_Email.value==''){
		alert("Please enter your Email Address");
		return false;
	}
	
	if(document.affForm.Aff_Address.value==''){
		alert("Please enter your street & house number");
		return false;
	}
	
	
	if(document.affForm.Aff_City.value==''){
		alert("Please enter your city");
		return false;
	}
	
	if(document.affForm.Aff_Country.selectedIndex==0){
		alert("Please choose your country.");
		return false;	
	}
	
	
	if(document.affForm.Aff_Zip.value==''){
		alert("Please enter your zip code");
		return false;
	}
	
	
	if(document.affForm.Aff_Email.value==''){
		alert("Please enter your Email Address");
		return false;
	}
	
	if(document.affForm.Aff_Phone.value==''){
		alert("Please enter your Personal Contact Phone number");
		return false;
	}
	
	if(document.affForm.Aff_BillingName.value==''){
		alert("Please enter your Billing name");
		return false;
	}
		
	if(document.affForm.Aff_Password.value==''){
		alert("Please enter a password for re-orders");
		return false;
	}
	
	if(document.affForm.Aff_Password2.value!=document.affForm.Aff_Password.value){
		alert("The passwords you entered do not match");
		return false;
	}
	
	if(!isStrNumeric(document.affForm.Aff_Phone.value)){
		alert("Your Contact Phone Number is Invalid");
		return false;
	}
	
	if(!validateEmail(document.affForm.Aff_Email.value)){
		alert("The Email Address you entered is invalid");
		return false;
	}
	return true;
}

function callValidate2(){

	return true;
}

function PL_isFormNumeric(strVal,strValidate){
	for(li=0;li<strVal.length;li++)
		if(strVal.charAt(li)!="0" && strVal.charAt(li)!="-" && strVal.charAt(li)!="." && !parseInt(strVal.charAt(li)))
			return false;
	strVal=parseFloat(strVal);
	var iRange=strValidate.indexOf("NUMBER")+6;
	var iRangeEnd=0,iLowLimit=0;iHighLimit=0;
	if(strValidate.charAt(iRange)=="("){
		iRangeEnd=strValidate.indexOf(")",iRange)-1;
		strValidate=strValidate.substr(iRange+1,(iRangeEnd-iRange))
		iLowLimit=parseFloat(strValidate.split("*")[0]);
		iHighLimit=parseFloat(strValidate.split("*")[1]);
		if(strVal<iLowLimit || strVal>iHighLimit){
			return false;
		}
	}
	return true;
}


function PL_validateForm(){
	var args=PL_validateForm.arguments;
	if(args.length==0)return;
	var strError="",bValid=true,bMes=false;;
	var objForm="document." + args[0];
	objForm=eval(objForm);
	if(args[1]!=""){
		var objMessages=eval(args[1]);bMes=true;		
	}
	for(i=2;i<args.length;i++){
		var objToValidate=eval("document." + args[0] + "." + args[i]);
		var strValidation=args[++i];
		var strErrorMessage=args[++i];
		var strToValidate=objToValidate.value;
		
		if(strValidation.indexOf("REQ")!=(-1)){
				if(strToValidate==""){
					if(bMes)strError+=strErrorMessage + "<br/>";
					else{alert(strErrorMessage);return false;}
					bValid=false;
				}
		}
		
		if(strValidation.indexOf("NUMBER")!=(-1)){
			if(strToValidate!="")
				if(!PL_isFormNumeric(strToValidate,strValidation)){
					if(bMes)strError+=strErrorMessage + "<br/>";
					else{alert(strErrorMessage);return false;}
					bValid=false;
				}
		}
		
		if(strValidation.indexOf("EMAIL")!=(-1)){
			if(strToValidate!="")
				if(strToValidate.length<6 || strToValidate.indexOf("@")<1 || strToValidate.indexOf(".")<3 || strToValidate.lastIndexOf(".")>(strToValidate.length-2)){
					if(bMes)strError+=strErrorMessage + "<br/>";
					else{alert(strErrorMessage);return false;}
					bValid=false;
				}
		}
		
		if(strValidation.indexOf("DATE")!=(-1)){
			var bTemp=false;
			if(strToValidate!="")
				if(strToValidate.length>5 && strToValidate.length<11 && strToValidate.indexOf("/")>0){
					if(strToValidate.split("/").length==3){
						if(PL_isFormNumeric(strToValidate.split("/")[0],'NUMBER(1*31)') && PL_isFormNumeric(strToValidate.split("/")[1],'NUMBER(1*12)') && PL_isFormNumeric(strToValidate.split("/")[2],'NUMBER'))
							bTemp=true;
					}
				}
			if(!bTemp){
				if(bMes)strError+=strErrorMessage + "<br/>";
				else{alert(strErrorMessage);return false;}
				bValid=false;
			}
		}
		
		if(strValidation.indexOf("SAMEAS")!=(-1)){
			if(strToValidate!="")
				if(strValidation.charAt(strValidation.indexOf("SAMEAS")+6)=="("){
					iPosStart=strValidation.indexOf("SAMEAS")+7;
					iPosEnd=strValidation.indexOf(")",iPosStart+1);
					strTemp=strValidation.substr(iPosStart,(iPosEnd-iPosStart));
					var objToValidate2=eval("document." + args[0] + "." + strTemp);
					if(strToValidate!=objToValidate2.value){
						if(bMes)strError+=strErrorMessage + "<br/>";
						else{alert(strErrorMessage);return false;}
						bValid=false;
					}
				}		
		}
		if(bMes && !bValid)objMessages.innerHTML=strError;
		else if(bMes)objMessages.innerHTML="";
	}
	return bValid;
}
 
/*function resetPrice(price){
	//alert(price);
	if(price==0){
		document.buyForm.Order_Price.value="0";
		return;
	}
	var p=eval("q" + price);
	//alert(p);
	document.buyForm.Order_Price.value=p;
}*/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function validateEmail(strToValidate){

	if(strToValidate.length<6 || strToValidate.indexOf("@")<1 || strToValidate.indexOf(".")<3 || strToValidate.lastIndexOf(".")>(strToValidate.length-2))
	{
		return false;
	}
	return true;
}
		
		
function isNumeric(strVal){
	for(li=0;li<strVal.length;li++)
		if(strVal.charAt(li)<"0" || strVal.charAt(li)>"9"){
			return false;
		}
	return true;
}	 
function isStrNumeric(strVal){
	for(li=0;li<strVal.length;li++)
		if((strVal.charAt(li)<"0" || strVal.charAt(li)>"9") && (strVal.charAt(li)!=" ") && (strVal.charAt(li)!="-")) {
			return false;
		}
	return true;
}	
