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


$(document).ready(function() {

NICCmenu("NICCmainNav","active");
NICCsluit("#NICCsluitBeeld");
NICCrandomKleurTimer(15000);
NICCfloatDiv("NICCfloat",25,70).floatIt();
NICCpdfLinks("NICCpdfLink");
NICCdocLinks("NICCdocLink");

});



function NICCsluit(SluitDiv){


	$(SluitDiv).parent("div").height($(window).height());
	$(SluitDiv).parent("div").width($(window).width());

	$(window).resize(function(){
	
		$(SluitDiv).parent("div").height($(window).height());
		$(SluitDiv).parent("div").width($(window).width());
	});

	$(SluitDiv).hover(function(){$(this).children("img").css("border","2px solid black")},function(){$(this).children("img").css("border","none")});
	$(SluitDiv).click(function(){ 
 			$(SluitDiv).parent().fadeOut();
 		});
 		
}

function NICCrandomKleur(){
	r = Math.floor(Math.random()*255);
	g = Math.floor(Math.random()*255);
	b = Math.floor(Math.random()*255);
	r2 = 255-r;
	g2 = 255-g;
	b2 = 255-b;
	
	$("#NICClogo a").css("background-color","rgb("+ r +","+ g +","+ b +")");
	$("#NICClogo a").hover(	
		function(){
		$(this).css("background-color","#000");
		},function(){
		$(this).css("background-color","rgb("+ r +","+ g +","+ b +")");
		});
	$("a").css("color","rgb("+r+","+g+","+b+")");
	//$("body").css("background-color","rgb("+ r2 +","+ g2 +","+ b2 +")");
	
}

function NICCanimateKleur() {
	r = Math.floor(Math.random()*255);
	g = Math.floor(Math.random()*255);
	b = Math.floor(Math.random()*255);
	r2 = 255-Math.floor(Math.random()*255);
	g2 = 255-Math.floor(Math.random()*255);
	b2 = 255-Math.floor(Math.random()*255);
	
	$("#NICClogo a").animate( { backgroundColor:"rgb("+r+","+g+","+b+")" }, 2000);	
	$("a").animate( { color: "rgb("+r+","+g+","+b+")" }, 2000);	
	//$("body").animate( { backgroundColor: "rgb("+r2+","+g2+","+b2+")" }, 2000);
}
	
function NICCrandomKleurTimer(interval){
	NICCrandomKleur();
	k = setInterval('NICCanimateKleur()',interval);

}


function NICCpdfLinks(ClassToAppend){

	$("a[href$=pdf]").addClass(ClassToAppend);
}

function NICCdocLinks(ClassToAppend){

$("a[href$=doc]").addClass(ClassToAppend);

}

function NICCmenu(menuDIV,activeClASS) {
	$('div#'+ menuDIV + ' li > ul').hide();
		$('div#'+ menuDIV + ' ul > li > a').click(function () {
		if ($(this).parent().children('ul').length) {							// zit er een Ul-child in de LI? (is er subnav?)
				if ($(this).parent().children('ul').is(':visible')){				// is de UL-child (subnav) zichtbaar?
					$(this).parent().parent().find('ul:visible').slideUp("fast");			// verberg de UL (subnav)
					
					return false;
				} else {															// is de subnav verborgen
					$(this).parent().parent().find('> li > ul:visible').slideUp("fast");		// verberg andere subnav
					$(this).parent().children('ul').slideDown();							// toon subnav
					test($(this).parent().children('ul').children("li").children("a"));
	

				return false;
			}
		} else {																// zit er geen UL in de li? (is er geen subnav)
			$(this).parent().parent().find('ul:visible').slideUp("fast");

			
		};
	
	});
}


function NICCfloatDiv(DIVid, xPos, yPos){

	document.getElementById(DIVid).cx = document.getElementById(DIVid).sx = xPos;

	document.getElementById(DIVid).cy = document.getElementById(DIVid).sy = yPos;
		
	//document.getElementById(DIVid).sP = function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
	
	document.getElementById(DIVid).newPos = function(x,y){
		
		$(this).css("left",x).css("top",y);
		
		}

	document.getElementById(DIVid).floatIt = function(){
		
		
			var pX, pY;
			
			pX = (this.sx >= 0) ? 0 : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
			
			pY = Math.floor((document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) / 35) * 35;

			if(this.sy<0)
			
				pY += document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
				
				this.cx += (pX + this.sx - this.cx)/4;
				
				this.cy += (pY + this.sy - this.cy)/4;
				
				this.newPos(this.cx, this.cy);
				
				setTimeout("floatIt()", 20);
				
		}
		
		return document.getElementById(DIVid);
}

function floatIt(){
  document.getElementById('NICCfloat').floatIt();
}



