// Auto Tab

var field_length=0;

function TabVolgendVeld(obj,event,len,next_field)
{
	if (event == "ingedrukt")
	{
		field_length=obj.value.length;
	}
	else if (event == "omhoog")
	{
		if (obj.value.length != field_length)
		{
			field_length=obj.value.length;

			if (field_length == len)
			{
				next_field.focus();
			}
		}
	}
}

function set_focus(zet)
{
  zet.focus();
}

function set_focusselect(zet)
{
  zet.focus();
  zet.select();
}

function controleervenster(functie)
{
     var iX = window.document.body.offsetWidth + window.event.clientX ;
     var iY = window.event.clientY ;

     if (iX <= 30 && iY < 0 )
     {
		//0 = leerling
		//1 = docent

		if(functie == 0)
		{
			opener.document.location.href='index.php3?loguit=ja&fout=ja';
		}

		if(functie == 1)
		{
			opener.document.location.href='index.php3?loguit=ja&docent=ja&fout=ja';
		}
      }
}

function refreshDag(value)
{
		document.location.replace( '$PHP_SELF?action=cli&s=1&waarde='+value );
}

function refreshKlas(value, klas)
{
		document.location.replace( '$PHP_SELF?action=cli&s=1&waarde='+value+'&klas='+klas );
}

function checkField(value)
{
	if(value == 0)
	{
		alert("U heeft de verkeerde waarde geselecteerd");
	      document.location.replace( 'index.php?action=cli' );
	}
}

function wijzigItem(type)
{
	document.myform.action='index.php?action='+type+'&s=1';
	document.myform.submit();
}

function openPrint(locatie2)
{
	mijnpagina=window.open(locatie2, 'Print', 'Width=600,Height=600,top=0,left=0,Status=no,Resizable=no,Scrollbars=yes,Menubar=no,Toolbar=no,Location=no');
}

function setCount(target)
{
	if(target == 0)
	{
		if(document.myform.lokaal.value == "0")
		{
			alert("U heeft geen lokaal geselecteerd");
			document.location.replace( 'index.php?action=cli' );
		}
		else
		{
			document.myform.action='index.php?action=cli&s=3';
			document.myform.submit();
		}
	}
	if(target == 1)
	{
		if(document.myform.lokaal.value == "0")
		{
			alert("U heeft geen lokaal geselecteerd");
			document.location.replace( 'index.php?action=cli' );
		}
		else
		{
			document.myform.action='index.php?action=cli&s=1';
			document.myform.submit();
		}
	}
	if(target == 2)
	{
		 document.myform.action='index.php?action=rvlresult&s=1';
		 document.myform.submit();
	}
	if(target == 3)
	{
		document.myform2.action='index.php?action=rvlresult&s=2';
		document.myform2.submit();
	}
	if(target == 4)
	{
		 document.myform2.action='index.php?action=rvlresult&s=1';
		 document.myform2.submit();
	}
	if(target == 5)
	{
		 document.myform.action='index.php?action=ledresult&s=1';
		 document.myform.submit();
	}
	if(target == 6)
	{
		document.myform2.action='index.php?action=ledresult&s=2';
		document.myform2.submit();
	}
	if(target == 7)
	{
		 document.myform2.action='index.php?action=ledresult&s=1';
		 document.myform2.submit();
	}
	if(target == 8)	
	{
		var datum;
		datum = document.myform.datum.value;
		
		document.myform.action='index.php?action=mediatheek&s=0&datum='+datum;

		document.myform.submit();	
	}	
	if(target == 9)	
 	{ 	
 		var datum;
		datum = document.myform.datum.value;
		var tijd;
 		tijd = document.myform.tijdstip.value;
 		
 		document.myform.action='index.php?action=mediatheek&s=0&datum='+datum+'&tijdstip='+tijd;
 		
 		document.myform.submit(); 
 	}
}

function sendTo(location)
{
	document.location.replace( location );
}

function uitleg()
{
	uitleg=window.open('studentIncludes/uitleg.php', 'uitleg', 'Width=500,Height=520,top=0,left=0,Status=no,Resizable=no,Scrollbars=yes,Menubar=no,Toolbar=no,Location=no');
}
function addtext(actie)
{
	if(actie == 'link')
	{
		temp = document.invoer.website.value;
		temp = temp.substr(0,4)

		if(temp == 'http')
		{
			var bericht = document.invoer.website.value;
		}
		else
		{
		    var bericht = 'http://'+ document.invoer.website.value;
		}

		if(document.invoer.doel.checked)
		{
			doel = 'target=blank';
		}
		else
		{
		    doel = '';
		}
		
		var mask 	= document.invoer.mask.value;

		var newtext = '<a href=\"'+ bericht + '\" ' + doel + '>' + mask +'</a>';
	}
	if(actie == 'speciaal')
	{
	    opmaak = document.invoer2.opmaak.value;
		tekst  = document.invoer2.tekst.value;
	    if(opmaak == 1){var beginText = '<b>'; 		 var endText = '</b>';}
	    if(opmaak == 2){var beginText = '<i>'; 		 var endText = '</i>';}
	    if(opmaak == 3){var beginText = '<u>'; 		 var endText = '</u>';}
	    if(opmaak == 4){var beginText = '<b><i>';  	 var endText = '</i></b>';}
	    if(opmaak == 5){var beginText = '<b><u>'; 	 var endText = '</u></b>';}
	    if(opmaak == 6){var beginText = '<i><u>'; 	 var endText = '</u></i>';}
	    if(opmaak == 7){var beginText = '<b><u><i>'; var endText = '</i></u></b>';}

	    var newtext = ''+beginText+''+tekst+''+endText;
	}
	if(actie == 'plaatje')
	{
	    plaats = document.invoer3.plaats.value;
	    naam   = document.invoer3.naam.value;
	    
	    var newtext = '<img src=\"'+plaats+'/'+naam+'.jpg\">';
	}

	document.myform.bericht2.value += newtext;
}
function EnterPressed(e)
{
	var keycode = e;
	if (keycode == 13)
	{
	 	var newtext = '<br>';
		document.myform.bericht2.value += newtext;
	}
}

function schrikkel(j)
{
            return ((j % 400 == 0) || (j % 100 != 0 && j % 4 == 0));
}

function maandLengte()
{
   			var month = document.myform.maand.value;
   			var year  = document.myform.jaar.value;

			if(month == 2)
				return 28 + schrikkel(year);

			else if(month == 4 || month == 6 || month == 9 || month == 11)
				return 30;
			else
				return 31;
}

function maandLengte2()
{
   			var month = document.myform.maand2.value;
   			var year  = document.myform.jaar2.value;

			if(month == 2)
				return 28 + schrikkel(year);

			else if(month == 4 || month == 6 || month == 9 || month == 11)
				return 30;
			else
                    return 31;
}

function getLengte()
{
	var maand = document.myform.maand.value;
	var lengte = maandLengte();
	var jaar1   = document.myform.jaar.value;

 	location2 = 'index.php?action=rvlresult&s=3&lengte='+lengte +'&maand2='+maand+'&jaar1='+jaar1; 	

 	document.location.replace( location2 );
}

function getLengte2()
{
	var maand2  = document.myform.maand.value;
	var maand3  = document.myform.maand2.value;
	var lengte  = maandLengte();
	var lengte2 = maandLengte2();
	var jaar1   = document.myform.jaar.value;
	var jaar2	= document.myform.jaar2.value;
	var dag2    = document.myform.dag.value;
 	location2   = 'index.php?action=rvlresult&s=3&lengte='+lengte+'&maand2='+maand2+'&maand3='+maand3+'&lengte2='+lengte2+'&jaar1='+jaar1+'&jaar2='+jaar2+'&dag2='+dag2;

 	document.location.replace( location2 );
}

function check(id)
{
	var agree=confirm('Weet u het zeker dat u deze wilt verwijderen?');	

	if(agree)
	{
        location2 = '?action=laptop&taak=3&io='+id;
        document.location.replace( location2 );
	}
}

function checkMedia(id)
{
	var agree=confirm('Weet u het zeker dat u deze reservering ongedaan wilt maken?');

	if(agree)
	{
        location2 = '?action=mediatheek&s=5&io='+id;
        document.location.replace( location2 );
	}
}

function printpage()
{
	window.print();
}

function checkLaptop()
{
	var empty = false;

	if(document.myform.nr1.value.length < 8)		{empty = true;}
	if(document.myform.nr2.value.length < 3)		{empty = true;}

	if(document.myform.mem.value.length < 1)		{empty = true;}
	if(document.myform.memSize.value.length < 2)	{empty = true;}

	if(document.myform.hd.value.length < 1)			{empty = true;}
	if(document.myform.hdSize.value.length < 2)		{empty = true;}

	if(document.myform.mac1.value.length < 2)		{empty = true;}
	if(document.myform.mac2.value.length < 2)		{empty = true;}
	if(document.myform.mac3.value.length < 2)		{empty = true;}
	if(document.myform.mac4.value.length < 2)		{empty = true;}
 	if(document.myform.mac5.value.length < 2)		{empty = true;}
 	if(document.myform.mac6.value.length < 2)		{empty = true;}
 	
 	if(document.myform.wifi1.value.length < 2)		{empty = true;}
	if(document.myform.wifi2.value.length < 2)		{empty = true;}
	if(document.myform.wifi3.value.length < 2)		{empty = true;}
	if(document.myform.wifi4.value.length < 2)		{empty = true;}
 	if(document.myform.wifi5.value.length < 2)		{empty = true;}
 	if(document.myform.wifi6.value.length < 2)		{empty = true;}
 	
 	if(empty == true)
 	{
 	    alert('Niet alle waarden zijn ingevuld');
 	}
 	else
 	{
 		document.myform.submit();
 	}
}

function conformatie()
{
	var datum;  datum  = document.myform.datum.value;
 	var tijd;   tijd   = document.myform.tijdstip.value;
 	var aantal; aantal = document.myform.aantalComs.value;

	var agree=confirm(' Zijn de gegevens juist: \n Datum:        '+datum +'\n Tijd:             ' +tijd +'\n Computers: '+aantal);

	if(agree)
	{
	    document.myform.submit();
	}
}

function wachtwoordreset(soort,id)
{
	var agree=confirm('Weet u het zeker dat u het wachtwoord wilt resetten?');

	if(agree)
	{
        location2 = '?action=adres&wat=gebruiker&stap=resetww&soort='+soort+'&gebruikersnr='+id;
        document.location.replace( location2 );
	}
}

function verwijderfunctie(functie,id)
{
	var agree=confirm('Weet u het zeker dat u deze functie wilt verwijderen?');

	if(agree)
	{
        location2 = '?action=beheer&wat=gebruiker&stap=6&soort=medewerker&gebruikersnr='+id+'&hetfunctieid='+functie;
        document.location.replace( location2 );
	}
}

function checkVeldwaarde(value,id)
{
	if(value == 0)
	{
		alert("U heeft de verkeerde waarde geselecteerd");
		location2 ='?action=beheer&wat=gebruiker&stap=4&soort=medewerker&gebruikersnr='+id;
	      document.location.replace( location2 );
	}
}

function verwijdernieuws(id)
{
	var agree=confirm('Weet u het zeker dat u dit bericht wilt verwijderen?');

	if(agree)
	{
        location2 = '?action=weekjournaal&stap=7&berichtid='+id;
        document.location.replace( location2 );
	}
}

function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}