
//requires jQuery


//wait for the DOM to be loaded
jQuery( document ).ready( function() {
	
	//PAGE BACKGROUND - insert drop shadow divs
	$( 'div#page' ).append( '<div id="pageBgTop"></div>' );
	$( 'div#page' ).append( '<div id="pageBgTopLeft"></div>' );
	$( 'div#page' ).append( '<div id="pageBgTopRight"></div>' );
	$( 'div#page' ).append( '<div id="pageBgRight"></div>' );
	$( 'div#page' ).append( '<div id="pageBgBottom"></div>' );
	$( 'div#page' ).append( '<div id="pageBgBottomLeft"></div>' );
	$( 'div#page' ).append( '<div id="pageBgBottomRight"></div>' );
	$( 'div#page' ).append( '<div id="pageBgLeft"></div>' );
	
	//HEADER 1 - move the main header above the main nav
	//$( 'h1' ).insertBefore( 'div#nav' );
	
	//Set captions to images
	$( 'img.caption' ).jcaption( {} );
	
	//$( 'img.heroRight' ).wrap( '<div class="heroRight"></div>' );
	//$( 'img.heroRight' ).removeClass( 'heroRight' );
	
	//Hide/ show more images in image galleries.
	oShowImages.init();
	
	// contact form error label
	$('.errorBox').each(
	    function(){
	        var visibilityItem = $(this).css("visibility");
	        if (visibilityItem == 'hidden')
	        {
	            $(this).css("display","none");
	        } 
	        else
	        {
	            $(this).css("display","block");
	        }
	    }
	);
} );

//Hide/ show more images in image galleries.
oShowImages =
{
	pHideLimit : 9
	,
	init : function()
	{
		//Validate list has more than the minimum photo count.
		if( $( 'ul.photoGallery li' ).size() <= oShowImages.pHideLimit ){ return; };
		
		//Hide all photos over the minimum amount.
		$( 'ul.photoGallery li:gt(' + (oShowImages.pHideLimit-1) + ')' ).addClass( 'hide' );
		
		//Add a link to show/ hide extra photos.
		$( 'ul.photoGallery' ).after( '<p><a id="moreImages" href="javascript:;">more images</a></p>' );
		$( 'a#moreImages' ).click( function () {
      		$( 'ul.photoGallery li:gt(' + (oShowImages.pHideLimit-1) + ')' ).toggleClass( 'hide' );
    	});
		/*
		//$( 'ul.photoGallery li:gt(9)' ).addClass( 'hide' );
		$( 'ul.photoGallery li:nth-child(9)' ).after( '<span id="poo">' );
		$( 'ul.photoGallery li:last-child' ).after( '</span>' );

		$( 'ul.photoGallery li span#poo' ).hide();
		
		//Add a link to show/ hide extra photos.
		$( 'ul.photoGallery' ).after( '<p><a id="moreImages" href="javascript:;">more images</a></p>' );
		$( 'a#moreImages' ).click( function () {
      		$( '#poo' ).slideToggle( 'fast' );
    	});
		*/
	}
};//end object literal 
