//write cookie for user resolution
function writeCookie() {
	 var today = new Date();
	 var the_date = new Date("December 31, 2023");
	 var the_cookie_date = the_date.toGMTString();
	 var availheight=screen.availHeight;
     var availwidth=screen.availWidth;
     var colordepth=screen.colorDepth + "bit";
	 var pixeldepth=screen.pixelDepth + "bit";
	 var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
	 var the_cookie = the_cookie + ";path=/;expires=" + the_cookie_date;
	 document.cookie=the_cookie
}
if (document.cookie.indexOf('users_resolution') != ''){
	writeCookie();
}

//search functions
if (!applesearch)	var applesearch = {};
applesearch.onChange = function (fldID, btnID){
	
	var fld = document.getElementById( fldID );
	var btn = document.getElementById( btnID );
	if (fld.value.length > 0 && !this.clearBtn)	{
		
		btn.style.backgroundImage = "url('" + window.location.protocol + "//" + window.location.host+"/themes/meesterfolie/images/search_sprite.png')";
		btn.style.backgroundPosition = "-24px 0";
		btn.fldID = fldID;
		btn.onclick = this.clearBtnClick;
		this.clearBtn = true;
        btn.style.cursor = "pointer";
		
	} else if (fld.value.length == 0 && this.clearBtn){
		
		btn.style.backgroundImage = "url('" + window.location.protocol + "//" + window.location.host+"/themes/meesterfolie/images/search_sprite.png')";
		btn.style.backgroundPosition = "0 0";
		btn.onclick = null;
        btn.style.cursor = "default";
		this.clearBtn = false;
		
	}
};
applesearch.clearFld = function (fldID,btnID){
	var fld = document.getElementById( fldID );
	fld.value = "";
	this.onChange(fldID,btnID);
};
applesearch.clearBtnClick = function (){
	applesearch.clearFld(this.fldID, this.id);
};

$(function(){
	//menu
	$("#mainmenu .haschild").hover(

	  //Opens drop down
	  function (event) { 
	 	event.preventDefault();
		$(this).find(".child").show();
	  },
	
	  //Closes drop down
	  function (event) {
		event.preventDefault();
		$(this).find(".child").hide();
	  }
	);
	
	//submit search field
	$(".sbox_r").click(function() {
			document.forms["searchForm"].submit();
	});
});
