var ns4 = (document.layers) ? true:false; // dunno :P
var ie4 = (document.all) ? true:false; // explorer
var ng5 = (document.getElementById) ? true:false; // firefox

function menuOver(menuId) {
	if (ng5)
	{
		if(document.getElementById(menuId)) eval('document.getElementById("' + menuId + '").style.background = "#00b9e9"');
	}
	else if (ns4) eval('document.' + menuId + '.background = "#00b9e9"');
	else if (ie4) eval(menuId + '.style.background = "#00b9e9"');

	if (ng5)
	{
		if(document.getElementById(menuId)) eval('document.getElementById("' + menuId + '").style.cursor = "pointer"');
	}
	else if (ns4) eval('document.' + menuId + '.cursor = "pointer"');
	else if (ie4) eval(menuId + '.style.cursor = "pointer"');
}

function menuOut(menuId,menuType) {
	if(menuType != "subMenu") {
		var bgColor = "#949494";
	} else {
		var bgColor = "#aaaaaa";
	}
	if (ng5)
	{
		if(document.getElementById(menuId)) eval('document.getElementById("' + menuId + '").style.background = "' + bgColor + '"');
	}
	else if (ns4) eval('document.' + menuId + '.background = "' + bgColor + '"');
	else if (ie4) eval(menuId + '.style.background = "' + bgColor + '"');
}

function showMenu(subCatId) {
	if (ng5)
	{
		if(document.getElementById(subCatId)) eval('document.getElementById("' + subCatId + '").style.display = "block";document.getElementById("' + subCatId + '").style.zindex="10"');
	}
	else if (ns4) eval('document.' + subCatId + '.display = "block";document.' + subCatId + '.zindex="10"');
	else if (ie4) eval(subCatId + '.style.display = "block";'+subCatId+'.style.zindex="10"');
}

function showMenuContent(subCatId) {
	if (ng5)
	{
		if(document.getElementById(subCatId)) eval('document.getElementById("' + subCatId + '").style.display = "block";document.getElementById("' + subCatId + '").style.zindex="10"');
	}
	else if (ns4) eval('document.' + subCatId + '.display = "block";document.' + subCatId + '.zindex="10"');
	else if (ie4) eval(subCatId + '.style.display = "block";'+subCatId+'.style.zindex="10"');
}

function hideMenu(subCatId) {
	if (ng5)
	{
		if(document.getElementById(subCatId)) eval('document.getElementById("' + subCatId + '").style.display = "none";document.getElementById("' + subCatId + '").style.zindex="-1"');
	}
	else if (ns4) eval('document.' + subCatId + '.display = "none";document.'+subCatId+'.zindex="-1"');
	else if (ie4) eval(subCatId + '.style.display = "none";'+subCatId+'.style.zindex="-1"');
}

function hideMenuContent(subCatId) {
	for(var i=1;i<13;i++) {
		if(i != subCatId && i != 1 && i != 3 && i != 4 && i != 7) {
			if (ng5)
			{
				if(document.getElementById(i)) eval('document.getElementById("' + i + '").style.display = "none";document.getElementById("' + i + '").style.zindex="-1"');
			}
			else if (ns4) eval('document.' + i + '.display = "none";document.'+i+'.zindex="-1"');
			else if (ie4) eval(i + '.style.display = "none";'+i+'.style.zindex="-1"');
		}
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function newsredir(pid) {
	var val=onf.ons.value;
	location.href='index.php?pageId='+pid+'&newsId='+val;
}

function swf(file) {
	document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"920\" height=\"209\">");
	document.writeln("<param name=\"movie\" value=\""+file+"\">");
	document.writeln("<param name=\"quality\" value=\"high\">");
	document.writeln("<embed src=\""+file+"\" width=\"920\" height=\"209\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" bgcolor=\"#333333\"></embed></object>");
}

function popwin(url,w,h) {
	window.open(url, "_pop", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h);
}

function checkSubmitK(fo)
{
	var err=0;
	var form=document.getElementById(fo);
	if(form.snum.value=='' || form.snum.value=='0') err=1;
	if(err==0) form.submit();
	else alert("Du måste ange ett antal!");
}
