var editor = null;
var x      = 0;
var sloganTeller = 1;

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 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++) { 
        var oFCKeditor = new FCKeditor( velden[x] ) ;
        oFCKeditor.BasePath = "/jsf/fckeditor/" ;
        oFCKeditor.Height	= 350;
        /* oFCKeditor.Config['ToolbarStartExpanded'] = false ; */								
        oFCKeditor.ReplaceTextarea();		
		}
	}
}

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

function parsepagina () {
	htmlarealaden ();

  var config = {    
     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
     interval: 50, // number = milliseconds for onMouseOver polling interval  
     timeout: 100, // number = milliseconds delay before onMouseOut       
     over: function(){
      $(this).addClass('actief');
      
	    if($('.submenu:first',this).css('display') != 'block') {
	      $('.submenu:first',this).slideDown('fast');
      }
    },    
     out: function(){
      $(this).removeClass('actief');
      
      if($('.submenu:first',this).css('display') == 'block') {
	      $('.submenu:first',this).slideUp('fast');
      }
    }
  };  
  
  $(".hoofdItem").hoverIntent(config);  
  
  //$('.slogans .slogan').hide();
	
	if($('.slogans').find('.slogan').length > 1) {
    slogansTimer = setInterval('volgendeSlogan()', 5000);
  }
  $('.slogans .actief').fadeIn();
  
  
  $('#footerLogosRight').hoverIntent(function () {
    footerLogosTimer = setInterval('verplaatsFooterLogosNaarRechts(200)', 1300);
    verplaatsFooterLogosNaarRechts(800);
  }, function() {
    clearInterval(footerLogosTimer);
  });
  
  $('#footerLogosLeft').hoverIntent(function () {
    footerLogosTimer = setInterval('verplaatsFooterLogosNaarLinks(200)', 1300);
    verplaatsFooterLogosNaarLinks(800);
  }, function() {
    clearInterval(footerLogosTimer);
  }); 
  
  $('#logosRight').hoverIntent(function () {
    logosTimer = setInterval('verplaatsLogosNaarRechts(10)', 50);
    verplaatsLogosNaarRechts(5);
  }, function() {
    clearInterval(logosTimer);
  });
  
  $('#logosLeft').hoverIntent(function () {
    logosTimer = setInterval('verplaatsLogosNaarLinks(10)', 50);
    verplaatsLogosNaarLinks(5);
  }, function() {
    clearInterval(logosTimer);
  });    
}

function volgendeSlogan() {
  var slogans = $('.slogans').find('.slogan');
  var aantal = slogans.length;
  
  sloganTeller++;  

  if (sloganTeller > aantal) {
    sloganTeller = 1;
  }  
  
  if ($('.slogans .actief').length) {
    $('.slogans .actief').slideToggle(function () {

      $(this).removeClass('actief');
    
      $('.slogans').find('.slogan:nth-child(' + sloganTeller + ')').each(function () {
        $(this).slideToggle();
        $(this).addClass('actief');
      });
    });
  }
}

function verplaatsFooterLogosNaarRechts(verplaats) {
  var width = $('#footerLogos .innerLogos').width()
  var baseWidth = $('#footerLogos').width()
  var scrollWidth = $('#footerLogos').scrollLeft() + baseWidth;

  if (scrollWidth + verplaats >= width) {
    $('#footerLogosRight').removeClass('actief');
  } else {
    if (!$('#footerLogosLeft').hasClass('actief')) {
      $('#footerLogosLeft').addClass('actief');
    }
    
    $('#footerLogos').scrollTo( {top:0, left:'+=' + verplaats}, 800 );
  }
}

function verplaatsFooterLogosNaarLinks(verplaats) {
  if (!$('#footerLogosRight').hasClass('actief')) {
    $('#footerLogosRight').addClass('actief');
  }
  
  $('#footerLogos').scrollTo( {top:0, left:'-=' + verplaats}, 800 );

  var scrollWidth = $('#footerLogos').scrollLeft();

  if (scrollWidth - verplaats <= 0) {
    $('#footerLogosLeft').removeClass('actief');
  }     
}

function verplaatsLogosNaarRechts(verplaats) {
  var width = $('#logos .innerLogos table').width()
  var baseWidth = $('#logos .innerLogos').width()
  var scrollWidth = $('#logos .innerLogos').scrollLeft() + baseWidth;

  if (scrollWidth + verplaats >= width) {
    $('#logosRight').removeClass('actief');
  } else {
    if (!$('#logosLeft').hasClass('actief')) {
      $('#logosLeft').addClass('actief');
    }
    
    $('#logos .innerLogos').scrollTo( {top:0, left:'+=' + verplaats}, 50 );
  }
}

function verplaatsLogosNaarLinks(verplaats) {
  if (!$('#logosRight').hasClass('actief')) {
    $('#logosRight').addClass('actief');
  }
  
  $('#logos .innerLogos').scrollTo( {top:0, left:'-=' + verplaats}, 50 );

  var scrollWidth = $('#logos .innerLogos').scrollLeft();

  if (scrollWidth - verplaats <= 0) {
    $('#logosLeft').removeClass('actief');
  }     
}

function sluitsubmenu(nr) {
  $('#topmenu #' + nr + ' .submenu:visible').slideUp();
  $('#topmenu #' + nr).removeClass('actief');
}

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 weergeefSWF(src, width, height, id, flashvars) {
   document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" id="' + id + '" align="middle">');
   document.write('<param name="wmode" value="transparent"><param name="flashvars" value="' + flashvars + '"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + webadres + 'swf/' + src + '" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />');
   document.write('<embed src="' + webadres + 'swf/' + src + '" flashvars="' + flashvars + '" wmode="transparent" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="' + id + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
   document.write('</object>');
}

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