﻿
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
if( app == "Microsoft Internet Explorer" && ver == 4 && (agt.indexOf("msie 7.")!=-1)) ie6 = true;
// IE8
if( app == "Microsoft Internet Explorer" && ver == 4 && (agt.indexOf("msie 8.")!=-1)) ie6 = true;

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)? 1:0
iepc = (iefamily) && (pc)? 1:0
browser = (iefamily) || (ns5) || (is_operaup)? 1:0
//if (is_safari) document.writeln('<LINK REL="stylesheet" HREF="css/safarifix.css" TYPE="text/css">')
if(iefamily){
		if(!pc){
			document.writeln('<LINK REL="stylesheet" HREF="css/macfix.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;
}
	
function openPopupWindow(url,windowname) {
  properties = 'toolbar=no,scrollbars=yes,menubar=no,statusbar=no,width=450,height=450,resizable=1,left=100,top=100,screenX=100,screenY=100';
  adress = 'http://www.skf.com'+url;
  popupWindow = window.open(adress,windowname,properties);
} 
function _openPopupWindow(url,windowname) {
  properties = 'toolbar=no,scrollbars=yes,menubar=no,statusbar=no,width=450,height=450,resizable=1,left=100,top=100,screenX=100,screenY=100';
  popupWindow = window.open(url,windowname,properties);
} 
function openSitemap(url,windowname) {
  properties = 'toolbar=no,scrollbars=yes,menubar=no,statusbar=no,width=900height=850,resizable=1,left=100,top=100,screenX=100,screenY=100';
  popupWindow = window.open(url,windowname,properties);
} 
	
printPage = function(){
	if(iefamily){
		if(pc) window.print();
		else alert("klicka p� skrivarsymbolen i toppen av din browser");
	} else {
		window.print();
	}
}

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 _changelan(oVal){
	if(oVal != "0") document.location.href=""+oVal+"/zino.aspx";	
}
function getWindow(urlArg,caseArg){
	var _w, _h
	switch ( caseArg ) {
		case "subscribe": _w = 340; _h = 306; break;
		case "slideshow": _w = 340; _h = 300; break;
		case "fact": _w = 383; _h = 420; break;
		case "send": _w = 340; _h = 426; break;
		case "form": _w = 400; _h = 520; break;
		case "contact": _w = 360; _h = 280; break;
		case "freecopy": _w = 400; _h = 520; break;
		case "media_player": _w = 340; _h = 300; break;
		case "help": _w = 720; _h = 520; break;
		case "subscribe_ru": _w = 340; _h = 334; break;
		case "send_ru": _w = 340; _h = 460; break;
	}
	window.open(urlArg , caseArg, "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width="+_w+", height="+_h+"");
}

var structureResize = false;
var margin = (pc)? 85:10;
var hmargin = 55;
var mozz_margin = 60;
function _resize(inW,inH){
	_w = parseInt(inW + hmargin);
	_h = (ns5)? parseInt(inH + mozz_margin):parseInt(inH + margin);
	window.resizeTo(_w,_h)
	var structure = document.getElementById("structure");
	if(structureResize && structure){
		structure.style.width  = _w + "px";
		structure.style.height = _h + "px";
	}
}

_resizeOld = function(inW,inH){
		var tempW = (inW <= 1000)? inW+30:1046;
		var tempH = (inH <= 700)? inH+55:710;
		window.resizeTo(tempW,tempH)
		if(document.getElementById("structure")) {
			document.getElementById("structure").style.width = inW+28+"px";
		}
	}
// onclick="getWindow(this.href,'subscribe');return false;"

function linkSetup() {
	var a;
	for (var i = 0; (a = document.links[i]); i++) {
		if (a.href && a.href.indexOf("fig") != -1){
			a.onclick = inlineFix;
		}
		/* l�gger till MyPaper link */
		else if(a.href && a.href.indexOf("mypaper") != -1){
			a.className = 'myPaperLink';
			var parent = a.parentNode;
			if(parent.className == 'item'){
				parent.className += ' myPaperItem';
			}
			var pid = a.href.split('=')[1];
			a.onclick = function(){
				var mp = window.open('http://www.mypaper.se/read.asp?showType=show&pid='+pid,'mypaper'+Math.floor(Math.random()*100000),'width=1020,height=745,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');
				return false;
			};
		}
		/* slut p� MyPaper */
	}
}

function openMyPaper(pid){
	var mp = window.open('http://www.mypaper.se/read.asp?showType=show&pid='+pid,'mypaper'+Math.floor(Math.random()*100000),'width=1020,height=745,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no');
	return false;
}

function inlineFix(){
	if(document.location.href && document.location.href.indexOf("articleID") != -1)
	{
		imgNum = 0;
		splitStr = document.location.href.split("=");
		if(this.href && this.href.indexOf("@") != -1){
			atsplit = this.href.split("@");
			if(atsplit[1].length > 0) imgNum = parseFloat(atsplit[1])-1;
		}
		articleID = splitStr[1];
		tempUrl = "zino.aspx?pageID=27&articleID="+articleID+"&image="+imgNum;
		getWindow(tempUrl,'slideshow');
	}
	return false;
}


window.onload = function(){
	linkSetup();
	//setArticle();
}

function getHeight(obj){
	if (obj == "window") {
		if (window.innerHeight) return window.innerHeight;
		else return document.getElementById("body").offsetHeight;
	} else {
		obj = document.getElementById(obj)
		if (obj.offsetHeight) return obj.offsetHeight;
	}
}
function getTop(obj){return document.getElementById(obj).offsetTop;}

function setArticle(){
		document.getElementById("artwrapper").style.height = 10+"px";
		daWin = getHeight("window")
		daTop = getTop("artwrapper")
		newTop = parseInt(daWin - daTop)
		document.getElementById("artwrapper").style.height = parseInt(newTop-5)+"px";
	}
		

/* 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();
	}
}


	