var name = "#menu";
var menuYloc = null;

$(document).ready(function(){
			$(".agenda-item").hover(makeTall,makeShort);
			$("#essays-list li").hide();
			$("#essays-list li:lt(3), #link-laag-essays").show();
			
			$.preloadImages("../img/bg-1.jpg", "../img/bg-2.jpg", "../img/bg-3.jpg", "../img/bg-4.jpg", "../img/bg-5.jpg");
	
			menuYloc = parseInt($(name).css("top").substring(0,$(name).css("top").indexOf("px")))
			$(window).scroll(function () { 
				offset = menuYloc+$(document).scrollTop()+"px";
				$(name).animate({top:offset},{duration:500,queue:false});
			});
			
			$('.main-menu').click(function(){
			setPage();
			return false;
			});
			
			setPage();
			
}); // close document.ready

function makeTall(){  $(this).animate({"height":'100%'},200);}
function makeShort(){ $(this).animate({"height":28},200);}

function wrapFotoVideo() {
	var count = 0;
	var o = document.getElementsByTagName("div");
	for(var i=0;i<o.length;i++){
    	if(o[i].className == "foto-film-item")
        	count ++;
	}
	
	if(count>7) {
		var y = Math.round(count/7);
		if(y<count) {
			y=y+1;
		}
	}
	else if (count<=7) {
		var y = 1;
	}
	
	for(var i=0;i<y;i++) {
		$('<li><a href="#tabs-'+(i+1)+'" class="din-ce-light">'+(i+1)+'</a></li>').appendTo('ul#tabs-nav');
		$("#foto-film-item-"+(1+i*7)+",#foto-film-item-"+(2+i*7)+",#foto-film-item-"+(3+i*7)+",#foto-film-item-"+(4+i*7)+",#foto-film-item-"+(5+i*7)+",#foto-film-item-"+(6+i*7)+",#foto-film-item-"+(7+i*7)+"").wrapAll('<div id="tabs-'+(i+1)+'"></div>');
	}
$(document).ready(function(){
	$("#tabs").tabs();
	});
}

function createPlayer(BaseURL, fileWidth, fileHeight, iFile)
{
var s1 = new SWFObject(BaseURL+'swf/flvplayer.swf', 'FlowPlayer', fileWidth, fileHeight, '8');
s1.addVariable('width', fileWidth);
s1.addVariable('height', fileHeight);
s1.addVariable('displayheight', fileHeight);
s1.addVariable('file', '../foto-film/items/'+iFile);
s1.addVariable('autostart', 'true');
s1.addVariable('backcolor', '0xFFFFFF');
s1.addVariable('frontcolor', '0xFFFFFF');
s1.addVariable('lightcolor', '0xFFFFFF');
s1.addVariable('usefullscreen', 'false');
s1.write('videodiv');
}

function unloadMenu() {
	$('#content-loader').load('foto-film/photo.php #empty');//$('#boeken-menu').load('foto-film/photo.php #empty');
}
function unloadEssays() {
	$('#essays-preview').css('z-index', '-1');
}
function unloadNieuws() {
	$('#agenda-nieuws').css('z-index', '-1');
}

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

function setPage() {
	var url = document.location.toString();
			if (url.match('#')) {
			var urlAnchor = url.split('#')[1];
			}
			
			$('#content-loader').load(urlAnchor);
	  //unloadMenu();
	  unloadEssays();unloadNieuws();
	  
	  /*if(urlAnchor == "/boeken/pfitem.php") {
			$('#boeken-menu').load('boeken/submenu.php')
			}*/
	  
	  var randomNr = Math.floor((6-1)*Math.random()) + 1;
	//alert(randomNr);
	$(document.body).css('backgroundImage', 'url(../img/bg-'+randomNr+'.jpg)');
	scroll(0,0);
}

function setBiblioPage(thisTarget) {
			$('#content-loader').load(thisTarget);
}

function hideAgendaMSIE(x) {
jQuery.each(jQuery.browser, function(i) {
  if($.browser.msie){
     $("#titel-laag-agenda").css("visibility",x);
  }
});
}

