if (navigator.appName=="Microsoft Internet Explorer")
{
	document.write("<link rel='stylesheet'  href='general/css/libralab_ie.css'>");
}

var helpArray = new Array;
function checkAll(frm, chkBox,pattern)
{		
	var check = true;
	if (! chkBox.checked)
	{
		check = false;
	}
	
	for (var c = 0; c < frm.elements.length; c++)
	{
		if (frm.elements[c].type == 'checkbox'&&(pattern!=null&&frm.elements[c].name.indexOf(pattern)>-1||pattern==null))
		{
			if(!frm.elements[c].disabled)
			{
				frm.elements[c].checked = check;
			}
		}
	}			
}

function checkKey(evt) {
	var keyCode = evt.keyCode;
	if(evt.shiftKey&&evt.ctrlKey&&evt.keyCode==68)
	{
		var strURL = window.location.toString();
		var strPrefix = strURL.indexOf('?')>0?'&':'?';
		strURL = strURL.replace('&debug=false','&debug=true');
		strURL = strURL.replace('?debug=false','?debug=true');
		if(strURL.indexOf('debug=true')<0)
		{
			strURL = window.location+strPrefix+"debug=true";
		}
		
		window.location = strURL;
	}
	else if(evt.shiftKey&&evt.altKey&&evt.keyCode==68)
	{
		var strURL = window.location.toString();
		strURL = strURL.replace('&debug=true','&debug=false');
		strURL = strURL.replace('?debug=true','?debug=false');
		window.location = strURL;
	}
}


function OpenPopup(url,width,height, left, top,debug) 
{
	var curWinLeft = 0;
	var curWinTop = 0;
	var resizable = 'no';
	if(width==null||height==null)
	{
		width = 600;
		height = 400;
		resizable = 'yes';
	}
	curWinLeft = screen.availWidth/2-(width/2);
	curWinTop = screen.availHeight/2-(height/2);
	if (left >= 0 && top >=0 )
	{
	
		if (navigator.appName=="Microsoft Internet Explorer")
		{
			curWinLeft =  window.screenLeft;
			curWinTop =  window.screenTop;
		} else {
			curWinLeft =    window.screenX;
			curWinTop = window.screenY;
		}		
		curWinLeft += left;
		curWinTop += top;
	}
	
	if(debug)
	{
		var popup = window.open(url,'New_Window','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height + ', left=' + curWinLeft+',top=' + curWinTop);
	}
	else
	{
		var popup = window.open(url,'New_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable='+resizable+',copyhistory=no,width='+width+',height='+height + ', left=' + curWinLeft+',top=' + curWinTop);
	} 
}

function mouse_over(context)
{
	var msg = helpArray[context];
	var el  = document.getElementById('contexthelp');
	
	el.innerHTML = msg;
}
function mouse_out()
{
	var el  = document.getElementById('contexthelp');
	el.innerHTML = '';
}

function mouse_str_over(msg)
{
	var el  = document.getElementById('contexthelp');
	
	el.innerHTML = msg;
}
function ch2(e) {
        mark=e.childNodes.item(0).childNodes.item(0);                 
        contents=e.childNodes.item(1);
        if (mark.innerHTML=="+") {
            mark.innerHTML="-";                   
            contents.style.display="block";  
        }
        else {
            mark.innerHTML="+";
            contents.style.display="none";
        }
 }       
 
 //lege functie, kan worden overloaded in eigen xslt (als event...)
 function SelectDeselectChange(strSelectedID){}
	
function SelectDeselect_Move(strFromID,strToID)
{

	var objFrom = document.getElementById(strFromID);
	var objTo = document.getElementById(strToID);
	var i;
	for (i = objFrom.length - 1; i >=0 ; i--) 
	{

		var objOptSelected = objFrom.options[i]

		if (objOptSelected.selected) 
		{
			var objOptNew = document.createElement('option');
			objOptNew.text = objOptSelected.text;
			objOptNew.value = objOptSelected.value;
			
			try 
			{
				objTo.add(objOptNew, null); // standards compliant; doesn't work in IE
			}
			catch(ex) 
			{
				objTo.add(objOptNew); // IE only
			}
			objFrom.remove(i);
		}
	}
}
	
	
function getRadioValue(theObj) 
{
	for (var i=0; i < theObj.length; i++) 
	{
		if (theObj[i].checked) { return theObj[i].value;}
	}
	return "";
}
		
function mkArrayFromElements(strNameToContain)
{
	var intSize				= ThisForm.elements.length; 
	var strName				= '';
	var arrNewNames			= new Array(intSize);
	var intArrLength		= 0;

	for( i = 0; i < intSize; ++i ) 
	{
		strName	= ThisForm.elements[i].name;
		
		if(strName != null)
		{
			if(strName.indexOf(strNameToContain) != -1)
			{
				arrNewNames[intArrLength] =  ThisForm.elements[i].value;
				if(ThisForm.elements[i].value == '')
				{
					blnHasEmptyValues = true;
				}
				intArrLength += 1;
			}
		}
	} 
	
	arrNewNames		= arrNewNames.slice(0,intArrLength);
	return (arrNewNames);
}

function CheckUniqueValuesInArray(arrToCheck)
{
	var strName				= '';
	var strNameToCompare	= '';
	var blnUnique			= true;			

	for( i = 0; i < arrToCheck.length; ++i ) 
	{
		strName	= arrToCheck[i];
	
		for( j = 0; j < arrToCheck.length; ++j ) 
		{
			if(i != j)//Dezelfde vergelijken heeft dus geen zin
			{
				strNameToCompare	= arrToCheck[j];
				if(strNameToCompare != '' && strName != '' && strName == strNameToCompare)//Lege waarden ook niet vergelijken
				{
					blnUnique = false;
				}
			}
		} 
	}
	return (blnUnique);
}

function ChangeTab(newtab)
{
	//alert('Hey collega!\nDeze functie moet je overloaden op je form zodat je van tab kan wisselen');
	
	/*
	Voorbeeld code:
	this.CurrentTab.value = newtab;
	submitform(this,'changetab')
	*/
}

function mkArrayFromSelectedElements()
{
	var intSize				= ThisForm.elements.length; 
	var strName				= '';
	var arrSelectedNrs			= new Array(intSize);
	var intArrLength		= 0;

	for( i = 0; i < intSize; ++i ) 
	{
		strName	= ThisForm.elements[i].name;
		
		if(strName != null)
		{
			if(strName.indexOf('blnSelected') != -1)
			{
				if(ThisForm.elements[i].checked == true)
				{
					stringNr	= new String(strName);
					stringNr	= stringNr.replace('blnSelected','');
				
					arrSelectedNrs[intArrLength] =  stringNr;
					intArrLength += 1;
				}
			}
		}
	} 
	
	arrSelectedNrs		= arrSelectedNrs.slice(0,intArrLength);
	return (arrSelectedNrs);
}


/*############################################
# Berekend iemands leeftijd in jaren 
##############################################*/
function GetAge(dtmJS)
{
	dd = dtmJS.getDate();
	mm = dtmJS.getMonth() + 1;
	yy = dtmJS.getFullYear();

	days = new Date();
	gdate = days.getDate();
	gmonth = days.getMonth()+1;
	gyear = days.getFullYear();
	age = gyear - yy;
	if ((mm > gmonth) || (mm == gmonth && gdate < dd))age --;
	
	return age;
}


/*############################################
# Functions om de x en y posities van een element op te halen 
##############################################*/
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function AllowTabCharacter() 
{   
	if (event != null) 
	{      
		if (event.srcElement) 
		{         
			if (event.srcElement.value) 
			{            
				if (event.keyCode == 9) 
				{  // tab character               
					if (document.selection != null) 
					{                  
						document.selection.createRange().text = '\t';                  
						event.returnValue = false;               
					}               
					else 
					{                  
						event.srcElement.value += '\t';                  
						return false;               
					}
	            }
			}
		}
	}
}


function loadTextFile(url)
{

url += "?" + Math.random();
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=state_Change
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=state_Change
    xmlhttp.open("GET",url,true)
    xmlhttp.send()
    }
  }
}

function showNoClickDiv()
{
	var objDiv	= document.getElementById("noClickDiv");
	var objProgressDiv	= document.getElementById("progressBar");
	
	objDiv.className			= 'noClickDivVisible';
	objProgressDiv.className	= 'progressBarVisible';
	
	resizeNoClickDiv();// Zet de initieele grootte
	
	hideAllCombos(); //Omdat deze anders door de div heen komen.
}

function resizeNoClickDiv()
{
	var strBrowserType	= navigator.appName;
	
	setStyle("noClickDiv", "top", (document.body.scrollTop) + "px");
	setStyle("noClickDiv", "width", (document.body.offsetWidth) + "px");
	
	
	if(strBrowserType.indexOf("Microsoft") > -1)//IE
	{
		setStyle("noClickDiv", "height", (document.body.offsetHeight) + "px");
	}
	else//Mozilla
	{
		setStyle("noClickDiv", "height", (document.documentElement.offsetHeight) + "px");
	}
	
	var intImageWidth	= 174;//getStyle(document.getElementById("progressImage"), "width");
	var intImageHeigth	= 25;//getStyle(document.getElementById("progressImage"), "height");
	
	
	setStyle("progressBar", "left", (document.body.offsetWidth/2) - (intImageWidth/2) + "px");
	setStyle("progressBar", "top", (document.body.offsetHeight/2) - (intImageHeigth/2) + document.body.scrollTop + "px");
}

function setStyle(objId, style, value)
{
    document.getElementById(objId).style[style] = value;
}

function getStyle(el, style)
{
	if(!document.getElementById) return;
   
	var value = el.style[toCamelCase(style)];
   
    if(!value)
    {
        if(document.defaultView)
        {
            value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
		}
        else
        {
			if(el.currentStyle)
			{
				value = el.currentStyle[toCamelCase(style)];
			}
		}
	}
	return value;
}

function toCamelCase( sInput )
{
    var oStringList = sInput.split('-');

    if(oStringList.length == 1)
    {
        return oStringList[0];
	}
    
    var ret = sInput.indexOf("-") == 0 ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
    
    for(var i = 1, len = oStringList.length; i < len; i++)
    {
        var s = oStringList[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1);
    }
    return ret;
}

function hideAllCombos()
{
	if(document.all)
	{
		var arrSelects = document.getElementsByTagName('select');
		
		for (var intI = 0; intI < arrSelects.length; intI++)
		{
			arrSelects[intI].style.visibility	= 'hidden';
			arrSelects[intI].style.display		= 'none';
		}
	}
}
function validateBaby()
{
  if(document.getElementById('babies').value > document.getElementById('adults').value)
    document.getElementById('baby-text').style.display='block';
  else
    document.getElementById('baby-text').style.display='none';
}