window.onresize = setContentSize;
var openMail = "";
var openDiv = "";
var OnlineChek;
var link;
var BullBord;
var widthbull;
var width;
var menu;
var onlineList;

function confirmation(url,bericht) {
	var answer = confirm(bericht)
	if (answer){
		window.location = url;
	}
}
function confirmationJava(ex,bericht) {
	var answer = confirm(bericht)
	if (answer){
		ex;
	}
}


function start() {
	
	
	klok();
	setAlpha();
	setContentSize();
chekSize();
				
}
function setAlpha(){
var alpha = 0.4;
				var tooltipShade = document.getElementById('tooltipShade');
				alpha = Math.round(alpha * 10) / 10;
				tooltipShade.style.opacity = alpha;
				tooltipShade.style.htmlOpacity = alpha;
				tooltipShade.style.filter ='alpha( opacity=' + Math.round( alpha * 100 ) + ' )';
				tooltipShade.style.mozOpacity = alpha;
				
				}
var heightCalendar = 39;
var oldWidthBul = 200;
  function setContentSize(){
		chekSize();
	document.getElementById('contextScroll').style.height = (winH-285)+"px";
	
	//hiding the bul bord
	BullBord = document.getElementById('BulletinBoard');
	widthbull = BullBord.offsetWidth;
	if (BullBord.style.display == "none"){widthbull = oldWidthBul}
	width = widthbull+winW;
	if (width < 900){
			if (BullBord.style.display == "block"){oldWidthBul = widthbull;}
			BullBord.style.display = "none";
		}else{
			BullBord.style.display = "block";
		}
		
		//hiding the online list
		menu = document.getElementById('menu');
			onlineList = document.getElementById('onlineList');
			if ((winH) < (130+menu.offsetHeight)){
			onlineList.style.display = "none";
		}else{
			onlineList.style.display = "block";
		}
}


var BulletinBoardOpen = false;
function moreBullNews(){
	var BulletinBoardExt = document.getElementById('BulletinBoardExt');
	if(BulletinBoardExt.style.display == "none"){
			BulletinBoardExt.style.display = "block";
						setTimeout("moreBullNews()", 5000);
	}
	else{
			BulletinBoardExt.style.display = "none";
	}
}


function openCalenderPopup(x){
	if ((!x )||(heightCalendar < 41)){
heightCalendar = heightCalendar+10;
document.getElementById('calenderButton').style.height = heightCalendar+"px";
if (heightCalendar < 170){
setTimeout("openCalenderPopup()", 5);
document.getElementById('calenderButton').style.backgroundImage="url('img/menu_hoek_r_down.gif')";
}
}
}

function admin(){
			var caldar = document.getElementById('calenderButton');
			caldar.innerHTML = "admin";
			var adMenu = true;
}

function closeCalenderPopup(x){

if ((!x )|| (heightCalendar > 170)){
heightCalendar = heightCalendar-10;
var caldar = document.getElementById('calenderButton');
caldar.style.height = heightCalendar+"px";
if (heightCalendar > 41){
setTimeout("closeCalenderPopup()", 5);
}
else{
caldar.style.backgroundImage="url('img/menu_hoek_r.gif')";
}
}
}
var slesh = 0;
function klok() {
	slesh++; 

var symbol = new Array();
symbol[0]="<a href='#'>&curren;</a>";
symbol[1]="";
symbol[2]="";
symbol[3]="";
symbol[4]="";
symbol[5]="";
symbol[6]="";
symbol[7]="";
symbol[8]="";
symbol[9]="";
	if (slesh == symbol.length){slesh = 0;}
document.getElementById('javaActiv').innerHTML = symbol[slesh];
var date = new Date();
var year = date.getYear();
var month = date.getMonth();
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September","October", "November", "December");
var monthname = months[month];
if (year < 1000) {
year = 1900+ year;
}
if (minute < 10) {
minute = "0" + minute;
}
if (second < 10) {
second = "0" + second;
}
document.title = "Website LEDA -" + monthname + "  " + day + " " + year + " - " + hour + ":" + minute;
document.getElementById('dateInsert').innerHTML = monthname + " " + day + " " + year + " - " + hour + ":" + minute;
setTimeout("klok()", 1000);
}

var winW = 630, winH = 860, reject = false, effect = false;
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouse;
var X = 0,
	Y = 0;
var openToolTip = false;
var hoogtetoolTip = 70;
function getMouse(e) {
  if (IE) {
   X = event.clientX + document.body.scrollLeft;
   Y = event.clientY + document.body.scrollTop;
  } else {
   X = e.pageX;
   Y = e.pageY;
  }  
  if(openToolTip){
		document.getElementById('tooltip').style.zIndex = 99;
		document.getElementById('tooltipShade').style.zIndex = 98;
  		document.getElementById('tooltip').style.left = (X+16)+"px";
		document.getElementById('tooltipShade').style.left = (X+19)+"px";
		document.getElementById('tooltip').style.top = (Y-hoogtetoolTip+22)+"px";
  		document.getElementById('tooltipShade').style.top = (Y-hoogtetoolTip+30)+"px";
	 	

  }
		
}


function tooltip(melding,hoogtetool){
var tooltipShade = document.getElementById('tooltipShade');
var tooltipDiv = document.getElementById('tooltip');
	
	if (melding){
openToolTip = true;
	if (hoogtetool){
hoogtetoolTip = hoogtetool+70;
}
	var strReplaceAll = melding;
	var intIndexOfMatch = strReplaceAll.indexOf( "[br]" );
  
	while (intIndexOfMatch != -1){
	strReplaceAll = strReplaceAll.replace( "[br]", "<br />" );
	intIndexOfMatch = strReplaceAll.indexOf( "[br]" );
}
	 
	document.getElementById('tooltipInhoudShade').innerHTML = strReplaceAll;
	document.getElementById('tooltipInhoud').innerHTML = strReplaceAll;
	}
	else{
	openToolTip = false;
	tooltipShade.style.zIndex = 0;
	tooltipDiv.style.zIndex = 0;
	tooltipDiv.style.left = 0+"px";
	tooltipShade.style.left = 0+"px";
	document.getElementById('tooltipInhoud').innerHTML = "";	
	document.getElementById('tooltipInhoudShade').innerHTML = "";
	hoogtetoolTip = 70;
	}
	
	
}


function chekSize() {
	if (parseInt(navigator.appVersion)>3) {
 if (navigator.appName=="Netscape") {
  winW = window.innerWidth;
  winH = window.innerHeight;
 }
 if (navigator.appName=="Opera") {
  winW = window.innerWidth;
  winH = window.innerHeight;
      
  
 }
if (navigator.appName=="Safari") {
  winW = window.innerWidth;
  winH = window.innerHeight;

}
 if (navigator.appName.indexOf("Microsoft")!=-1) {
  winW = document.documentElement.offsetWidth;
  winH = document.documentElement.offsetHeight;
 } 
}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}




function OnlineList(){
if (OnlineChek == 'yes'){
open_url('opbouw/onlineList.php', 'onlineList');
		setTimeout("OnlineList()", 5000);
}
}




//pagina ophalen

var please_wait = null;


function open_url(url, target) {
 	if ( ! document.getElementById) {
  		return false;
 	}
 	if (please_wait != null) {
  		document.getElementById(target).innerHTML = please_wait;
 	}
 	if (window.ActiveXObject) {
  		link = new ActiveXObject("Microsoft.XMLHTTP");
 	} else if (window.XMLHttpRequest) {
  		link = new XMLHttpRequest();
 	}
 	if (link == undefined) {
  		return false;
 	}
 	link.onreadystatechange = function() { response(url, target); }
	url = url+"?rand="+Math.random();
	url = url+"&from=javascript";
	link.open("GET", url, true);
 	link.send(null);
		return true;
}
function response(url, target) {
 	if (link.readyState == 4) {
		if (link.status == 404){
		document.getElementById(target).innerHTML = "&nbsp;&nbsp;Page not yet available";
		}
		else{
	 	document.getElementById(target).innerHTML = (link.status == 200) ? link.responseText : "<img src='img/plus-wait2.gif' alt='please wait' align='middle'> &nbsp;&nbsp;Loading...";
		}
	}
}











var openMail = "";
//MOVE
var opject = "";
var opjectOld = opject;
var IE = document.all?true:false
//if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouse;
var X = 0
var Y = 0
var alpha = 0;

var OpenDivInbox = 'mailMI1';
function menuOpenDivInbox(x,a,b,c,d,e,f,g){
	document.getElementById(OpenDivInbox).style.backgroundColor = '';document.getElementById(OpenDivInbox).style.color = '#ffffff';
	if (x){	document.getElementById(x).style.backgroundColor = '#F9F9FB';document.getElementById(x).style.color = '#25206C';OpenDivInbox=x;}
	if (a){	document.getElementById(a).style.display = 'block';	}
	if (b){	document.getElementById(b).style.display = 'none';	}
	if (c){	document.getElementById(c).style.display = 'none';	}
	if (d){	document.getElementById(d).style.display = 'none';	}
	if (e){	document.getElementById(e).style.display = 'none';	}
	if (f){	document.getElementById(f).style.display = 'none';	}
	if (g){	document.getElementById(g).style.display = 'none';	}
}
var div='';


function delMail(id,name,hideid){
	var answer = confirm("Are you sure you want to delete the message '"+name+"' ?")
	if (answer){
		document.getElementById(hideid).style.display = "none";
		parent.parent.parent.bewerkingen.location.href = "../opbouw/proces.php?action=delMail&id="+id;
		document.getElementById("totaalMailCount").innerHTML= document.getElementById("totaalMailCount").innerHTML-1;
	}

}

function mailToAll(form,x){
	if (x){
	var answer = confirm("Sent this mail to everybody?\n")
	if (answer){
	document.form1.parsoon.disabled = true;
	document.form1.forShow.disabled = true;
	document.form1.forAll.value='all';
	}
	}
	else{
	document.form1.forAll.value='';
	document.form1.parsoon.disabled = false;
	document.form1.forShow.disabled = false;
	}

}

function mailToPers(form){

form.options[form.selectedIndex].disabled = true;
//document.form1.forShow.value=document.form1.forShow.value+form.options[form.selectedIndex].text+',';
document.form1.forShow.value=document.form1.forShow.value+form.options[form.selectedIndex].value+',';
if (form.options[form.selectedIndex].text != 'all'){form.selectedIndex = 0;}
}

function vadeInOut(key) {
	div=document.getElementById('tooltipAvatar');
	
	if (key == 'off'){

			
			if(alpha > 0){
				clearTimeout ( timerOut );
				alpha = alpha-0.1;
				alpha = Math.round(alpha * 10) / 10;
				div.style.opacity = alpha;
				div.style.khtmlopacity = alpha;
				div.style.filter ='alpha( opacity=' + Math.round( alpha * 100 ) + ' )';
				div.style.mozOpacity = alpha;
				
				timerOut = setTimeout("vadeInOut('off')", 10);
			}
			else{
				div.style.visibility="hidden";
				clearTimeout ( timerOut );
			}
	}
	else{
		div.style.visibility="visible";

		if(alpha < 1.3){
			if (alpha > 0){
				clearTimeout ( timerOut );
				}
			alpha = alpha+0.1;
			alpha = Math.round(alpha * 10) / 10;
			
			div.style.opacity = alpha;
			div.style.khtmlopacity = alpha;
			div.style.filter ='alpha( opacity=' + Math.round( alpha * 100 ) + ' )';
			div.style.mozOpacity = alpha;
			
			timerOut = setTimeout("vadeInOut('on')", 10);
		}
		else{
			clearTimeout ( timerOut );
		}
	}
}
function tooltipAvatar(hide, id, avatar){

	id9 = document.getElementById('tooltipAvatar');
	if (hide == "no"){

		id9.innerHTML = "<img src='img/avatar/"+avatar+"' height='168px'><br /><div class='info'>Info</div><div class='info'>"+"more info"+"</div><div class='info'>"+"more info</div><div class='info'>"+"more info</div>";
		vadeInOut('on')
	}
	else{

		vadeInOut('off')
	}
}
var menu_open = 'yes';
function COMenu(a)
{
	
	if (a){
	menu_open = 'yes';
	if (OnlineChek == "yes"){
	open_url('opbouw/menu_login.php', 'menu2');
	}
	else{
	open_url('opbouw/menu.php', 'menu2');
	}
	document.getElementById('menu2').style.width=171+"px";
	document.getElementById('menu_bg').style.width=176+"px";
	document.getElementById('menu_bg2').style.width=171+"px";
	document.getElementById('iframe').style.left=230+"px";
	document.getElementById('tooltip').style.left=250+"px";
	document.getElementById('subName').style.left=248+"px";
	document.getElementById('iframe').style.width=(winW-245)+"px";
	}
	else
	{
	menu_open = 'no';
	document.getElementById('menu2').style.width=30+"px";
	document.getElementById('menu_bg').style.width=30+"px";
	document.getElementById('menu_bg2').style.width=30+"px";
	document.getElementById("menu3").innerHTML = "<a onClick=\"COMenu('1'),tooltip('')\" onmouseover=\"tooltip('Open menu');\"  onMouseOut=\"tooltip()\"><div id='menu_open_a'>&nbsp;&nbsp;</div></a>";
	document.getElementById('iframe').style.left=90+"px";
	document.getElementById('tooltip').style.left=107+"px";
	document.getElementById('subName').style.left=105+"px";
	document.getElementById('iframe').style.width=(winW-107)+"px";
	}
}
var path = 'Home';

function Input(){
	if(OnlineChek == 'yes'){	
		document.getElementById("subName").innerHTML = SystemNamePersoneel;
	}	
	else{
		document.getElementById("subName").innerHTML = SystemNameKlant;
	}
}

function LoadExtraElemants(){
		if(OnlineChek == 'yes'){	
			window.defaultStatus = CompanyName + SystemNamePersoneel;
		}
		else{
			window.defaultStatus = CompanyName + 'Plus';
		}
}

var winW = 630;
var winH = 860;
var winW_old = 640;
var winH_old = 870;
var iframe = 15;

	var wide=245;
function clock() {

	chekSize();
	if ((winW != winW_old) || (winH != winH_old))
{

	winH_old = winH;
	winW_old = winW;
		document.getElementById('iframe').style.height=(winH-148)+"px";
	
		
			if (winH>440){
	document.getElementById('menu2').style.height=(winH-182)+"px";
		
	}
	else{
			document.getElementById('menu2').style.height=343+"px";
	}
	document.getElementById('menu_bg').style.height=(winH-90)+"px";
		document.getElementById('menu_bg2').style.height=(winH-178)+"px";
			if (menu_open == 'yes'){wide=245;}else{wide=96;}
		document.getElementById('iframe').style.width=(winW-wide)+"px";
	if (winW<780){
		document.getElementById('kalender_out').style.visibility="hidden";
		document.getElementById('date').style.visibility="hidden";
	}
	else{
		document.getElementById('kalender_out').style.visibility="visible";
		document.getElementById('date').style.visibility="visible";
		}
}
	
var date = new Date();
var year = date.getYear();
var month = date.getMonth();
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
var months = new Array("Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December");
var monthname = months[month];
if (year < 1000) {
year = 1900+ year;
}
if (minute < 10) {
minute = "0" + minute;
}
if (second < 10) {
second = "0" + second;
}
if (OnlineChek == "yes"){
	if (dateVisible){
		document.getElementById("date").innerHTML = day + " " + monthname + " " + year + " &nbsp; " + hour + ":" + minute;
	}
	else{
		document.getElementById("date").innerHTML = '';
	}
}

setTimeout("clock()", 1000);
}

function breadkrum(a,b) {
if (a){
path = a;
}
if (b){
path = a+b;
}
return path;

}

























function chekInputTime(inputName,evt,vanOfTot,nummer) {
	
	inhoud = inputName.value;
	charCode = (evt.which) ? evt.which : event.keyCode
	 if ((charCode > 7) && (charCode < 58)) {
		if(inhoud.length == 1){
			if((inhoud != 0) && (inhoud != 1)  && (inhoud != 2)){
				inputName.value  = 1;
    		}
		}
		if(inhoud.length == 2){
		if (charCode == 8){ 
			inputName.value=inhoud.substring(0,1);
		}
		else{
			if((inhoud.substring(0,1) == 2) && (inhoud.substring(1,2) != 0) && (inhoud.substring(1,2) != 1)  && (inhoud.substring(1,2) != 2)  && (inhoud.substring(1,2) != 3)){
				inputName.value  = inhoud.substring(0,1)+2+":";
			}
				else{
					inputName.value  = inputName.value+":";
				}
			}
		}
		if(inhoud.length > 4){
			if (inhoud.substring(3,5) < 99){
				if (charCode == 38){ inputName.value = inhoud.substring(0,2)+":"+((inhoud.substring(3,5))/2*2+1);}
			}
			if (inhoud.substring(3,5) > 10){
				if (charCode == 40){ inputName.value = inhoud.substring(0,2)+":"+((inhoud.substring(3,5))/2*2-1);}
			}
			if (inhoud.substring(3,5) > 10){
				if (charCode == 40){ inputName.value = inhoud.substring(0,2)+":"+((inhoud.substring(3,5))/2*2-1);}
			}
		}
		if(inhoud.length > 4){
  				if (vanOfTot == "van"){
				document.getElementById("tot"+nummer).focus();
				}
				  if ((vanOfTot == "tot") && (nummer < 7)){
				document.getElementById("van"+(nummer+1)).focus();
				}
				//inputName.value = inhoud.substring(0,4)+inhoud.substring(5,6);
			}
	 	}
	else{
		inputName.value = inhoud.substring(0,(inhoud.length-1));
	}
	
	
	if (vanOfTot == "van"){
document.getElementById("tot"+nummer).value =inputName.value; 
	}
	else{
	//totaal er in stoppen
	document.form.totaal.value = document.form.totaal.value/2*2+((document.getElementById("tot"+nummer).value)-(document.getElementById("van"+nummer).value));
		}
}







function inputDate(field,evt){
	if (!evt) evt = window.event;
	charCode = (evt.which) ? evt.which : event.keyCode;
	fvalue = field.value;
if (((charCode > 47)&&(charCode < 59))||(charCode == 8)||((charCode > 37)&&(charCode < 59))||(charCode == 45)) {
	 if ((charCode > 47)&&(charCode < 59)) {
			if(fvalue.length == 2){
				if(fvalue>31){field.value=31;}
				field.value = field.value+'-';
			}
			if(fvalue.length == 5){
				if((fvalue[3]+fvalue[4])>12){field.value=fvalue[0]+fvalue[1]+'-12';}
				field.value = field.value+'-20';
			}
		if(fvalue.length == 10){
				if((fvalue[6]+fvalue[7]+fvalue[8]+fvalue[9])>2037){field.value=fvalue[0]+fvalue[1]+fvalue[2]+fvalue[3]+fvalue[4]+fvalue[5]+2037;}
				if((fvalue[6]+fvalue[7]+fvalue[8]+fvalue[9])<2000){field.value=fvalue[0]+fvalue[1]+fvalue[2]+fvalue[3]+fvalue[4]+fvalue[5]+2000;}
			}
			
		}
}
else{
	field.value = 'Alleen 0-9';
}
	
}






