
//-- contactformulier invullen
function CheckForm(objButton)
{
	var blnError = false;
	var objForm = $(objButton).parents("form:first");

	$.post(strPath + "ajax_form.php",  objForm.serialize(), function(arrObjecten)
	{
		//var arrObjecten = eval(html.responseText);

		for(i = 0; i < arrObjecten.length; i++)
		{
			var	arrObject = arrObjecten[i];
			var fieldname = arrObject.element;
			$('#' + fieldname + '-message').html("");

			if(arrObject.value == 0)
			{
				$('#' + fieldname + '-message').append(html_entity_decode(arrObject.message)).hide();
				$('#' + fieldname + '-message').fadeIn('fast');
				$('#' + fieldname + '-label').addClass("form-error");
				blnError = true;
				//$("#" + arrObject.element).addClass("form-error");
			}
			else
			{
				$('#' + fieldname + '-message').html("");
				$('#' + fieldname + '-label').removeClass("form-error");
				//$("#" + arrObject.element).removeClass("form-error");
			}
		}

		//-- als er geen errors zijn => submitten
		if(blnError == false)
		{
			if ($('#redirect-url').val() && $('#redirect-url').val() != "")
			{
				window.location = $('#redirect-url').val();
			}
			else
			{
				$(objForm).unbind("submit");
				var strFormId = objForm.attr('id');
				if (strFormId == "frmContact" || strFormId == "frmEventSubscribe")
				{
					objForm.submit();
				}
				else
				{
					$('#contactfields').fadeOut('fast');
					$('#successmsg').fadeIn('fast');
				}
			}
		}
	}, "json");
}



//-- gebruikt bij submitten van formulieren (om velden mee te geven naar ajax)
function MakeParameters(arr)
{
	var strParameters = "";
	var ampersant = "";

	//--Parameters maken met de inhoude van de velden
	for(var i=0;i<arr.length;i++)
	{
		
		if(document.getElementById(arr[i]))
		{			
			//-- bij checkbox => kijken of checkbox aangevinkt staat
			if (arr[i] == "newsletter")
			{
				if (document.getElementById(arr[i]).checked == 1)
				{
					fieldvalue = "on";
				}
				else
				{
					fieldvalue = "off";
				}
			}
			else
			{
				fieldvalue = document.getElementById(arr[i]).value;
			}
			strParameters += ampersant + arr[i] + "=" + fieldvalue;
			ampersant = "&";
		}
	}
	return strParameters;
}


/* sendemail = spam controle op formulieren */
/*function SendEmail(){
	alert('test');
	$('#frmContact').attr('action', $('#frmContact').attr('action') + '&contactcode=co7');
}*/


function calcHeight()
{
	//find the height of the internal page
	var the_height=document.getElementById('newsletterpreview').contentWindow.document.body.scrollHeight;

	//change the height of the iframe
	document.getElementById('newsletterpreview').height=the_height;
}

function initMenus() {
	$('ul.menu li.notactive ul').hide();
	/*$.each($('ul.menu'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});*/
	$('ul.menu li a').click(
		function() {
		
			var strHref = $(this).attr('href');
			void(0);
			
			var submenu = $(this).next();
									
				var parent = this.parentNode.parentNode.id;
			
				/*if($('#' + parent).hasClass('noaccordion')) {
					$(this).next().slideToggle('normal', function()
					{
						//document.location = strHref;
					});
					alert('test');
					return false;
				}*/
				//alert(this.parentNode.parentNode.id)
				//parent = "leftmenu2";
			
				
				if((submenu.is('ul')) && (submenu.is(':visible'))) {
					$(this.parentNode).addClass("active");
					if($('#' + parent).hasClass('collapsible')) {
						$('#' + parent + ' ul:visible').slideUp('normal');
					}
					document.location = strHref;
					return false;
				}
				if((submenu.is('ul')) && (!submenu.is(':visible'))) {
					$(this.parentNode).addClass("active");
					$('#' + parent + ' ul:visible').slideUp('normal');
					submenu.slideDown('normal', function()
					{
						document.location = strHref;
					});
					return false;
				}
			//}
		}
	);
}


//ZOOM FUNCTI VOOR DE co7 lINKS

$(document).ready(function(){

	$("ul.thumb li").hover(function() {
		$(this).css({'z-index' : '10'});
		$(this).find('img').addClass("hover").stop()
			.animate({
				marginTop: '-20px', 
				marginLeft: '-20px', 
				top: '0%', 
				left: '0%', 
				width: '30px', 
				height: '112px',
				padding: '20px' 
			}, 250);
		
		} , function() {
		$(this).css({'z-index' : '0'});
		$(this).find('img').removeClass("hover").stop()
			.animate({
				marginTop: '0', 
				marginLeft: '0',
				top: '0', 
				left: '0', 
				width: '22px', 
				height: '82px', 
				padding: '5px'
			}, 400);
	});

});


//you tube filmpjes
function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
		h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}


function html_entity_decode(str)
{
	try
	{
		var  tarea=document.createElement('textarea');
		tarea.innerHTML = str;
		return tarea.value;
		tarea.parentNode.removeChild(tarea);
	}
	catch(e)
	{
		//for IE add<div id="htmlconverter" style="display:none;"></div> to the page
		document.getElementById("htmlconverter").innerHTML = '<textarea id="innerConverter">' + str + '</textarea>';
		var content = document.getElementById("innerConverter").value;
		document.getElementById("htmlconverter").innerHTML = "";
		return content;
	}
}


// voor de images op de home

$(document).ready(function() {
    $('.slideshow').cycle({	fx: 'fade', timemout: 4000});
    $('.slideshow2').cycle({	fx: 'fade',  delay: 1000, timeout: 4000 });
    $('.slideshow3').cycle({	fx: 'fade',  delay: 4000, timeout: 4000});
    $('.slideshow4').cycle({	fx: 'fade',  delay: 7000, timeout: 4000});
});


$(document).ready(function(){  
     $(".button1").hover(function() {  
         $(this).attr("src","images/co7-hover.jpg");  
             }, function() {  
         $(this).attr("src","images/logo_intro_co7.jpg");  
     }); 

		$(".button2").hover(function() {  
         $(this).attr("src","images/archeo7-hover.jpg");  
             }, function() {  
         $(this).attr("src","images/logo_intro_archeo7.jpg");  
     }); 
     

		$(".button3").hover(function() {  
         $(this).attr("src","images/cultuurdienst-hover.jpg");  
             }, function() {  
         $(this).attr("src","images/logo_intro_cultuurdienst.jpg");  
     }); 

		
	     $(".button4").hover(function() {  
         $(this).attr("src","images/erfgoedcelco7-hover.jpg");  
             }, function() {  
         $(this).attr("src","images/logo_orange.jpg");  
     }); 	
}); 
