<!--
//check browser
var w3c = false;
var ie = false;
var ns = false;
var sa = false;
if (document.getElementById) {
	var w3c = true;
}
if (document.all) {
	var ie = true;
}
if (document.layers) {
	var ns = true;
}
if ((navigator.userAgent).indexOf("Safari")!=-1) {
	var sa = true;
}
if (w3c==false && ie==false && ns==false) {
	alert('too old (or bad) browser. get a newer one at \n\n - www.mozilla.org \n - www.microsoft.com \n - www.netscape.com');
	location.href='http://www.mozilla.org';
}

//show a hidden layer
function showLayer(strName,evt,offSetX,offSetY,move){
	if (ie) {
		eval(strName).style.visibility = "visible";
		if (move == true) {
			eval(strName).style.left = evt.x + offSetX;
			eval(strName).style.top = evt.y + document.body.scrollTop + offSetY;
		} else {
			eval(strName).style.left = offSetX;
			eval(strName).style.top = document.body.scrollTop + offSetY;
		}
	} else if (sa) {
		eval(strName).style.visibility = "visible";
		eval(strName).style.left = 200;
		eval(strName).style.top = document.body.scrollTop + 50;
	} else if (w3c) {
		document.getElementById(strName).style.visibility = "visible";
		if (move == true) {
			document.getElementById(strName).style.left = evt.pageX + offSetX;
			document.getElementById(strName).style.top = evt.pageY + offSetY; //tog bort + document.body.scrollTop
		} else {
			document.getElementById(strName).style.left = offSetX;
			document.getElementById(strName).style.top = document.body.scrollTop + offSetY;
		}
 	} else if (ns) {
		document.layers[strName].visibility = "show";
	}
}

//hide a shown layer
function hideLayer(strName){
	if (w3c) {
		document.getElementById(strName).style.visibility = "hidden";
		document.getElementById(strName).style.left = 0;
		document.getElementById(strName).style.top = 0;
	} else if (ie) {
		eval(strName).style.visibility = "hidden";
		eval(strName).style.left = 0;
		eval(strName).style.top = 0;
 	} else if (ns) {
		document.layers[strName].visibility = "hide";
	}
}

//open a layer with an image in it
function selectImage(layerName,img){
	showLayer(layerName);
	innerHtmlCode = "<a href=javascript:hideLayer('" + layerName + "');><img src=" + img + " border='0'></a>";
	
	if (w3c){
		document.getElementById(layerName).innerHTML=innerHtmlCode;
	}
	else if (ie){
		window.layerName.innerHTML=innerHtmlCode;
	}
	else if (ns){
		document.layers[layerName].document.open()
		document.layers[layerName].document.write(innerHtmlCode)
		document.layers[layerName].document.close()
	}
}

//make it impossible to write anything but numbers in a form-element
function onlyNumbers(character, warning){
	var myAsciiCode = (navigator.appName.toLowerCase().indexOf("netscape") == 0)? character.which : character.keyCode;
	
	if(myAsciiCode > 47 && myAsciiCode < 58 || myAsciiCode == 8){
		if (ns){
		return true;
	}
	}else{
		alert (warning);
		return false;
	}
}

//show a text onMouseOver that tags along with the mouse

var layer = null;
var isOver = false;
 
var xPos;
var yPos;
 
function initBubbles() {
	if (ns||w3c && ie!=true) {
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = setValue;
	}
}

function setValue(evt) {
	if (ns==true && w3c==false) {
		xPos = evt.pageX;
		yPos = evt.pageY;
		//alert("X:" + xPos + "   " + "Y:" + yPos);
			if(isOver) { 
				document.layers["nummerDIV" + layer].visibility = "show";
				document.layers["nummerDIV" + layer].top = yPos -20;
				document.layers["nummerDIV" + layer].left = xPos +15;
			} else if(!isOver) {
				if(layer != null) {
					document.layers["nummerDIV" + layer].visibility = "hide";
				}
			}
	}
	else if (w3c==true && ie!=true) {
		xPos = evt.pageX;
		yPos = evt.pageY;
		//alert("X:" + xPos + "   " + "Y:" + yPos);
		if(isOver) { 
			showLayer("nummerDIV" + layer);
			document.getElementById("nummerDIV" + layer).style.top = yPos -20;
			document.getElementById("nummerDIV" + layer).style.left = xPos +15;
		} else if(!isOver) {
			if(layer != null) {
				hideLayer("nummerDIV" + layer);
			}
		}
	}
}

function dialog(what, number) {
	if(what == "show") {
		isOver = true;
		layer = number;
	} else if(what == "hide") {
		isOver = false;
		layer = number;
	}

	if(isOver) {
		if(ns||w3c && ie!=true) {
			layer = number;
		}
		if(ie) {
			var xPos = event.x;
			var yPos = event.y;
		    showLayer("nummerDIV" + layer);
		    eval("nummerDIV" + layer).style.pixelTop = yPos -20 + document.body.scrollTop;
		    eval("nummerDIV" + layer).style.pixelLeft = xPos +15;
		}
	} else if(!isOver) {
		hideLayer("nummerDIV" + layer);
	}
}


//change a links href and linktext
function changeLink(linkid) { //function changeLink(href,linktext,linkid) 
	if (w3c) {
		//document.getElementById(linkid).href=href;
		if (document.getElementById(linkid).innerHTML == "+&nbsp;") {
			document.getElementById(linkid).innerHTML = "-&nbsp;&nbsp;"
		} else {
			document.getElementById(linkid).innerHTML = "+&nbsp;"
		}
	}
	else if (ie) {
		//document.all[linkid].href=href;
		if (document.all[linkid].innerText=linktext == "+&nbsp;") {
			document.all[linkid].innerText=linktext = "-&nbsp;&nbsp;"
		} else {
			document.all[linkid].innerText=linktext = "+&nbsp;"
		}
		document.all[linkid].innerText=linktext;
	}
}

//change the bgColor of anything
function changeBgColor(HexColor,linkid) {
	if (w3c) {
	document.getElementById(linkid).style.background=HexColor;
	}
	if (ie) {
	document.getElementById(linkid).style.cursor="hand";
	}
}

//link anything
function linkIt(url,frameName) {
	if (frameName=="") {
		location.href = url;
	} else if (frameName=="new") {
		window.open(url)
	} else {
		temp = frameName + ".location.href = '" + url + "'";
		eval (temp);
	}
}

//open a new browser window
function openWin(theUrl,theName, theSettings) {
	window.open(theUrl,theName,theSettings); void(0);
}

//open a new sb_browser window
function openSbWin(theUrl,theName, theSettings) {
	theSettings = theSettings + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";
	window.open(theUrl,theName,theSettings); void(0);
}

//lock a form-element so that it can't be edited
function lockField(falt,formName){
	var temp = "document." + formName + "." + falt + ".blur()";
	eval (temp);
}

//invert checkbox-selection
function InvertAll(formName) {
	for (var i=0;i<document.forms[formName].elements.length;i++) {
		var e=document.forms[formName].elements[i];
		e.checked=!e.checked;
	}
}

//self-submitting select
function selectBrowse(frameName,formName,selectName) {
	var temp = "document." + formName + "." + selectName + ".options[document." + formName + "." + selectName + ".options.selectedIndex].value";
	if (eval (temp) != "do_nothing") {
		if (frameName=="") {
			location.href = eval (temp);
		} else if (frameName=="new") {
			window.open(eval (temp))
		} else {
			temp = frameName + ".location.href = " + temp;
			eval (temp);
		}
	}
}

//a running clock
var flasher = false
function updateTime() {
	var now = new Date()
	var theHour = now.getHours()
	var theMin = now.getMinutes()
	var theSec = now.getSeconds()
	var theTime = "" + ((theHour < 10) ? "0" : "") + theHour
		theTime += ((flasher) ? " " : ":")
	theTime += ((theMin < 10) ? "0" : "") + theMin
		theTime += ((flasher) ? " " : ":")
	theTime += ((theSec < 10) ? "0" : "") + theSec
	flasher = !flasher

	var theTime;

	if (w3c) {
		document.getElementById("showTime").innerHTML=theTime
		}
	else if (ns) {
		document.showTime.document.open()
		document.showTime.document.write("<pre>" + theTime + "</pre>")
		document.showTime.document.close()
		}
	else {
		window.showTime.innerText=theTime;
		}
	timerID = setTimeout("updateTime()",1000)
}

//swap image
function swapImage(imgName,imgSrc) {
	document.images[imgName].src=imgSrc;
}

//a layer that stays on the same y position in the window

function stayXY(layerName,yPos,xPos) {
	if (w3c) {
		document.getElementById(layerName).style.top = yPos + document.body.scrollTop;
		document.getElementById(layerName).style.left = xPos;
	}
	else if (ns) {
		document.layers[layerName].top = yPos;
		document.layers[layerName].left = xPos;
	}
}

//a function to select a random number from 0 to what is passed in
function randomNumber(no) {
	var number;
	number = (Math.floor(Math.random() * no));
	return number;
}

//submit a form bu pressing enter in ns as it works in w3c and ie
function submitEnter(character,formName) {
	if (ns && character.which == 13) {
		document.forms[formName].submit();
	}
}

//a function to clear an imput-field when focused, unless it's value differs from what is set as "value"
function clearField(theInput) {
	if (theInput.defaultValue==theInput.value) {
		theInput.value = "";
	}
}

//functions for the forum
function changeDisplay( elementId, setTo ) {
    if( w3c ) {
        var theElement = document.getElementById( elementId );
    } else if( ie ) {
           var theElement = document.all[ elementId ];
       } else if (ns) {
           var theElement = new Object();
       }
    if( theElement.style ) {
		theElement = theElement.style;
	}
    theElement.display = setTo;
}
function changeItem(iNum) {
	sItem = "id" + iNum;
	if (document.getElementById(sItem).style.display == 'block'){
		hideItem(sItem);
	} else {
		showItem(sItem);
	}
}
function hideItem(sItem) {
	changeDisplay( sItem, 'none' );
}

function showItem(sItem) {
	changeDisplay( sItem, 'block' );
}

function evaluateForm(f) {
	if (f == 'document.newTopic') {
		if (eval(f).topic.value == "" || eval(f).name.value == "") {
			alert(emptyFieldsTopic);
			return false;
		}
	} else if (f == 'document.contactModerator') {
		if (eval(f).subject.value == "" || eval(f).message.value == "") {
			alert(emptyFieldsContactModerator);
			return false;
		}
	}
}

function checkTop(f) {
	if (top == self) {
		thisPage = location.href;
		page = thisPage.lastIndexOf("/")+1;
		goToThisPage = thisPage.substring(page,thisPage.length);
		top.location = f + "?f=" + goToThisPage;
	}
}

function validateEmail(formIn) {
	f = eval(formIn);
	var at="@";
	var dot=".";
	var lat=f.value.indexOf(at);
	var lstr=f.value.length;
	var ldot=f.value.indexOf(dot);
	var correct = 1;
	if (f.value.indexOf(at)==-1) {
		correct = 0;
	}
	if (f.value.indexOf(at)==-1 || f.value.indexOf(at)==0 || f.value.indexOf(at)==lstr){
		correct = 0;
	}
	if (f.value.indexOf(dot)==-1 || f.value.indexOf(dot)==0 || f.value.indexOf(dot)==lstr){
		correct = 0;
	}
	if (f.value.indexOf(at,(lat+1))!=-1){
		correct = 0;
	}
	if (f.value.substring(lat-1,lat)==dot || f.value.substring(lat+1,lat+2)==dot){
		correct = 0;
	}
	if (f.value.indexOf(dot,(lat+2))==-1){
		correct = 0;
	}
	if (f.value.indexOf(" ")!=-1){
		correct = 0;
	}
	if (!correct) {
		alert(emailFormatError);
		return false;
	}
}
//-->
