



// Cookie-kontroll

	var today = new Date();
	var expires = new Date(today.getTime() + (6560 * 86400000));

	function checklogin() {
		if (loginform.uid.value!="" && loginform.password.value!="") {
			return true;
		} else {
			return false;
		}
	}

	function delcookie() {

		Set_Cookie('time_login','',expires);
	}

	function Set_Cookie(name,value,expires,path,domain,secure) {

	    document.cookie = name + "=" +escape(value) +
	        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
	        ( (path) ? ";path=" + path : "") + 
	        ( (domain) ? ";domain=" + domain : "") +
	        ( (secure) ? ";secure" : "");
	}



	function setcookie(cookieName,cookieValue,nDays) {
		var today = new Date();
		var expire = new Date();
		if (nDays==null || nDays==0) nDays=1;
		expire.setTime(today.getTime() + 3600000*24*nDays);
		document.cookie = cookieName+"="+escape(cookieValue)
			+ ";expires="+expire.toGMTString();
	}






// Maxlängd i TEXTAREA

function CheckMaxLength(Object, MaxLen) {
	if(Object.value.length > MaxLen)  {     
		Object.value = Object.value.substring(0, MaxLen);
	}
}


function ShowMaxLeft(Object, MaxLen, target, prefix, suffix) {
	document.getElementById(target).innerHTML = prefix+(MaxLen-Object.value.length)+suffix;
}



function ShowMaxLeft2(Object, MaxLen, target, prefix, suffix,prefix2, suffix2) {
	var cred = 1;
	
	if (MaxLen<=425) {
		// Ej pro
		if (Object.value.length>133) { cred = 2; }
		if (Object.value.length>286) { cred = 3; }
	
	} else {
		// Pro
		if (Object.value.length>153) { cred = 2; }
		if (Object.value.length>306) { cred = 3; }
	} 
	
	document.getElementById(target).innerHTML = prefix+(MaxLen-Object.value.length)+suffix+prefix2+cred+suffix2;
}



function togglediv(sel) {

	var tidsel = document.getElementById(sel);

	if (tidsel.style.display=="block") {
		tidsel.style.display = "none";
	} else {
		tidsel.style.display = "block";
	}
}


function showdiv(sel,typ) {

	var tidsel = document.getElementById(sel);

	if (typ==0) {
		tidsel.style.display = "none";
	
	} else {
		tidsel.style.display = "block";
	}
}

function showhidden(sel,typ) {

	var tidsel = document.getElementById(sel);

	if (typ==0) {
		tidsel.style.visibility = "hidden";
	
	} else {
		tidsel.style.visibility = "visible";
	}
}



function checkpaminn() {

	if (document.bokatid.sendmail.checked || document.bokatid.sendsms.checked) {
		document.getElementById('paminn').style.display='block';
	} else {
		document.getElementById('paminn').style.display='none';
	}

}



function showtab(num,typ) { 
	
	selectedLayer = 'tab'+num;
	selectedTab = 'select'+num;
	
	// Dölj alla lager som börjar på tab, utom det som är valt
	var div = document.getElementsByTagName('div');
	for(var i=0; i<div.length; i++){ 
		if((/^(tab)/i).test(div[i].id)){
			div[i].style.display = 'none';
		} 
	}

	// Sätt alla tabs till ovald
	var li = document.getElementsByTagName('li');
	for(var i=0; i<li.length; i++){ 
		if((/^(select)/i).test(li[i].id)){
			li[i].className = 'none';
		} 
	}
	
	document.getElementById(selectedLayer).style.display = 'block';
	//alert(document.getElementById(selectedLayer).id);
	
	document.getElementById(selectedTab).className = 'current';

	setcookie('flik_'+typ,num,2)
	document.getElementById('totabcontent').focus();
}




function helphide() {
		setcookie('hidehelp','1',10000);
		showdiv('helpbox',0);
}

function helpshow() {
		setcookie('hidehelp','0',10000);
		showdiv('helpbox',1);
}




function qstring() {
	var que = unescape(location.search)  ;
	return que;

}




function visaallabok(test) {
	var q = qstring();
	q = q.replace('&visabok=1','');
	q = q.replace('&visabok=-1','');
	if (test.checked) {
		location.href = q + '&visabok=1';
	} else {
		location.href = q + '&visabok=-1';
	}
	//alert(test.checked);
		
}



function hideSelects(action) {
  //documentation for this script at http://www.shawnolson.net/a/1198/
  //possible values for action are 'hidden' and 'visible'
  if (action!='visible'){action='hidden';}
    if (navigator.appName.indexOf("MSIE")) {
      for (var S = 0; S < document.forms.length; S++){
      for (var R = 0; R < document.forms[S].length; R++) {
      		if (document.forms[S].elements[R].options) {
      		 document.forms[S].elements[R].style.visibility = action;
      	 }
      }
    }
  }
}






