var $_GET=Array()
$chunks=window.location.href.split("/");
for($x=0; $x<$chunks.length; $x++){
	if($chunks[$x].search("_")){
		$parts=$chunks[$x].split("_");
		$_GET[$parts[0]]=$parts[1];
	}
}
function amILocal($needle){
	$haystack=window.location.href;
	if($haystack.search($needle)>=0){
		return true;
	} else {
		return false;
	}
}
if(amILocal(LOCAL_HOST)){
	ROOT="http://"+LOCAL_HOST+"/"+LOCAL_FOLDER+"/";
	AJAXURLstop=LOCAL_FOLDER;
} else {
	ROOT="http://"+LIVE_URL+"/";
	AJAXURLstop=LIVE_URL;
}
function createCookie(name,value,days) {
	if(days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
URLparts=window.location.href.split("/");
addParts=true;
AJAXlink="";
for(i=URLparts.length-2; i>0; i--){
	if(URLparts[i]==AJAXURLstop){
		addParts=false;
	}
	if(addParts){
		AJAXlink+="../";
	}
}
AJAXlink+="ajax/";

if(!readCookie("tomgourdiemenustate")){
	createCookie("tomgourdiemenustate", "closed", 30);
}
window.addEvent("domready", function(){
	$$("#header form input")[0].onfocus=function(){
		this.value="";
	}
	$$("#header form input")[0].onblur=function(){
		if(this.value==""){
			this.value="Search the catalogue...";
		}
	}
	if(readCookie("tomgourdiemenustate")=="closed"){
		$("gallerymenu").setStyles({
			overflow:"hidden",
			height:"0px"
		});
	}
	$("gallerymenu").opener=new Fx.Styles($("gallerymenu"), {duration:1000});
	$("gallerylink").onclick=function(){
		if(readCookie("tomgourdiemenustate")=="open"){
			createCookie("tomgourdiemenustate", "closed", 30);
			$("gallerymenu").opener.start({
				height:0
			});
		} else {
			createCookie("tomgourdiemenustate", "open", 30);
			$("gallerymenu").opener.start({
				height:$("gallerymenu").getSize().scrollSize.y
			});
		}
		return false;
	}
});