$(document).ready(function() {
	if($.browser.msie == true && $.browser.version < 6 && check55 == true){
		// alert("ie 5.5");
		$("#page").html("<p>Deze pagina wordt niet ondersteund door jouw browser.</p><p>Download een van onderstaande browsers als je deze pagina wil bekijken.</p><ul><li><a href='http://www.microsoft.com/belux/nl/windows/downloads/ie/getitnow.mspx' target='_blank'>Internet Explorer 7</a></li><li><a href='http://www.getfirefox.com' target='_blank'>Firefox</a></li></ul>");
	}else{
			/* thumb carousel
			------------------------------------------------------------ */
			$('#mycarousel').jcarousel({
				buttonNextHTML : "<a><!-- &nbsp; --></a>",
				buttonPrevHTML : "<a><!-- &nbsp; --></a>",
				scroll: 5,
				itemFirstInCallback: {onAfterAnimation: mycarousel_itemFirstInCallback},
				animation: "slow"
			});
	
	}
	
	$('#img_doc ul li').mouseover( function(){
		$(this).addClass("hoever");
	});
	
	$('#img_doc ul li').mouseout( function(){
		$(this).removeClass("hoever");
	});
	
	if($.browser.msie == true && $.browser.version < 6){
		// alert("ie 5.5");
		$("#detail_doc").css("display","none");
		$("#img_doc").css("display","none");
		$("#tabs").css("display", "none");
	}else{
		/* big carousel
		------------------------------------------------------------ */
		$('#mycarousel2').jcarousel({
			buttonNextHTML : null,
			buttonPrevHTML : null,
			scroll: 1,
			itemFirstInCallback: {onAfterAnimation: initializeCarousel},
			initCallback: mycarousel_initCallback,
			animation: "slow"
		});
	}
	
	function mycarousel_initCallback(carousel) {
			carousel2 =  carousel;
			bindKeys(carousel);
			jQuery('.volgende').bind('click', function() {
					carousel.next();
				itemVisibleInCallback: {
			 		 onBeforeAnimation: switchToActive(carousel.prevFirst+1)
				}
				
				return false;
			});
					
			jQuery('.vorige').bind('click', function() {
				carousel.prev();
				itemVisibleInCallback: {
			 		 onBeforeAnimation: switchToActive(carousel.prevFirst-1)
				}
				return false;
			});
			
			totalpictures = 0;
			$('#fotoholder ul li').each(function(){
				totalpictures = totalpictures + 1;
			});
	};
		
});

function bindKeys(carousel){
	jQuery('.carousel2-control').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr("id")), false);
			//switchToActive(jQuery.jcarousel.intval(jQuery(this).text()));
			itemLastInCallback: {
			  onAfterAnimation: {switchToActive(jQuery.jcarousel.intval(jQuery(this).attr("id")))}
			}
			return false;
	});
}


function switchToActive(id){
	if(activepicture == 1 && id > 1){
		$('.vorige').removeClass("vorige_disabled");
	}
	if(activepicture > 1 && id == 1){
		$('.vorige').addClass("vorige_disabled");
	}
	if(activepicture < totalpictures && id == totalpictures){
		$('.volgende').addClass("volgende_disabled");
	}
	if(activepicture == totalpictures && id < totalpictures){
		$('.volgende').removeClass("volgende_disabled");
	}
	if(id>0 && id <= totalpictures){
		$('.on').removeClass("on");
		$('#'+id).addClass("on");
		
		if(id>activepicture && (thumbcarousel.first + 4)<id){
			thumbcarousel.scroll(id);
		} 
		if(id<activepicture && (thumbcarousel.first > id)){
			thumbcarousel.scroll(id-4);
		}
		activepicture = id;
	}
}

	

function styleMyMap(){
		alert("Style my map");
		/*if($("#map div").text() == "Map"){
			alert(this);
		}*/
}
