
	
	var activeTab = 0;
var iterator = 0;

(function( $ ) {
	$.extend( {
		init: function() {
			// Init sIFR
			//$('.cnvContent h1').sifr({font: '/sifr/dinmedium.swf', color: '#771c7f;'});
			//$('.cnvContent h2').sifr({font: '/sifr/dinmedium.swf', color: '#771c7f;'});

			if(typeof sIFR == "function"){
			// This is the preferred "named argument" syntax
			sIFR.replaceElement(named({sSelector:".cnvContent h1", sFlashSrc:"/sifr/dinmedium.swf", sColor:"#771c7f", sWmode: "transparent",   sFlashVars:"textalign=left"}));
			sIFR.replaceElement(named({sSelector:".cnvContent h2", sFlashSrc:"/sifr/dinmedium.swf", sColor:"#771c7f", sWmode: "transparent",  nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left"}));
			};
			
			
			// FAQ toggle init
			$(".cnvAnswer").each (function () {
					$(this).hide();	
			});
			
			$(".cnvFAQuestion").click (function () {
					$(this).next(".cnvAnswer").toggle("100");
					if ($(this).parent().attr('className') != '') {
						$(this).parent().removeClass('cnvOpened');
					} else {
						$(".cnvAnswer").each (function () {
							if ( $(this).parent().attr('className') !='' ) { $(this).toggle("20"); $(this).parent().removeClass('cnvOpened'); };	
						});						
						$(this).parent().addClass('cnvOpened');
					}
			});
			
			// Centering Paging
			$(".cnvPaging ul").css({marginLeft: (($(".cnvPaging").attr("clientWidth") - $(".cnvPaging ul").attr("clientWidth"))/2) + 'px'});
			
			//Set current tab content
			$(".cnvTabs li").each(function () {
				iterator++;							
				if ($(this).attr("className") == 'cnvActive') { activeTab = iterator;}								
			});
			// Hide all tabs content
			
			// Show selected tab content
			if ($(".cnvTabContent")[activeTab-1]) { $(".cnvTabContent").hide(); $(".cnvTabContent")[activeTab-1].style.display = ''; }
			
			// Tabs
			$(".cnvTabs li").click(function () {
				$(".cnvTabs li").each (function () {
					$(this).removeClass('cnvActive');									 
				});
				$(this).addClass('cnvActive');
				
				iterator = 0;
				$(".cnvTabs li").each(function () {
					iterator++;							
					if ($(this).attr("className") == 'cnvActive') { activeTab = iterator;}								
				});
				$(".cnvTabContent").hide();
				$(".cnvTabContent")[activeTab-1].style.display = '';
			});
			
			// Accordion on home panel edit
			
			/* prc 20-05-2009  uitgeschakeld code herschreven.
			$(".cnvCare ul li p").hide();
			
			$(".cnvSwitchLink").click (function () {
				$(this).next("p").toggle("10");
				if ($(this).parent().attr("className") != '') {
					$(this).parent().removeClass("cnvOpened");
				} else {
					$(".cnvCare ul li").each(function () {
						if ($(this).attr("className") != '') {
							$(this).removeClass("cnvOpened");
							$(this).children("p").toggle("10");
						}
					});
					$(this).parent().addClass('cnvOpened');
				}
			}); */			
			
			
			/* prc 20-05-2009  toegevoegd om favorieten automatisch te laten uitklappen.*/
			
			
			
			$(document).ready(function(){
			   $('a#favswitch1').click(function() {
			   	  $('#favrow2').hide();
				  $('#favrow3').hide();
				  $('#favrow4').hide();
				  $('#favrow5').hide();
				  $('#favrow6').hide();
			      $('#favrow1').toggle(400);
				  $.cookie('favrow'+ metaKeywords(), '1');
			      return false;
			   });
			});		

		   $(document).ready(function(){
			   $('a#favswitch2').click(function() {
			   	  $('#favrow1').hide();
				  $('#favrow3').hide();
				  $('#favrow4').hide();
				  $('#favrow5').hide();
				  $('#favrow6').hide();
			      $('#favrow2').toggle(400);
				  $.cookie('favrow'+ metaKeywords(), '2');
			      return false;
			   });
			});	

		  $(document).ready(function(){
			   $('a#favswitch3').click(function() {
			   	  $('#favrow2').hide();
				  $('#favrow1').hide();
				  $('#favrow4').hide();
				  $('#favrow5').hide();
				  $('#favrow6').hide();
			      $('#favrow3').toggle(400);
				  $.cookie('favrow'+ metaKeywords(), '3');
			      return false;
			   });
			});	
		  $(document).ready(function(){
			   $('a#favswitch4').click(function() {
			   	  $('#favrow2').hide();
				  $('#favrow3').hide();
				  $('#favrow1').hide();
				  $('#favrow5').hide();
				  $('#favrow6').hide();
			      $('#favrow4').toggle(400);
				  $.cookie('favrow'+ metaKeywords(), '4');
			      return false;
			   });
			});	
		  $(document).ready(function(){
			   $('a#favswitch5').click(function() {
			   	  $('#favrow2').hide();
				  $('#favrow3').hide();
				  $('#favrow4').hide();
				  $('#favrow1').hide();
				  $('#favrow6').hide();
			      $('#favrow5').toggle(400);
				  $.cookie('favrow'+ metaKeywords(), '5');
			      return false;
			   });
			});	
		  $(document).ready(function(){
			   $('a#favswitch6').click(function() {
			   	  $('#favrow2').hide();
				  $('#favrow3').hide();
				  $('#favrow4').hide();
				  $('#favrow1').hide();
				  $('#favrow5').hide();
			      $('#favrow6').toggle(400);
				  $.cookie('favrow'+ metaKeywords(), '6');
			      return false;
			   });
			});		
						
			
			// Accordion on blog reactions
			$(".cnvBlogreacties .cnvReacties dl dd").hide();
			
			$(".cnvBlogreacties .cnvReacties dl dt").click (function () {
				$(".cnvBlogreacties .cnvReacties dl dt").each(function () {
					$(this).next("dd").hide("10");
				});
				$(this).next("dd").show("10");
			});
			
			// Init Contacts Bar Items
			$(".cnvContactsBar ul li").each(function() {
				if ($(this).attr("className") != 'cnvActive') {
					$(this).children("p").hide();	
				}
			});
			
			$(".cnvContactBarLink").click (function() {
				$(".cnvContactsBar ul li p").hide();
				$(this).next("p").show();
				$(".cnvContactsBar ul li").removeClass("cnvActive");
				$(this).parents("li").addClass("cnvActive");
			});
			
			/* extra onclicks voor Nieuwsbrief en Mail Pagina toevoegen */
			$(document).ready(function(){
			   $('#layernavnews').hide(); 
			   $('a#menulink_NWSBRIEF').click(function() {
			   	  $('#layernavemail').hide();
			      $('#layernavnews').toggle(400);
			      return false;
			   });
			});
			$(document).ready(function(){
			   $('#layernavemail').hide(); 
			   $('a#menulink_MAILPAGINA').click(function() {
			      $('#layernavnews').hide();
			      $('#layernavemail').toggle(400);
			      return false;
			   });
			});

			
		}
	} );
} )(jQuery);

jQuery( function( $ ) {
	$.init(); // Inits sifr
} );

/* Validations */

function validateEmail(input,title){
	var emailRegEx = /^\S+@\S+$/;
	var errMsg = '';
	var strTitle = (title?title+': ':'');
	if(input){
		var str = new String(input.value);
		if(!str.match(emailRegEx)){
			errMsg = String(strTitle+'Gelieve een geldig email adres in te vullen.\n');
		}
	}
	return errMsg;
}

/* End Validations */

/* Start Poll */

function request(url, target, outer) {   
   try {var xmlHttp = new ActiveXObject('MSXML2.XMLHTTP.3.0')} //IE
   catch (e) {var xmlHttp = new XMLHttpRequest()}
   xmlHttp.onreadystatechange = function() {
     if (xmlHttp.readyState==4) {
     target.innerHTML = xmlHttp.responseText;
     if(outer) {target.className=''}
     init();
     }
   }
   xmlHttp.open('GET', url, true);
   xmlHttp.send(null);
 }
 
/* End Poll */


/* Get metatag pageid  */

function metaKeywords() { 
	metaCollection = document.getElementsByTagName('meta'); 
	for(i=0;i < metaCollection.length ;i++) { 
		nameAttribute = metaCollection[i].name.search(/pageid/); 
		if (nameAttribute!= -1) { 
			return metaCollection[i].content;
		}}} 

/* End metatag pageid  */


