

//default vars
var defaultEmptyOK=false;
// whitespace characters
var whitespace = " \t\n\r";



// show me functie
function LatenZien(_objName,sMode)
 {
   if(sMode=="true")
   {document.getElementById(_objName).style.display="block";}
   else
   {document.getElementById(_objName).style.display="none";}
   
 }
 
 
 
 // leeg forumveld
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 
 		
 
 
// open site map 
var popUpWin=0;
function OpenSiteMap(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}




// externe link opvang (validatie hack)
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 



// texteare veld resizen
function textarea_v_size(id, cols, rows, mode)
{
var txtId = document.getElementById(id);

if(mode=="plus"){
		if(txtId.rows<25){
		txtId.cols = cols;
		d = parseInt(txtId.rows);
		c = parseInt(rows);
		txtId.rows = d + c;
	}
}
else if(mode=="min"){
		if(txtId.rows>5){
			txtId.cols = cols;
			d = parseInt(txtId.rows);
			c = parseInt(rows);
			txtId.rows = d + c;
			}
	
}
}



// tpggle vacature
function toggleVac(obj, obj2, text1, text2) {
	var el = document.getElementById(obj);
	var al = document.getElementById(obj2);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
			al.innerHTML='<a href=\"#niks\" class=\"togglehref\">'+text1+'</a>';
	}
	else {
		el.style.display = 'block';
		al.innerHTML='<a href=\"#niks\" class=\"togglehref\">'+text2+'</a>';
	}
}


// toggle elements
function mtoggle(obj, obj2) {
	var el = document.getElementById(obj);
	var al = document.getElementById(obj2);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
		al.className='menu_col_up';
	}
	else {
		el.style.display = 'block';
		al.className='menu_col_down';
	}
}



// stel hoogte in van pagina_back (IE6 HACK)
function setHeight() {
  var wh = getWindowHeight(); // Window Height
  var d = document.getElementById('pagina_back') // Get div element
  var dh = d.offsetHeight // div height
  d.style.height = wh + 'px'; // Set div height to window height
}
// haal window hoogte op
function getWindowHeight() {
  var windowHeight = 0;
	
  if (typeof(window.innerHeight) == 'number')
    windowHeight = window.innerHeight;
	
  else {
		
    if (document.documentElement && document.documentElement.clientHeight)
      windowHeight = document.documentElement.clientHeight;
		
    else {
      if (document.body && document.body.clientHeight)
        windowHeight = document.body.clientHeight; }; };
				
  return windowHeight;
};





// Tab blaadjes pagina cookie functie
var tabberOptions = {

  'cookie':"tabber", /* Name to use for the cookie */

  'onLoad': function(argsObj)
  {
    var t = argsObj.tabber;
    var i;

    /* Optional: Add the id of the tabber to the cookie name to allow
       for multiple tabber interfaces on the site.  If you have
       multiple tabber interfaces (even on different pages) I suggest
       setting a unique id on each one, to avoid having the cookie set
       the wrong tab.
    */
    if (t.id) {
      t.cookie = t.id + t.cookie;
    }

    /* If a cookie was previously set, restore the active tab */
    i = parseInt(getCookie(t.cookie));
    if (isNaN(i)) { return; }
    t.tabShow(i);
   // alert('getCookie(' + t.cookie + ') = ' + i);
  },

  'onClick':function(argsObj)
  {
    var c = argsObj.tabber.cookie;
    var i = argsObj.index;
   // alert('setCookie(' + c + ',' + i + ')');
    setCookie(c, i);
  }
};

/*==================================================
  Cookie functions
  ==================================================*/
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}



/*============== BROWSER DETECTOR ==================*/


v3 = 0; op = 0; ie4  = 0; ie5 = 0; ie7=0; nn4 = 0; nn6 = 0; 
isMac = 0; aol = 0;

if(document.images){
    if(navigator.userAgent.indexOf("Opera") != -1){
        op = 1;
    } else {
        if(navigator.userAgent.indexOf("AOL") != -1){
            aol = 1;
        } else {
            ie4 = (document.all && !document.getElementById);
            nn4 = (document.layers);
            ie5 = (document.all && document.getElementById);
            nn6 = (document.addEventListener);
						ie7 = (document.all && document.getElementById);
        }
    }
} else {
    v3 = 1;	
}

if(navigator.userAgent.indexOf("Mac") != -1){
    isMac = 1;
}


// email validation
// str = emailstring
function ValidateEmail(str) {
return (str.lastIndexOf(".") > 2) && (str.indexOf("@") > 0) && (str.lastIndexOf(".") > (str.indexOf("@")+1)) && (str.indexOf("@") == str.lastIndexOf("@"));
} 





//*********************************

// isEmail (STRING s [, BOOLEAN emptyOK])
function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}


//************************************
// maak string save voor sql
function sqlSafe (s)
{
	// string, from, to
	var new_s = s;
	new_s = replaceAll (new_s, "'", "|");
	new_s = replaceAll (new_s, "|", "''");
	new_s = replaceAll (new_s, "\"", "|");
	new_s = replaceAll (new_s, "|", "''");
	return new_s;
}

function replaceAll (s, fromStr, toStr)
{
        var new_s = s;
        for (i = 0; i < 100 && new_s.indexOf (fromStr) != -1; i++)
        {
                new_s = new_s.replace (fromStr, toStr);
        }
        return new_s;
}


function makeSafe (i)
{
	i.value = sqlSafe (i.value);
}




//**************************

// Check whether string s is empty.
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}




// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}



//*********************************

// message is displayed...
function ForceEntry(objField, FieldName)
{
	var strField = new String(objField.value);
	if (isWhitespace(strField)) {
		alert("Je dient gegevens in te vulllen in veld: " + FieldName);
		objField.focus();
		objField.select();
		return false;
	}

	return true;
}


// message is displayed...
function CheckEmpty(objField, FieldName)
{
	var strField = new String(objField.value);
	if (strField=="") {
		alert("Je dient gegevens in te vulllen in veld: " + FieldName);
		objField.focus();
		return false;
	}

	return true;
}

/****************************************************************/

// Returns true if the string passed in is a valid number
//  (no alpha characters), else it displays an error message

function ForceNumber(objField, FieldName)
{
	var strField = new String(objField.value);
	
	if (isWhitespace(strField)) return true;

	var i = 0;

	for (i = 0; i < strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9') {
			alert("In" +FieldName + " mogen alleen nummerieke gegevens instaan. Dus geen commas, punten of spaties");
			objField.focus();
			return false;
		}

	return true;
}


/****************************************************************/

// Returns true if the string passed in is a valid money
//  (no alpha characters except a decimal place), 
//   else it displays an error message

function ForceMoney(objField, FieldName)
{
		var strField = new String(objField.value);
		if (isWhitespace(strField)) return true;
	var i = 0;
	for (i = 0; i < strField.length; i++)
		if ((strField.charAt(i) < '0' || strField.charAt(i) > '9') && (strField.charAt(i) != '.')) {
			alert("In "+FieldName + " mogen alleen valute gegevens staan. Dus geen commas of letters.");
			objField.focus();
			return false;
		}
	return true;
}



function CheckRadio(objField, Fieldname, veld)
{
myOption = -1;

for (i=objField.Fieldname.length-1; i > -1; i--) {
if (objField.Fieldname[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("U heeft geen keuze gemaakt voor "+veld+". Maak aub een keuze ");
return false;
}
}


/****************************************************************/

/* PURPOSE:  Returns true if the string is a valid date number.
	A method is passed in (1 = month, 2 = day).  If the string is
	nonnumeric, false is passed back.  If the day in the date string
	is greater than 31, false is returned.  If the month is greater
	than 12, an error is returned.
*/

function isDateNumber(strNum,method)
{
	var str = new String(strNum);
	var i = 0;

	if (isNaN(parseInt(str)) || parseInt(str) < 0) return false;

	if (method == 2)
		if (parseInt(str) > 31)
			return false;
	if (method == 1)
		if (parseInt(str) > 12)
			return false;

	for (i = 0; i < str.length; i++)
		if (str.charAt(i) < '0' || str.charAt(i) > '9')
			return false;


	return true;
}


/****************************************************************/

/* PURPOSE: Checks to see if the string is a valid date.  A valid
	date is defined as any of the following:

		MM/DD/YY, MM/DD/YYYY, M/D/YY, M/D/YYYY,
		MM-DD-YY, MM-DD-YYYY, M-D-YY, M-D-YYYY
*/

function ForceDate(strDate,strField)
{
	alert(strDate);
	var str = new String(strDate.value);

	if (isWhitespace(str)) {
		return true;
		// if the field is empty, just return true...
	}

	var i = 0, count = str.length, j = 0;
	while ((str.charAt(i) != "/" && str.charAt(i) != "-") && i < count)
		i++;

	if (i == count || i > 2) {
				alert("Vul aub het juiste geboortedatum  in bij  "+strField+".");
	strDate.focus();
		return false;
	}

	var addOne = false;
	if (i == 2) addOne = true;

	if (!isDateNumber(str.substring(0,i),1)) {
		alert("Vul aub het juiste geboortedatum  in bij  "+strField+".");
	strDate.focus();
		return false;
	}

	j = i+1;
	i = 0;

	while ((str.charAt(i+j) != "/" && str.charAt(j+i) != "-") && i+j < count)
		i++;

	if (i+j == count || i > 2) {
			alert("Vul aub het juiste geboortedatum  in bij  "+strField+".");
	strDate.focus();
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),2)) {
				alert("Vul aub het juiste geboortedatum  in bij  "+strField+".");
	strDate.focus();
		return false;
	}

	j = i+3;
	i = 0;

	if (addOne) j++;

	while (i+j < count)
		i++;


	if (i != 2 && i != 4) {
			alert("Vul aub het juiste geboortedatum  in bij  "+strField+".");
	strDate.focus();
		return false;
	}

	if (!isDateNumber(str.substring(j,i+j),3)) {
				alert("Vul aub het juiste geboortedatum  in bij  "+strField+".");
	strDate.focus();
		return false;
	}

	return true;
}


/****************************************************************/

// This function determines if the string passed in is a valid
// US zip code.  It accepts  #### ##.  If the
// string is valid, it returns true, else false.

function isZipcode(strZip)
{
	var s = new String(strZip);

	if (s.length != 7)
		// inappropriate length
		return false;


	for (var i=0; i < s.length; i++)
		if ((s.charAt(i) < '0' || s.charAt(s) > '9') && s.charAt(i) != ' ')
			return false;

	return true;
}


function PostCodeCheck(objField, Fieldname) 
{ 
var strField= document.getElementById(objField);
if((typeof strField.value=='string'    ?strField.value.match(/[1-9][0-9]{3} ?[a-zA-Z]{2}/)==strField.value    :false)==false)
{
	alert("Vul aub het juiste postode in bij de "+Fieldname+".");
	strField.focus();
		strField.select();
	return false
}else{
return true;
}
}

/****************************************************************/

// This function ensures that a field is less than or equal to the
// Length passed in.  You must call this function with the element
// name in your form (for example: "ForceLength(document.forms[0].txtElement)"
// as opposed to "ForceLength(document.forms[0].txtElement.value)"
// If the field's value is too large, an error message is displayed
// and false is returned, else true is returned.

function ForceLength(objField, nLength, strWarning)
{
	var strField = new String(objField.value);

	if (strField.length < nLength)
	{
		alert(strWarning);
		objField.focus();
		return false;
	} else{
		return true;
}
}

function CheckFileType(objField, FileType, strWarning)
{
var strField = new String(document.getElementById(objField));
if(strField.value.lastIndexOf(FileType)==-1)
{
   alert(strWarning);
   return false;
	 }else{
		 return true;
	 }
}



// Deze functie zorgt ervoor dat men een tekxt kan invullen en als een gebruiker bij dat veld komt deze leeg maakt...
function ClearInput(objField, defaulttext)
{
			var strField = document.getElementById(objField); 
		if (strField.value == defaulttext) 
		{
		strField.value = "";
		}

}


// Toggle TR
function showtr(master, tra, trb)
{
	var sha= document.getElementById(tra);
	var shb= document.getElementById(trb);
	
if(sha.style.display=="none")
{
	master.className='select_item';
	sha.style.display='';
 shb.style.display='';
}
else{
		master.className='select_item2';
	sha.style.display="none";
	shb.style.display="none";
	}
}








window.onload = externalLinks;



