
var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';


}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
var btw_checked=1;

function contactcontrole(form)
{
  if (form.opmerking.value == "")
  {
     alert("Please enter a remark")
     form.opmerking.focus()
     return false
  }
  if (form.naam.value == "")
  {
     alert("Please enter your name")
     form.naam.focus()
     return false
  }
  
  if (form.contact_email.value == "")
  {
     alert("Please enter an e-mail address")
     form.contact_email.focus()
     return false
  }
  
  if (form.contact_email.value != "")
  {
   	if ((str=form.contact_email.value.indexOf(".") < 2) && (str=form.contact_email.value.indexOf("@") < 1))
   	{
	   	    	   	 alert("E-mail address is incorrect")
     	form.contact_email.focus()
     return false
   	}

  }
}

function bestelcontrole(form)
{
  if (!form.accepted.checked)
  {
     alert("You have to accept the non-recurring authorization or choose another method of payment.")
     form.accepted.focus()
     return false
  }
  if (form.rekening2.value == "")
  {
     alert("Enter a valid bank account number")
     form.rekening2.focus()
     return false
  }
  
  if (form.tenname.value == "")
  {
     alert("Enter the field to the attention of")
     form.tenname.focus()
     return false
  }
  
  if (form.machtplaats.value == "")
  {
     alert("Enter the field ?city?")
     form.machtplaats.focus()
     return false
  }
}


function openpopup(popurl)
{
	var winpops=window.open(popurl,"","width=790,height=600,status,scrollbars=yes")
}

function complete()
{
	var winpops=window.open("index.php?page=complete","","width=780,height=600,status,scrollbars=yes");
	winpops.close();
}

function checkadminsend()
{
	msg = "Did you already process and print the invoice?";
	if (confirm(msg)) return true;
	else return false;

}

function checkbestellenbedrag(form)
{
	if (form.bestelmethode.value == "3"||form.bestelmethode.value == "4")
	{
		msg = "On orders below 25.00 pound that are paid with visa or mastercard there is a premium charge of 1.40 GBP.\nYou can accept this or choose another method of payment.";
		if (confirm(msg)) return true;
		else return false;
	}

}

function checkdeleteorders()
{
	msg = "Are you sure you want to remove all orders and invoices of this year?";
	if (confirm(msg)) return true;
	else return false;

}

function openpopup2(popurl)
{
	var winpops=window.open(popurl,"","width=480,height=600,status,scrollbars=yes")
}

function registercheck(form)
{
  if (form.voornaam.value == "")
  {
     alert("First name is a compulsory field!")
     form.voornaam.focus()
     return false
  }
  
  if (form.achternaam.value == "")
  {
     alert("Last name is a compulsory field!")
     form.achternaam.focus()
     return false
  }
  
  if (form.achternaam.value.length < 2)
  {
     alert("Last name is incorrect!")
     form.achternaam.focus()
     return false
  }
  
  if (form.straat.value == "")
  {
     alert("Street is a compulsory field!")
     form.straat.focus()
     return false
  }
  
  if (form.straat.value.length < 2)
  {
     alert("Street is incorrect!")
     form.straat.focus()
     return false
  }
  
  if (form.postcode.value == "")
  {
     alert("Zip code is a compulsory field!")
     form.postcode.focus()
     return false
  }
  
  if (form.postcode.value.length < 4)
  {
     alert("Zip code is incorrect!")
     form.postcode.focus()
     return false
  }
  
  if (form.woonplaats.value.length < 2)
  {
     alert("City is incorrect!")
     form.woonplaats.focus()
     return false
  }
  
  
  
 if (form.btw_nummer.value!="")
  {
      if (form.CountryCode.value!="NL")
	  {
	      if (form.bedrijf.value=="")
		  {
		     alert("For a VAT-number is a company name compulsory!")
		     form.bedrijf.focus()
		     return false
		  }
	  }
  }
  
  if (form.woonplaats.value == "")
  {
     alert("City is a compulsory field!")
     form.woonplaats.focus()
     return false
  }
 
  if (form.huisnummer.value == "")
  {
     alert("House number is a compulsory field!")
     form.huisnummer.focus()
     return false
  }
  
  if (form.email.value == "")
  {
     alert("E-mail address is a compulsory field!")
     form.email.focus()
     return false
  }
  
  if (form.email.value != "")
  {
   	if ((str=form.email.value.indexOf(".") < 1) || (str=form.email.value.indexOf("@") < 1))
   	{
	  	alert("E-mail address is incorrect")
     	form.email.focus()
     return false
   	}
  }
  
  if (form.telefoon.value == "")
  {
     alert("Phone number is a compulsory field!")
     form.telefoon.focus()
     return false
  }
  
  if (form.telefoon.value.length < 8)
  {
     alert("Phone number is incorrect!")
     form.telefoon.focus()
     return false
  }
  
  if (!form.voorwaarden.checked)
  {
     alert("You have to accept the general terms!")
     form.voorwaarden.focus()
     return false
  }
  return check_btw(form,form.CountryCode);
}

function check_btw(form,land)
{
	if (form.bedrijf.value!="")
  {
  	if (form.btw_nummer.value!=""&&form.btw_nummer.value!="novalidation")
	  {
	  	string=form.btw_nummer.value;
	  	validated=true;
	  	try
	  	{
	  		pre_btw=document.getElementById('pre_btw_id').value;
	  	}
	  	catch(err)
	  	{
	  		pre_btw=land;
	  	}
	  	switch(pre_btw)
		{
			case 'NL':
		  		if (string.length < 9)
  				{
  					validated=false;
  				}
		  	break;    
			case 'BE':
		  		if (string.length < 9)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'DE':
		  		if (string.length < 9)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'UK':
		  		if (string.length < 5)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'SW':
		  		if (string.length < 13)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'SP':
		  		if (string.length < 9)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'PT':
		  		if (string.length < 9)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'LU':
		  		if (string.length < 8)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'IE':
		  		if (string.length < 8)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'FR':
		  		if (string.length < 11)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'FI':
		  		if (string.length < 8)
  				{
  					validated=false;
  				}
		  	break;
		  	case 'AU':
		  		if (string.length < 9)
  				{
  					validated=false;
  				}
		  	break;
		}
		
		if(!validated)
		{
			alert("The VAT-number is not correct!");
			form.btw_nummer.focus();
		     return false;
		}
		else
		{
			if(land.value!='NL')
			{
				btw_checked++;
				alert("Your vat number will be checked online, one moment!");
				
				loc="automate/check_vat.php?vat="+form.btw_nummer.value;
				AjaxRequest.get
				({
					'url':loc,
					'async': true,
					'onSuccess':function(req)
					{
						if(req.responseText=="no")
						{
		     				if(btw_checked>2)
							{
								form.exclude_icl.value="1";
							}
							else
							{
								alert('The VAT-number is not correct!');
								form.btw_nummer.focus();
		     					return false;
							}
						}
						else
						{
							form.exclude_icl.value="0";
							form.submit();
						}
					}
				});
				return false;
			}
		}
	  }
      if (land.value!="NL")
	  {
	      if (form.btw_nummer.value=="")
		  {
		     alert("For foreign companies a VAT-number is compulsory!")
		     form.btw_nummer.focus()
		     return false
		  }
	  }
  }
}

function klantgegevens(form)
{
  if (form.voornaam.value == "")
  {
     alert("First name is a compulsory field!")
     form.voornaam.focus()
     return false
  }
  
  if (form.achternaam.value == "")
  {
     alert("Last name is a compulsory field!")
     form.achternaam.focus()
     return false
  }
  
  if (form.achternaam.value.length < 2)
  {
     alert("Last name is incorrect!")
     form.achternaam.focus()
     return false
  }
  
  if (form.straat.value == "")
  {
     alert("Street is a compulsory field!")
     form.straat.focus()
     return false
  }
  
  if (form.straat.value.length < 2)
  {
     alert("Street is incorrect!")
     form.straat.focus()
     return false
  }
  
  if (form.postcode.value == "")
  {
     alert("Zip code is a compulsory field!")
     form.postcode.focus()
     return false
  }
  
  if (form.postcode.value.length < 4)
  {
     alert("Zip code is incorrect!")
     form.postcode.focus()
     return false
  }
  
  if (form.woonplaats.value.length < 2)
  {
     alert("City is incorrect!")
     form.woonplaats.focus()
     return false
  }
  
  if (form.woonplaats.value == "")
  {
     alert("City is a compulsory field!")
     form.woonplaats.focus()
     return false
  }
 
  if (form.huisnummer.value == "")
  {
     alert("House number is a compulsory field!")
     form.huisnummer.focus()
     return false
  }
  
  if (form.geg_email.value == "")
  {
     alert("E-mail address is a compulsory field!")
     form.geg_email.focus()
     return false
  }
  
  if (form.geg_email.value != "")
  {
   	if ((str=form.geg_email.value.indexOf(".") < 1) || (str=form.geg_email.value.indexOf("@") < 1))
   	{
	  	alert("E-mail address is incorrect")
     	form.geg_email.focus()
     return false
   	}
  }
  
  if (form.telefoon.value == "")
  {
     alert("Phone number is a compulsory field!")
     form.telefoon.focus()
     return false
  }
  
  if (form.telefoon.value.length < 8)
  {
     alert("Phone number is incorrect!")
     form.telefoon.focus()
     return false
  }
  return check_btw(form,form.land);
}

function affiliates_form_check(form)
{
  
  if (form.voornaam.value == "")
  {
     alert("First name is a compulsory field!")
     form.voornaam.focus()
     return false
  }
  
  if (form.achternaam.value == "")
  {
     alert("Last name is a compulsory field!")
     form.achternaam.focus()
     return false
  }
  
  if (form.achternaam.value.length < 2)
  {
     alert("Last name is incorrect!")
     form.achternaam.focus()
     return false
  }
  
  if (form.straat.value == "")
  {
     alert("Street is a compulsory field!")
     form.straat.focus()
     return false
  }
  
  if (form.straat.value.length < 2)
  {
     alert("Street is incorrect!")
     form.straat.focus()
     return false
  }
  
  if (form.postcode.value == "")
  {
     alert("Zip code is a compulsory field!")
     form.postcode.focus()
     return false
  }
  
  if (form.postcode.value.length < 4)
  {
     alert("Zip code is incorrect!")
     form.postcode.focus()
     return false
  }
  
  if (form.woonplaats.value.length < 2)
  {
     alert("City is incorrect!")
     form.woonplaats.focus()
     return false
  }
  
  if (form.woonplaats.value == "")
  {
     alert("City is a compulsory field!")
     form.woonplaats.focus()
     return false
  }
 
  if (form.huisnummer.value == "")
  {
     alert("House number is a compulsory field!")
     form.huisnummer.focus()
     return false
  }
  
  if (form.email2.value == "")
  {
     alert("E-mail address is a compulsory field!")
     form.email2.focus()
     return false
  }
  
  if (form.email2.value != "")
  {
   	if ((str=form.email2.value.indexOf(".") < 2) && (str=form.email2.value.indexOf("@") < 1))
   	{
	  	alert("E-mail address is incorrect")
     	form.email2.focus()
     return false
   	}
  }
  
  if (form.telefoon.value == "")
  {
     alert("Phone number is a compulsory field!")
     form.telefoon.focus()
     return false
  }
  
  if (form.telefoon.value.length < 8)
  {
     alert("Phone number is incorrect!")
     form.telefoon.focus()
     return false
  }
  
  if (form.website.value.length < 8)
  {
     alert("Website is incorrect!")
     form.website.focus()
     return false
  }
  if ((str=form.website.value.indexOf(".") < 8))
  {
     alert("Website is incorrect!")
     form.website.focus()
     return false
  }
  
  if (!form.informatie_1.checked&&!form.informatie_2.checked&&!form.informatie_3.checked)
  {
     alert("You have to choose at least one item you want to receive information about!");
     form.informatie_1.focus();
     return false;
  }
  if (form.bezoekers.value =="")
  {
     alert("The number of visitors of your website has not been entered or entered incorrect!")
     form.bezoekers.focus()
     return false
  }
}

function affiliates_check(form)
{
  if (form.voorwaarden.value=="1")
  {
  	if (!form.aff_voorwaarden.checked)
  	{
     alert("You must accept the affiliate terms!")
     form.aff_voorwaarden.focus()
     return false
  	}
  }


  if (form.banknaam.value.length < 2)
  {
     alert("The name of the bank has not been entered or entered incorrectly!")
     form.banknaam.focus()
     return false
  }
  if (form.bankplaats.value.length < 2)
  {
     alert("The city of the bank has not been entered or entered incorrectly!")
     form.bankplaats.focus()
     return false
  }
  
  if (form.voornaam.value == "")
  {
     alert("First name is a compulsory field!")
     form.voornaam.focus()
     return false
  }
  
  if (form.achternaam.value == "")
  {
     alert("Last name is a compulsory field!")
     form.achternaam.focus()
     return false
  }
  
  if (form.achternaam.value.length < 2)
  {
     alert("Last name is incorrect!")
     form.achternaam.focus()
     return false
  }
  
  if (form.straat.value == "")
  {
     alert("Street is a compulsory field!")
     form.straat.focus()
     return false
  }
  
  if (form.straat.value.length < 2)
  {
     alert("Street is incorrect!")
     form.straat.focus()
     return false
  }
  
  if (form.postcode.value == "")
  {
     alert("Zip code is a compulsory field!")
     form.postcode.focus()
     return false
  }
  
  if (form.postcode.value.length < 4)
  {
     alert("Zip code is incorrect!")
     form.postcode.focus()
     return false
  }
  
  if (form.woonplaats.value.length < 2)
  {
     alert("City is incorrect!")
     form.woonplaats.focus()
     return false
  }
  
  if (form.woonplaats.value == "")
  {
     alert("City is a compulsory field!")
     form.woonplaats.focus()
     return false
  }
 
  if (form.huisnummer.value == "")
  {
     alert("House number is a compulsory field!")
     form.huisnummer.focus()
     return false
  }
  
  if (form.email2.value == "")
  {
     alert("E-mail address is a compulsory field!")
     form.email2.focus()
     return false
  }
  
  if (form.email2.value != "")
  {
   	if ((str=form.email2.value.indexOf(".") < 2) && (str=form.email2.value.indexOf("@") < 1))
   	{
	  	alert("E-mail address is incorrect")
     	form.email2.focus()
     return false
   	}
  }
  
  if (form.telefoon.value == "")
  {
     alert("Phone number is a compulsory field!")
     form.telefoon.focus()
     return false
  }
  
  if (form.telefoon.value.length < 8)
  {
     alert("Phone number is incorrect!")
     form.telefoon.focus()
     return false
  }
  
  if (form.website.value.length < 8)
  {
     alert("Website is incorrect!")
     form.website.focus()
     return false
  }
  if ((str=form.website.value.indexOf(".") < 8))
  {
     alert("Website is incorrect!")
     form.website.focus()
     return false
  }
  
  if (form.rekening.value.length < 4)
  {
     alert("Bank account number has not been entered or entered incorrectly!")
     form.rekening.focus()
     return false
  }
  if (form.tername.value.length < 2)
  {
     alert("At the attention of has not been entered or entered incorrectly!")
     form.tername.focus()
     return false
  }
  

}

function upload_controle(form)
{
  if (!form.copyright_check.checked)
  {
     alert("You must accept the Copyright statement!")
     form.copyright_check.focus()
     return false
  }
  if (form.userfile.value == "")
  {
     alert("Choose a file to upload!")
     form.upfile_0.focus()
     return false
  }
   
  var ext = form.userfile.value;
  ext = ext.substring(ext.length-3,ext.length);
  ext = ext.toLowerCase();
  
  if(ext != 'jpg'&&ext != 'jpeg'&&ext != 'eps') 
  {
    alert('We only accept images with the extension .jpg. \nPlease try again ');
    return false; 
   }
   
    var string = form.userfile.value;
	
	if(countChars('.', string)>1)
	{
		alert("To many strange characters in the filename! These are probaly points. Change the filename and keep it short!");
		return false; 
	}

}
	
function newwin(location,name,w,h)
{
	var scrw=(screen.width/2)-(w/2);
	var scrh=(screen.height/2)-(h/2);
	
	window.open(location,name,'scrollbars=no,left='+scrw+',top='+scrh+',width='+w+',height='+h);
}

function newwin2(location,name,w,h)
{
	var scrw=(screen.width/2)-(w/2);
	var scrh=(screen.height/2)-(h/2);
	
	window.open(location,name,'scrollbars=yes,left='+scrw+',top='+scrh+',width='+w+',height='+h);
}

function countChars(dchar, string)
{   
	string=getStats(string);
       string=new String(string);

	var i;
    var amountchar = 0;
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < string.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = string.charAt(i);
        
        if(c==dchar)
        {
        	amountchar++;
        }
    }
    return amountchar;
}
function getStats(fName)
{

	fullName = fName;
	shortName = fullName.match(/[^\/\\]+$/);
	return shortName;
}
 


function checkMaat(form)
{
	if(form.maat.options[form.maat.selectedIndex].value=='')
	{
		alert("Choose a size !");
		return false;
	}
	return true;
}

var submenu=10;
function expandCollapse() 
{
	var x = document.getElementsByTagName("select");

	for (i = 0; i < x.length; i++) 
	{
	   x[i].style.display = "";
	}
	
	for (var i=0; i<expandCollapse.arguments.length; i++) 
	{
		var element = document.getElementById(expandCollapse.arguments[i]);
		if(element)
		{
			element.style.display = (element.style.display == "none") ? "" : "none";
		}
	}
}
function changePromo()
{
	document.location.href='/index.php?page=promotiekleding';
}
function expandCollapseOut() 
{
	var x = document.getElementsByTagName("select");

	for (i = 0; i < x.length; i++) 
	{
	   x[i].style.display = "none";
	}
   
	for (var i=0; i<expandCollapseOut.arguments.length; i++) 
	{
		var element = document.getElementById(expandCollapseOut.arguments[i]);
		if(element)
		{
			element.style.display =  "";
		}
	}
	
	return false;
}

function emailErrorFormCheck(errortext)
{
	if(document.getElementById('email_error_id').value=="1")
	{
		alert(errortext);
		return false;
	}
	return true;
}

function checkDoubleEmail(field)
{
	AjaxRequest.get
	({
		'url':'extern.php?page=account&action=check_double_email&email='+field.value,
		'async': true,
		'onSuccess':function(req)
		{
			if(req.responseText=="1")
			{
				document.getElementById('input_email_field_id').className='enlightment_error';
				document.getElementById('err_email_id').style.display='';
				document.getElementById('email_error_id').value="1";
			}
			else
			{
				document.getElementById('input_email_field_id').className='enlightment';
				document.getElementById('err_email_id').style.display='none';
				document.getElementById('email_error_id').value="0";
			}
		}
	});
}

function openPromotiekledingSpecialist()
{
	document.location.href='/index.php?page=promotiekledingwerkkleding';
}

function openPromotiekledingSpecialistHome()
{
	document.location.href='/index.php?page=promotiekleding';
}

function setPopupContent(loc)
{
	begin = loc.indexOf ( "external_upload" );
	// If the parameter name is not found, skip it, otherwise return the value
	if ( begin != -1 ) 
	{
	
		try
		{
			document.getElementById("fancy_content_selector3").href=loc;
			$("#fancy_content_selector3").trigger('click');
		}
		catch(err)
		{
			alert(err);
		}
		/*
		scroll(0,0);
		container=document.getElementById('inline_popup_content');
		AjaxRequest.get
		({
			'url':loc,
			'async': true,
			'onSuccess':function(req)
			{
				container.innerHTML=req.responseText;
				document.getElementById('box2').scrollTop = document.getElementById('box2').scrollHeight;
			}
		});
		expandCollapseOut('boxB','over');*/
	}
	else
	{
		try
		{
			document.getElementById("fancy_content_selector3").href=loc;
			$("#fancy_content_selector3").trigger('click');
		}
		catch(err)
		{
			alert(err);
		}
	}
}

function scrollFancyBox(loc)
{
	begin = loc.indexOf ( "page=productinfo" );
	if ( begin != -1 ) 
	{
		setTimeout("scrollFancyBox2()", 500);
	}
	else
	{
		
	}
}

function scrollFancyBox2()
{
	document.getElementById('fancybox-inner').scrollTop = document.getElementById('fancybox-inner').scrollHeight;
}

// Determine browser and version.
function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 1000;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
function addBookmarkForBrowser() 
{
   bookmarksite(document.title, location.href);
}

function bookmarksite(title, url)
{
    if (document.all)
    {
        window.external.AddFavorite(url, title);
    }
    else if (window.sidebar)
    {
        window.sidebar.addPanel(title, url, "")
    }
}

function recalculate_price(hit)
{
	totalitems=getTotalItems();
	
	if(totalitems<10)
	{
		document.getElementById('button_container_id').style.display='none';
		document.getElementById('alternative_container_id').style.display='';
	}
	else
	{
		document.getElementById('button_container_id').style.display='';
		document.getElementById('alternative_container_id').style.display='none';
		
		container=document.getElementById('show_price_id');
		AjaxRequest.get
		({
			'url':'extern.php?page=suggestion&action=get_price&hit='+hit+'&total='+totalitems,
			'async': true,
			'onSuccess':function(req)
			{
				container.innerHTML=req.responseText;
			} 
		});
	}
}
function finalize(hit,showResult,redirect)
{
	totalitems=getTotalItems();
	container=document.getElementById('show_price_id');
	string='';
	
	for(i=0; i<document.order_change.elements.length; i++)
	{
		//document.write("The field name is: " + document.order_change.elements[i].name + " and it’s value is: " + document.order_change.elements[i].value + ".<br />");
		//alert();
		number=parseInt(document.order_change.elements[i].value);
		//alert(number);
		if(number||number==0)
		{
			string=string+"&"+document.order_change.elements[i].name+"="+number;
		}
	}
	
	AjaxRequest.get
	({
		'url':'extern.php?page=suggestion&action=finalize&hit='+hit+'&total='+totalitems+string,
		'async': true,
		'onSuccess':function(req)
		{
			if(showResult)
			{
				//alert('Je order us aangepast! \nKlik onderaan een button om verder te gaan of af te rekenen!');
			}
			if(redirect!=undefined&&redirect)
			{
				top.location.href='index.php?page=winkelwagen';
			}
		}
	});
}
function isNumberString (element)  
{
	InString=element.value;
    if(InString.length==0) return (false);
    var RefString="1234567890";
    for (Count=0; Count < InString.length; Count++)  {
        TempChar= InString.substring (Count, Count+1);
        if (RefString.indexOf (TempChar, 0)==-1) 
        {
        	element.focus();
            return (false);
        }
    }
    return (true);
}
function isNumberStringValue (InString)  
{
    if(InString.length==0) return (false);
    var RefString="1234567890";
    for (Count=0; Count < InString.length; Count++)  {
        TempChar= InString.substring (Count, Count+1);
        if (RefString.indexOf (TempChar, 0)==-1) 
        {
            return (false);
        }
    }
    return (true);
}

function getTotalItems()
{
	total=0;
	for(i=0; i<document.order_change.elements.length; i++)
	{
		//document.write("The field name is: " + document.order_change.elements[i].name + " and it’s value is: " + document.order_change.elements[i].value + ".<br />");
		//alert();
		number=parseInt(document.order_change.elements[i].value);
		//alert(number);
		if(number)
		{
			total+=number;
		}
	}
	return total;
}
function setSubMenuElement(menu,submenu)
{
	if(menu!="null")
	{
		try
		{
			document.getElementById('submenu_'+menu+'_'+submenu).className='main_submenu_active';
		}
		catch(err)
		{
		}
	}
}
function setMainSubMenu(submenu_enable)
{
	resetMainSubMenu();
	document.getElementById('submenu_row_id').style.display='';
	document.getElementById('submenu_'+submenu_enable).style.display='';
	submenu=200;
 
	//alert(document.location.href);
}
	//history.go(-1);
	
function resetOrSetMainSubMenu()
{
	try
	{
		resetMainSubMenu();
	
		if(getParameter(document.location.href,"submenu")!="null")
		{
			setMainSubMenu(getParameter(document.location.href,"submenu"));
			
			if(getParameter(document.location.href,"subelement")!=null)
			{
				setSubMenuElement(getParameter(document.location.href,"submenu"),getParameter(document.location.href,"subelement"));
			}
		}
		else
		{
					}
	}
	catch(err)
	{
	}	
}

function setPopupLightBox(loc)
{
	try
	{
		document.getElementById("fancy_content_selector").href=loc;
		$("#fancy_content_selector").trigger('click');
	}
	catch(err)
	{
		
	}
}

function setPopupCreator(loc)
{
	try
	{
		document.getElementById("fancy_content_selector4").href=loc;
		$("#fancy_content_selector4").trigger('click');
	}
	catch(err)
	{
		
	}
}

function setPopupIframe(loc)
{
	try
	{
		document.getElementById("fancy_content_selector").href=loc;
		$("#fancy_content_selector").trigger('click');
	}
	catch(err)
	{
		alert(err);
	}
}

function setPopupAjax(loc)
{
	try
	{
		document.getElementById("fancy_content_selector2").href=loc;
		$("#fancy_content_selector2").trigger('click');
	}
	catch(err)
	{
		alert(err);
	}
}

function resetMainSubMenu()
{
	try
	{
		for (i=1; i < 10; i++)  
		{
			document.getElementById('submenu_'+i).style.display='none';
		}
	}
	catch(err)
	{
	}	
}
function submenuMustReset()
{
	if(submenu<100)
	{
		resetMainSubMenu();
	}
}
function getParameter ( queryString, parameterName ) 
{
	// Add "=" to the parameter name (i.e. parameterName=value)
	var parameterName = parameterName + "=";
	
	if ( queryString.length > 0 ) 
	{
		// Find the beginning of the string
		begin = queryString.indexOf ( parameterName );
		// If the parameter name is not found, skip it, otherwise return the value
		if ( begin != -1 ) 
		{
			// Add the length (integer) to the beginning
			begin += parameterName.length;
			
			// Multiple parameters are separated by the "&" sign
			end = queryString.indexOf ( "&" , begin );
			
			if ( end == -1 ) 
			{
				end = queryString.length
			}
			
			// Return the string
			return unescape ( queryString.substring ( begin, end ) );
		}
		
		// Return "null" if no parameter has been found
		return "null";
	}
} 

function addLoadEvent(func) 
{
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
  {
    window.onload = func;
  } 
  else 
  {
    window.onload = function() 
    {
      if (oldonload) 
      {
        oldonload();
      }
      func();
    }
  }
}

function trim(value) 
{
  value = value.replace(/^\s+/,''); 
  value = value.replace(/\s+$/,'');
  return value;
}

function holdSessionAlive()
{
	document.getElementById('tracker_image_id').src="image.php?affid=309";
}