function Menu_MOver(obj) {
	obj.style.backgroundImage = "url(/i/Menu-Bg2.png)";
}

function Menu_MOut(obj) {
	obj.style.backgroundImage = "none";
}

function Header_OnChange(index) {
	createCookie("headerIndex", index, 7);
}

function txtSearch_OnFocus(obj) {
	if (obj.value == "Search") {
		obj.value = "";
		obj.style.color = "#404142";
	}
}

function txtSearch_OnBlur(obj) {
	/*if (obj.value == "") {
		obj.value = "Search";
		obj.style.color = "#808182";
	}*/
}

function txtSearch_OnKeyPress(obj, e) {
	if (!e) e = window.event;
	if (e.keyCode == 13) txtSearch_OnSubmit(obj.value);
}

function txtSearch_OnSubmit(s) {
	window.location.href = "/Search.aspx?p=" + encodeURIComponent(s);
}

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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function setEventsAonb(value) {
    var y = Phizz.Navigation.QueryString.Get("y");
    if (y == null || y.length == 0) y = (new Date()).getFullYear();
    
    var m = Phizz.Navigation.QueryString.Get("m");
    if (m == null || m.length == 0) m = (new Date()).getMonth() + 1;

    if (value.length == 0) {
        window.location.href = "/events/?y=" + y + "&m=" + m;
    } else if (value == "1") {
        window.location.href = "/antrim-coast-and-glens-aonb/events/?y=" + y + "&m=" + m;
    } else if (value == "2") {
        window.location.href = "/binevenagh-aonb/events/?y=" + y + "&m=" + m;
    } else if (value == "3") {
        window.location.href = "/causeway-coast-aonb/events/?y=" + y + "&m=" + m;
    }
}

function SetURLParameter(key, value) {
	var url = window.location.href;
	var qs = "";
	if (url.indexOf("?") > -1) {
		qs = url.substr(url.indexOf("?") + 1);
		var pairs = qs.split("&");
		qs = "";
		for (var i = 0; i < pairs.length; i++) {
			if (pairs[i].substr(0, key.length + 1) != (key + "=")) qs += (qs.length == 0 ? "?" : "&") + pairs[i];
		}
		url = url.substr(0, url.indexOf("?")) + qs;
	}
	window.location.href = url + (qs.length == 0 ? "?" : "&") + encodeURIComponent(key) + "=" + encodeURIComponent(value);
}

function fixIE6PNGs() {
	if (navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion.indexOf("MSIE 6.0") > -1 || navigator.appVersion.indexOf("MSIE 5.5") > -1)) {
		var src = "";
	
		var objsImg = document.getElementsByTagName("IMG");
		for (var i = 0; i < objsImg.length; i++) {
			src = objsImg[i].src;
			if (/\/(FR)?s\d+\.png$/.test(src) || /\/Icon\-.+\.png$/.test(src)) {
				objsImg[i].src = "/i/_.gif";
				objsImg[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', src='" + src + "')";
			}
		}
		
	}
}