//---------------------------------------------------------------------------------// Magnus Hillerdal//---------------------------------------------------------------------------------// Cookie functions ---------------------------------------------
function getexpirydate(timmar){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+timmar*24*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}

function getcookie(cookiename) {
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="")
		return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1)
		index2=cookiestring.length; 
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function setcookie(name,value,duration){
	cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
	document.cookie=cookiestring;
	if(!getcookie(name)){
		return false;
	}
	else{
		return true;
	}
}

// Menu functions -----------------------------------------------
function loadMenu() {
	var menuarray = getcookie('WapMenu').split(',');
	if (menuarray.length != menyer.length || menyer.length == 1) {
		menuarray = new Array(menyer.length);
		for (var x=0; x<menyer.length; x++) 
			menuarray[x]=(x==0?1:0);
	}
	for (var i=0; i<menyer.length; i++) {
		if(menuarray[i]==1)
			changeStyle(menyer[i], 'display', 'block');
		else
			changeStyle(menyer[i], 'display', 'none');
	}
}

function saveMenu() {
	var menustring = ((document.getElementById(menyer[0]).style.display=='block')?'1':'0');
	for (var i=1; i<menyer.length; i++) {
		menustring += ","+((document.getElementById(menyer[i]).style.display=='block')?'1':'0');
	}
	ret = setcookie('WapMenu',menustring,6);
}

function changeStyle(Id, Property, Value) {
	if (document.all)
		eval('document.all[Id].style.'+Property+'="'+Value+'"');
	else if (document.layers)
		eval('document.layers[Id].style.'+Property+'="'+Value+'"');
	else if (document.getElementById)
		eval('document.getElementById(Id).style.'+Property+'="'+Value+'"');
}
function swap(meny) {
	if(document.getElementById){
		document.getElementById(meny).style.display=(document.getElementById(meny).style.display=='block')?'none':'block';
	}
}

// Highlight an object/tag
function highlight(obj,newcolor) {
	if(!document.getElementById) { return true; }
	obj.style.color="rgb("+newcolor+")";
}

// Highlight an table row
function highlightrow(obj,newcolor) {
	if(!document.getElementById) { return true; }
	obj.style.backgroundColor=newcolor;
}

// Popup med bild
var bildID=0;
function popupimage(image) {
	window.open('e_popupimage.php?'+image,'_new','width=200,height=200');
	bildID = (bildID+1)%4;
}

