// mvr 06/5/2008 10:45 voor WriteLogo is defaultURL en  currentModeUrl; deze worden normaal gezien gezet in 1Control.js maar in bepaalde
// gevallen is 1Control.js niet nodig (bv. tonen insursmall.htm)
var defaultURL;
var SecureSURL;
var currentModeUrl;
var selectedMenu;
if (SecureSURL==null) SecureSURL = 'https://' + location.host;
if (defaultURL==null) defaultURL = 'http://' + location.host;
if (currentModeUrl==null) currentModeUrl=defaultURL;



// WriteLogo script voor normale logo (zonder and go)
function WriteLogo() {
  document.write('<a href="' + defaultURL + '/index.htm" target="_parent"><img src="' + currentModeUrl +  '/img/design/logo_airstop.gif" width="255" height="41" border="0"></a>')
}

// WriteLogo Airstop 20 jaar
// function WriteLogo() {
//
//  document.write('<a href="' + defaultURL + '/index.htm" target="_parent"><img src="' + currentModeUrl + '/img/design/logo_airstop_20.gif" border="0" style="margin-left:8px"></a>')
// }
// mvr 26/3/2009 16:23 securelink in new window openen zodat window na afhandeling gewoon kan gesloten worden
function WriteSecureLinkTo(ThePath,styleClass,Content) {
 if (styleClass=='') { document.write('<a target="_blank" href="' + SecureSURL + ThePath +'">' + Content + '</a>') } else { document.write('<a  target="_blank" href="' + SecureSURL + ThePath +'" class="' + styleClass + '">' + Content + '</a>') }
}
//
function WriteLinkTo(ThePath,styleClass,Content) {
 if (styleClass=='') { document.write('<a href="' + defaultURL + ThePath +'">' + Content + '</a>') } else { document.write('<a href="' + defaultURL + ThePath +'" class="' + styleClass + '">' + Content + '</a>') }
}
function air_Over(it) {
 it.className='mainnavactive'
 it.parentNode.className='MenuNavB'
 it.parentNode.parentNode.childNodes[0].className='MenuNavB'
}
function air_Out(it) {
 it.className='mainnav';
 it.parentNode.className='MenuNavA';
 it.parentNode.parentNode.childNodes[0].className='MenuNavA'
}
function air_OverSub(it) {
 it.className='subnavactive';
 it.parentNode.className='SubMenuNavA';
 it.parentNode.parentNode.childNodes[0].className='SubMenuNavA';
}
function air_OutSub(it) {
 it.className='subnav';
 it.parentNode.className='subnav';
 it.parentNode.parentNode.childNodes[0].className='subnav';
}
function AddMenuItem(name,url,target,TType) {  // + extra anonieme arguments: ids
 var m = menuArray.length;
 var i;
 menuArray[m] = new Array();
 menuArray[m][0] = name;
 menuArray[m][1] = url;
 menuArray[m][2] = target;
 menuArray[m][3] = new Array();
 menuArray[m][4] = TType;
 for (i = 4; i < arguments.length; i++) {
  menuArray[m][menuArray[m].length] = arguments[i];
 }
}
function AddMenuSubItem(name,url,target,TType) {  // + extra anonieme arguments: ids
 var m = menuArray.length-1;
 var n = menuArray[m][3].length;
 var i;
 menuArray[m][3][n] = new Array();
 menuArray[m][3][n][0] = name;
 menuArray[m][3][n][1] = url;
 menuArray[m][3][n][2] = target;
 menuArray[m][3][n][3] = TType;
 for (i = 4; i < arguments.length; i++) {
  menuArray[m][3][n][menuArray[m][3][n].length] = arguments[i];
 }
}
function OpenInfo (path) {
 var infoScreen = open(defaultURL + path , "InfoScreen", "width=700,height=550,toolbar=1,scrollbars=yes");
 if (infoScreen.opener == null) { infoScreen.opener = self; }
}

function isThisMenuItem(id, m) {
 var i;
 for (i = 5; i <menuArray[m].length; i++) {
  if(menuArray[m][i] == id) {
   return true;
  }
 }
 return false;
}
function isThisMenuSubItem(id, m, n) {
 var i;
 for (i = 4; i < menuArray[m][3][n].length; i++) {
  if(menuArray[m][3][n][i] == id) {
   return true;
  }
 }
 return false;
}

function iframeContent (taalcode) {
    var match = document.location.search.match(/[;&?]p_nmr_id=([^;&]+)/i);
    if(match) {
        if(!taalcode) taalcode = document.location.toString().match(/\/(\d)?/)[1];
        if(!taalcode) taalcode = 1;
        var iframe = document.getElementsByTagName('iframe')[0];
        if(iframe) iframe.src='/' + taalcode + '/albpub/nieuwsShow.showText?p_nmr_id=' + unescape(match[1].replace(/\+/g, '%20'));
    }
}

// function iframeContentLMH (taalcode) {
//     var match = document.location.search.match(/[;&?]P_BESTEMMINGCODE=([^;&]+)/i);
//     if(match) {
//         if(!taalcode) taalcode = document.location.toString().match(/\/(\d)?/)[1];
//         if(!taalcode) taalcode = 1;
//         var iframe = document.getElementsByTagName('iframe')[0];
//         if(iframe) iframe.src='/' + taalcode + '/albpub/lmh$pkg.lmhview?P_BESTEMMINGCODE=' + unescape(match[1].replace(/\+/g, '%20'));
//     }
// }

// function iframeContentALB (taalcode) {
//     var match = document.location.search.match(/[;&?]P_CITY=([^;&]+)/i);
//     if(match) {
//         if(!taalcode) taalcode = document.location.toString().match(/\/(\d)?/)[1];
//         if(!taalcode) taalcode = 1;
//         var iframe = document.getElementsByTagName('iframe')[0];
//         if(iframe) iframe.src='/' + taalcode + '/albpub/aas_query$afbodaanbod.Egazettequerylist?P_TAALCODE='+taalcode+'&P_CITY=' + unescape(match[1].replace(/\+/g, '%20'));
//     }
// }




function openWin(URL)
{
aWin = window.open(URL, "window", "location=yes, toolbar=no, width = 727, status=YES, height = 500, resizable=yes, scrollbars=yes, menubar=no");
}

function hideShow(menu){
  var maxSubmenus=11;
  var subel;
  var currentMenu;
  var el;
  // welk menu werd nu getoond ? (assign currentMenu)
	for (i=1;i<=maxSubmenus;i++){
	  subel='submenu'+i;
	  el=document.getElementById(subel);
	  if(el && el.style.display=="block") currentMenu=subel;
  }

  // if(currentMenu) {
   // hide it if there was an active menu item
   // document.getElementById(currentMenu).style.display="none";
   // make menu item active if it was not previously active
   // if(currentMenu!=menu)
   // document.getElementById(menu).style.display="block";

   // de-highlight previous selected menu
	 // for (i=1;i<=maxSubmenus;i++){
	 //   subel='submenu'+i+'Text';
	 //   el=document.getElementById(subel);
	 //   if(el && el.className=="btnContinue") el.className=null;
   // }
   // alert(selectedMenu);
   // highlight select menu
   // if (selectedMenu)	document.getElementById("+ selectedMenu +").className="btnContinue";
  // }
  // else
  // geen active item gevonden, dus maak nu menu item active
  // {
    // alert('first time');
    // document.getElementById(menu).style.display="block";
    // document.getElementById("submenu1").style.display="block";
   //  document.getElementById("submenu1Text").style.display="block";
   // alert("na unhide");
  // }
}

function getScrollHeight()
{
   var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;

   return h ? h : 0;
}


// a) putting the onload to the iframe, the iframe re-configures the height everytime the iframe loads. Also,
// b) putting the f.style.height to change twice, the iframe has always the correct height, even if i go from a bigger to a smaller linked page.
// It works for me in ie v7, ff v3.0.7 and Chrome.

// Firefox worked fine. Internet Explorer shows scrollbar because of frameborder
// mvr 02/1/2010 15:20 werkt toch niet bij mij
function resizeFrame(f) {
	var s;
	s = 100;
	if (f.style) f.style.height = s;
	s = f.contentWindow.document.body.scrollHeight + "px";
	// alert ('s='+s);
	if (f.style) f.style.height = s;
}



// pas hoogte v.d. iframe autom. aan (anders bestaat gevaar dat content niet volledig zichtbaar is)
		// f.height=100; // truukje zie hieboven twice ... werkt niet
		// see http://www.codehouse.com/javascript/articles/scroll_area/
		// ie_the_height=f.contentWindow.document.body.scrollHeight;
		// alert (BrowserName);
	//find the height of the internal page
		// document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;
		// var ie_the_height=getScrollHeight();
		// Gecko browsers (Firefox) en Opera gebruiken blijkbaar clientHeight .. toch niet ...
	 	   // alert(' hoogte wordt niet correct berekend, daarom maar 220 bijgeteld');
	 	 	 // ff_the_height =250+f.contentWindow.document.body.parentNode.clientHeight;
	 	 	 // mvr 13/1/2010 15:32 bug corrected clientHeight vervangen door scrollHeight
		// alert('the_height='+the_height);
		//var the_height=document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;
function calcIframeHeightDO()
{
	var BrowserName = navigator.appName;
	var ie_the_height=0;
	var ff_the_height=0;
	var the_height=0;
	var f;
	if (document.getElementById('the_iframe')) {
	  f=document.getElementById('the_iframe');

		if (BrowserName=="Microsoft Internet Explorer") {
			 // ie_the_height=f.document.documentElement.scrollHeight;
			 ie_the_height=f.contentWindow.document.body.scrollHeight;
		}
		if (BrowserName!="Microsoft Internet Explorer") {
		  if(f.contentWindow) {
	 	 	 ff_the_height =f.contentWindow.document.body.parentNode.scrollHeight;
	 	 	}
		}
		if (ie_the_height>ff_the_height)  the_height= ie_the_height;
		else                              the_height= ff_the_height;
		if (the_height>0)	f.height=the_height + 40;
	}
}

function calcIframeHeight()
{
	calcIframeHeightDO();
	// werkt niet resizeFrame('the_iframe');
	// obsolete: wait 0.5 sec for the iframe to be fully loaded so the height can be calculated correctly (solves problem in Opera 9.6)
	// beter zou zijn te kunnen triggeren of iframe volledig geladen is
	// var BrowserName = navigator.appName;
	// alert(BrowserName);
  // if (BrowserName=="Opera") setTimeout('calcIframeHeightDO()', 500);
	// else                               	 calcIframeHeightDO();
  // if (BrowserName!="Microsoft Internet Explorer") {
    // alert("wait 2 secs before adapting the height of the iframe");
  	// setTimeout('calcIframeHeightDO()', 2000);
  // }

}
function detectOldIE()
{
  // alert('ie6?');
  // we supporteren I.E. 6 niet meer
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var msieVersion=b_version.indexOf('MSIE 6',1);
	// onderstaande er weer uitlaten
	// var version=parseFloat(b_version);
	// alert ('b_version='+b_version + ' is not correct bij IE');
	// alert ('msieVersion='+msieVersion);
	// alert ('browser='+browser);

	// mvr 21/8/2009 10:12 voorlopig uitgeschakeld want IE8 incompatible (zie pc arne)
	// if ((browser=="Microsoft Internet Explorer") && (msieVersion!='-1'))
  //	alert("Gelieve je browser te upgraden.\nGebruik Internet Explorer 7 of hoger. Of gebruik de meest recente versie van Firefox, Opera of Google Chrome.\nVeuillez utiliser un browser plus recent.\nPlease upgrade your browser.");
}

function maandJaar(maand,jaar) {
	  if (maand<10) document.write('<option style="width:5em" value="'+'0'+maand+'\/'+jaar+'">'+'0'+maand+'/'+jaar+'<\/option');
	  else	    document.write('<option style="width:5em" value="'+maand+'\/'+jaar+'<\/option');
	  return true;
}
function datumReeks() {
	var d=new Date();
	var maand=1+d.getMonth();
	var jaar=d.getFullYear();
	for (i=maand;i<13;i++) {maandJaar(i,jaar);}
	jaar=jaar+1;
	for (i=1;i<maand;i++){maandJaar(i,jaar);
	}
	return true;
}