var errorMsg = "gelieve&nbsp;alle&nbsp;verplichte&nbsp;velden&nbsp;correct&nbsp;in&nbsp;te&nbsp;vullen";
	
function rollOver(evt) {
	evt.style.background = "#" + moodColor;
}

function rollOut(evt) {
	evt.style.background = "";
}

function submitUserDataForm(form) {
	formId = form;
	jQuery("#" + formId + "_errors").html("<span class='loading'>bezig&nbsp;met&nbsp;laden</span>");
	var params = Form.serialize(formId)
	params += "&form_name=" + form;

	jQuery.ajax({
		   type: "POST",
		   url: "/ajax/validate-user-data-form/",
		   data: params,
		   success: function(msg){
				if (msg.indexOf("id=") == -1) {
					jQuery("#" + formId + "_errors").html("<span class='error'>" + errorMsg + "</span>");
					
					var array = eval( '(' + msg + ')' );
	
					if (array.length > 0) {
						for(var i = 0;i<array.length;i++) {
							var _obj = document.getElementById(array[i]);
							_obj.className = "textfield_error";
						}	
					} 
				}else {
					msg = eval(msg);
					var id = msg.split("id=").join("");
					resultUserDataForm(id);
				}
		   }
		 });
	
	return false;
}

var formId = null;
var click_sub = null;

/**
 * in het begin wordt er maar een deel van het nieuwsbrief formulier getoond,
 * vanaf wanneer het de focus heeft, helemaal tonen
 * @param evt
 * @return
 */
function showNewsletter(evt) {
	
	removeError("form_newsletter",evt);
	var _obj = document.getElementById("newsletter");
	_obj.style.visibility = "visible";
	_obj.style.height = "100%";
}


function removeError(form,evt)
{
	evt.className = "textfield";
	var _obj = document.getElementById(form + "_errors");
	_obj.innerHTML = "";
}

function init()
{
	var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }


	if (myWidth < 1000) {
		this.moveTo(0,0);
		resizeTo(screen.availWidth,screen.width);
	}
	
}

init();

/**
 * submit van het nieuwsbrief inschrijvings formulier via ajax laten verlopen
 * @param form
 * @return
 */
function submitNewsletterForm(form) {
    formId = form;
	var _obj = document.getElementById(formId + "_errors");
	_obj.innerHTML = "<span class='loading'>bezig&nbsp;met&nbsp;laden</span>";
	
	var params = Form.serialize(formId)

	jQuery.ajax({
		   type: "POST",
		   url: "/ajax/validate-newsletter/",
		   data: params,
		   success: function(msg){
				var array = eval( '(' + msg + ')' );
				if (array.length > 0) {
					jQuery("#" + formId + "_errors").html("<span class='error'>" + errorMsg + "</span>");
					
					for(var i = 0;i<array.length;i++) {
						var _obj = document.getElementById(array[i]);
						if (_obj) {
							_obj.className = "textfield_error";
						}
					}	
				} else {
					var _obj = document.getElementById("newsletter_holder");
					_obj.innerHTML = "inschrijving gelukt";					
				}
		   }
		 });
	
	return false;
}

function embedYoutube(videoId, divId)
{
    var youtubeSO = new SWFObject("http://www.youtube.com/v/" + videoId + "&enablejsapi=1&playerapiid=ytplayer", divId,"480","290", "8", "#FFFFFF");
	youtubeSO.addParam("allowScriptAccess", "always");
	youtubeSO.addParam("wmode", "transparent");
	youtubeSO.setAttribute("id", "myytplayer");
	youtubeSO.write(divId);
}
function fotoFullscreen(url,caption) {
	Lightbox.prototype.start_array(url,caption);
}
function search(evt)
{
	var searchString = document.getElementById("inputSearch").value;
	openPage("search/index/q/" + searchString + "/page/1");
}
function multisort(arrayOfArrays){
	if(!arrayOfArrays || typeof(arrayOfArrays)!="object"){return false;};
	var gather=[];
	//Sort leading array only.
	arrayOfArrays[0].sort(
		function(a,b){
		var copyA=a+"";
		var copyB=b+"";
		return gather[++gather.length-1]=
		(copyA.toLowerCase()<copyB.toLowerCase())?-1:
		(copyA.toLowerCase()>copyB.toLowerCase())?1:0;
		}
	);
	//Reorder other arrays:
	for(var i=1; i<arrayOfArrays.length; i++){
	var feedIterator=0;
	arrayOfArrays[i].sort(
		function(a,b){
		return gather[feedIterator++];
		}
	);
	}
	return arrayOfArrays;
}
function print(url) {
	var obj = window.open(url, '', 'width=595, height=842, resizable=no, menubar=no, scrollbars=no, status=no, toolbar=no');
	obj.focus();
}

function replaceSpecialText() {
	var wmode = "transparent";
	sIFR.replaceElement("h2.content_header_title_left_sub", "/media/swf/sifr/DINCond-Regular22.swf", "#FFFFFF", null, null, null, 0, 0, 0, 0,null,null,wmode,100);	
	sIFR.replaceElement("h2.content_header_title_left", "/media/swf/sifr/DINCond-Regular22.swf", "#FFFFFF", null, null, null, 0, 0, 0, 0,null,null,wmode, 100);	
	sIFR.replaceElement("h2.content_header_title_left_main", "/media/swf/sifr/DINCond-Regular22.swf", "#FFFFFF", null, null, null, 0, 0, 0, 0,null,null,wmode, 100);	
	sIFR.replaceElement("h2.content_header_subtitle_left", "/media/swf/sifr/DINCond-Regular22.swf", "#FFFFFF", null, null, null, 0, 0, 0, 0,null,null,wmode, 100);	
	sIFR.replaceElement("h2.content_header_subtitle_right", "/media/swf/sifr/DINCond-Regular22.swf", "#FFFFFF", null, null, null, 0, 0, 0, 0,"textalign=right",null,wmode, 100);	
	sIFR.replaceElement("h2", "/media/swf/sifr/DINCond-Regular22.swf", "#000000", null, null, null, 0, 0, 0, 0,null,null,wmode, 100);	
}

function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
    {
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
          {
            break;
          }
          obj = obj.offsetParent;
        }
    }
    else if(obj.x)
    {
        curleft += obj.x;
    }
    
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
    {
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
          {
            break;
          }
          obj = obj.offsetParent;
        }
    }
    else if(obj.y)
    {
    	curtop += obj.y;
    }
    
    return curtop;
}
 
function kalenderOver(evt,actief)
{
	if(!actief) {
		var obj = document.getElementById(evt.id+"_img");
		obj.src = "/media/images/kalender/" + evt.id.split("kalender_").join("") + "_o.png";
	}
}
function kalenderOut(evt,actief)
{
	if(!actief) {
		var obj = document.getElementById(evt.id+"_img");
		obj.src = "/media/images/kalender/" + evt.id.split("kalender_").join("") + ".png";	
	}
}

function navOver(evt)
{
	var div_img = document.getElementById("div_" + evt.id + "_img");
	div_img.className = "nav_over";
	var img = document.getElementById(evt.id + "_img");
	img.src = img.src.split(evt.id.split("navigation_").join("")).join(evt.id.split("navigation_").join("") + "_o");

	var nav_obj = document.getElementById(evt.id + "_sub");
	
	var aantal = 0;
	for(var i = 0;i<nav_obj.childNodes.length;i++)
	{
		if(nav_obj.childNodes[i].nodeType==1)
		{
			aantal++;	
		}
	}

	if(aantal>0)
	{
		nav_obj.style.visibility = "visible";
		nav_obj.style.height = aantal*34 + "px";
		nav_obj.style.width = 280 + "px";
		
		nav_obj.style.top = findPosY(evt) + "px";
		nav_obj.style.left = (findPosX(evt) + 147) + "px";
	}
}

function navSubOver(evt)
{
	var id = evt.id;
	id = id.split("navigation_").join("sub_navigation_") + "_img";
	
	var _obj = document.getElementById(id);
	_obj.className = "nav_image_over";
}

function navSubOut(evt)
{
	var id = evt.id;
	id = id.split("navigation_").join("sub_navigation_") + "_img";
	
	var _obj = document.getElementById(id);
	_obj.className = "nav_image_out";
}

function navOut(evt)
{
	var div_img = document.getElementById("div_" + evt.id + "_img");
	div_img.className = "nav_out";
	var img = document.getElementById(evt.id + "_img");
	img.src = img.src.split(evt.id.split("navigation_").join("") + "_o").join(evt.id.split("navigation_").join(""));

	var nav_obj = document.getElementById(evt.id + "_sub");
	nav_obj.style.visibility = "hidden";
	nav_obj.style.height = 0+"px";
	nav_obj.style.width = 0+"px";
}
function ficheCheck(evt)
{
	if (evt.id) {
		var id = evt.id.split("row_").join("");
		if (document.getElementById("check_" + id)) {
			var _obj = document.getElementById("check_" + id);
			_obj.checked = !_obj.checked;
		}
	}
}

function ficheOver(evt) {
	evt.className = "fiche_over";
	if (evt.id) {
		var id = evt.id.split("row_").join("");
		
		if (document.getElementById("title_" + id)) {
			var _obj = document.getElementById("title_" + id);
			_obj.className = "content_order_title_over";
		}
		
		if (document.getElementById("status_" + id)) {
			var _obj = document.getElementById("status_" + id);
			_obj.className = "content_order_status_over";
		}
	}
}
function ficheOut(evt)
{	
	evt.className = "fiche_out";
	if(evt.id){
		var id = evt.id.split("row_").join("");
		if(document.getElementById("title_" + id))
		{
			var _obj = document.getElementById("title_" + id);
			_obj.className = "content_order_title";
		}
		
		if(document.getElementById("status_" + id))
		{
			var _obj = document.getElementById("status_" + id);
			_obj.className = "content_order_status";
		}
	}
}

function reviewItemOver(evt)
{
	evt.className = "sidebar_reviewitem_over";
}

function reviewItemOut(evt)
{
	evt.className = "sidebar_reviewitem_out";
}

function newsItemOver(evt)
{
	evt.className = "sidebar_newsitem_over";
}
function newsItemOut(evt)
{
	evt.className = "sidebar_newsitem_out";
}

function navClick(evt)
{
	var page = evt.id.split("navigation_").join("");
	
	if(!click_sub)
	{
		openPage("/" + page);
	}
}

function navSubClick(evt)
{
	click_sub = evt;
	
	var page = evt.id.split("navigation_").join("");
	page = page.split("__").join("/");
	openPage("/" + page);
}

function openPage(page)
{
	if(page=="home" || page == "")
	{
		page = "";
	}else
	{
		if(page.substring(0,1) != "/")
		{
			page = "/" + page;
		}
	}
	
	window.location = page;
}
