function addLoadHandler(handler)  {
    
	if (window.addEventListener) {
		window.addEventListener("load", handler, false);
	} else if (window.attachEvent) {
		window.attachEvent("onload", handler);
	} else if(window.onload) {
		var oldHandler = window.onload;
		window.onload = function piggyback() {
			oldHandler();
			handler();
		};
	} else {
		window.onload = handler;
	}
}


function postSearch(searchStr){
	
	if(searchStr != ""){
		location = "/Om_ALKA/search.aspx?search=" + encodeURI(searchStr) + "&page=1";
	}
	else{
		return false;
	}
}


function checkEnter(e,caller) //e is event object passed from function invocation
{
	var characterCode //literal character code will be stored in this variable

	if(e && e.which)
	{ 
		//if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	if(characterCode == 13)//if generated character code is equal to ascii 13 (if enter key)
	{ 
		document.getElementById(caller).click();
		
		return false
	}
	else
	{
		return true
	}
}


// DROPDOWN 

function setLanguage(pUrl) {
	
	var href = location.href;
	
	if (href.indexOf("lang=") < 0) {
		if (location.href.indexOf("?") < 0) {
			location.href = location.href + "?lang=" + pUrl;
		}
		else {
			location.href = location.href + "&lang=" + pUrl;
		}
	}
	else {
		var replacedString = href.substr(href.indexOf("lang="),7);
		href = href.replace(replacedString, "lang=" + pUrl);
		location.href = href;
	}
}


function setCountryID(countryID) {
	var href = location.href;
	
	if (href.indexOf("cID=") < 0) {
		if (location.href.indexOf("?") < 0) {
			location.href = location.href + "?cID=" + countryID;
		}
		else {
			location.href = location.href + "&cID=" + countryID;
		}
	}
	else {
		var newUrl = href.substr(0,href.indexOf(location.search)) + "?cID=" + countryID;
		location.href = newUrl;
	}
}

function toggleMenu(show){
	if(document.getElementById("langDropDown").style.display != "block" || show){
		document.getElementById("langDropDown").style.display = "block";
	}
	else {
		document.getElementById("langDropDown").style.display = "none";
	}
}


function toggleContactDDL(input, show) {
	if(show){
		document.getElementById(input).style.display = "block";
	}
	else {
		document.getElementById(input).style.display = "none";
	}
}