
  
  $(document).ready(function(){

	if($("table.thumbnails").length>0)
		$("table.thumbnails").addTablePager({results : 6, position : "bottom"});	

	if($.cookie('treeview')===null) {
		//Set it also in a cookie so its restored after a page refresh
		var options = { path: '/', expires: 10 };
		$.cookie('treeview', '00000', options);
	}


    $("#tree").treeview({
		animated: "fast",
		unique: true,
		persist: "cookie"
	});
	$("#tree").css("display","block");

	
	//Taking care of the menu items and the hovers
	$("img[class=menu]").each(function() {
		
		//Hightlight when mouseover
		$(this).mouseover(function() {
			resetMenuItems();
			if(arrayKeyExists(menuButtons, $(this).attr('id')))
				$(this).attr('src', menuButtons[$(this).attr('id')]['buttonOn']);
		});

		//Remove highlight when move off
		$(this).mouseout(function() {
			resetMenuItems();
			if(arrayKeyExists(menuButtons, $(this).attr('id')) && $.cookie('currentMenuItem')!=$(this).attr('id'))
				$(this).attr('src', menuButtons[$(this).attr('id')]['buttonOff']);
		});
		
		//Register current menuItem
		$(this).click(function() {
			
			//Set it also in a cookie so its restored after a page refresh
			var options = { path: '/', expires: 10 };
			$.cookie('currentMenuItem', $(this).attr('id'), options);

		});

	});
	resetMenuItems();


	/*		Creating the click function for the blockUI			*/
	if($('a.enlarge').length>0) {
		
		$('a.enlarge').click(function() {

			//When the bigPhoto layer is not there add it
			if($('#bigPhoto').length==0) 
				$('#content').append('<div id="bigPhoto" class="displayNone"></div>');
			
			var headerBg = false;
			if(/pressItemId/i.exec(document.location.href)!==null)
				headerBg = '/images/pressBgTop.jpg';
			else if(/newsId/i.exec(document.location.href)!==null)
				headerBg = '/images/newsBgTop.jpg';
			


			//Creating the inside html
			var html = '<div id="bigPhotoHeading"><div class="bigPhotoLink">'
						+ '<a href="#" id="back">BACK</a></div></div><div id="bigPhotoMain">'
						+ '<div><img src="'+this.href+'" alt="" border="0"></div>'
						+ '</div>';
			
			//Overwrite any existing html
			$('#bigPhoto').html(html);
			$('#bigPhoto').css('height', $('body').innerHeight() + 'px');
			$('#bigPhotoMain').css('height', ($('body').innerHeight()-168) + 'px');
			$.blockUI.defaults.css.left = (($('body').innerWidth()-962)/2) + 'px';
			$.blockUI.defaults.css.width = '960px';
			$.blockUI.defaults.css.top = '0px';
			$.blockUI.defaults.css.border = '0px solid #000';
			$.blockUI.defaults.css.backgroundColor = '#000';
			$.blockUI.defaults.css.cursor = 'default';
			$.blockUI.defaults.overlayCSS.opacity = '0.0';
			$.blockUI.defaults.overlayCSS.backgroundColor = '#340068';
			$.blockUI.defaults.overlayCSS.cursor = 'default';
		    $.blockUI({ message: $('#bigPhoto') }); 
				
			if(headerBg!==false)
				$('#bigPhotoHeading').css('background-image', 'url('+headerBg+')');	

			$('div.blockPage').css('height', $('body').innerHeight());
			$('div.blockPage').css('background-image', 'url(/images/pressBg.jpg)');

			$('div.blockOverlay').click(function() {
				$.unblockUI();
				$('#bigPhoto').html('');
			});
			$('#back').click(function() {
				$.unblockUI();
				$('#bigPhoto').html('');
			});
			return false;

		});
	}


  });