$(document).ready(function(){	
	
	// CALL FUNCTIONS
	otherdropdown();
	work_meta_team();
	work_meta_team_none();
	
	thumbnail_listing();
	
	contact_showhide();
	contact_submit()
	
	scroll_totop();

}); 



// 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;
    	}
    );
}
