/* This script by $criptMaster B  Duall 2008 */
/* JQuery 1.3.2 needed */
/* www.duall.be */


/////////////////////////////////////////////////////////////////////////////////////////////

function KDKexternal() {


	$("a[rel=external]").click( function(){
		window.open($(this).attr("href")); 
		return false;
		});
}



function KDKbanner(DIV){
jQuery.each(jQuery.browser, function(i) {
  if($.browser.msie){
  	$(DIV).show();
  }else{
	 $(DIV).hide();
	 $(DIV).fadeIn(5000);
  }
});
}

function KDKslide(DIV){
	$(DIV).cycle({	  
	fx:	'fade', 
	speed:	2500 
	});
}
function KDKslideNav(DIV,NXT,PRV){
	$(DIV).cycle({	  
	    fx: 'scrollHorz',
        speed: 1000,
        timeout: 0,
        prev: PRV,
        next: NXT,
        nowrap: 1,
        after: function KDKslideOnAfter(curr, next, opts) {
				var index = opts.currSlide;
				$(PRV)[index == 0 ? 'addClass' : 'removeClass']('nvt');
				$(NXT)[index == opts.slideCount - 1 ? 'addClass' : 'removeClass']('nvt');
}
	});
}

function KDKsideDiv(){
	
	$("ul.KDKfootNav li a.openDiv").click(function(){
		var openDiv = $(this).attr("href");
		openDiv = openDiv.split("#");
		openDiv = $("#"+openDiv[1]);
		
		if (openDiv.is(":visible")) {
		 		openDiv.fadeOut();
		 		(".KDKslideShow").cycle('stop');
		 } else {
		 		$("div.KDKslide").fadeOut();
		 		openDiv.fadeIn();
		 		KDKslideNav(".KDKslideShow",".KDKslide .next",".KDKslide .prev");
		 }
		return false;
	});

}

function KDKevents() {
if ($('body').hasClass('home')) {
	$("#KDKbuEvents div.KDKslideShow").load("sanakor/events.htm #KDKeventsCntr div");
	} else {	
	$("#KDKbuEvents div.KDKslideShow").load("events.htm #KDKeventsCntr div");
		}
}

function KDKjobsHomePage() {

	$("ul#GKDKjobsList").load("jobs/default.htm dt",function(){
		$("ul#GKDKjobsList dt").each(function(){
			html = $(this).html();
			$(this).wrap("<li></li>");
			$(this).parent("li").html(html);
			$(this).remove();
		});
	});
	
}

function KDKjobsHeader(){

	BUclass = $("div#KDKbu.JOBS dt:visible").attr("class");
	$("div#KDKheader.JOBS").removeClass();
	$("div#KDKheader").addClass("JOBS");
	$("div#KDKheader").addClass(BUclass);
	$("ul#JOBSnav li a.active").addClass(BUclass);

}

function KDKjobs() {
	
	$("div#KDKbu.JOBS dt").each(function(i){
		$(this).attr("id","job"+i);
		html = $(this).html();
		$(this).html(html+"<span>:</span>"); //om straks te splitten
		$(this).hide();
		$(this).next("dd").hide();
	});

	jobs = $("div#KDKbu.JOBS dt").text();
	$("div#KDKbu.JOBS dt span").remove();
	jobs = jobs.split(":");
	jobs.pop();
	aantal = jobs.length;
	
	$("#KDKheader.JOBS h3 strong").text(aantal);
	
	for (i in jobs)
	{ 	
		$("ul#JOBSnav").append("<li><a href=\"#job"+i+"\" >"+jobs[i]+"</a></li>");
	}
	
		//prepare
	$("dt#job0").show();
	$("dt#job0").next("dd").show();
	$("a[href$='#job0']").addClass("active");
	
	
	$("ul#JOBSnav li a").click(function(){
		openDiv = $(this).attr("href");
		openDiv = openDiv.split("#");
		openDiv = $("#"+openDiv[1]);
		
		if( openDiv.is(":visible")){
			return false;
			//$(this).removeClass("active");
			//$(doel).fadeOut();
			//$(doel).next("dd").fadeOut();
		} else {
			$("ul#JOBSnav li a").removeClass();
			$(this).addClass("active");
			$("dt,dd").hide();
			openDiv.fadeIn();
			openDiv.next("dd").fadeIn();
			KDKjobsHeader();

		}
	
	});
	

}




/////////////////////////////////////////////////////////////////////////////////////////////


$(document).ready(function(){
	KDKslide(".KDKfoto");
	KDKslideNav("#KDKbuMeerSlider","#KDKbuMain .next","#KDKbuMain .prev");
	KDKevents();
	KDKsideDiv();
	KDKjobsHomePage();
	KDKjobs();
	KDKjobsHeader();
	KDKexternal();
});

