/*
	Quetools Renderer Custom Script
	For Quetools Renderer
	Copyright 2010 Decomplexity
*/

/*
	Executed on DOM Ready	
*/
var domLoaded = function(){

	// Autosizes the mainmenu items to fill their containing UL element
	// A width must be set on the top level <ul> element of the menu
	elastoNav($($('.lMainLevel:first').parent()).width());
	
	highlightSelectedDay();

}


/*
	Executed on Window Load
*/
var contentLoaded = function(){

	//cleanup(); // Clear extra whitespace from content
	
	/*
		Set up Menus
	*/
	$("ul.sf-menu").supersubs({ 
		minWidth:    12,
		maxWidth:    27,
		extraWidth:  1
	}).superfish({
		animation:   {opacity:'show',height:'show'}
	});	
	
	$(".dAnimalListEntryObject a").fancybox({
		onComplete: function(e){
			
				// Process thumbnails, make em open in big foto
				$(".aAnimalDetailImage").each(function(i, e){
	
					$(e).click(function(el){
	
						el.preventDefault();
						
						if($(this).children('img')[0]){ 
						
							$('#dAnimalMaximisedPhoto').attr('src', $(this).children('img')[0].src.replace('maxx=120', 'maxx=400').replace('maxy=120', 'maxy=400'));
						
							// Add Title
							var title = $(this).attr('title').split("::");
							if(title) $("#dAnimalDescription").html("<strong>"+title[0]+"</strong> "+title[1]);
							
						}
					
					});
				
				});
				
				// Fix EBVs
				
				$('.ebvVal').each(function(i, e){
				
					if($(e).html() != ""){
					
						if($(e).html()[0] != "-") $(e).html("+"+$(e).html());
					
					}
				
				});
				
				$('.accuracy').each(function(i, e){
				
					if($(e).html() != ""){
					
						$(e).html($(e).html()+"%");
					
					}
				
				});
				
				if($('#ebvContainer').html().trim() == ""){
				
					$('#ebvlnk').hide();
				
				}
				
				if($('#notesContainer').html().trim() == ""){
				
					$('#noteslnk').hide();
				
				} 
				
			}
		});
	
	hideOverlay();
	
	// Autosizes the mainmenu items to fill their containing UL element
	// Run for a second time to check after images have loaded
	// A width must be set on the top level <ul> element of the menu
	elastoNav($($('.lMainLevel:first').parent()).width());

}

/*
	Tick Loading Animation
*/
var loadingTick = function(progress, canvas){
	
	// Draw loading animation here
	
}
