//show email modal

function show_become_client(state) {
	if(state === 1) {
		$("#personSearchForm").hide(); 
		$('#general_backdrop').height($(document).height());
		$('#general_backdrop').css('opacity', 0.6).fadeIn("fast");
		$("#becomeclient_window").fadeIn("fast");
		
	} else {
		$("#personSearchForm").show(); 
		$("#becomeclient_window").fadeOut("fast");
		$("#general_backdrop").fadeOut("fast");
	}
	return false
}

function loadModalPage(page)
{
	var pageUrl ='/BAC/content/' + page + '.html';
	$("#bc_content").load(pageUrl,{},function(){ applyRules(page); } );
}

function loadApproachContent(navsection, page)
{
	$('div.item:*').removeClass('approach_tab_on');
	$('div.item:eq(' + navsection +')').addClass('approach_tab_on');
	$("#approach-content").load(page);
}

/* ALL DOM READY ACTIONS */

$(document).ready(function(){

	
	$("li.navtab")
	.hover(
			function () {
				$(this).css("backgroundImage","url(/BAC/img/bc/" + this.id + "_over.gif)");
			}, 
			function () {
				//If this is not currently selcted
				if(!$(this).hasClass('nav_selected')){
					$(this).css("backgroundImage","url(/BAC/img/bc/" + this.id + "_off.gif)");
				}
			}
		)
	.click(
			function () {
				activateNavTab(this.id);
			}
		);



});

function activateNavTab(elemId){
	
				var elem = '#'+elemId;
	
				$('li.navtab:*').removeClass('nav_selected');
				//Foreach nav item, set its default bg.
				
				$('li.navtab:*').each(function() {  $(this).css("backgroundImage","url(/BAC/img/bc/" + this.id + "_off.gif)");  });
				$(elem).css("backgroundImage","url(/BAC/img/bc/" + elemId + "_over.gif)");
				$(elem).addClass('nav_selected');	
				
}

function applyRules(page){

	$(".one_case")
	  .css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0 -440px)"}, {duration:300, complete:function(){
							$(this).addClass('one_case_on');
					}})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:300, complete:function(){
							$(this).removeClass('one_case_on');
					}})
		});


	switch(page)
	{
	case 'overview':
    activateNavTab('navtab_' + page); //Set top nav
		//Deactivate for now //$('#become_client_home > #img_container').cycle({  fx: 'fade',  speed:  2500  });
		break;    
	case 'approach':
    activateNavTab('navtab_' + page); //Set top nav

		$(".item").css('opacity','0'); //hide all		
    $('#item1').animate( {opacity: 0}, 100).animate( {opacity: 1.0}, 500) ;
    $('#item2').animate( {opacity: 0}, 500).animate( {opacity: 1.0}, 500) ;
    $('#item3').animate( {opacity: 0}, 800).animate( {opacity: 1.0}, 500) ;
    $('#item4').animate( {opacity: 0}, 1300).animate( {opacity: 1.0}, 500) ;
		
		loadApproachContent(0, '/BAC/content/approach-text-1.html');
		break;
	case 'casestudies':
    activateNavTab('navtab_' + page); //Set top nav
		break;  		
	case 'getintouch':
    activateNavTab('navtab_' + page); //Set top nav
		break;
 default:
		
	}





}

	
