
	function MenuItem (sId, bCats) {
		
		this.id = sId;
		this.cats = bCats;
		this.open = false;
		this.timer = null;
		this.timeout = 10;
		this.rootUrl = oPage.rootUrl;
		
		OnLoadObject (this);
		
	}
	
	MenuItem.prototype.init = function () {
		
		if (this.cats) {
			
			this.pane = document.getElementById ('menuPane' + this.id);
			this.catPane = document.getElementById ('menuCatPane' + this.id);
			
		}
		
		this.img = document.getElementById ('menuImg' + this.id);
		
	}
	
	
	MenuItem.prototype.mouseOver = function () {
		
		if (this.cats && this.catPane) {
			
			clearTimeout (this.timer);
			this.showPane ();
			
		}
		
		if (this.img)
			this.img.src = this.rootUrl + 'images/layout/menu/' + this.id + '_mo.gif';
		
	}

	
	MenuItem.prototype.mouseOut = function () {
		
		if (this.cats) {
			
			var self = this;
			clearTimeout (this.timer);
			this.timer = window.setTimeout (function () {self.hidePane ();}, this.timeout);
			
		}
		
		if (this.img)
			this.img.src = this.rootUrl + 'images/layout/menu/' + this.id + '.gif';
		
	}
	
	
	MenuItem.prototype.showPane = function () {
		
		if (!this.open) {
			this.catPane.style.display = 'block';
			this.pane.style.zIndex = 100;
			this.open = true;
		}
		
	}


	MenuItem.prototype.hidePane = function () {
		
		if (this.open) {
			this.catPane.style.display = 'none';
			this.pane.style.zIndex = 20;
			this.open = false;
		}
		
	}


	function Cat (sId) {
		
		this.id = sId;
		
	}
	
	
	function EndDiv (sId, iCorrection) {
		
		this.id = sId;
		
		OnLoadObject (this);
		
	}
	
	EndDiv.prototype.init = function () {
		
		this.div = document.getElementById ('endDiv' + this.id);
		//alert(this.id);
		this.div.style.height = oPage.mainDivHeight - this.findPosY (this.div) + 142;
		
	}
	
	
	EndDiv.prototype.findPosY = function (obj) {
		var curtop = 0;
		if(obj.offsetParent)
			while(1)
			{
			  curtop += obj.offsetTop;
			  if(!obj.offsetParent)
				break;
			  obj = obj.offsetParent;
			}
		else if(obj.y)
			curtop += obj.y;
		return curtop;
	}
	
	
	function ImagePreloader (arrayImages) {
		
		this.images = arrayImages;
		
		OnLoadObject (this);
		
	}
	
	
	ImagePreloader.prototype.init = function () {
		
		var arrayImages = new Array;
		
		if (document.images) {
			
			for (var i = 0; i < this.images.length; i++) {
				
				arrayImages[i] = new Image();
				arrayImages[i].src = this.images[i];
				
			}
			
		}
		
	}
	
	
    function loadGoogleMap () {
		
		if (GBrowserIsCompatible()) {
			
			var map = new GMap2(document.getElementById("map"));
			var point = new GLatLng(51.76827809442263, 5.860111713409424);
			var centerPoint = new GLatLng(51.95357579376812, 5.10040283203125);
			
			map.addControl(new GSmallMapControl());
			map.setCenter(centerPoint, 9);
			
			var icon = new GIcon();
			icon.image = "http://www.axitraxi.nl/images/layout/googlemap_marker.png";
			icon.iconSize = new GSize(227, 80);
			icon.iconAnchor = new GPoint(79, 72);
			icon.infoWindowAnchor = new GPoint(96, 13);
			
			var marker = new GMarker(point, icon);
			map.addOverlay(marker);
			
		}
		
		// http://www.google.com/apis/maps/documentation/
		// http://www.infosports.com/m/map.htm
		
	}
	
	
	function DialogBox (sId) {
		
		this.id = sId;
		
		OnLoadObject (this);
		
	}
	
	
	DialogBox.prototype.init = function () {
		
		var messageElem = document.getElementById (this.id);
		
		messageElem.innerHTML = oPage.getParameter ('dialogboxmelding');
		
	}
	
    
	
	function Carrousel (sId, iImageCount) {
		
		this.id = sId;
		this.imageCount = iImageCount;
		this.sliderWidth = 357;
		this.sliderPos = 0;
		this.sliderMin = 0;
		this.sliderMax = this.sliderWidth * Math.ceil (this.imageCount / 3);
		
		OnLoadObject (this);
		
	}
	
	Carrousel.prototype.init = function () {
		
		this.mainImage = document.getElementById ('CarMainImage' + this.id);
		this.slider = document.getElementById ('CarSlider' + this.id);
		this.buttonPrevious = document.getElementById ('CarButtonPrevious' + this.id);
		this.buttonNext = document.getElementById ('CarButtonNext' + this.id);
		this.selectedThumb = document.getElementById ('carThumbFotoKader' + this.id);
		
		if (this.sliderPos - this.sliderWidth > -this.sliderMax)
			this.enableNext ();
		
	}
	
	
	Carrousel.prototype.showImage = function (sProductId) {
		
		this.selectedThumb.style.borderColor = '#0032D7';
		this.selectedThumb = document.getElementById ('carThumbFotoKader' + sProductId);
		this.selectedThumb.style.borderColor = '#FCDD20';
		this.mainImage.src = 'images/fotos/' + sProductId + '.jpg';
		
	}
	
	
	Carrousel.prototype.goNext = function () {
		
		if ((this.sliderPos - (2 * this.sliderWidth)) <= -this.sliderMax)
			this.disableNext ();
		
		if (this.sliderPos - this.sliderWidth >= -this.sliderMax)
			this.enablePrevious ();
		
		this.animNext (-this.sliderWidth);
		
	}

	Carrousel.prototype.goPrevious = function () {
		
		if (this.sliderPos + this.sliderWidth >= this.sliderMin)
			this.disablePrevious ();
		
		if (this.sliderPos + this.sliderWidth < this.sliderMax)
			this.enableNext ();
		
		this.animNext (this.sliderWidth);
		
	}
	
	Carrousel.prototype.enablePrevious = function () {
		
		this.buttonPrevious.style.display = 'block';
		
	}
	
	Carrousel.prototype.enableNext = function () {
		
		this.buttonNext.style.display = 'block';
		
	}

	Carrousel.prototype.disablePrevious = function () {
		
		this.buttonPrevious.style.display = 'none';
		
	}
	
	Carrousel.prototype.disableNext = function () {
		
		this.buttonNext.style.display = 'none';
		
	}

	Carrousel.prototype.animNext = function (iTogo) {
		
		var self = this;
		var iStepSize = ((Math.abs(iTogo)/35) * Math.abs ((Math.abs(iTogo)/35))) + (Math.abs(iTogo)/5);
		
		if (iTogo < 0)
			iStepSize = -iStepSize;
		
		var iTogoNew = iTogo - iStepSize;
		this.sliderPos += iStepSize;
		this.slider.style.left = Math.round (this.sliderPos);
		
		if (Math.round (Math.abs (iTogoNew)) > 0)
			setTimeout (function () {self.animNext (iTogoNew)}, 15);
		else
			this.sliderPos = Math.round (this.sliderPos);
		
	}
	
	
	function Search () {
		
		this.rootUrl = oPage.rootUrl;
		
		this.submitUrl = this.rootUrl + 'parser.asp?xml=nl_zoekresultaten.xml&xsl=website_paginas.xsl&lang=nl';
		
		var oImagePreloaderSearch = new ImagePreloader (new Array (this.rootUrl + 'images/layout/knoppen/zoeken_mo.gif'));
		
		OnLoadObject (this);
		
	}
	
	
	Search.prototype.init = function () {
		
		this.inputBox = document.getElementById ('seachInputBox');
		this.searchString = document.getElementById ('searchStringInput');
		this.searchDep = document.getElementById ('searchDepInput');
		
		// Activate search input box
		this.inputBox.style.visibility = 'visible';
		
		this.retrieveSearchData ();
		
	}
	
	
	Search.prototype.keyDown = function (e) {
		
		var evt = (e)?e:(window.event)?window.event:null;
		
		if (evt){
			
			var key = (evt.charCode)?evt.charCode:
				((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
			
			if (key=="13")
				this.submit ();
			
		}
		
	}
	
	
	Search.prototype.storeSearchData = function () {
		
		setCookie ('searchDataString', encodeURIComponent (this.searchString.value));
		setCookie ('searchDataDepIndex', this.searchDep.selectedIndex);
		
	}
	
	
	Search.prototype.retrieveSearchData = function () {
		
		var sSearchString = getCookie ('searchDataString');
		
		if (sSearchString)
			this.searchString.value = sSearchString;
		
		this.searchDep.selectedIndex = getCookie ('searchDataDepIndex');
		
	}


	Search.prototype.submit = function () {
		
		if (this.searchString.value.length > 0) {
			
			var sSubmitUrl = this.submitUrl; 
			
			sSubmitUrl += '&zoekstring=' + encodeURIComponent (this.searchString.value);
			sSubmitUrl += '&afdeling=' + encodeURIComponent (this.searchDep.value);
			
			this.storeSearchData ();
			
			location.href = sSubmitUrl;
			
		} else {
			
			setCookie ('searchDataString', '');
			setCookie ('searchDataDepIndex', this.searchDep.selectedIndex);
			
			this.searchString.focus ();
			
		}
		
	}
	

	function CurrencyFormatted (num) {
		
		num = num.toString().replace(/\$|\,/g,'');
		
		if (isNaN(num))
			num = "0";
			
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		
		if (cents<10)
			cents = "0" + cents;
			
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+'.'+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '\u20AC ' + num + ',' + cents);
	}

	

	function AxicodeBase (arrayAxicode, products) {
		
		this.codeLength = 6;
		this.axicode = arrayAxicode;
		this.products = products
		this.activatedAxicode;
		
		this.message = new Melding ();
		
		OnLoadObject (this);
		
	}
	
	
	AxicodeBase.prototype.init = function () {
		
		this.activatedAxicode = this.validCode (getCookie ('axicode'));
		
		if (this.activatedAxicode)
			this.products.alterPrices (this.activatedAxicode.discount, this.activatedAxicode.department, this.activatedAxicode.code);
		
	}
	
	
	AxicodeBase.prototype.drawBox = function () {
	
		this.codeBox = document.getElementById ('axicodeBox');
		
		var activatedCode = '';
		
		if (this.activatedAxicode)
			activatedCode = this.activatedAxicode.code;
		
		if (this.codeBox) {
		if (this.activatedAxicode)
			this.codeBox.innerHTML = '<p>Axicode <input id="axicodeInput" type="password" onkeyup="oAxicodeBase.onKeyUp (this.value);" maxlength="' + this.codeLength + '" value="' + activatedCode + '"></p>';
		else
			this.codeBox.innerHTML = '<p>Klik <a href="javascript:oAxicodeBase.openCodeBox ();">hier</a> indien u een Axicode wilt invoeren.</p>';
		}
	}
	
	
	AxicodeBase.prototype.openCodeBox = function () {
		
		this.codeBox = document.getElementById ('axicodeBox');
		
		this.codeBox.innerHTML = '<p>Axicode <input id="axicodeInput" type="password" onkeyup="oAxicodeBase.onKeyUp (this.value);" maxlength="' + this.codeLength + '" value=""></p>';
		
	}
	
	
	AxicodeBase.prototype.validCode = function (sCode) {
		
		for (var i = 0; i < this.axicode.length; i++) {
			
			if (this.axicode[i].code == sCode)
				return this.axicode[i];
			
		}
		
	}
	
	
	AxicodeBase.prototype.onKeyUp = function (sCode) {
		
		if (sCode.length == 6) {
			
			this.activatedAxicode = this.validCode (sCode);
			
			if (this.activatedAxicode)
				this.activateCode ();
			else
				this.deactivateCode (true);
			
		}
		
		if (sCode.length == 0)
			this.deactivateCode (false);
		
	}
	
	
	AxicodeBase.prototype.activateCode = function () {
		
		setCookie ('axicode', this.activatedAxicode.code);
		
		this.message.openDialog ('U hebt een juiste Axicode ingevoerd. ' + decodeURIComponent (this.activatedAxicode.message));
		
		this.products.alterPrices (this.activatedAxicode.discount, this.activatedAxicode.department, this.activatedAxicode.code);
		
	}
	
	
	AxicodeBase.prototype.deactivateCode = function (bShowMessage) {
		
		this.activatedAxicode = null;
		
		setCookie ('axicode', '');
		
		if (bShowMessage)
			this.message.openDialog ('U hebt een ongeldige Axicode ingevoerd.');
		
		// Clear the value inside the Axicode inputbox.
		document.getElementById ('axicodeInput').value = '';
		
		this.products.resetPrices ();
		
	}
	
	
	function Axicode (sCode, iDiscount, sValidFrom, sValidTo, arrayDepartment, sMessage) {
		
		this.code = this.dc (sCode);
		this.discount = iDiscount;
		this.validFrom = sValidFrom;
		this.validTo = sValidTo;
		this.department = arrayDepartment;
		this.message = sMessage;
		
	}
	

	Axicode.prototype.dc = function (sCodeEncrypted) {
		
		var sCodeDecrypted = new String ();
		var num_in;
		
		for (i = 0; i < sCodeEncrypted.length; i += 2) {
			num_in = parseInt(sCodeEncrypted.substr(i,[2])) + 23;
			num_in = unescape('%' + num_in.toString(16));
			sCodeDecrypted += num_in;
		}
		
		return sCodeDecrypted;
		
	}
	
  	
	// =======================================
	// MyAxitraxi
	// =======================================

	function MyAxitraxi (oAXProducts) {
		
		this.AXProducts = oAXProducts;
		
		this.loggedIn = false;
		this.loggedStatusCookieName = 'loggedIn';
		this.discountCookieName = 'discount';
		this.loginNameCookieName = 'axitraxiloginnaam';
		this.menuButtonId = 'menuPanemijnaxitraxi';
		
	};
	
	
	MyAxitraxi.prototype.init = function () {
		
		this.discountPerc = parseFloat (getCookie (this.discountCookieName));
		
		var sLoggedIn = getCookie (this.loggedStatusCookieName);
		var menuButton = document.getElementById (this.menuButtonId);
		
		if (sLoggedIn === 'true') {
			
			this.loggedIn = true;
			
		};
		
		if (this.loggedIn) {
			
			menuButton.style.display = 'block';
			this.AXProducts.alterPrices (this.discountPerc, ['verhuur', 'events'], '');
			
		} else {
			
			menuButton.style.display = 'none';
			
		};
		
	};
	
	
	MyAxitraxi.prototype.setDiscount = function (iDiscount) {
		
		
		
	};
	
	
	MyAxitraxi.prototype.login = function (iDiscountPerc, sUserName) {
		
		this.loggedIn = true;
		this.discountPerc = iDiscountPerc;
		
		setCookie (this.loggedStatusCookieName, 'true', null);
		setCookie (this.discountCookieName, this.discountPerc, null);
		plaatsCookie (this.loginNameCookieName, sUserName, 100);
		
	};

	
	MyAxitraxi.prototype.logout = function () {
		
		this.loggedIn = false;
		
		setCookie (this.loggedStatusCookieName, 'false', null);
		setCookie (this.discountCookieName, 0, null);
		
		window.location.href = 'logout.asp';
		
	};

	
