var editor = null;
var x      = 0;
var headerfotos = new Array;
var headernr = 0;
var submenu_breedtes = new Array;
var gallerij_fotos = new Array;
var gallerij_pointer = 0;

function popUp(URL, breed, hoog) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=" + breed + ",height=" + hoog + ",left=150,top=150');");
}

function setOpacity(obj, value) {
	obj.style.opacity = value/10;
	obj.style.filter = 'alpha(opacity=' + value + ')';
}

function popUpcontent(name, inhoud, breed, hoog) {
  var generator=window.open(name,'popup','height=' + hoog + ',width=' + breed + 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left=150,top=150');
  generator.document.write('<html><head><title>' + name + '</title><link rel="stylesheet" href="/css/site_popup.css" type="text/css"/></head><body>');
  generator.document.write(inhoud);
  generator.document.write('</body></html>');
  generator.document.close();
}

function htmlarealaden () {
	if (typeof (velden) == "object") {
		for (x=0; x < velden.length; x++) { 
		  if (velden[x][1]) {
        var editor = CKEDITOR.replace( velden[x][0], { height: velden[x][1] } );
			} else {
        var editor = CKEDITOR.replace( velden[x][0] );
			}		
      
			//CKFinder.setupCKEditor( editor, '/jsf/ckeditor/ckfinder/' );		
		}
	}
}

function putfocus (formInst, elementInst) {
	if (document.forms.length > 0) {
		document.forms[formInst].elements[elementInst].focus();
		document.forms[formInst].elements[elementInst].select();
	}
}

function parsepagina () {
	htmlarealaden ();
	
	/*
	if (isset('texts')) {
	  fade();
	}
	*/
	
	if (headerfotos.length) {
	  setInterval('headerFoto()', 5000);
	} 
	
	//browserCheck();
}

function isset(variable_name)
{
try
{
if (typeof(eval(variable_name)) != 'undefined')
if (eval(variable_name) != null)
return true;
} catch(e) { }

return false;
}



window.onload = parsepagina;

function in_array(my_array,my_value){
	caseSensitive = in_array.arguments.length<3?0:in_array.arguments[2];

	for(i=0;i<my_array.length;i++){
		if((caseSensitive==0?my_array[i]:my_array[i].toUpperCase())==(caseSensitive==0?my_value:my_value.toUpperCase())){
			return true;
		}
	}

	return false;
}

function hasOptions(obj) {if (obj!=null && obj.options!=null) { return true; }	return false;}
function swapOptions(obj,i,j) {	var o = obj.options;	var i_selected = o[i].selected;	var j_selected = o[j].selected;	var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);	o[i] = temp2;o[j] = temp;o[i].selected = j_selected;o[j].selected = i_selected;}
function moveOptionUp(obj) {if (!hasOptions(obj)) { return; }	for (i=0; i<obj.options.length; i++) {if (obj.options[i].selected) {if (i != 0 && !obj.options[i-1].selected) { swapOptions(obj,i,i-1);	obj.options[i-1].selected = true;}}} volgordeclasses ();}
function moveOptionDown(obj) {if (!hasOptions(obj)) { return; }	for (i=obj.options.length-1; i>=0; i--) {if (obj.options[i].selected) {if (i != (obj.options.length-1) && ! obj.options[i+1].selected) { swapOptions(obj,i,i+1);	obj.options[i+1].selected = true; }}} volgordeclasses ();}
function submitForm(url, veld) { var	list = document.getElementById(veld); 	var velden = '';	for (i = 0; i <= list.options.length - 1; i++) { 	velden = velden + '_SPLIT_' + list.options[i].value;}	window.location.href = url + velden; }
function volgordeclasses () {
	list		= document.getElementById('volgorde');
	var	kleur	= 'nee';

	for (i = 0; i <= list.options.length - 1; i++) {
		if (kleur == 'ja') {
			list.options[i].className = 'een';
			kleur = 'nee';
		} else {
			list.options[i].className = 'twee';
			kleur = 'ja';
		}

		if (typeof(volgordetitel) == "object") {
			for (a=0;a < volgordetitel.length;a++) {
				if (volgordetitel[a] == list.options[i].value) {
						list.options[i].style.color = 'red';
				}
			}
		}
	}
}

function submenu_open (nr) {
  if (document.getElementById('submenu_' + nr)) {
  	box = document.getElementById('submenu_' + nr);
  	box.style.display = 'block';
  	box.style.width   = document.getElementById('topitem_' + nr).offsetWidth + 1;
  }

	document.getElementById('topimg_' + nr + 'a').style.display = 'none';
	document.getElementById('topimg_' + nr + 'b').style.display = 'block';
}

function submenu_sluit (nr) {
  if (document.getElementById('submenu_' + nr)) {
	  box = document.getElementById('submenu_' + nr);
	  box.style.display = 'none';
  }

	document.getElementById('topimg_' + nr + 'b').style.display = 'none';
	document.getElementById('topimg_' + nr + 'a').style.display = 'block';
}

function weergeefSWF(src, width, height) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
		document.write('  <param name="movie" value="' + src + '">');
		document.write('  <param name=quality value=high>');
		document.write('  <param name="allowScriptAccess" value="always" />');
		document.write('  <param name="wmode" value="transparent" /><param name="SCALE" value="exactfit">');
		document.write('  <embed wmode="transparent" src="' + src + '" width="' + width + '" height="' + height + '" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" scale="exactfit"></embed>');
		document.write('</object>');
}

function weergeefStemmen(id) {
    var width = 120;
		var height= 50;
		var src = '/swf/rating_id.swf?id=' + id;
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
		document.write('  <param name="movie" value="' + src + '">');
		document.write('  <param name=quality value=high>');
		document.write('  <param name="allowScriptAccess" value="always" />');
		document.write('  <param name="wmode" value="transparent" /><param name="SCALE" value="exactfit">');
		document.write('  <embed wmode="transparent" src="' + src + '" width="' + width + '" height="' + height + '" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" scale="exactfit"></embed>');
		document.write('</object>');
}


function weergeefLogo() {
		document.write('<a id="site_logo" href="http://www.europarcs.nl/" title="Europarcs"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="169" height="107">');
		document.write('  <param name="movie" value="' + webadres + 'img/design/logo.swf">');
		document.write('  <param name=quality value=high>');
		document.write('  <param name="allowScriptAccess" value="always" />');
		document.write('  <param name="wmode" value="transparent" /><param name="SCALE" value="exactfit">');
		document.write('  <embed wmode="transparent" src="' + webadres + 'img/design/logo.swf" width="169" height="107" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" scale="exactfit"></embed>');
		document.write('</object></a>');
}

function weergeefLandkaart() {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="164" height="240">');
		document.write('   <param name="movie" value="/swf/kaart.swf">');
		document.write('   <param name="quality" value="high">');
		document.write('  <param name="wmode" value="transparent" />');		
		document.write('   <embed wmode="transparent" src="/swf/kaart.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="164" height="240"></embed>');
		document.write('</object>');
}

function advertentieFotos(fotos) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="300" height="200" align="right" style="margin: 5px">');
		document.write('  <param name="movie" value="' + webadres + 'swf/fotos.swf">');
		document.write('  <param name=quality value=high>');
		document.write('  <param name="allowScriptAccess" value="always" />');
		document.write('  <param name="wmode" value="transparent" /><param name="SCALE" value="exactfit">');
		document.write('  <param name="FlashVars" value="fotos=' + fotos + '">');
		document.write('  <embed wmode="transparent" flashvars="fotos=' + fotos + '" src="' + webadres + 'swf/fotos.swf" width="300" height="200" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" scale="exactfit"></embed>');
		document.write('</object>');
}

function weergeefVideos() {
    //document.write('<iframe width=640 border=0 frameborder=0 height=500 src="/videos/"></iframe>');
		
		
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="635" height="331">');
		document.write('          <param name="movie" value="' + webadres + 'videos/list.swf">');
		document.write('          <param name="quality" value="high">');
		document.write('          <embed src="' + webadres + 'videos/list.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="635" height="331"></embed>');
		document.write('        </object>');
		
}

function naarPark(url) {
  if (url) {
	  document.location.href = url;
	}
}

function openSubmenu(nr) {
  box = document.getElementById('submenu_' + nr);
	box.style.display = 'block';

	// Dit is een belachelijke fix omdat IE6 en IE7 de breedte van het submenu wel kennen, maar niet toepassen. Mag ook maar 1x per submenu uitgevoerd worden, anders gaat het ook mis
  	if (submenu_breedtes[nr] != 'ja') {
  	  box.style.width = box.offsetWidth;
  		submenu_breedtes[nr] = 'ja';
  	}
	
  box = document.getElementById('topa_' + nr);
	box.className = 'topactief';	
}

function sluitSubmenu(nr) {
  box = document.getElementById('submenu_' + nr);
	box.style.display = 'none';
	
  box = document.getElementById('topa_' + nr);
	box.className = 'topa';		
}

function openSubSubmenu(nr) {
  box = document.getElementById('subsubmenu_' + nr);
	box.style.display = 'block';

	// Dit is een belachelijke fix omdat IE6 en IE7 de breedte van het submenu wel kennen, maar niet toepassen. Mag ook maar 1x per submenu uitgevoerd worden, anders gaat het ook mis
	/*
  	if (submenu_breedtes[nr] != 'ja') {
  	  box.style.width = box.offsetWidth;
  		submenu_breedtes[nr] = 'ja';
  	}
		*/
	
	/*
  box = document.getElementById('topa_' + nr);
	box.className = 'topactief';	
	*/
}

function sluitSubSubmenu(nr) {
  box = document.getElementById('subsubmenu_' + nr);
	box.style.display = 'none';
	
	/*
  box = document.getElementById('topa_' + nr);
	box.className = 'topa';
	*/		
}

function controleerNieuwsbrief() {
  box1 = document.getElementById('nieuwsbrief_naam');
  box2 = document.getElementById('nieuwsbrief_email');
	
	if (!box1.value || box1.value == 'Naam') {
	  alert ('Er is geen naam ingevuld.');
	} else if (!box2.value || box2.value == 'E-mail adres') {
	  alert ('Er is geen e-mail adres ingevuld.');
	} else {
	  return true;
	}
	
	return false;	
}

function controleerActieAanmelden() {
  box1 = document.getElementById('actie_naam');
  box2 = document.getElementById('actie_email');
  box3 = document.getElementById('actie_telefoon');
	
	if (!box1.value || !box2.value || !box3.value) {
	  alert('Niet alle velden zijn ingevuld.');
		return false;
	} else {
	  return true;
	}
}

function controleerReactie() {
  box1 = document.getElementById('reageer_naam');
  box2 = document.getElementById('reageer_email');
  box3 = document.getElementById('reageer_titel');
  box4 = document.getElementById('reageer_inhoud');	
	
	if (!box1.value || !box2.value || !box3.value || !box4.value) {
	  alert('Niet alle velden zijn ingevuld.');
		return false;
	} else {
	  return true;
	}
}

function weergeefReserveren() {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="207" height="35">');
		document.write('   <param name="movie" value="/swf/boeknu.swf">');
		document.write('   <param name="quality" value="high">');
		document.write('  <param name="wmode" value="transparent" />');		
		document.write('   <embed wmode="transparent" src="/swf/boeknu.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="207" height="35"></embed>');
		document.write('</object>');
}

function headerFoto() {
  headernr++;

	if (headernr >= headerfotos.length) {
	  headernr = 0;
	}
	
  blendimage('fader', 'headerfoto', '/php/verwerk/bestanden.php?code=' + headerfotos[headernr], 1000);
}

function blendimage(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //make image transparent 
    changeOpac(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
} 

function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function veranderFoto(src, nr, klik) {
  if (klik) {
  	fotoPause();	
	}
	
  blendimage('foto', 'fotoinhoud', '/php/verwerk/bestanden.php?code=' + src, 1000);
	huidigefoto = nr;
}





var Browser = {
  Version: function() {
    var version = 999; // we assume a sane browser
    if (navigator.appVersion.indexOf("MSIE") != -1)
      // bah, IE again, lets downgrade version number
      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    return version;
  }
}


function browserCheck()
{
	if (Browser.Version())
	{
		var list = document.getElementById("topmenu_ul_check");
		var count_sub = list.getElementsByTagName("ul");
		var setWidth;

		if(list != null)
		{
			for(i=0; i < count_sub.length; i++)
			{
				var list_elements;
				//count_sub[i].style.width = "400px";
				setWidth = count_sub[i].offsetWidth;

				list_elements = count_sub[i].getElementsByTagName("li");

				for(ia=0; ia < list_elements.length; ia++)
				{
					//list_elements[ia].style.width = setWidth;
				}
			}
		}
	}
}

function getWidth(object)
{
	var count_sub = object.getElementsByTagName("ul");
	var setWidth = count_sub[0].offsetWidth;

	list_elements = count_sub[0].getElementsByTagName("li");

	for(i=0; i < list_elements.length; i++)
	{
		list_elements[i].style.width = setWidth;
	}
}

function trLocatie(url) {
  document.location.href = url;
}

function galleryLeft() {
  var box1 = document.getElementById('ad_afbeelding_vorige');
  var box2 = document.getElementById('ad_afbeelding_volgende');
  var box3 = document.getElementById('ad_afbeelding_bg');
  var box4 = document.getElementById('ad_afbeelding_img');
	
	nu_img = gallerij_fotos[gallerij_pointer];
	
	gallerij_pointer = gallerij_pointer - 1;	
	
	next_img = gallerij_fotos[gallerij_pointer];	
	
	blendimage('ad_afbeelding_bg', 'ad_afbeelding_img', '/php/verwerk/bestanden.php?code=' + next_img, 1000);
	
//	alert(gallerij_fotos[gallerij_pointer]);

  if (gallerij_pointer == 0) {
	  box1.style.display = 'none';
	}
	
	box2.style.display = 'block';
}

function galleryRight() {
  var box1 = document.getElementById('ad_afbeelding_vorige');
  var box2 = document.getElementById('ad_afbeelding_volgende');
  var box3 = document.getElementById('ad_afbeelding_bg');
  var box4 = document.getElementById('ad_afbeelding_img');
	
	box1.style.display = 'block';
	
	nu_img = gallerij_fotos[gallerij_pointer];	
	
	gallerij_pointer = gallerij_pointer + 1;	
	
	next_img = gallerij_fotos[gallerij_pointer];
	
	blendimage('ad_afbeelding_bg', 'ad_afbeelding_img', '/php/verwerk/bestanden.php?code=' + next_img, 1000);
	
	if (gallerij_pointer == gallerij_fotos.length - 1) {
	  box2.style.display = 'none';
	}	
}


$(document).ready(function(){
  setInterval('volgendNieuwsItem()', 4000);
  
  $('#brochureKnop').click(function() {
    $(this).fadeOut('fast', function() {
      $('#brochureFormulier').html('<iframe src="/php/verwerk/vakantiebrochure.php" border="0" frameborder="0" allowtransparency="true"></iframe><a class="buttonSluiten"></a>').fadeIn();
      $('.buttonSluiten').click(function() {
        $('#brochureFormulier').fadeOut('fast', function() {
          $(this).html('');
          $('#brochureKnop').fadeIn('fast');
        });
      });
    });
  });
	
	// Lightbox
    $('.thumbnails a, .lightbox').lightBox();

    $('#ad_afbeelding_img').click(function () { $('.thumbnails').find('a:first').click();  });
		
		$('.vorigeIMG img').click(function() {
		   $('.volgendeIMG img').fadeIn();
			 
			 IMGpointer--;
			 
			 var src = $('.thumbnails').find('li:nth-child(' + IMGpointer + ')').find('a').attr('href');
			 var aantal = $('.thumbnails').find('li').length;
			 
			 $('#ad_afbeelding_img').attr('src', src);
			 
			 if (IMGpointer == 2) {
			   $(this).fadeOut();
			 }
		});		
		
		$('.volgendeIMG img').click(function() {
		   $('.vorigeIMG img').fadeIn();
			 
			 IMGpointer++;
			 
			 var src = $('.thumbnails').find('li:nth-child(' + IMGpointer + ')').find('a').attr('href');
			 var aantal = $('.thumbnails').find('li').length;
			 
			 $('#ad_afbeelding_img').attr('src', src);
			 
			 if (IMGpointer >= aantal - 1) {
			   $(this).fadeOut();
			 }
		}); 
});

function volgendNieuwsItem() {
  $('.nieuwslezer .actief').fadeOut('fast', function() {
	  $(this).removeClass('actief');

		if($(this).next().length > 0) {
  		$(this).next().addClass('actief').fadeIn('fast');
		} else {
		  $('.nieuwslezer a').first().addClass('actief').fadeIn('fast');
		}
	});
}


