function expandform(visibility,id_count){
	if(visibility == "hidden"){
		document.getElementById(id_count).style.visibility = "hidden";
	}else{
		document.getElementById(id_count).style.visibility = "visible";
	}
}
function selectAll(){
	for(i=0;i<document.newuser.courses.length;i++){
		document.newuser.courses[i].checked = true;
	}
}
function unselectAll(){
	for(i=0;i<document.newuser.courses.length;i++){
		document.newuser.courses[i].checked = false;
	}
}
function print_date() {
        today = new Date();
        timme = today.getHours();
        if (timme<10) { timme = "0" + timme };
        minut = today.getMinutes();
        if (minut<10) { minut = "0" + minut };
        manad = today.getMonth();
        if (manad == 0) { manadt = "januari" };
        if (manad == 1) { manadt = "februari" };
        if (manad == 2) { manadt = "mars" };
        if (manad == 3) { manadt = "april" };
        if (manad == 4) { manadt = "maj" };
        if (manad == 5) { manadt = "juni" };
        if (manad == 6) { manadt = "juli" };
        if (manad == 7) { manadt = "augusti" };
        if (manad == 8) { manadt = "september" };
        if (manad == 9) { manadt = "oktober" };
        if (manad == 10) { manadt = "november" };
        if (manad == 11) { manadt = "december" };
        vdag = today.getDay();
        if (vdag == 0) { vdagt = "S&ouml;ndag" };
        if (vdag == 1) { vdagt = "M&aring;ndag" };
        if (vdag == 2) { vdagt = "Tisdag" };
        if (vdag == 3) { vdagt = "Onsdag" };
        if (vdag == 4) { vdagt = "Torsdag" };
        if (vdag == 5) { vdagt = "Fredag" };
        if (vdag == 6) { vdagt = "L&ouml;rdag" };
		vyear = today.getYear();
		if (vyear < 1000) { vyear+=1900 }
        dag = today.getDate();
        datum = "" + vdagt + "en den " + dag + ":e " + manadt + " " + vyear + "";
        return(datum);
}
function checktestlevel() {
	 if(isNaN(document.testlevelform.testlevel.value)) {
		 alert("Endast nummer mellan 0-100 kan anges som procentv"+unescape("%E4")+"rde");
		 document.testlevelform.testlevel.focus();
	return false;
 	}
}
function checknewgroup() {
	if((document.newgroup.group_name.value.length < 3) || (document.newuser.user_id.value.length > 45)){
		alert("Du m"+unescape("%E5")+"ste v"+unescape("%E4")+"lja ett gruppnamn med mellan 3-20 tecken!");
		document.newgroup.group_name.focus();
		return false;
	}
}
function checkactivecode1() {
	if (document.selfregform.activatecode.value.search(/^[^0-9]{1}[0-9A-Za-z_ ]+$/) == -1) {
		alert("En giltig aktiveringskod ska bara inneh"+unescape("%E5")+"lla a-z, A-Z, 0-9 och \n aktiveringskoden f"+unescape("%E5")+"r inte b"+unescape("%F6")+"rja med en siffra.");
		document.selfregform.activatecode.focus();
	return false;
	} else if((document.selfregform.activationcode.value.length < 6) || (document.newuser.user_id.value.length > 10)){
		alert("Du m"+unescape("%E5")+"ste v"+unescape("%E4")+"lja en aktiveringskod med mellan 6-10 alfanumeriska tecken!");
		document.selfregform.activatecode.focus();
		return false;
	}
}
function checkactivecode2() {
	if (document.newgroup.activationcode.value.search(/^[^0-9]{1}[0-9A-Za-z_ ]+$/) == -1) {
		alert("En giltig aktiveringskod ska bara inneh"+unescape("%E5")+"lla a-z, A-Z, 0-9 och \n aktiveringskoden f"+unescape("%E5")+"r inte b"+unescape("%F6")+"rja med en siffra.");
		document.newgroup.activationcode.focus();
	return false;
	} else if((document.newgroup.activationcode.value.length < 6) || (document.newuser.user_id.value.length > 10)){
		alert("Du m"+unescape("%E5")+"ste v"+unescape("%E4")+"lja en aktiveringskod med mellan 6-10 alfanumeriska tecken!");
		document.newgroup.activationcode.focus();
		return false;
	}
}
function checknewuser() {
	if (document.newuser.user_id.value.search(/^[^0-9]{1}[0-9A-Za-z_ ]+$/) == -1) {
		alert("Ett giltigt anv"+unescape("%E4")+"ndarnamn ska bara inneh"+unescape("%E5")+"lla a-z, A-Z, 0-9 och \n Anv"+unescape("%E4")+"ndarnamnet f"+unescape("%E5")+"r inte b"+unescape("%F6")+"rja med en siffra.");
		document.newuser.user_id.focus();
	return false;
	} else if((document.newuser.user_id.value.length < 3) || (document.newuser.user_id.value.length > 20)){
		alert("Du m"+unescape("%E5")+"ste v"+unescape("%E4")+"lja ett anv"+unescape("%E4")+"ndarnamn med mellan 3-20 alfanumeriska tecken!");
		document.newuser.user_id.focus();
		return false;
	} else if(document.newuser.password1.value.length < 6) {
		alert("Du m%c3%a5ste v"+unescape("%E4")+"lja ett l"+unescape("%F6")+"senord med minst 6 tecken!");
		document.newuser.password1.focus();
		return false;
	} else if(document.newuser.password1.value != document.newuser.password2.value) {
		alert("L"+unescape("%F6")+"senorden matchar inte!");
		document.newuser.password1.focus();
		return false;
	}
}
function checknewuser1() {
	if ((document.newuserform.username.value.length < 3) || (document.newuser.username.value.length > 20)){
		alert("Du m"+unescape("%E5")+"ste v"+unescape("%E4")+"lja ett anv"+unescape("%E4")+"ndarnamn med mellan 3-20 alfanumeriska tecken!");
		document.newuserform.username.focus();
		return false;
	} 
}
function checkpassword() {
	if((document.changepassword.newpassword.value.length < 6) || (document.changepassword.newpassword.value.length > 20)){
		alert("Du m"+unescape("%E5")+"ste v"+unescape("%E4")+"lja ett l"+unescape("%F6")+"senord med mellan 6-20 alfanumeriska tecken!");
		document.changepassword.newpassword.focus();
		return false;
	} else if(document.changepassword.newpassword.value != document.changepassword.newpassword2.value) {
		alert("L"+unescape("%F6")+"senorden matchar inte!");
		document.changepassword.newpassword.focus();
		return false;
	}
}
function checknewuser2() {
	 if((document.newuser.username.value.length < 3) || (document.newuser.username.value.length > 50)){
		alert("Du m"+unescape("%E5")+"ste v"+unescape("%E4")+"lja ett anv"+unescape("%E4")+"ndarnamn med mellan 3-50 alfanumeriska tecken!");
		document.newuser.username.focus();
		return false;
	} else if(document.newuser.password1.value.length < 5) {
		alert("Du m\345ste v\344lja ett l\366senord med minst 6 tecken!");
		document.newuser.password1.focus();
		return false;
	} else if(document.newuser.password1.value != document.newuser.password2.value) {
		alert("L"+unescape("%F6")+"senorden matchar inte!");
		document.newuser.password1.focus();
		return false;
	} else if ((document.newuser.uservalid.value.indexOf("-") != -1) || (document.newuser.uservalid.value.indexOf("/") != -1)) {
			alert("Giltighetsdatumet \344r fel format det ska vara \345\345\345\345mmdd och inte inneh\345lla - eller / t.ex. 20080909");
			document.newuser.uservalid.focus();
			return false;
	}
	
}
function checkFind() {
	if(document.findform.searchargs.value.length < 3){
		alert("Du m"+unescape("%E5")+"ste v"+unescape("%E4")+"lja ett s"+unescape("%F6")+"kargument som "+unescape("%E4")+"r minst 3 tecken!");
		return false;
	}else{
		document.getElementById('findform').submit();
	}
}
function SQL(insert){
	document.sqlform.sqlmaster.value = insert
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function confirmDelete(url, q){
	if(confirm("Vill du verkligen ta bort: "+q)){
		window.location.href = url
	}
}
function confirmDuplicate(url, q){
	if(confirm("Dupplicera: "+q+"?")){
		window.location.href = url
	}
}
function submitfind()
	{
		checkFind();
	}
function submitQfind()
	{
		document.findform.submit();
	}
if (navigator.userAgent.indexOf('Mac') != -1 && navigator.userAgent.indexOf('MSIE') == -1){
	document.write('<link href="css/design.css" rel="stylesheet" type="text/css" />')
}else{
	document.write('<link href="css/design.css" rel="stylesheet" type="text/css" />')
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
	if (theValue == true || theValue == false)
	  eval("obj."+theProp+"="+theValue);
	else eval("obj."+theProp+"='"+theValue+"'");
  }
}
function adslText(visibility,id_count){
	if(visibility == "hidden"){
		document.getElementById(id_count).style.visibility = "hidden";
	}else{
		document.getElementById(id_count).style.visibility = "visible";
	}
}
function infoText(visibility,id_count){
	if(visibility == "hidden"){
		document.getElementById(id_count).style.visibility = "hidden";
	}else{
		document.getElementById(id_count).style.visibility = "visible";
	}
}
function center(URL,width,height){ 
	if (parseInt(navigator.appVersion) >= 3){ 
		if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)<5){ 
			var tools = new Packages.java.awt.Toolkit.getDefaultToolkit(); 
			screen=tools.getScreenSize(); 
		} 
		x = screen.width; y = screen.height; 
	} 
	window.open(URL,"sidan","top=" + parseInt(y/2-height/2-16) + ",left=" + parseInt(x/2-width/2-5) + ",width=" + width + ",height=" + height); 
}
function print_date2() {
        today = new Date();
        timme = today.getHours();
        if (timme<10) { timme = "0" + timme };
        minut = today.getMinutes();
        if (minut<10) { minut = "0" + minut };
        manad = today.getMonth();
        if (manad == 0) { manadt = "January" };
        if (manad == 1) { manadt = "February" };
        if (manad == 2) { manadt = "March" };
        if (manad == 3) { manadt = "April" };
        if (manad == 4) { manadt = "May" };
        if (manad == 5) { manadt = "June" };
        if (manad == 6) { manadt = "July" };
        if (manad == 7) { manadt = "August" };
        if (manad == 8) { manadt = "September" };
        if (manad == 9) { manadt = "October" };
        if (manad == 10) { manadt = "November" };
        if (manad == 11) { manadt = "December" };
        vdag = today.getDay();
        if (vdag == 0) { vdagt = "Sunday" };
        if (vdag == 1) { vdagt = "Monday" };
        if (vdag == 2) { vdagt = "Tuesday" };
        if (vdag == 3) { vdagt = "Wednesday" };
        if (vdag == 4) { vdagt = "Thursday" };
        if (vdag == 5) { vdagt = "Friday" };
        if (vdag == 6) { vdagt = "Saturday" };
		vyear = today.getYear() 
		if (vyear < 1000) { vyear+=1900 }
        dag = today.getDate();
        datum = "" + vdagt + ", " + manadt + " " + dag + ", " + vyear + "";
        return(datum);
}
function confirmhide() {
		a=0
		for(i=0;i<document.hidestat.testid.length;i++){
			if (document.hidestat.testid[i].checked==true)
				a=a+1
			}
			if (a==0)
				alert ("Inga resultat att radera!");		
			else
			var answer = confirm ("Vill du radera "+a+" testresultat?")
			if (answer)
				document.hidestat.submit();
			else
				return false;
}
function confirmChide() {
		a=0
		for(i=0;i<document.hideCstat.testid.length;i++){
			if (document.hideCstat.testid[i].checked==true)
				a=a+1
			}
			if (a==0)
				alert ("Inga resultat att radera!");		
			else
			var answer = confirm ("Vill du radera "+a+" testresultat?")
			if (answer)
				document.hideCstat.submit();
			else
				return false;
}
function rememberMe() {
	if(document.getElementById('inputCheck0').value == "false") //if a value is not true, use this rather than == false, 'cos the first time no value will be set and it will be undefined, not true or false
		{
		document.getElementById('imgCheck0').src = "http://www.klickportalen.se/gfx/checkbox_true.png"; //change the image
		document.getElementById('inputCheck0').value = "true"; //change the field value
		}
	else
		{
		document.getElementById('imgCheck0').src = "http://www.klickportalen.se/gfx/checkbox_false.png";
		document.getElementById('inputCheck0').value = "false";
		}
}
