
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;
}

var lib = {
	object : null,
	isMoving : false,
	
	id : function(el) {
		return document.getElementById(el);
	},
	
	init : function(el) {
		if (this.object == null) {
			this.object = el;
		}
	},
	
	setHeight : function(object,h) {
		object.style.height = h+"px";
	},
	
	getHeight : function(object) {
		return parseInt(object.style.height);
	},
	
	getContentHeight : function(object) {
		return parseInt(object.offsetHeight);
	},
	
	animHeight : function(object,h) {
		distance = parseInt(h-lib.getHeight(object))
		acc = parseInt(distance/3)
		if (Math.abs(distance) > 0 && acc != 0) {
			lib.setHeight(object,lib.getHeight(object)+acc)
			lib.isMoving = true;
		} else {
			lib.setHeight(object,h)
			lib.isMoving = false;
		}
		arg = object
		if(lib.isMoving) doIT = setTimeout("lib.animHeight(arg,"+h+")",10);
		else clearTimeout(doIT);
	}

};
var toggle = true;

function _toggle(oDiv,h){
		if(toggle){
			if(!lib.isMoving) lib.animHeight(lib.id(oDiv),h)
			toggle = false;
		} else {
			if(!lib.isMoving) lib.animHeight(lib.id(oDiv),0)
			toggle = true;
		}
	}

var toggle2 = true;

function __toggle(oDiv,h){
		if(toggle2){
			if(!lib.isMoving) lib.animHeight(lib.id(oDiv),h)
			toggle2 = false;
		} else {
			if(!lib.isMoving) lib.animHeight(lib.id(oDiv),0)
			toggle2 = true;
		}
	}

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){
	if(document.getElementById(oElement)){
		if(hide) document.getElementById(oElement).style.display = "none";
		else document.getElementById(oElement).style.display = "block";
	}
}
	

window.onload = function(){
	if(document.getElementById("search-help"))
		lib.setHeight(lib.id('search-help'),0);
	if(document.getElementById("helpwrapper"))
		lib.setHeight(lib.id('helpwrapper'),0);
	if(document.getElementById("helpwrapper2"))
		lib.setHeight(lib.id('helpwrapper2'),0);
}

/* 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();
	}
}

	