function getXMLHttp() {
	var xmlHttp

	try {
		xmlHttp = new XMLHttpRequest();
		} catch(e) {
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
				} catch(e) {
					try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
					} catch(e) {
						return false;
					}
				}
		}
	return xmlHttp;
}


function udTopMenu(item) {
	var xmlHttp = getXMLHttp();

	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
			showUpdated(xmlHttp.responseText);
		}
	}
	
	xmlHttp.open("GET", "http://www.storyfall.se/topMenu.php?val=" + item, true);
	xmlHttp.send(null);
}

function showUpdated(response) {	
	document.getElementById('topMenu').innerHTML = response;
}

function nlOpenWin(val) {
	if (window.innerHeight && window.scrollMaxY) {
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight) { 
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else {
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
	}

	document.getElementById('nlWin').style.width = xWithScroll + "px";
	document.getElementById('nlWin').style.height = yWithScroll + "px";
	document.getElementById('nlWin').style.visibility = 'visible';
	document.getElementById('nlWin').style.display = '';
	document.getElementById('thid2').innerHTML = val;
	document.getElementById('thid1').value = '1';
}

function nlCloseWin(val) {
	var date = new Date();
	
	if (val == 1) {
		date.setTime(date.getTime() + 300000);
		document.cookie = "qcheckout" + "=" + "true" + date.toGMTString();
	}
	
	document.getElementById('nlWin').style.visibility = 'hidden';
	document.getElementById('nlWin').style.display = 'none';
}

function confCancel(val, val2) {
	if (val == 1) {
		//alert("För att avsluta din prenumeration fyll i din epost-adress och klicka på avsluta");
		document.getElementById('thid2').innerHTML = val2;
		document.getElementById('thid1').value = '0';
	} else {
		alert("false");
	}
}

function sndOnEntr(myfield, e) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13) {
  		myfield.form.submit();
   		return false;
	} else {
		return true;
	}
}

document.onclick=check;
function check(e){
var target = (e && e.target) || (event && event.srcElement);
var obj = document.getElementById('iniSearch');
var obj2 = document.getElementById('sho');
checkParent(target)?obj.style.visibility='hidden':null;
target==obj2?obj.style.visibility='visible':null;
}
function checkParent(t){
while(t.parentNode){
if(t==document.getElementById('iniSearch')){
return false
}
t=t.parentNode
}
return true
}
