var ISIE=false;
var CurrentPollID;

$('html').addClass('js'); 



// >>> START JQUERY >>>
$().ready(function() { 


//alert(jQuery.support.boxModel);
//alert(IsThisBrowserIE6());

// basic vars:


// check of het Internet Explorer is
ISIE=$.browser.msie; 




// ### CORNER EFFECTS ###
// (note: ALTIJD BOVENAAN ANDERS Problemen met andere effecten) 
$(".tab_li_items").corner("5px");
$("#search_page").corner("8px");
$(".corners5").corner("5px");
$(".corners10").corner("10px");
$(".corners15").corner("15px");
$(".corners20").corner("20px");
$("#main_layout").corner("12px");



// Vervang email links door spamprotected email link:
$("a.email").nospam();


// ### initialiseer items ##
$("#menu_002").hide();



// Table Tbody hiden (voor inklappen/uitklappen functie)
$(".sh_tbody").hide();

// replace HR met iets anders
$("hr").each(function(){
$(this).before("<div class=\"hr\">").after("</div>").remove();
});



// external links
$('A[rel="external"]').click( function() {
  window.open( this.href );
  return false;
});	


// ## Toggle table Tbody secties ###
$(".toggle_tbody").css({cursor:"pointer"}); 
$(".toggle_tbody").toggle(function(){
// onclick 1
var tableID= $(this).parent().parent().parent().attr("id");
if($("#"+tableID+" tbody:eq(1)").attr("class")!="show_tbody"){
	$("#"+tableID+" .ud_toggle").attr("src","/images/folders/resultset_up_blue.png");
	$("#"+tableID+" .sh_tbody").fadeIn("slow");
}else{ // als al uitgeklapt (show_tbody)
	$("#"+tableID+" .ud_toggle").attr("src","/images/folders/resultset_down_blue.png");
	$("#"+tableID+" .show_tbody").fadeOut("fast");
}
},function(){
	// onclclick 2
var tableID= $(this).parent().parent().parent().attr("id");
if($("#"+tableID+" tbody:eq(1)").attr("class")!="show_tbody"){
$("#"+tableID+" .ud_toggle").attr("src","/images/folders/resultset_down_blue.png");
$("#"+tableID+" .sh_tbody").fadeOut("fast");
}else{ // als al ingeklapt (show_tbody)
$("#"+tableID+" .ud_toggle").attr("src","/images/folders/resultset_up_blue.png");
$("#"+tableID+" .show_tbody").fadeIn("slow");
}
});



// ### TAB BAR: ###
$("#portotabs div").hide();
$("#portotabs div:first-child").show();
$('#portotabs ul li:first-child').addClass('t_active');

// check lege tabs
$("#portotabs div div").each(function(){
		if(this.html=="&nbsp;"){
		var xid=this.id;

	  $("#portotabs ul li a").each(function(){														
	  		if(xid=="P"+this.html){
			$(this).removeAttr("href");
			$(this).addClass('t_dis');
			return false;
			}
		});		
	}
});

$('#portotabs ul li a').hover(function(){
	if($(this).attr("class")!="t_dis"){												
		$('#portotabs ul li').removeClass('t_active');
		$(this).parent().addClass('t_active');
		var currentTab = $(this).attr('href');
		$('#portotabs div div').hide();
		$(currentTab).show();
		return false;
 }
});

// ## Page Tabs ####
$("#paginatabs .page_vnr").hide();
$("#paginatabs .page_vnr:first-child").show();
$('#paginatabs ul li:first-child').addClass('t_active');
$("#paginatabs .pagina_aanhef_text").hide();

$("#paginatabs ul li").each(function () {
var Alink=$(this).children("a")
var tTitle= Alink.attr("title");
Alink.html(Alink.text() + "&nbsp;&nbsp;"+tTitle);
 });

$('#paginatabs ul li a').click(function(){
	if($(this).attr("class")!="t_dis"){												
		$('#paginatabs ul li').removeClass('t_active');
		$(this).parent().addClass('t_active');
		var currentTab = $(this).attr('href');
		$('#paginatabs .page_vnr').hide();
		$(currentTab).fadeIn(1000);
		return false;
 }
});


//### MENU OPTIES ###



// ##DROPDOWN MENU##
$("ul li.menuchild ul").parent().append("<span class=\"has_child\"></span>");
$("ul.topmenu li:last-child").css({"border-right":"4px"});
$("ul.subnav .mselected").parents("li").children("a").addClass("childselected");

$(".subnav").each(function () {
	$(this).parent().eq(0).hoverIntent({
		timeout: 100,over: function () {
			var current = $(".subnav:eq(0)", this);current.slideDown(100);
		},out: function () {
			var current = $(".subnav:eq(0)", this);current.fadeOut(200);
		}
	});
});

$("ul.subnav li").hover(function () {
	$(this).stop(true).css({"cursor":"pointer","background-image":"url(/custom/remarq/menusubitemlinkhover_background.png)","background-position":"left center","background-repeat":"no-repeat"}).children("a").css({"color":"#fff"}).animate({paddingLeft: "10px"}, {speed: 100, easing: "easeOutBack"});
	
	if($(this).hasClass("mselected")){
		$(this).stop(true).css({"cursor":"pointer"});
	}
	
	}, function () {
	$(this).stop(true).css({"background-image":"none"}).children("a").css({"color":"#FFF"}).animate({paddingLeft: "5px"}, {speed: 100, easing: "easeOutBounce"});
});

												  


// ## fotoalbum modev ###
// vergberg sidebars 
// Pagina extenden naar breedte pagina 
if($("#fotoalbum").is("*")){
// inatieer photo popup
$("a[rel^='prettyPhoto']").prettyPhoto();
															
} // einde fotoalbum mode



// ######### EFFECTEN  ALGEMEEN ##############

// archifact inline page boxes
$(".openbox").toggle(function(){
var showitem=$(this).text().toLowerCase();
$("#"+showitem+"").slideDown();
},function(){
var showitem=$(this).text().toLowerCase();
$("#"+showitem+"").slideUp();	
 });



// layout switching:
/*
$(".layout_selected img").click(function() {
        $("#customstyle").attr("href","/custom/custom_"+$(this).attr('alt')+".css");
		  alert($(this).attr('alt'));
        return false;
    });
*/



$(".ar").css({backgroundImage:"url(/images/folders/resultset_next.png)",backgroundPosition:"right",paddingRight:"20px",backgroundRepeat:"no-repeat"});
$(".al").css({backgroundImage:"url(/images/folders/resultset_previous.png)",backgroundPosition:"left",paddingLeft:"20px",backgroundRepeat:"no-repeat"});


$("#toggle_1").toggle(function(){
(this).next("display:none;");
},function(){
(this).next("display:block;");
});



// ## FOOTER OPTIONS 




// ##### SIDEBAR NIEUWS########
// scrolling nieuws items
if($("#sidebar002").is(":visible")){ 
var nwsItemsTotal=$(".tab_ul_items li").length;
$(".nws_total").text("nieuws items: ("+nwsItemsTotal+")");
$("#sidebar_nieuws_items").scrollable({
items:"ul",
size:3,
horizontal:false
});

var escroll=$("#sidebar_nieuws_items");
$(".nws_next").click(function(){
escroll.scrollable("move", 3,1000);
});
$(".nws_prev").click(function(){
escroll.scrollable("move", -3, 200);
});
}



// ### SIDEBAR KALENDER ### 
if($("#kalender").is(":visible")){
$("#kalender").html("<img src=\"/images/ajaxloaders/ajax-loader_small3.gif\" style=\"margin:0px auto;\"/>");
$.get('/include/ajax_kalender.asp', function(output){
if(output!=""){	
		$("#kalender").html(output);
		}		
	});
$("#kalender .dd_dag").livequery('mouseover',function(){
	$(this).css({backgroundColor:"#dceffd"});
});
$("#kalender .dd_dag").livequery('mouseout',function(){
	$(this).css({backgroundColor:""});
});
}



// ### SIDEBAR RSS FEEDS ##
if($("#sidebar004").is(":visible")){

var furl= $("#newsfeed").attr("furl");
var fname= $("#newsfeed").attr("fname");
var faantal= $("#newsfeed").attr("faantal");
$("#newsfeed").feedreader({										
        targeturl:"/include/proxy.aspx?url="+furl, 
        items: 12, 
		  FeedName:fname,
     	  HeaderLength:30,
		  ContentLength:14
});
} 



// ### SIDEBAR Sitemap ##


// ### SIDEBAR TAG CLOUD ##
if($("#sidebar007").is(":visible")){
$("#pagina_back").dynaCloud();
}

		
// ### SIDEBAR POLL ##
$("#poll").submit(formProcess); 
if ($.cookie('Archipoll')){
 $("#poll_container").empty();
 CurrentPollID = $.cookie('Archipoll');
	$.get("/include/polls.asp?Poll_id="+CurrentPollID,function(Results){
   		if(Results!=""){$("#poll_container").append(Results).fadeIn("fast",function(){animateResults();});}	
	}); 
}






// ### FORM  OPTIONS EN SPAM CHECK ###


// form buttons effect:
$('.submit_button').hover(function(){
//mouseover
$(this).addClass('submit_buttonhover'); 
},function(){
//mouseout
$(this).removeClass('submit_buttonhover'); 
});


// doe checks op formulieren met class webform:
$(".webform").validate({
  rules: {antispam_veld:{required: true, minlength:6}},
  messages:{antispam_veld:{required:"Vul de juiste code in.", minlength:"Code bestaat uit 6 cijfers"}},
  submitHandler: function(form){			
		var imgID=$("#antispam_img").attr("title");
		var spamNaam=$("input#antispam_veld").val();			
		if($("#spamchecker").val()!="true"){						
			$.get('/include/ajax_antispam.asp?antispam='+spamNaam+'&imgID='+imgID, function(response){
				if(response=="true"){
				//	alert("ok");
				$("#spamchecker").val("true");
				form.submit();
				}else	{
				$("#antispam_msg").html("<img src=\"/images/folders/arrow_down.png\" alt=\"Fout!\" style=\"vertical-align:middle;\"/>Vul de juiste code in.<br/>");
				$("#antispam_msg").show("fast");
				return false;
				}
			});		
		}else{
			form.submit();				
   	}	
		}			
});



// Vegroot textarea als men typed:
$("textarea").elastic();


// limiet voor textarea
$('.ta_limit100').keyup(function() {
      var maxlen = 122;
      var len = this.value.length;
      if (len >= maxlen) { this.value = this.value.substring(0, maxlen); }
      $('#charleft').text("Max chars:" + (maxlen - len));
  });

// form validatie
$(".weblogin").validate();






// ### Debug items: ####
$(".string_debug").prependTo($("#container")); 
$(".array_debug").prependTo($("#container")); 
$(".array_debug_drag").mouseover(function(){$(".array_debug").draggable();});
$(".string_debug_drag").mouseover(function(){$(".string_debug").draggable();});


 }); 
/////////////////// EINDE JQUERY READY \\\\\\\\\\\\\\\\\\



//################### LOAD WINDOW SCRIPTS ##################

$(window).load(function(){								
	
}); 
// _____________ / window load ___________



// ie6 check
function IsThisBrowserIE6() {
return ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined))
}



// ###################### FUNCTIONS  #############

function kal_maand(maand, jaar, P, M, G){
$("#kalender").load('/include/ajax_kalender.asp?KM='+maand+'&KY='+jaar+'&P='+P+'&M='+M+'&G='+G, function(response){
if(response!="false"){$("#kalender").html(response);}
	});																														  
};
// swap kalender items voor de pagina die er eerst stond
function pagina_terug(P, M, G){
$.get('/include/ajax_pagina.asp?P='+P+'&M='+M+'&G='+G,'pagina_inhoud','html',function(response){
if(response!="false"){$("#kalender").html(response);}
	});																														  
};





// nieuws headlines: volgende / vorige
function get_headlines(page){
$("#tab-nieuws").load('/include/ajax_nieuws.asp?mode=nhl&page='+page, function(response){
if(response!="false"){$("#tab-nieuws").html(response);}
	});																														  
};




// ### POLL FUNCTIONS //
function formProcess(event){
 event.preventDefault();   
  var SelectedVote = $("input[@name='vote']:checked").attr("value");
  var PollID= $("#poll_id").val();
  var GID= $("#GID_ID").val();
  VoteID = SelectedVote.replace("opt",'');
  CurrentPollId=PollID;
  
	$("#poll_container").fadeOut("fast",function(){
   	 $(this).empty();
		 
		 $.get('/include/polls.asp?vote='+VoteID+'&poll_id='+PollID+'&GID_ID='+GID, function(output){
			
			if(output!=""){	
			$("#poll_container").append(output).fadeIn("fast",function(){animateResults();});
			}	
				
		});
	});
  $.cookie('Archipoll',PollID,{expires: 365});  
}

function animateResults(){
  $("#poll_container .bar_bar div").each(function(){
      var percentage = $(this).next().text();
      $(this).css({width: "0%"}).animate({
		width: percentage}, 'slow');
  });
}



// _________________ / FUNCTIONS ________________


// slideshow subheader
function slideSwitch() {
    var $active = $('.client_box ul li.active');
    if ( $active.length == 0 ) $active = $('.client_box ul li:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('.client_box ul li:first');
    // uncomment the 3 lines below to pull the images in random order    
     var $sibs  = $active.siblings();
     var rndNum = Math.floor(Math.random() * $sibs.length );
     var $next  = $( $sibs[ rndNum ] );
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 500, function() {
            $active.removeClass('active last-active');
        });
}
$(function() {
    setInterval( "slideSwitch()", 9000 );
});






