$(document).ready(function(){	

	

	// CALL FUNCTIONS

	otherdropdown();

	work_meta_team();

	work_meta_team_none();

	

	thumbnail_listing();

	

	contact_showhide();

	contact_submit()

	

	scroll_totop();

	

	hpContent();



}); 







// OTHER PROJECTS ON PROJECT/CASE STUDY PAGE

function otherdropdown() {

    $('div#other_projects').hide();

	

	$("h4#other_projects_toggle").click(

		function () {

    		$("div#other_projects").slideToggle("middle");

    		$(this).toggleClass("down");

			return false;

		}

	);

}





		

// WORK SINGLE ENTRY META TEAM COUNT (used for styling)

function work_meta_team() {

	var list_children = $('ul#project_team').children();

    $('ul#project_team').addClass('count'+list_children.length);

}







// WORK SINGLE ENTRY META TEAM COUNT - NO RELATED TEAM MEMBERS (hide the list and the previous heading)

function work_meta_team_none() {

    // $('ul#project_team.count0').hide();

    $('ul#project_team.count0').prev('h5').hide();

}

	





// THUMBNAIL LISTING

function thumbnail_listing() {

    $('ul.thumbs_list li a').click(

        function () {

            var new_href = $(this).attr('href');

            

            // SWAP IMAGES

            $('ul.thumbs_list').prev('img').attr({"src":new_href});

            

            //REMOVE CLASSES FROM ALL LIST ITEMS

            $('ul.thumbs_list li').removeClass('cur');

            

            // ADD CLASS TO CLICKED ON ITEM

            $(this).parent().addClass('cur');

            

            return false;

        }

    );

}







// CONTACT FORM SHOW/HIDE 

function contact_showhide() {

    $('fieldset#contact_more').hide();

    

    $('div#contact_options ul li a').click(

		function () {

        	$('fieldset#contact_more').slideToggle('slow');

        	$(this).parent().toggleClass('less');

          	return false;

      	}  

    );

	

	$('div#contact_options ul li a').toggle(

		function () {

	    	$(this).text('Hide Form');

	    },

	    function () {

	        $(this).text('Extend Form');

	    }

	);

}







// CONTACT FORM SUBMIT BUTTON

function contact_submit() {

	$('fieldset#contact_action input').click(

		function () {

			$(this).addClass('loading');

		}

	);

}







// FOOTER TO TOP SCROLL

function scroll_totop() {

	$('p#to_top a').click(

	    function(){

    		$.scrollTo( '#branding', 500 );

    		return false;

    	}

    );

}





function hpContent(){

	

	$('body.home2 ul#homepage_featured_navigation li a').click(

	

		function() {

			

			var target = $(this).attr('href');

			

			$('div#content_sec').height( $('div#content_sec').height() );

			

			$('ul#homepage_featured_navigation').load(target+' ul#homepage_featured_navigation > ', function(){



            $('div#content_sec >').fadeOut('fast');



				var clone = $('div#content_sec').clone().load(target+' #content_sec >',



				function(){

					$('div#content_sec').replaceWith(clone);

					$('div#content_sec >').hide();

					$('div#content_sec >').fadeIn('fast');

					hpContent();

				}



			);

			

			});

			

		    return false;

		}

		

	);



}
