
function goToURL(url) { document.location=url; }

function opencartwindow(path, name, width, height, btop, bleft)
{
	dummy=window.open(path, name, 'width='+width+',height='+height+',left='+bleft+',top='+btop+ ',toolbar=no,menubar=no,resizable=yes,status=no,alwaysRaised=yes,scrollbars=no');
}

function SendPasswordEmail(lang){document.passwordform.action='password.php?lang='+lang+'&sendschaftpassword=ok';}

var Prices=new Array();
var Pricenames=new Array();

function Price(filling, price) {
	this.filling=filling;
	this.price=price
}

function addPrices(filling) 
{
	filling=unescape(filling);
	for (var i=1; i < arguments.length; i++) 
	{
		Prices[Prices.length]=new Price(filling, unescape(arguments[i]));
	}
}

function addPricenames(filling) 
{
	filling=unescape(filling);
	for (var i=1; i < arguments.length; i++) 
	{
		Pricenames[Pricenames.length]=new Price(filling, unescape(arguments[i]));
	}
}

function fillPricedesc(select, filling) 
{
	select.options.length=0;

	var count=0;
	for (var n=0; n < Prices.length; n++) 
	{
		if (Prices[n].filling == filling) 
		{
			select.options[select.options.length]=new Option(Pricenames[n].price, Prices[n].price);
			count++;
		}
	}
}

function emailcheck(lang)
{
	var frm=document.passwordform;
	var email=trim(frm.email.value);
	
	if (lang=="nl" || lang=="NL") {
		var error1="Gelieve een e-mail adres in te geven!";
		var error2="Gelieve een correct e-mail adres in te geven!";
	} else if (lang=="fr" || lang=="FR") {
		var error1="Veuillez remplir une adresse e-mail!";
		var error2="Veuillez remplir une adresse e-mail correct!";
	} else if (lang=="en" || lang=="EN") {
		var error1="Please enter an e-mail address!";
		var error2="Please enter a correct e-mail address!";
	}
	
	if (email=="")
	{
		  alert(error1);
		  frm.email.focus();
		  return false
	} else {
		if (frm.email.value.indexOf("@")==-1 || frm.email.value.indexOf(".")==-1 || frm.email.value.indexOf(" ")!=-1 || frm.email.value.length<6) 
		{
		  alert(error2);
		  frm.email.focus();
		  return false
		}
	}
}

function quantcheck(lang, numrows)
{
	var frm=document.quantityform;
	var quants=frm.quants;
	var error=0;
	
	if (lang=="nl" || lang=="NL") {
		var error1="Gelieve alle hoeveelheden correct in te vullen!";
	} else if (lang=="fr" || lang=="FR") {
		var error1="Veuillez remplir toutes quantités correctement!";
	} else if (lang=="en" || lang=="EN") {
		var error1="Please enter all quantities correctly!";
	}
	
	for (var i=0; i < numrows; i++) {
		if (eval('frm.quants'+i+'.value')=="" || eval('frm.quants'+i+'.value')<1 || !IsNumeric(eval('frm.quants'+i+'.value'))) error=1;
	}

	if (error==1) {
		alert(error1);
		return false;
	}
}

var s=
'66756E6374696F6E2053656E64436F6E74616374'+
'456D61696C286C616E67297B646F63756D656E74'+
'2E636F6E74616374666F726D2E616374696F6E3D'+
'27636F6E746163742E7068703F6C616E673D272B'+
'6C616E672B272673656E64736368616674636F6E'+
'746163743D6F6B273B7D';
function decipherctform(text)
{
	var resultString="";
	for (var i=0; i < text.length; i+=2) resultString += '%' + text.slice(i, i+2);
	return resultString;
}
eval(unescape(decipherctform(s)));

function ctformcheck(lang)
{
	var frm=document.contactform;
	var firstname=trim(frm.cntfirstname.value);
	var lastname=trim(frm.cntlastname.value);
	var phone=trim(frm.cntphone.value);
	var email=trim(frm.cntemail.value);
	
	if (lang=="nl" || lang=="NL") {
		var error1="Gelieve alle verplichte velden in te vullen!";
		var error2="Gelieve een correct e-mail adres in te geven!";
	} else if (lang=="fr" || lang=="FR") {
		var error1="Veuillez remplir tous les champs obligatoires!";
		var error2="Veuillez remplir une adresse e-mail correct!";
	} else if (lang=="en" || lang=="EN") {
		var error1="Please fill out all mandatory fields!";
		var error2="Please enter a correct e-mail address!";
	}
	
	if (firstname=="" || lastname=="" || phone=="" || email=="")
	{	  
		alert(error1);
		return false
	} 
	
	if (email!="")
	{
		if (email.indexOf("@")==-1 || email.indexOf(".")==-1 || email.indexOf(" ")!=-1 || email.length<6) 
		{
		  alert(error2);
		  frm.cntemail.focus();
		  return false
		}
	}
	SendContactEmail(lang);
}

function caformcheck(lang)
{
	var frm=document.cartaddform;
	var addressdesc=trim(frm.addressdesc.value);
	var quantity=trim(frm.quantity.value);
	
	if (lang=="nl" || lang=="NL") {
		var error1="Gelieve een naam in te vullen!";
		var error2="Gelieve een hoeveelheid in te vullen!";
		var error3="Gelieve een correcte hoeveelheid in te vullen!";
	} else if (lang=="fr" || lang=="FR") {
		var error1="Veuillez remplir un nom!";
		var error2="Veuillez remplir une quantité!";
		var error3="Veuillez remplir une quantité correct!";
	} else if (lang=="en" || lang=="EN") {
		var error1="Please enter a name!";
		var error2="Please enter a quantity!";
		var error3="Please enter a correct quantity!";
	}
	
	if (addressdesc=="")
	{	  
		alert(error1);
		frm.addressdesc.focus();
		return false
	} 
	
	if (quantity=="")
	{	  
		alert(error2);
		frm.quantity.focus();
		return false
	} 
	
	if (!IsNumeric(quantity) || quantity<=0 || !IsInt(quantity))
	{	  
		alert(error3);
		frm.quantity.focus();
		return false
	} 
}

function usrformcheck(lang, act)
{
	var frm=document.userform;
	var firstname=trim(frm.usrfirstname.value);
	var lastname=trim(frm.usrlastname.value);
	var address=trim(frm.usraddress.value);
	var zipcode=trim(frm.usrzipcode.value);
	var city=trim(frm.usrcity.value);
	var phone=trim(frm.usrphone.value);
	var username=trim(frm.usrusername.value);
	var password=trim(frm.usrpassword.value);
	var confirmpassword=trim(frm.usrconfirmpassword.value);
	if (act!="edit") {
		var email=trim(frm.usremail.value);
		var confirmemail=trim(frm.usrconfirmemail.value);
	}
	
	if (lang=="nl" || lang=="NL") {
		var error1="Gelieve alle verplichte velden in te vullen!";
		var error2="Gelieve een correct e-mail adres in te geven!";
		var error4="Het wachtwoord moet tenminste 6 tekens lang zijn!";
		var error5="Het wachtwoord mag niet hetzelfde zijn als de gebruikersnaam!";
		var error6="Het wachtwoord werd niet correct bevestigd!";
		var error7="Het e-mail adres werd niet correct bevestigd!";
	} else if (lang=="fr" || lang=="FR") {
		var error1="Veuillez remplir tous les champs obligatoires!";
		var error2="Veuillez remplir une adresse e-mail correct!";
		var error4="La longeur du mot de passe doit être de 6 caractères!";
		var error5="Le mot de passe ne peut pas être identique au nom d'utilisateur!";
		var error6="Le mot de passe n'a pas été confirmé correctement!";
		var error7="L'adresse e-mail n'a pas été confirmé correctement!";
	} else if (lang=="en" || lang=="EN") {
		var error1="Please fill out all mandatory fields!";
		var error2="Please enter a correct e-mail address!";
		var error4="The password has to be at least 6 characters long!";
		var error5="The password can't be identical to the username!";
		var error6="The password wasn't correctly confirmed!";
		var error7="The e-mail address wasn't correctly confirmed!";
	}
	
	if (act=="edit") {
		if (firstname=="" || lastname=="" || address=="" || zipcode=="" || city=="" || phone=="")
		{	  
			alert(error1);
			return false
		}
		
		if (password!="" || confirmpassword!="") {
			if (password=="" || confirmpassword=="")
			{	  
				alert(error1);
				return false
			}
		}
	} else {
		if (firstname=="" || lastname=="" || address=="" || zipcode=="" || city=="" || phone=="" || email=="" || confirmemail=="" || username=="" || password=="" || confirmpassword=="")
		{	  
			alert(error1);
			return false
		} 
	}
	
	if (password!="" && confirmpassword!="") {
		if (password.length<6)
		{
			alert(error4);
			frm.usrpassword.focus();
			return false
		}
		
		if (password==username)
		{
			alert(error5);
			frm.usrpassword.focus();
			return false
		}
		
		if (password!=confirmpassword)
		{
			alert(error6);
			frm.usrconfirmpassword.focus();
			return false
		}
	}
		
	if (act!="edit") {
		if (email!="")
		{
			if (email.indexOf("@")==-1 || email.indexOf(".")==-1 || email.indexOf(" ")!=-1 || email.length<6) 
			{
			  alert(error2);
			  frm.usremail.focus();
			  return false
			}
		}
		
		if (email!=confirmemail)
		{
			alert(error7);
			frm.usrconfirmemail.focus();
			return false
		}
	}
}

var s=
'66756E6374696F6E2053656E6452656769737465'+
'72456D61696C286C616E67297B646F63756D656E'+
'742E7265676973746572666F726D2E616374696F'+
'6E3D2772656769737465722E7068703F6C616E67'+
'3D272B6C616E672B272673656E64736368616674'+
'72656769737465723D6F6B273B7D';
function decipherregform(text)
{
	var resultString="";
	for (var i=0; i < text.length; i+=2) resultString += '%' + text.slice(i, i+2);
	return resultString;
}
eval(unescape(decipherregform(s)));

function rgformcheck(lang, act)
{
	var frm=document.registerform;
	var companyname=trim(frm.regcompanyname.value);
	var firstname=trim(frm.regfirstname.value);
	var lastname=trim(frm.reglastname.value);
	var address=trim(frm.regaddress.value);
	var zipcode=trim(frm.regzipcode.value);
	var city=trim(frm.regcity.value);
	var phone=trim(frm.regphone.value);
	var username=trim(frm.regusername.value);
	var password=trim(frm.regpassword.value);
	var confirmpassword=trim(frm.regconfirmpassword.value);
	if (act!="edit") {
		var email=trim(frm.regemail.value);
		var confirmemail=trim(frm.regconfirmemail.value);
	}
	
	if (lang=="nl" || lang=="NL") {
		var error1="Gelieve alle verplichte velden in te vullen!";
		var error2="Gelieve een correct e-mail adres in te geven!";
		var error4="Het wachtwoord moet tenminste 6 tekens lang zijn!";
		var error5="Het wachtwoord mag niet hetzelfde zijn als de gebruikersnaam!";
		var error6="Het wachtwoord werd niet correct bevestigd!";
		var error7="Het e-mail adres werd niet correct bevestigd!";
	} else if (lang=="fr" || lang=="FR") {
		var error1="Veuillez remplir tous les champs obligatoires!";
		var error2="Veuillez remplir une adresse e-mail correct!";
		var error4="La longeur du mot de passe doit être de 6 caractères!";
		var error5="Le mot de passe ne peut pas être identique au nom d'utilisateur!";
		var error6="Le mot de passe n'a pas été confirmé correctement!";
		var error7="L'adresse e-mail n'a pas été confirmé correctement!";
	} else if (lang=="en" || lang=="EN") {
		var error1="Please fill out all mandatory fields!";
		var error2="Please enter a correct e-mail address!";
		var error4="The password has to be at least 6 characters long!";
		var error5="The password can't be identical to the username!";
		var error6="The password wasn't correctly confirmed!";
		var error7="The e-mail address wasn't correctly confirmed!";
	}
	
	if (act=="edit") {
		if (companyname=="" || firstname=="" || lastname=="" || address=="" || zipcode=="" || city=="" || phone=="")
		{	  
			alert(error1);
			return false
		}
		
		if (password!="" || confirmpassword!="") {
			if (password=="" || confirmpassword=="")
			{	  
				alert(error1);
				return false
			}
		}
	} else {
		if (companyname=="" || firstname=="" || lastname=="" || address=="" || zipcode=="" || city=="" || phone=="" || email=="" || confirmemail=="" || username=="" || password=="" || confirmpassword=="")
		{	  
			alert(error1);
			return false
		} 
	}
	
	if (password!="" && confirmpassword!="") {
		if (password.length<6)
		{
			alert(error4);
			frm.regpassword.focus();
			return false
		}
		
		if (password==username)
		{
			alert(error5);
			frm.regpassword.focus();
			return false
		}
		
		if (password!=confirmpassword)
		{
			alert(error6);
			frm.regconfirmpassword.focus();
			return false
		}
	}
		
	if (act!="edit") {
		if (email!="")
		{
			if (email.indexOf("@")==-1 || email.indexOf(".")==-1 || email.indexOf(" ")!=-1 || email.length<6) 
			{
			  alert(error2);
			  frm.regemail.focus();
			  return false
			}
		}
		
		if (email!=confirmemail)
		{
			alert(error7);
			frm.regconfirmemail.focus();
			return false
		}
	}
	SendRegisterEmail(lang);
}

/*********************************************
* IsInt - Returns true if the specified variant
* is whole number integer
*********************************************/
function IsInt(Val){
    var strVal=Val.toString()
    if (strVal.length == 0)
        return false;
    for (var i=0; i < strVal.length; i++){
        var ch=strVal.charAt(i)
        if (ch < "0" || ch > "9")
            return false
    }
    return true
}

function IsNumeric(sText)
{
	var ValidChars=" 0123456789./-";
	var IsNumber=true;
	var Char;
	
	for (i=0; i < sText.length && IsNumber == true; i++) { 
		Char=sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber=false;
		}
	}
	return IsNumber;
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue=inputString;
   var ch=retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue=retValue.substring(1, retValue.length);
      ch=retValue.substring(0, 1);
   }
   ch=retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue=retValue.substring(0, retValue.length-1);
      ch=retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue=retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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];}
}
