// JavaScript functions
// onderstaand script zorgt ervoor dat er geen pagina's buiten het parentframe om kunnen geladen worden

// Netscape???
// var NN = (document.layers ? true : false);
// if (NN == true) {alert('true')} else {alert('false')};

// aantal image objecten die gleaden moeten worden
var aantalObj = 0;
var arImages = new Array();
var popupWin;

// clickfunctie
function Klik(name){
	// zet alle image waarde op false
   for (i = 0; i < aantalObj; i++) {
	    arImages[i][3] = false;
   }
	// zet aangeklikte waarde op true zodat deze niet door de uit functie verwisseld wordt
	// maar de hilightversie blijft behouden
   	for (i = 0; i < aantalObj; i++) {
	    if (arImages[i][2] == name ) {
	    	arImages[i][3] = true;
	    }
   	}
	Uit();
}	

// laden van images voor het swappen
function Laden(name, first, second, value) {
    arImages[aantalObj] = new Array(4);
    arImages[aantalObj][0] = new Image();
    arImages[aantalObj][0].src = first;
    arImages[aantalObj][1] = new Image();
    arImages[aantalObj][1].src = second;
    arImages[aantalObj][2] = name;
    arImages[aantalObj][3] = value;
    aantalObj++;
}

// swapfunctie aan
function Aan(name){
   window.status = name;
     for (i = 0; i < aantalObj; i++) {
      if (document.images[arImages[i][2]] != null)
        if ((name != arImages[i][2]) && (arImages[i][3] == false)) {
          // alle anderen arItemImages zuruecksetzen
          document.images[arImages[i][2]].src = arImages[i][0].src;
        	}
        else {
          document.images[arImages[i][2]].src = arImages[i][1].src;
        }
	  	}
	}


// swapfunctie uit
function Uit(){
   // alle arImages terugzetten
   for (i = 0; i < aantalObj; i++) {
    if ((document.images[arImages[i][2]] != null) && (arImages[i][3] == false))
    	document.images[arImages[i][2]].src = arImages[i][0].src;
   }
   window.status = '';
}
// clickfunctie
function klikItem(id){
	// zet alle image waarde op false
	var strCategorie;
   for (i = 0; i < parent.arItems.length; i++) {
	    parent.arItems[i][intArrayLength-1] = 0;
   }
	// zet aangeklikte waarde op true zodat deze niet door de uit functie verwisseld wordt
	// maar de hilightversie blijft behouden
   for (i = 0; i < parent.arItems.length; i++) {
	    if (parent.arItems[i][0] == id )	{
	    	parent.arItems[i][intArrayLength-1] = 1;
			strCategorie = parent.arItems[i][5];
			break;
	    }
   }
   // zet alle eerste menu op 1 behalve de eerste waarde van het aangeklikte menu
   // op deze manier is het eerste menu altijd gehighlight als je naar een ander menu (via item) overschakeld
   for (i = 0; i < parent.arMenu.length; i++) {
	    if ((parent.arMenu[i][3] == 1 ) && (parent.arMenu[i][1] == strCategorie ))	{
	    	parent.arMenu[i][intArrayLength-1] = 1;
	    }
   }

}

function klikMenu(id){
	// zet alle image waarde op false
   for (i = 0; i < parent.arMenu.length; i++) {
	    parent.arMenu[i][intArrayLength-1] = 0;
   }
	// zet aangeklikte waarde op true zodat deze niet door de uit functie verwisseld wordt
	// maar de hilightversie blijft behouden
   for (i = 0; i < parent.arMenu.length; i++) {
	    if (parent.arMenu[i][0] == id )	{
	    	parent.arMenu[i][intArrayLength-1] = 1;
			break;
	    }
   }
}


// oude refreshframes met items bovenin:
//function refreshframes(var1,var2,var3,var4,var5,var6)	{
//	// 1 = top, 2 = blank, 3 = item, 4 = menu, 5 = main 6 = hulpitem
//	if (var1 != "")	{parent.location.href=var1;}
//	else {
//		if (var2 != "") {if (popupWin==null || popupWin.closed) {popupWin=window.open(var1)} else {popupWin.location.href=var1};popupWin.focus();}
//		if (var3 != "")	{parent.frames[0].location.href=var3;}
//		if (var4 != "")	{parent.frames[1].location.href=var4;}
//		if (var5 != "")	{parent.frames[2].location.href=var5;}
//		//if (var6 != "") {parent.frames[4].location.replace(var4);}
//		//if (var7 != "")	{parent.frames[5].location.replace(var7);}
//	}
//}

function refreshframes(var1,var2,var3,var4,var5,var6)	{
	// 1 = top, 2 = blank, 3 = item, 4 = menu, 5 = main 6 = hulpitem
	// 1 = top, 2 = blank, 3 = hulpitem, 4 = menu, 5 = main 6 = item
	if (var1 != "")	{parent.location.href=var1;}
	else {
		if (var2 != "") {if (popupWin==null || popupWin.closed) {popupWin=window.open(var1)} else {popupWin.location.href=var1};popupWin.focus();}
		if (var3 != "") {parent.frames[5].location.href=var3;}
		if (var4 != "")	{parent.frames[3].location.href=var4;}
		if (var5 != "")	{parent.frames[4].location.href=var5;}
		if (var6 != "")	{parent.frames[2].location.href=var6;}
	}
}

// onderstaand script zorgt ervoor dat er geen pagina's buiten het parentframe om kunnen geladen worden
function checkParent()	{
	if (parent.location.href == self.location.href)	
		parent.location.href = '/default.php';
}

function clearStatus()	{
	self.status="";
	}

function GetFileName (UrlToSplit)	{
	// haal de filenaam uit een url

	var FileName = "";

	arrayOfStrings = UrlToSplit.split("/");
	FileName = arrayOfStrings[arrayOfStrings.length-1];
	arrayOfStrings = FileName.split(".");
	FileName = arrayOfStrings[0];
	return FileName;
}	
	
function Trim(theString) {
    theString = theString.replace(/^\s+/, "");	// LTrim
    theString = theString.replace(/\s+$/, "");	// RTrim
    return(theString);
}

function openBrowser(file){
	var new_window = window.open (file,'browser','scrollbars=yes,toolbar=yes,menubar=no,status=no,width=750,height=500,top=25,left=25,alwaysRaised');
	new_window.focus();
}

function openWindow(strLink) {
	if (popupWin==null || popupWin.closed) 
		{popupWin=window.open(strLink,'','width=600,height=500,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes')} 
	else 
		{popupWin.location.href=strLink;}
	popupWin.focus();
}
function openCalendarWindow(strLink) {
	if (popupWin==null || popupWin.closed) 
		{popupWin=window.open(strLink,'','width=550,height=400,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes')} 
	else 
		{popupWin.location.href=strLink;}
	popupWin.focus();
}
var dossierWin
function openDossierWindow(strLink) {
	if (dossierWin==null || dossierWin.closed) 
		{dossierWin=window.open(strLink,'','')} 
	else 
		{dossierWin.location.href=strLink;}
	dossierWin.focus();
}

function openWindowWithFocus(Target2) {
	var Target;
	Target = window.open("/"+Target2, "Target", "width=450,height=650,left=100,top=0,scrollbars=1, resizable=1");
	Target.window.focus();
}

function changeFrame(file1) {
	parent.frames["inhoud"].document.location.href = file1;
}

// email-scramblers:
function emailAddress() { 
	s1 = 'in'+'fo'+'@'; 
	s2 = 'cb'+'advi'+'es.c'+'om'; 
	return s1 + s2; 
} 

function emailAddressMAILTO() { 
	return '<a href="mailto:' + emailAddress() + '">' + emailAddress() + '</a>'; 
} 

function telAddress() { 
	s1 = '06-' + '2269' + '8865';
	return s1; 
} 

function faxAddress() { 
	s1 = '024-' + '696' + '3835';
	return s1; 
} 

function workAddress() {
	s1 = 'Cok Buijs';
	s2 = '<br>Ubbergseveldweg 30';
	s3 = '<br>6522 HH Nijmegen';
	return s1 + s2 + s3; 
}

// javascript bij uitklapmenu Marlon:
startList1 = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav1");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
    			node.onmouseout=function() {
    				this.className=this.className.replace(" over", "");
    			}
   			}
  		}
 	}
}

// disable right mouse button
var clickmessage="Copyright CB Advies";
				
function protectImages () {
	if (document.all)
		document.oncontextmenu=disableclick
	else if (document.getElementById)
		document.oncontextmenu=disableclick
	else if (document.layers)
		associateimages()
}

function disableclick(e) {
	if (document.all) {
		if (event.srcElement.tagName=="IMG"){
			alert(clickmessage);
			return false;
		}
	}
	else if (document.layers) {
		if (e.which == 3) {
			alert(clickmessage);
			return false;
		}
	}
	else if (document.getElementById){
		if (e.target.tagName=="IMG"){
			alert(clickmessage)
			return false
		}
	}
}

function associateimages(){
	for(i=0;i<document.images.length;i++)
		document.images[i].onmousedown=disableclick;
}
// end disable right mouse button

// start divs 
/**
 * Show element by id
 */
function show(targetID) {
	if (document.getElementById) {
		if(document.getElementById(targetID)) {
			var target = document.getElementById(targetID);
			target.style.display = "";
	  		target.isVisible = true; 
	  	}
	}
}

/**
 * Hide element by id
 */
function hide(targetId) {
  if (document.getElementById) {
    if (document.getElementById(targetId)) {
      var target = document.getElementById(targetId);
      target.style.display = "none";
	  target.isVisible = false; 
    }
  }
}
/**
 * Show text in html div
 */
function setTextToInnerHTML(targetID, text) {
	//alert(targetID);
	if (document.getElementById) {
		var target = document.getElementById(targetID);
		if (target != null)	{
			target.innerHTML = text;
		} else	{
			alert('object not found');
		}
	}
}

/**
 * Show text in html input field
 */
function setTextToValue(targetID, text) {
	//alert(targetID);
	if (document.getElementById) {
		var target = document.getElementById(targetID);
		if (target != null)	{
			target.value = text;
		} else	{
			alert('object not found');
		}
	}
}

/**
 * Set startvalues of divs: show or hide
 */
function initDivs() {
	// startwaarden divs site:
	show('home');
	hide('drive');
	hide('focus');
	hide('tools');
	hide('roots');
	hide('trackrecord');
	hide('trackrecord_index');
	hide('contact');
	hide('contactform');
	hide('contactform2');

	// startwaarden animatie blokken:
	hide('animatie_drive');
	hide('animatie_focus');
	hide('animatie_tools');
	hide('animatie_roots');
	hide('animatie_trackrecord');
	hide('animatie_contact');	

	// startwaarden subdivs trackrecord:
	hide('projecten');
	hide('usus');
	hide('shanghai');
	hide('portaal');
	hide('rotterdam');
	hide('doornroosje');
	
	hide('trackrecord_shanghai1');
	hide('trackrecord_shanghai2');
}
function initDivsContact() {
	// startwaarden divs site:
	hide('home');
	hide('drive');
	hide('focus');
	hide('tools');
	hide('roots');
	hide('trackrecord');
	hide('trackrecord_index');
	show('contact');
	hide('contactform');
	show('contactform2');

	// startwaarden animatie blokken:
	hide('animatie_drive');
	hide('animatie_focus');
	hide('animatie_tools');
	hide('animatie_roots');
	hide('animatie_trackrecord');
	show('animatie_contact');	

	// startwaarden subdivs trackrecord:
	hide('projecten');
	hide('usus');
	hide('shanghai');
	hide('portaal');
	hide('rotterdam');
	hide('doornroosje');

	hide('trackrecord_shanghai1');
	hide('trackrecord_shanghai2');
}

// macromedia-functies:
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function browserVersion() {
	var browser = new Object();
	browser.major = parseInt(navigator.appVersion);
	return browser.major
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// tot hier !
