/*
	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('#dMenu ul');
	
	// Calendar Function
	highlightSelectedDay();
}


/*
	Executed on Window Load
*/
var contentLoaded = function(){

	//cleanup(); // Clear extra whitespace from content
	
	/*
		Set up Menus
	*/
	var arrow;
	var closeDelay = 400;
	
	$("ul.sf-menu").supersubs({ 
		minWidth:   12,
		maxWidth:   27,
		extraWidth: 1
	}).superfish({
		animation:  {opacity:'show',height:'show'},
		speed:		300,
		easing:		'swing',
		delay:		closeDelay,
		onBeforeShow: function(){ 
			
			arrow = ($(this).prev().after('<img class="arrow" src="/images/subnav_arrow.png" alt="" />'));
			$(this).prev().animate({opacity:'show'},300);
			$(this).addClass('open');
			
			
		},
		onHide: function(){ 

			if($(this).hasClass('open')){
				$(this).prev().remove();
				$(this).removeClass('open');
				arrow = null;
			}

		}
	});	
	
	$('.dAnimalEntryParents').each(function(i, e){ 
	
		var text = $(e).html();
		text = text.replace('Dam:', '<br />Dam:');
		$(e).html(text);
		
	});
	
	$('.dAnimalListEntryColour').each(function(i, e){ 
	
		var text = $(e).html();
		text = text.replace('Horn: ', '');
		$(e).html(text);
		
	});
	
	$(".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=500').replace('maxy=120', 'maxy=500'));
					
						// Add Title
						var title = $(this).attr('title').split("::");
						if(title) $("#dAnimalDescription").html("<strong>"+title[0]+"</strong> "+title[1]);
						
					}
				
				});
			
			});
			
		}
	});
	
	hideOverlay();
	
	//$('#dScroller').nivoSlider();
	
	//$('.nivo-controlNav').css('width', $('.nivo-controlNav').width());
	
	// 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($('#dMenu ul'));

}

/*
	Tick Loading Animation
*/
var loadingTick = function(progress, canvas){
	
	// Draw loading animation here
	
}
