function faijzing_HeadMenu(id) {
	var d = document.getElementById(id);
		for (var i = 1; i<=10; i++) {
			if (document.getElementById('hm'+i)) {document.getElementById('hm'+i).style.display='none';}
		}
	if (d) {d.style.display='block';}
	}

function faijzing_SubMenu(id) {
	var d = document.getElementById(id);
		for (var i = 1; i<=10; i++) {
			if (document.getElementById('sm'+i)) {document.getElementById('sm'+i).style.display='none';}
		}
	if (d) {d.style.display='block';}
	}

function toggleVisibility(me){
	if (me.style.visibility=='hidden'){
		me.style.visibility='visible';
		}
	else {
		me.style.visibility='hidden';
		}
	}

function showGulKnapp(ide) {
	var e = document.getElementById(ide);
		if(e.style.visibility == 'none')
			e.style.visibility = 'block';
		else
			e.style.visibility = 'block';
}

function showGraKnapp(ida) {
	var e = document.getElementById(ida);
		if(e.style.visibility == 'block')
			e.style.visibility = 'none';
		else
			e.style.visibility = 'none';
}

/* el=this;setTimeout('el.style.display=\'none\'',1000) */

function hideGulKnapp(id) {
	var e = document.getElementById(id);
		if(e.style.display == 'block')
			{e.style.display = 'none';}
		else
			{e.style.display = 'none';}
}

function oflip(me) {
         ele = document.getElementById(me);
         setTimeout("ele.style.display = 'none'", 5000);
}

function flip(mes) {
         ela = document.getElementById(mes);
         setTimeout("ela.style.display = 'block'", 1000);
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

/************* end http://www.dyn-web.com/ **************/

/* Detta script finns att hämta på http://www.jojoxx.net och
   får användas fritt så länge som dessa rader står kvar. */

function querystring(){
	if(!location.search){ return null; }
	var querystr=location.search.split("?")[1].replace(/\+/g," ");
	for(var n=0;n<querystr.split("&").length;n++){
		var name=unescape(querystr.split("&")[n].split("=")[0]);
		var value=unescape(querystr.split("&")[n].split("=")[1]);
		if(this[name]){
			if(typeof(this[name])=="object"){
				this[name][this[name].length]=value;
			}else{
				this[name]=new Array(this[name],value);
			}
		}else{
			this[name]=value;
		}
	}
}

var q=new querystring();

// eget hack som bygger på ovan http://www.dyn-web.com och http://www.jojoxx.ne
/*
var cur_lyr2;	// holds id of currently visible layer
function swapLayers2(id,part,bb) {
	if (q['part'] == "creatures" && cur_lyr2 == "bb10" && id == "bb10") {
		hideLayer(cur_lyr2);
		showLayer(id);
	}
	else if (q['part'] == "creatures" && cur_lyr2 == "bb10") {
		hideLayer(cur_lyr2);
		showLayer(id);
		iss[0].gostop(this);
	}
	else if (q['part'] == "creatures" && id == "bb10"  ) {
		hideLayer(cur_lyr2);
		showLayer(id);
		setTimeout( "iss[0].gostop(this)" , 2000);
	}
	else {
		hideLayer(cur_lyr2);
		showLayer(id);
	}
cur_lyr2 = id;
}
*/

var cur_lyr2;	// holds id of currently visible layer
function swapLayers2(id,part,bb1,bb2) {
	if (q['part'] == part && cur_lyr2 == bb1 && id == bb1) {
		hideLayer(cur_lyr2);
		showLayer(id);
	}
	else if (q['part'] == part && cur_lyr2 == bb2 && id == bb2) {
		hideLayer(cur_lyr2);
		showLayer(id);
	}
	else if (q['part'] == part && cur_lyr2 == bb1 && id == bb2) {
		hideLayer(cur_lyr2);
		showLayer(id);
		iss[0].gostop(this);
		setTimeout( "iss[1].gostop(this)" , 1500);
	}
	else if (q['part'] == part && cur_lyr2 == bb2 && id == bb1) {
		hideLayer(cur_lyr2);
		showLayer(id);
		iss[1].gostop(this);
		setTimeout( "iss[0].gostop(this)" , 1500);
	}
	else if (q['part'] == part && cur_lyr2 == bb1 && id !== bb2) {
		hideLayer(cur_lyr2);
		showLayer(id);
		iss[0].gostop(this);
	}
	else if (q['part'] == part && cur_lyr2 == bb2 && id !== bb1) {
		hideLayer(cur_lyr2);
		showLayer(id);
		iss[1].gostop(this);
	}
	else if (q['part'] == part && id == bb1) {
		hideLayer(cur_lyr2);
		showLayer(id);
		setTimeout( "iss[0].gostop(this)" , 1500);
	}
	else if (q['part'] == part && id == bb2) {
		hideLayer(cur_lyr2);
		showLayer(id);
		setTimeout( "iss[1].gostop(this)" , 1500);
	}
	else {
		hideLayer(cur_lyr2);
		showLayer(id);
	}
cur_lyr2 = id;
}

function externalFormLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("form");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("action"))
			anchor.target = "_blank";
	}
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
	var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
			anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}

function faijzing_popup(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function faijzing_rollover(bildplats,bildattvisa) {
	if(document.images) {
		document.images[bildplats].src=bild[bildattvisa].src 
	}
}

var timerID = null;
var timerOn = false;
var timecount = 1000;

function hideAll() {
	faijzing_SubMenu('');
	faijzing_HeadMenu('');
}

function startTime() {
	if (timerOn == false) {
	timerID=setTimeout( "hideAll()" , timecount);
	timerOn = true;
	}
}

function stopTime() {
	if (timerOn) {
	clearTimeout(timerID);
	timerID = null;
	timerOn = false;
	}
}

function faijzingResize(iW,iH) {
		window.resizeBy(iW-windowWidth(),iH-windowHeight());
}

function faijzingWindowWidth() {return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;}

function faijzingWindowHeight() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;}

function faijzingCheckWinSize() {
	var winh = faijzingWindowHeight();
	var winw = faijzingWindowWidth();

	if (winh < 596 && winw >= 752 ) {
		document.getElementById("global").style.marginTop = 0;
		document.getElementById("global").style.marginLeft = "-376px";
		document.getElementById("global").style.top = 0;
		document.getElementById("global").style.left = "50%";
	}
	else if (winh >= 596 && winw >= 752) {
		document.getElementById("global").style.marginTop = "-298px";
		document.getElementById("global").style.marginLeft = "-376px";
		document.getElementById("global").style.top = "50%";
		document.getElementById("global").style.left = "50%";
	}
	
	else if (winh >= 596 && winw < 752) {
		document.getElementById("global").style.marginTop = "-298px";
		document.getElementById("global").style.marginLeft = 0;
		document.getElementById("global").style.top = "50%";
		document.getElementById("global").style.left = 0;
	}
	
	else if (winh < 596 && winw < 752) {
		document.getElementById("global").style.marginTop = 0;
		document.getElementById("global").style.marginLeft = 0;
		document.getElementById("global").style.top = 0;
		document.getElementById("global").style.left = 0;
	}

}

function faijzingCheckWinSizeFront() {
	var winh = faijzingWindowHeight();
	var winw = faijzingWindowWidth();

	if (winh < 428 && winw >= 674 ) {
		document.getElementById("frontglobal").style.marginTop = "10px";
		document.getElementById("frontglobal").style.marginLeft = "-337px";
		document.getElementById("frontglobal").style.top = 0;
		document.getElementById("frontglobal").style.left = "50%";
	}
	else if (winh >= 428 && winw >= 674) {
		document.getElementById("frontglobal").style.marginTop = "-214px";
		document.getElementById("frontglobal").style.marginLeft = "-337px";
		document.getElementById("frontglobal").style.top = "50%";
		document.getElementById("frontglobal").style.left = "50%";
	}
	
	else if (winh >= 428 && winw < 674) {
		document.getElementById("frontglobal").style.marginTop = "-214px";
		document.getElementById("frontglobal").style.marginLeft = "10px";
		document.getElementById("frontglobal").style.top = "50%";
		document.getElementById("frontglobal").style.left = 0;
	}
	
	else if (winh < 428 && winw < 674) {
		document.getElementById("frontglobal").style.marginTop = "10px";
		document.getElementById("frontglobal").style.marginLeft = "10px";
		document.getElementById("frontglobal").style.top = 0;
		document.getElementById("frontglobal").style.left = 0;
	}

}

window.onresize = faijzingCheckWinSize;
