
///////////// MAINFORMULES /////////////
var xmlhttp = false;
//Check if we are using IE.
try {
	//If the Javascript version is greater than 5.
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
	//If not, then use the older active x object.
	try {
		//If we are using Internet Explorer.
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
		//Else we must be using a non-IE browser.
		xmlhttp = false;
	}
}
//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	xmlhttp = new XMLHttpRequest();
}
function makerequest(serverPage, objID, objURL, vars) {
	var objURLfield = '';
	var fletchertxt = '';
	var subURL = '';
	if(objURL){
		setElmDisplay('blackout','');
		setElmDisplay('blackout_cnt','');
		objURLfield ='<input type="hidden" id="mb_url" value="' + objURL +'" />';
		if(vars){
			subURL = '&relationurl=' + objURL;
		}else{
			subURL = '?relationurl=' + objURL;
		}
	}
	xmlhttp.open("GET", serverPage + subURL);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			if(objURL == 'http://www.molenheide.be/de/promoties-met-code' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>242KS</b> aus bei Ihrer Buchung und Sie bekommen diese exklusive Ermäßigung.';}
			if(objURL == 'http://www.vliegles.nl/vlieglessen/1-1-1-1-437-1-0/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>TLVL12</b> aus bei Ihrer Buchung und Sie bekommen diese exklusive Ermäßigung.';}
			if(objURL == 'http://www.vliegles.nl/rondvluchten/1-1-1-1-451-1-0/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>TLRV12</b> aus bei Ihrer Buchung und Sie bekommen diese exklusive Ermäßigung.';}
			if(objURL == 'http://www.vliegles.nl/meer-vliegbelevenissen/paragliding/1-1-1-1-442-1-0/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>TLPG12</b> aus bei Ihrer Buchung und Sie bekommen diese exklusive Ermäßigung.';}
			if(objURL == 'http://www.vliegles.nl/parachutespringen/1-1-1-1-573-1-0/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>TLPS12</b> aus bei Ihrer Buchung und Sie bekommen diese exklusive Ermäßigung.';}
			if(objURL == 'http://www.vliegles.nl/zweefvliegen/1-1-1-1-439-1-0/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>TLZV12</b> aus bei Ihrer Buchung und Sie bekommen diese exklusive Ermäßigung.';}
			if(objURL == 'http://www.vliegles.nl/ballonvaren/1-1-1-1-532-1-0/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>TLBV12</b> aus bei Ihrer Buchung und Sie bekommen diese exklusive Ermäßigung.';}
			if(objURL == 'http://www.sandton.eu/driedaagsespecial' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>TRUE2012</b> tijdens uw boeking in bij promotiecode om te profiteren van deze exclusieve korting.';}
			if(objURL == 'http://slagharen.com/reserveren' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Noteer de kortingscode: <b>TRUE2011</b> om tijdens uw telefonische boeking te profiteren van deze exclusieve korting.';}
			if(objURL == 'http://www.roompot.nl/persoonlijkepas' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Noteer de kortingscode: <b>CC-Europe</b> om te profiteren van dit waanzinnige voordeel tijdens uw boeking.';}
			if(objURL == 'http://www.buroscanbrit.nl/vakantie' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>Z10059</b> tijdens uw boeking in bij het boekingsformulier en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'https://ticketing2.wheretocard.nl/duinrell/ctrl/promotionCodeLogin?webshoptype=promotion' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>Cadeautje</b> in en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.movieparkgermany.nl/Home/home_nl/Prijzen/Ticketinfoenonlinetickets/Actiecodeverzilveren/tabid/775/language/de-DE/Default.aspx' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>Carcard3eur</b> in en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.fletcher.nl' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>CC-Europe</b> in bij stap 3 van uw reservering en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.brabantia-webshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>B4EH7STDPA</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.hartmanwebshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.jardinwebshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.curverwebshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>425MQTJPX3</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.allibertwebshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.blomus-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.leitmotiv-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.medisanashop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.beurershop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.suckuk-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.gadgetfabriek.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>WZ959P54ZP</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.brassa.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.mondaine-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.alessi-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.menu-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.apartdesign.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.nonplusultra.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.jacobjensenwebshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.vacuvin-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.babyliss-shop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.remington-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>B4EH7STDPA</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.rowenta-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>B4EH7STDPA</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.braun-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>B4EH7STDPA</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.jamie-oliver-shop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.bredemeijer-webshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.bk-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.peugeot-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>B4EH7STDPA</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.tefalpannen-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>B4EH7STDPA</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.bodum-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.josephjoseph-webshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.solis-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>B4EH7STDPA</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.colemason-webshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.cuisinartshop.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>BGKXKHEY52</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.sabatier-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>B4EH7STDPA</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.skandia-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>B4EH7STDPA</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.altrex-by-fonq.nl/informatie/cceurope/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>425MQTJPX3</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.beddengoedonline.nl/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>CC-Europe</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.bedbad.nl/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>CC-Europe</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.shop4fans.nl/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>CC-Europe</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.babyandkidsplanet.nl/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>CC-Europe</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
			if(objURL == 'http://www.camerabrillen.nl/' && jstr_count('Sie sind eingeloggt',xmlhttp.responseText)){fletchertxt = ' Füllen Sie die Aktionskode: <b>CC-Europe</b> in tijdens het afrekenen en profiteer van dit exclusieve voordeel.';}
setElminnerHTML(objID,objURLfield + xmlhttp.responseText + fletchertxt);
			if(fieldexists('vc_logincheck')){
				if(getElmVal('vc_logincheck') == 'valid'){
					window.open('ulogin_pageopener.php?url=' + getElmVal('mb_url'));
					setElmDisplay('blackout','none');
					setElmDisplay('blackout_cnt','none');
				}
			}
		}
	}
	xmlhttp.send(null);
}
function popup(URL,fotohor,fotover,scrolls) {
midhor=""
midver=""
minhor=(screen.availwidth-8)
minver=(screen.availheight-35)
Day = new Date()
id = Day.getTime()

if ((screen.availheight < fotover) || (screen.availwidth < fotohor))
{eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=" + scrolls + ",location=0,statusbar=0,menubar=0,resizable=0,width=" + minhor + ",height=" + minver + ",left = 0,top = 0');");
}
else
{midhor=((screen.availwidth-fotohor)/2);
midver=((screen.availheight-fotover)/2);
if(fotover == 0){fotover = screen.availheight - 75;
	midver=0;
}
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=" + scrolls + ",location=0,statusbar=0,menubar=0,resizable=0,width=" + fotohor + ",height=" + fotover + ",left = " + midhor + ",top = " + midver + "');");
}
}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return false;
		}	
	} 
		
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return -1;		
		} 
	}
}

//////////////////////////////// CALENDARCONTROL ///////////////////
//////////////////////////////// CALENDARCONTROL ///////////////////
function positionInfo(object) {

  var p_elm = object;

  this.getElementLeft = getElementLeft;
  function getElementLeft() {
    var x = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      x+= elm.offsetLeft;
      elm = elm.offsetParent;
    }
    return parseInt(x);
  }

  this.getElementWidth = getElementWidth;
  function getElementWidth(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetWidth);
  }

  this.getElementRight = getElementRight;
  function getElementRight(){
    return getElementLeft(p_elm) + getElementWidth(p_elm);
  }

  this.getElementTop = getElementTop;
  function getElementTop() {
    var y = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      y+= elm.offsetTop;
      elm = elm.offsetParent;
    }
    return parseInt(y);
  }

  this.getElementHeight = getElementHeight;
  function getElementHeight(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetHeight);
  }

  this.getElementBottom = getElementBottom;
  function getElementBottom(){
    return getElementTop(p_elm) + getElementHeight(p_elm);
  }
}

function CalendarControl() {

  var calendarId = 'CalendarControl';
  var currentYear = 0;
  var currentMonth = 0;
  var currentDay = 0;

  var selectedYear = 0;
  var selectedMonth = 0;
  var selectedDay = 0;

  var months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'];
  var dateField = null;

  function getProperty(p_property){
    var p_elm = calendarId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if (elm != null){
      if(elm.style){
        elm = elm.style;
        if(elm[p_property]){
          return elm[p_property];
        } else {
          return null;
        }
      } else {
        return null;
      }
    }
  }

  function setElementProperty(p_property, p_value, p_elmId){
    var p_elm = p_elmId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if((elm != null) && (elm.style != null)){
      elm = elm.style;
      elm[ p_property ] = p_value;
    }
  }

  function setProperty(p_property, p_value) {
    setElementProperty(p_property, p_value, calendarId);
  }

  function getDaysInMonth(year, month) {
    return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
  }

  function getDayOfWeek(year, month, day) {
    var date = new Date(year,month-1,day)
    return date.getDay();
  }

  this.clearDate = clearDate;
  function clearDate() {
    dateField.value = '';
    hide();
  }

  this.setDate = setDate;
  function setDate(year, month, day) {
    if (dateField) {
      if (month < 10) {month = "0" + month;}
      if (day < 10) {day = "0" + day;}

      var dateString = day+"-"+month+"-"+year;
      dateField.value = dateString;
      hide();
    }
    return;
  }

  this.changeMonth = changeMonth;
  function changeMonth(change) {
    currentMonth += change;
    currentDay = 0;
    if(currentMonth > 12) {
      currentMonth = 1;
      currentYear++;
    } else if(currentMonth < 1) {
      currentMonth = 12;
      currentYear--;
    }

    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  this.changeYear = changeYear;
  function changeYear(change) {
    currentYear += change;
    currentDay = 0;
    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  function getCurrentYear() {
    var year = new Date().getYear();
    if(year < 1900) year += 1900;
    return year;
  }

  function getCurrentMonth() {
    return new Date().getMonth() + 1;
  } 

  function getCurrentDay() {
    return new Date().getDate();
  }

  function calendarDrawTable() {

    var dayOfMonth = 1;
    var validDay = 0;
    var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
    var daysInMonth = getDaysInMonth(currentYear, currentMonth);
    var css_class = null; //CSS class for each day

    var table = "<table cellspacing='0' cellpadding='0' border='0'>";
    table = table + "<tr class='header'>";
    table = table + "  <td colspan='2' class='previous'><a href='javascript:changeCalendarControlMonth(-1);'>&lt;</a> <a href='javascript:changeCalendarControlYear(-1);'>&laquo;</a></td>";
    table = table + "  <td colspan='3' class='title'>" + months[currentMonth-1] + "<br>" + currentYear + "</td>";
    table = table + "  <td colspan='2' class='next'><a href='javascript:changeCalendarControlYear(1);'>&raquo;</a> <a href='javascript:changeCalendarControlMonth(1);'>&gt;</a></td>";
    table = table + "</tr>";
    table = table + "<tr><th>M</th><th>D</th><th>W</th><th>D</th><th>V</th><th>Z</th><th>Z</th></tr>";

    for(var week=0; week < 6; week++) {
      table = table + "<tr>";
      for(var idayOfWeek=1; idayOfWeek < 8; idayOfWeek++) {
      	if(idayOfWeek == 7){dayOfWeek = 6;}else{dayOfWeek = idayOfWeek;}
        if(week == 0 && startDayOfWeek == dayOfWeek) {
          validDay = 1;
        } else if (validDay == 1 && dayOfMonth > daysInMonth) {
          validDay = 0;
        }

        if(validDay) {
          if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
            css_class = 'current';
          } else if (dayOfWeek == 0 || dayOfWeek == 6) {
            css_class = 'weekend';
          } else {
            css_class = 'weekday';
          }

          table = table + "<td><a class='"+css_class+"' href=\"javascript:setCalendarControlDate("+currentYear+","+currentMonth+","+dayOfMonth+")\">"+dayOfMonth+"</a></td>";
          dayOfMonth++;
        } else {
          table = table + "<td class='empty'>&nbsp;</td>";
        }
      }
      table = table + "</tr>";
    }

    table = table + "<tr class='header'><th colspan='7' style='padding: 3px;'><a href='javascript:hideCalendarControl();'>Sluiten</a></td></tr>";
    table = table + "</table>";

    return table;
  }

  this.show = show;
  function show(field) {
    can_hide = 0;
  
    // If the calendar is visible and associated with
    // this field do not do anything.
    if (dateField == field) {
      return;
    } else {
      dateField = field;
    }

    if(dateField) {
      try {
        var dateString = new String(dateField.value);
        var dateParts = dateString.split("-");
        
        selectedDay = parseInt(dateParts[0],10);
        selectedMonth = parseInt(dateParts[1],10);
        selectedYear = parseInt(dateParts[2],10);
      } catch(e) {}
    }

    if (!(selectedYear && selectedMonth && selectedDay)) {
      selectedMonth = getCurrentMonth();
      selectedDay = getCurrentDay();
      selectedYear = getCurrentYear();
    }

    currentMonth = selectedMonth;
    currentDay = selectedDay;
    currentYear = selectedYear;

    if(document.getElementById){

      calendar = document.getElementById(calendarId);
      calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);

      setProperty('display', 'block');

      var fieldPos = new positionInfo(dateField);
      var calendarPos = new positionInfo(calendarId);

      var x = fieldPos.getElementLeft();
      var y = fieldPos.getElementBottom();

      setProperty('left', x + "px");
      setProperty('top', y + "px");
 
      if (document.all) {
        setElementProperty('display', 'block', 'CalendarControlIFrame');
        setElementProperty('left', x + "px", 'CalendarControlIFrame');
        setElementProperty('top', y + "px", 'CalendarControlIFrame');
        setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame');
        setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame');
      }
    }
  }

  this.hide = hide;
  function hide() {
    if(dateField) {
      setProperty('display', 'none');
      setElementProperty('display', 'none', 'CalendarControlIFrame');
      dateField = null;
    }
  }

  this.visible = visible;
  function visible() {
    return dateField
  }

  this.can_hide = can_hide;
  var can_hide = 0;
}

var calendarControl = new CalendarControl();

function showCalendarControl(textField) {
  // textField.onblur = hideCalendarControl;
  calendarControl.show(textField);
}

function clearCalendarControl() {
  calendarControl.clearDate();
}

function hideCalendarControl() {
  if (calendarControl.visible()) {
    calendarControl.hide();
  }
}

function setCalendarControlDate(year, month, day) {
  calendarControl.setDate(year, month, day);
}

function changeCalendarControlYear(change) {
  calendarControl.changeYear(change);
}

function changeCalendarControlMonth(change) {
  calendarControl.changeMonth(change);
}

document.write("<iframe id='CalendarControlIFrame' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>");
document.write("<div id='CalendarControl'></div>");

/////// INFRAME POPUP /////////
////// onClick="imagehere.src='/bijzonder/images//satelliet/0708NOAAAZIE_zgr.jpg'; showbox();//////////


/******************************************
* Popup Box- By Jim Silver @ jimsilver47@yahoo.com
* Visit http://www.dynamicdrive.com/ for full source code
* This notice must stay intact for use
******************************************/

var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////


function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")

////drag drop functions end here//////

function showbox(){
	crossobj=ns6? document.getElementById("showimage") : document.all.showimage
	if (ie4||ns6) {
		crossobj.style.top=document.documentElement.scrollTop+50;
		crossobj.style.visibility="visible"
	}else if (ns4){
		document.showimage.top=document.documentElement.scrollTop+50;
		document.showimage.visibility="visible"
	}
}

function hidebox(){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
if (ie4||ns6)
crossobj.style.visibility="hidden"
else if (ns4)
document.showimage.visibility="hide"
}
	
