var t = new Array(); //timeout ID's
var ts= new Array(); //timeout ID's subsubmenu's
var banner = 0;


function setVis(element, vis)
{
	theElement = document.getElementById(element);
	if(vis)
	{
		theElement.style.visibility='visible';
	}
	else
	{
		theElement.style.visibility='hidden';
	}	
}
function setDisplay(element, parent, submenu)
{
	theElement = document.getElementById(element);
	if(submenu)
	{
		theParent  = (document.getElementById(parent)).parentNode;
	}
	else
	{
		theParent  = document.getElementById(parent);
	}
	var positionXY = findPos(theParent);
	theElement.style.display='block';
	if(submenu)
	{
		theElement.style.left = '0px';
		theElement.style.top = '30px';
	}
	else
	{
		theElement.style.left = (positionXY[0]-10)+'px';
		theElement.style.top  = (positionXY[1]+14)+'px';
	}
}
function hideDisplay(element)
{
	hideSub(element);
	theElement = document.getElementById(element);
	theElement.style.display ='none';
	theElement.style.left = '-400px';
	theElement.style.top  = '-400px';
}
function hideSub(elem)
{
	var tmp='';
	theElement = document.getElementById(elem);
	elems= theElement.getElementsByTagName('DIV');
	for(i=0;i<elems.length;i++)
	{
		tmp +=(elems[i].id);
		elems[i].style.display='none';
	}
}

function cleartimeouts(ar)
{
	for(i=0;i<ar.length;i++)
	{
		clearTimeout(ar[i]);
	}
}
//vind x,y coordinaten van een bepaald object
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return new Array(curleft,curtop);
}


// om een bepaalde link te koppelen aan de iframe
function setURL(url)
{
	theElement=document.getElementById('iframeURL');
	theElement.src=url;
}


// roterende banner
var smallbanner 	= new Array();
var smallbannerLink = new Array();

//urls van roterende banner                         //imgs van roterende banner
smallbanner[0] = '/images/sponsoren/collstrop.jpg'; 		smallbannerLink[0] = 'http://www.collstrop.be';
smallbanner[1] = '/images/sponsoren/brabotech.jpg';			smallbannerLink[1] = 'http://www.brabotech.nl';
smallbanner[2] = '/images/sponsoren/ridley.jpg';			smallbannerLink[2] = 'http://www.ridley-bikes.com';
smallbanner[3] = '/images/sponsoren/logo_sms_santini.jpg';	smallbannerLink[3] = 'http://www.santinisms.it/en/home_page.aspx';
smallbanner[4] = '/images/sponsoren/bovemij.jpg';			smallbannerLink[4] = 'http://www.bovemij.nl';
smallbanner[5] = '/images/sponsoren/narviflex.jpg';			smallbannerLink[5] = 'http://www.narviflex.be';
smallbanner[6] = '/images/sponsoren/palmans.jpg';			smallbannerLink[6] = '#';
smallbanner[7] = '/images/sponsoren/logo_bbb.jpg';			smallbannerLink[7] = 'http://www.bbbparts.com';
smallbanner[8] = '/images/sponsoren/sanmarco.jpg';			smallbannerLink[8] = 'http://www.sellesanmarco.com';
smallbanner[9] = '/images/sponsoren/logo_lecoq.jpg';		smallbannerLink[9] = 'http://www.lecoqsportif.nl';
smallbanner[10] = '/images/sponsoren/logo_etixx.jpg';		smallbannerLink[10] = 'http://www.etixx.be';
smallbanner[11] = '/images/sponsoren/logo_skinfit.jpg';		smallbannerLink[11] = 'http://www.skinfit.eu';
smallbanner[12] = '/images/sponsoren/logo_deda.jpg';		smallbannerLink[12] = 'http://www.dedaelementi.com';
smallbanner[13] = '/images/sponsoren/logo-dutchspirit.jpg';smallbannerLink[13] = 'http://www.dutchspiritfashion.com';
smallbanner[14] = '/images/sponsoren/dynamico.jpg';			smallbannerLink[14] = 'http://www.dynamico.nu';
smallbanner[15] = '/images/sponsoren/look.jpg';				smallbannerLink[15] = 'http://www.lookcycle.com';
smallbanner[16] = '/images/sponsoren/fastforward.jpg';		smallbannerLink[16] = 'http://www.ffwdwheels.com';
smallbanner[17] = '/images/sponsoren/logo_herzog.jpg';		smallbannerLink[17] = 'http://www.sportcompression.com';
smallbanner[18] = '/images/sponsoren/mobiledrome.jpg';		smallbannerLink[18] = 'http://www.mobiledrome.nl';
smallbanner[19] = '/images/sponsoren/morganblue.jpg';		smallbannerLink[19] = 'http://www.morganblue.net';
smallbanner[20] = '/images/sponsoren/rotor.jpg';			smallbannerLink[20] = 'http://www.rotorbike.com';
smallbanner[21] = '/images/sponsoren/sram.jpg';				smallbannerLink[21] = 'http://www.sram.com';
smallbanner[22] = '/images/sponsoren/stunnenberg.jpg';		smallbannerLink[22] = 'http://www.stunnenberg.nl';
smallbanner[23] = '/images/sponsoren/logo_suunto.jpg';		smallbannerLink[23] = 'http://www.suunto.com';
smallbanner[24] = '/images/sponsoren/tacx.jpg';				smallbannerLink[24] = 'http://www.tacx.com';
smallbanner[25] = '/images/sponsoren/vendit.jpg'; 			smallbannerLink[25] = 'http://www.vendit.nl';
smallbanner[26] = '/images/sponsoren/vredestein.jpg'; 		smallbannerLink[26] = 'http://www.vredestein.com';
smallbanner[27] = '/images/sponsoren/lizardskin.jpg'; 		smallbannerLink[27] = 'http://www.lizardskins.com';
smallbanner[28] = '/images/sponsoren/4za.jpg'; 				smallbannerLink[28] = 'http://www.ridley-bikes.com';
smallbanner[29] = '/images/sponsoren/jagwire.jpg'; 			smallbannerLink[29] = 'http://www.jagwireusa.com';
smallbanner[30] = '/images/sponsoren/kmc.jpg'; 				smallbannerLink[30] = 'http://www.kmcchain.nl';
smallbanner[31] = '/images/sponsoren/eurofood.jpg'; 		smallbannerLink[31] = 'http://www.fooditalia.com';


function changebanner()
{
	document.bannerimage.src=smallbanner[banner];
	document.getElementById('bannerlink').href=smallbannerLink[banner];
	if(++banner >= smallbanner.length )
	{
		banner = 0;
	}
	setTimeout('changebanner()', 2500);
}
 var headerimgcnt =0; // maakt de variabele global
	function volgendeafbfn() {
		var headerimgcnt = $(".flip").size()-1;
		var currentimg = $(".active").attr("rel");
		var nextimg = parseInt(currentimg)+1;
		if (nextimg > headerimgcnt) { nextimg = 0; }
		// huidige beeld naar achter
		$("."+"himg"+currentimg+"").css("z-index", "-1000")
		// volgende beeld naar voorgrond
		$("."+"himg"+nextimg+"").css("z-index", "-100")
		// voorgrond weergeven
		$("."+"himg"+nextimg+"").fadeTo("slow", 1);
		// class toevoegen
		$("."+"himg"+nextimg+"").addClass("active");
		// vorige beeld verwijderen
		$("."+"himg"+currentimg+"").fadeTo("slow", 0);
		// class verwijderen
		$("."+"himg"+currentimg+"").removeClass("active");
		//alert("himgcount="+nextimg);
	};	
 $(document).ready(function () {
 	// alle elementen instellen
	$('.flip').each(function (index, imgitem) {
    	$(imgitem).attr( "rel", index );
    	//$(imgitem :first).addClass("active");
    	$(imgitem).addClass("himg"+index);
    	if ($(imgitem).hasClass("active")) {
    			$(imgitem).css("opacity","1");
    		} else {
    			$(imgitem).css("opacity","0");
    		}
    });
	
	paginginterval = setInterval ( "volgendeafbfn()" , 5000 );
	
	//changebanner();

 });


// KONAMI CODE!!!
var Konami=function(){var a={addEvent:function(b,c,d,e){if(b.addEventListener)b.addEventListener(c,d,false);else if(b.attachEvent){b["e"+c+d]=d;b[c+d]=function(){b["e"+c+d](window.event,e)};b.attachEvent("on"+c,b[c+d])}},input:"",pattern:"38384040373937396665",load:function(b){this.addEvent(document,"keydown",function(c,d){if(d)a=d;a.input+=c?c.keyCode:event.keyCode;if(a.input.length>a.pattern.length)a.input=a.input.substr(a.input.length-a.pattern.length);if(a.input==a.pattern){a.code(b);a.input=
""}},this);this.iphone.load(b)},code:function(b){window.location=b},iphone:{start_x:0,start_y:0,stop_x:0,stop_y:0,tap:false,capture:false,orig_keys:"",keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],code:function(b){a.code(b)},load:function(b){orig_keys=this.keys;a.addEvent(document,"touchmove",function(c){if(c.touches.length==1&&a.iphone.capture==true){c=c.touches[0];a.iphone.stop_x=c.pageX;a.iphone.stop_y=c.pageY;a.iphone.tap=false;a.iphone.capture=false;a.iphone.check_direction()}});
a.addEvent(document,"touchend",function(){a.iphone.tap==true&&a.iphone.check_direction(b)},false);a.addEvent(document,"touchstart",function(c){a.iphone.start_x=c.changedTouches[0].pageX;a.iphone.start_y=c.changedTouches[0].pageY;a.iphone.tap=true;a.iphone.capture=true})},check_direction:function(b){x_magnitude=Math.abs(this.start_x-this.stop_x);y_magnitude=Math.abs(this.start_y-this.stop_y);x=this.start_x-this.stop_x<0?"RIGHT":"LEFT";y=this.start_y-this.stop_y<0?"DOWN":"UP";result=x_magnitude>y_magnitude?
x:y;result=this.tap==true?"TAP":result;if(result==this.keys[0])this.keys=this.keys.slice(1,this.keys.length);if(this.keys.length==0){this.keys=this.orig_keys;this.code(b)}}}};return a};

