
/**
 * Opens a new window with the specified url. Example:
 *
 *    openPopup("mypage.html", "myPopupWindow", null, null, 400, null);
 *
 * @param  url            url of the page to load in the popup window, null will
 *                        load 'about:blank' in the popup window.
 * @param  windowName     name of the popup window, use null or '_blank' to open
 *                        a new window every time.
 * @param  windowX        screen x coordinate for the popup window, null will
 *                        center the popup window horizontaly, a negative value
 *                        will align the popup window to the right side of the
 *                        screen keeping the specified amount of space between
 *                        the right side of the window and the right side of the
 *                        screen.
 * @param  windowY        screen y coordinate for the popup window, null will
 *                        center the popup window verticaly, a negative value
 *                        will align the popup window to the bottom of the screen
 *                        keeping the specified amount of space between the bottom
 *                        of the window and the bottom of the screen.
 * @param  windowWidth    (inner) width of the popup window, null will size the
 *                        window to the available screen width minus 20,
 *                        a negative value will subtract that value from the
 *                        available screen width.
 * @param  windowHeight   (inner) height of the popup window, null will size the
 *                        window to the available screen height minus 180,
 *                        a negative value will subtract that value from the
 *                        available screen height.
 * @return                a reference to the opened window.
 */
function openPopup(url, windowName, windowX, windowY, windowWidth, windowHeight) {
	// constants
	var windowBorderV = 25 + 6;
	var windowBorderH = 2 * 6;

	// set defaults
	if (url == null)           url = "about:blank";
	if (windowName == null)    windowName = "_blank";
	if (windowWidth == null)   windowWidth = screen.availWidth - 20;
	else if (windowWidth < 0)  windowWidth = screen.availWidth + windowWidth;
	if (windowHeight == null)  windowHeight = screen.availHeight - 180;
	else if (windowHeight < 0) windowHeight = screen.availHeight + windowHeight;
	if (windowX == null)       windowX = (screen.availWidth - (windowWidth + windowBorderH)) / 2;
	else if (windowX < 0)      windowX = screen.availWidth + windowX - (windowWidth + windowBorderH);
	if (windowY == null)       windowY = (screen.availHeight - (windowHeight + windowBorderV)) / 2;
	else if (windowY < 0)      windowY = screen.availHeight + windowY - (windowHeight + windowBorderV);

	// prepare flags
	var windowFlags = "resizable=0";
	windowFlags += ",directories=0";
	windowFlags += ",location=0";
	windowFlags += ",menubar=0";
	windowFlags += ",scrollbars=1";
	windowFlags += ",status=0";
	windowFlags += ",toolbar=0";
	windowFlags += ",left=" + windowX + ",screenX=" + windowX;
	windowFlags += ",top=" + windowY + ",screenY=" + windowY;
	windowFlags += ",width=" + windowWidth + ",innerWidth=" + windowWidth;
	windowFlags += ",height=" + windowHeight + ",innerHeight=" + windowHeight;
	
	// open popup
	var popupWindow = window.open(url, windowName, windowFlags);
	popupWindow.focus();

	return popupWindow;
}

var PopUpTimelessX = (screen.width/2)-255;
var PopUpTimelessY = (screen.height/2)-81;
var pos = "left="+PopUpTimelessX+",top="+PopUpTimelessY;

function PopUpTimeless(){
PopUpTimelessWindow = window.open("timeless.html","Timeless","width=510,height=162,"+pos);
}

function form_onSubmit()
{

var url = "http://tools.locatienet.com/finder/address.asp?resulttype=BEST&client_id="+ document.invoerform.client_id.value + "&country=" + document.invoerform.country.value + "&zipcode=" + document.invoerform.zipcode.value;

openPopup(url, null, null, null, 600, 400);

return false;
}

//##################################################################
//                      HIGHLIGHT SCRIPT:
//##################################################################

//De image source van de highlight is hetzelfde als de image soure van de normal state plus een teken reeks
//Bijv image source normal state = BU10001.gif dan image source highlight state = BU10001_h.gif
//De string die aan de image source wordt toegevoegd voor de highlight state staat in de globale
//variabele HighLightString
	var HighLightString = "h";
	var HighLightedSource = "";

//Lijst van de buttons (zijn de images die gepreload moeten worden)
	var ButtonImageArray = new Array;

//Functie om een button te highlighten
	function MakeHigh (ButtonName){
		var ArrayLength = 0; //Lengte van document.images array
		if (ButtonName == null)
		{
			ButtonName = HighLightedSource;
		}
		ArrayLength = ButtonImageArray.length; //aantal images in de pagina bepalen
		for(var i=0; i<ArrayLength; i++){
			if (ButtonImageArray[i].name == ButtonName){  //Als de image gevonden wordt die de naam ButtonName heeft
				(ButtonImageArray[i].ImgObject).src = ButtonImageArray[i].high;
				}
			}
		}

//Functie om een button te dehighlighten
	function MakeNormal (ButtonName){
		var ArrayLength = 0; //Lengte van document.images array

		ArrayLength = ButtonImageArray.length; //aantal images in de pagina bepalen
		for(var i=0; i<ArrayLength; i++){
			if (ButtonImageArray[i].name == ButtonName){  //Als de image gevonden wordt die de naam ButtonName heeft
				if (ButtonImageArray[i].makenorm){  //checken of de button gedehighlight mag worden
					(ButtonImageArray[i].ImgObject).src = ButtonImageArray[i].normal;
					}
				}
			}
		}


	//Deze preload alle highlightstates van de buttons die als de naam van de button de karakter reeks
	//ButtonNameContains bevat
	function PreloadButtons(ButtonNameContains){
		FindImage(document,ButtonNameContains);
		}	
	
	//Deze functie voert de eigenlijke preload uit
	function FindImage(d, ButtonNameContains) { //v3.0
		var i,j;  
		var ArrayLength = 0; //Lengte van document.images array
		var NewImage = "";
		var ButtonImTeller = ButtonImageArray.length;
	//alle images in het document aflopen
		if(!d) d=document;
		ArrayLength = d.images.length; //aantal images in de pagina bepalen
		for(var i=0; i<ArrayLength; i++){
			if (d.images[i].name.indexOf(ButtonNameContains) > -1){
				ButtonImageArray[ButtonImTeller] = new ImageButton(d.images[i].src,d.images[i].name,d.images[i]);//Source van de image bepalen
				NewImage = new Image();
				NewImage.src = ButtonImageArray[ButtonImTeller].high;		//De highlight source toekennen aan de image
				ButtonImTeller++;
			}
		}
	//kijken of er layers zijn en zo ja dan de images op deze layers ook indexeren
 		for(j=0;d.layers&&j<d.layers.length;j++){
			FindImage(d.layers[j].document,ButtonNameContains); 		
		}	
	}
	
	//wordt door de findimages functie gebruikt om info op te slaan van een image object
	function ImageButton(ImageSource,ImageName,ImageObject){
		var TImagesrc = ""; //De source van de Image met de naam <ButtonName>
		var TImageType = ""; //Het type van de image (bijv .jpg)
		var CharLengthImageSrc = ""; //Karakter lengte van de Image source

		this.name = ImageName; //naam van de image
		this.normal = ImageSource; //source van de normal state van de image 
		CharLengthImagesrc = ImageSource.length;	//Lengte van de source van de image bepalen
		TImageType = ImageSource.substring((CharLengthImagesrc - 4),  CharLengthImagesrc);	//Het type van de image source bepalen
		this.high = ImageSource.substring(0, (CharLengthImagesrc-4)) + HighLightString + TImageType;		//De highlight source toekennen aan de image
		this.ImgObject = ImageObject;  //referentie (pointer) naar image object
		this.makenorm = 1; //waarde 1 of 0 -- 1 button mag gedehighlight worden  en 0 button moet gehighlight blijven
		}

	//functie waarmee de globale var HighLightString gezet wordt
	function SetHighLightString(Tstring){
		HighLightString = Tstring;
		}

	//functie waarmee de globale var HighLightString gezet wordt
	function SetHighLightedSource(Tstring){
		HighLightedSource = Tstring;
		}

	//functie die de highlight state van een button op high zet
	//en ervoor zorgt dat de button niet meer gedehighlight mag worden
	//kan voor meerdere buttons aangeroepen worden 
	function SetKeepHigh(ButtonName){
		MakeHigh(ButtonName);
		var ArrayLength = 0; //Lengte van button images array

		ArrayLength = ButtonImageArray.length; //aantal images in de pagina bepalen
		for(var i=0; i<ArrayLength; i++){
			if (ButtonImageArray[i].name == ButtonName){
				ButtonImageArray[i].makenorm = 0;
				}
			}

		}

	//functie die de highlight state van een button op high zet
	//en ervoor zorgt dat de button niet meer gedehighlight mag worden
	//alle vorige waarden voor andere buttons worden gereset
	function ReplaceKeepHigh(ButtonName){
		var ArrayLength = 0; //Lengte van button images array

		ArrayLength = ButtonImageArray.length; //aantal images in de pagina bepalen
		for(var i=0; i<ArrayLength; i++){
			ButtonImageArray[i].makenorm = 1;
			MakeNormal(ButtonImageArray[i].name);
			}
		SetKeepHigh(ButtonName);
	}

	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_showHideLayers() { //v6.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
	}



