
var app, os, ver, agt;
app = navigator.appName;
os = navigator.userAgent;
ver = parseInt(navigator.appVersion)
agt = navigator.userAgent.toLowerCase();

ns4 = (app == "Netscape" && ver >= 4 && ver < 5)? 1:0
ns5 = (app == "Netscape" && ver >= 5)? 1:0
ie = (app == "Microsoft Internet Explorer" && ver == 4)? 1:0
ie5 = (app == "Microsoft Internet Explorer" && ver == 4 && (agt.indexOf("msie 5.")!=-1))? 1:0
ie6 = (app == "Microsoft Internet Explorer" && ver == 4 && (agt.indexOf("msie 6.")!=-1))? 1:0
ie7 = (app == "Microsoft Internet Explorer" && ver == 4 && (agt.indexOf("msie 7.")!=-1))? 1:0
ie8 = (app == "Microsoft Internet Explorer" && ver == 4 && (agt.indexOf("msie 8.")!=-1))? 1:0
var is_safari = (agt.indexOf("safari") != -1);
var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
var is_operaup = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5);
pc = (os.indexOf("Win") != -1)? 1:0
iefamily = (ie5 || ie6 || ie7 || ie8)? true:false
iepc = (iefamily) && (pc)? 1:0
iemac = (iefamily) && (!pc)? 1:0
browser = (iefamily) || (ns5) || (is_operaup)? 1:0
if (is_safari || iemac) {
	document.writeln('<LINK REL="stylesheet" HREF="css/safarifix.css" TYPE="text/css">')
}

var keepieapart = false;
if(keepieapart){
	if (document.all)
	{
		var detect = navigator.userAgent.toLowerCase();
		var browser,thestring;
		var version = 0;

		if (checkIt('msie')) 
		{
			browser = "IE "
			browser += detect.substr(place + thestring.length,3);
			document.title = browser + ' - ' + document.title;
		}
	}
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}	
	
printPage = function(){
	if(iefamily){
		if(pc) window.print();
		else alert("klicka på skrivarsymbolen i toppen av din browser");
	} else {
		window.print();
	}
}

toggleDiv = function(obj)
{
	 oDiv = document.getElementById(obj)
	 if(oDiv){
	 	if(oDiv.style.display == "block") oDiv.style.display = "none";
		else oDiv.style.display = "block";
	 }
}

var tA = new Array;
function eForm(obj,etext,num){
	if(tA[num] != undefined) {
		if(obj.value == tA[num])obj.value= "";
	} else {
		if(obj.value == etext)obj.value= "";
		tA[num] = etext
	}
}
function fForm(obj,etext,num){
	if(tA[num] != undefined) {
		if(obj.value == "")obj.value = tA[num];
	} else {
		if(obj.value == "")obj.value = etext;
	}
}	

function trapKeeDown(evt,btn){
	evt = (evt) ? evt : event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode == 13){
		if (ns5) {
			evt.cancelBubble = true;
			document.getElementById(btn).focus();
		} else {
			evt.returnValue=false;
			evt.cancel = true;
			document.getElementById(btn).click();
		}
	}
}
function linkSetup() {
	var a;
	for (var i = 0; (a = document.links[i]); i++) {
		if (a.target && a.target.indexOf("_download") == 0) a.onclick = _download;
	}
}

function _download() {
	var a = this.target.split(":");
	if (a[2] != null) window.location.href="components/download.aspx?file=" + a[1] + "&type=" + a[2];
	else window.location.href="components/download.aspx?file=" + a[1];
	return false;
}
function oResize(_height)
	{
		if(document.getElementById('slideshow')) {
			document.getElementById('slideshow').height = _height;
		}	
	}
	
	var numbers = "0123456789 ";
	function isNumber(el){
		if(numbers.indexOf(el.value.charAt(el.value.length-1)) == -1) el.value = el.value.substring(0,el.value.length-1)
	}

	var numofitems;
	function itemCheck(value){ numofitems = value;}
	function itemUpdate(value)
	{	
		if(value != numofitems) autoUpdateGrid();
	}
	function autoUpdateGrid()
	{
		oDiv = document.getElementById("updateCart");
		if(oDiv)
		{
			anchors = oDiv.getElementsByTagName("A");
			if(anchors[0].href && anchors[0].href.indexOf(":") != -1){
				trimString = anchors[0].href.split(":");
				eval(trimString[1]);
			}
		}
	}
	
function toggleVisibility(hide,oElement,hideElement,hideElement2){
	if(document.getElementById(oElement)){
		if(hide) document.getElementById(oElement).style.display = "none";
		else document.getElementById(oElement).style.display = "block";
	}
	if(document.getElementById(hideElement))
		document.getElementById(hideElement).style.display = "none";
	if(document.getElementById(hideElement2))
		document.getElementById(hideElement2).style.display = "none";
}
	
function setOption(object,index){
	if(object){
		object.options[index].selected = true;
	}
}

function initMenu(el) {
		if (iepc) {
			for (i=0; i<el.childNodes.length; i++) {
				if (el.childNodes[i] && el.childNodes[i]["tagName"] && el.childNodes[i].tagName.toLowerCase() == "li") {
					el.childNodes[i].onmouseover=function() { this.className+=" over";}
  					el.childNodes[i].onmouseout=function() {this.className=this.className.replace(" over", "");}
   			}
  			}
 		}
	}

var newWindow = null;
var preHtml = "<html><head><title>S&#246;khj&#228;lp</title><style type='text/css' media='screen'> @import url(css/nobelmuseet_screen.css); </style></head>";
function createNewWin(string){
	newWindow = window.open("","",'width=350, height=400')
	if(newWindow != null){
		newWindow.document.write(preHtml + "<body id='popup'>" + string + "</body></html>");
		newWindow.document.close();
	}
}

/* zinoEdit function */
function execArgument(arg, sysID){
	if (sysID > 0)
	{ 
		switch ( arg ) {
			case "text": window['zinoWin'] = open("zino/default.aspx?pageID=11&articleID="+sysID  , "zinoWin", "width=1014,height=708,left=0,top=0,status=0,resizeable=0,scrollbars=no"); break;
			case "area": window['zinoWin'] = open("zino/default.aspx?pageID=34&areaID="+sysID  , "zinoWin", "width=1014,height=708,left=0,top=0,status=0,resizeable=0,scrollbars=no"); break;
			case "banner": window['zinoWin'] = open("zino/default.aspx?pageID=72&bannerID="+sysID  , "zinoWin", "width=1014,height=708,left=0,top=0,status=0,resizeable=0,scrollbars=no"); break;
			//case "image": window['zinoWin'] = open("zino/default.aspx?pageID=36&imageID="+sysID  , "zinoWin", "width=1014,height=708,left=0,top=0,status=0,resizeable=0,scrollbars=no"); break;
			//case "addimage": window['zinoWin'] = open("zino/default.aspx?pageID=38&imageID="+sysID  , "zinoWin", "width=1014,height=708,left=0,top=0,status=0,resizeable=0,scrollbars=no"); break;
		}
		//document.getElementById("cMenu").style.display = "none";
		if (window['zinoWin']) window['zinoWin'].focus();
	}
}

