
/* Global variables for links in browse to next or previous*/
var	sPrevLink = "";
var	sNextLink = "";
var ipid = 0;

jQuery(document).ready(function() {
	



	/* Create box for displaying pictures*/
	SqueezeBox.initialize({
		size: {x: 350, y: 0}
	});

	
	/* Activate popup box on clicks of hperlinks with the class "Boxed"*/
	SqueezeBox.assign($$('a.Boxed'), {
		parse: 'rel'
	});

	/* give class name to every LI of the top level items*/
	jQuery('.Menu').children('ul').children('li').addClass("MenuHead");
		
	jQuery('#nav>li>ul').addClass('subnav');
		
	/* Function for closing the panel before redirecting to the clicked page*/			
	jQuery('.menuitem').children('a').click(function()
	{	
		var iPageClicked = jQuery(this).attr('id');		
				
		/* close opened menus*/		
		jQuery(".smOW").hide(function()
		{
			/* set redirect URL*/
			sUrl = "http://www.bureauvijftig.nl/" + iPageClicked + "/"
					
			/* empty panel cannot be collapsed*/
			if (jQuery('#Panel').children().children().length > 0)
			{
				jQuery('#Panel').children('span').slideUp(600, function(){
					document.location = sUrl;
				});					
			} else 
			{
				document.location = sUrl;				
			}
		});
	});
	
	if(jQuery('#content h1').length > 0)
	{
		var myMenu = new MenuMatic({direction:{y:'up'}, hideDelay: 100, opacity:90});
	}	
	else 
	{

		var myMenu = new MenuMatic({direction:{y:'down'}, hideDelay: 100, opacity: 90});
		var subMenus = jQuery("##subMenusContainer ul")
		for (iCounter = 0; iCounter < subMenus.length; iCounter++)
		{
			jQuery(subMenus[iCounter]).css("border-top","none")
			jQuery(subMenus[iCounter]).css("border-bottom","1px solid rgb(210, 35, 42 )")
		}
	}		
});

jQuery('#Panel').ready(function(){		

	/* open the panel when accessing the page*/
	if (jQuery('#Panel').children().children().length > 0)
	{
		jQuery('#Panel').children('span').slideDown(400);
	}

	/*calculate page width*/
	oMenu = jQuery('table tr td ul').children('li');
	
	/*set default page width*/
	iMinWidth = 488;
	iMenuWidth = 0;

	for(iCounter = 0; iCounter < oMenu.length; iCounter++)
	{
		if (jQuery(oMenu[iCounter]).parent().parent("td").length > 0)
		{
			iMenuWidth += jQuery(oMenu[iCounter]).width();
				/*add margin*/
				iMenuWidth += 10; 
		}
	}

	if(iMinWidth < iMenuWidth)
	{
		iMinWidth = iMenuWidth;
	}
	jQuery('#content').width(iMinWidth);
		
});
	
function ShowFlash(sDelay)
{
	if (sDelay == "true")
	{
		self.setTimeout("ShowFlash('false')", 3000);
	} else
	{
		flash = document.getElementById("Flash");
		flash.style.display = 'Block';
		Timer("false");
	}
}
	
function Timer(sRedirect)
{
	if (sRedirect == "true")
	{
		document.location = sys_BaseUrl;
	} else
	{
		self.setTimeout("Timer('true')", 6000);
	}
}
	
function ToggleNavigation(sHeading)
{		
	jQuery(".smOW").hide(function(){
		/* empty panel cannot be collapsed*/
		if (jQuery('#Panel').children().children().length > 0)
		{
			jQuery('#Panel').children('span').slideUp(600, function(){
				switch(sHeading)
				{
					case "previous":
						location.href = sPrevLink + '/'
						break;
					case "next":
						location.href = sNextLink + '/'
						break;
				}							
			});					
		} else 
		{
			switch(sHeading)
			{
				case "previous":
					location.href = sPrevLink + '/'
					break;
				case "next":
					location.href = sNextLink + '/'
					break;
			}								
		}	
	});	
}