/*

	Lost Boys 2005.
	
	De inhoud van dit bestand is in opdracht vervaardigd en eigendom van onze opdrachtgever.
	Niet hergebruiken zonder toestemming.
	Neem voor vragen contact op met Lost Boys, www.lostboys.nl.

	The contents of this file have been produced for and are the property of our client.
	Do not reuse without permission.
	Any questions? Please contact Lost Boys, www.lostboys.nl.

*/
var w=null;function log(m){if(!w)w=window.open();w.document.write(m+'<br />');}
Page = function () {
	this.navigation = new Navigation("navigation");
	//TransformSelects();
	TransformSubmits("button");
	if (document.getElementById("giftswitch")) new GiftFinder();
	if (document.getElementById("basket")) new Basket();

	if (document.getElementById("sidescroller")) new Rotator(document.getElementById("sidescroller"), document.getElementById("sidescroller").getElementsByTagName("div")[0], "ul", document.getElementById("sidescrollerbuttons"), 1, 177, 4000);

	if (document.getElementById("faqs")) {
		new FAQ();
	}
	/* Check for advanced search button */
	if (document.getElementById("advancedsearch")) {
		document.getElementById("advancedsearch").onclick = function () {
			if (navigator.product && navigator.product == "Gecko") {
				document.getElementById("advanced").style.display = "block";
				document.body.style.height = "1%";
			} else {
				document.getElementById("advanced").style.display = (document.getElementById("advanced").style.display == "block") ? "none" : "block";
			}
			return false;
		}
	}
	/* Check for photoalbums */
	if (document.getElementById("look") || document.getElementById("zoombutton")) {
		new Album("look");
	}
	/* Check for carrousels */
	if (document.getElementById("home")) {
		var candidates = document.getElementsByTagName("div");
		for (var i=0; i < candidates.length; i++) {
			if (candidates[i].className.indexOf("carroussel-small") != -1) {
				var delay = (candidates[i].className.indexOf("carroussel-last") != -1) ? 6000 : 2000;
				new Rotator(candidates[i].getElementsByTagName("div")[0], candidates[i].getElementsByTagName("ul")[0], "li", candidates[i].getElementsByTagName("h2")[0], 2, 185, delay);
			}
			if (candidates[i].className.indexOf("carroussel-large") != -1) {
				new Rotator(candidates[i].getElementsByTagName("div")[0], candidates[i].getElementsByTagName("ul")[0], "li", candidates[i].getElementsByTagName("h2")[0], 4, 185, 10000);
			}
		}
	}
	/* Check for tooltips */
	var uls = document.getElementsByTagName("ul");
	for (var i=0; i < uls.length; i++) {
		if (uls[i].className.indexOf("products") != -1) {
			var as = uls[i].getElementsByTagName("a");
			for (var a=0; a < as.length; a++) {
				if (as[a].className != "subcategory") new ToolTip(as[a]);
			}
		}
	}
	/* Check for tickertape on homepage */
	if (document.getElementById("payoff")) {
		new TextFader(document.getElementById("payoff"), 3000, 50);
	}

	/* Check for popup links */
	var as = document.getElementsByTagName("a");
	var popup = null;
	for (var i=0; i < as.length; i++) {
		if (as[i].className == "popup") {
			if (!popup) popup = new PopUp(as[i].name);
			as[i].onclick = function () {
				popup.setURL(this.href);
				popup.show();
				return false;
			}
		}
	}

	/* Check for giftexample popup */
	if (document.getElementById("giftexample")) {
		document.getElementById("giftexample").onclick = function () {document.getElementById("giftpopup").style.display = "block";return false};
		document.getElementById("giftexamplecloser").onclick = function () {document.getElementById("giftpopup").style.display = "none";return false};
	}

	

	var page = this;
	window.onunload = function () {page.destruct()}
}
Page.prototype.destruct = function () {
	//Memory management
}

function TransformSubmits(anchorClassName) {
	var inputs = document.getElementsByTagName("input");
	for (var i=inputs.length-1; i >= 0; i--) {
		if (inputs[i].type == "submit") {
			var anchor = document.createElement("a");
			anchor.id = inputs[i].id + "_a";
			anchor.button = inputs[i];
			anchor.innerHTML = inputs[i].value;
			anchor.href="#";
			anchor.className = anchorClassName;
			anchor.onclick = function () {this.button.click();return false}
			inputs[i].parentNode.insertBefore(anchor, inputs[i]);
			inputs[i].style.display = "none";
		}
	}
}
