$(document).ready(function(){

/* ----------------- Global Vars----------------- */
var theCurrentSec = "#theHome";
var theCurrentServices = "#servicesConsulting";
var theCurrentSales = "#salesPrinters";
var secHeight = $("#theHome").height() + "px";
hideAllSectionsButHome();
// End Global Vars

/* ----------------- Functions ----------------- */
function hideAllSectionsButHome()
{
	$("#theServices").hide();
	$("#theSales").hide();
	$("#theAbout").hide();
	$("#theContact").hide();
	$("#loadSpinnerLeft").hide();
	$("#servicesTraining").hide();
	$("#servicesProCal").hide();
	$("#servicesPhotoTut").hide();
	$("#servicesPrinters").hide();
	$("#salesMedia").hide();
	$("#salesRIPs").hide();
	$("#salesColor").hide();
	$("#salesLights").hide();
	$("#salesAccessories").hide();
}

function showNewSection(nextSec)
{
	disableNavigation();
	showLoaderAnimation();
	$("#theContent").animate(
							 {height: "0px"},
							 750,
							 "easeOutQuart",
							 function()
							 {
								$(theCurrentSec).hide();
								$(nextSec).show();
								theCurrentSec = nextSec;
								changeSecHeight(nextSec);
								$("#theContent").animate(
														 {height:secHeight},
														 750,
														 "easeInQuart",
														 function()
														 {
															 hideLoaderAnimation();
															 $("#theNavigation ul li").unblock();
															 $("#theContent").css("height", "");
														 });
							 });	
}

function showServiceSubSection(nextSec)
{
	if(theCurrentSec != "#theServices")
	{
		$(theCurrentServices).hide();
		$(nextSec).show();
		showNewSection("#theServices");
		animateBanner(-840);
		theCurrentServices = nextSec;
	}
	else
	{
		$(theCurrentServices).hide("normal");
		$(nextSec).show("normal");
		theCurrentServices = nextSec;
	}
}

function showSalesSubSection(nextSec)
{
	if(theCurrentSec != "#theSales")
	{
		$(theCurrentSales).hide();
		$(nextSec).show();
		showNewSection("#theSales");
		animateBanner(-1680);
		theCurrentSales = nextSec;
	}
	else
	{
		$(theCurrentSales).hide("normal");
		$(nextSec).show("normal");
		theCurrentSales = nextSec;
	}
}


function disableNavigation()
{
	$("#theNavigation ul li, ").block({ 
									message: null,
									overlayCSS: {backgroundColor:'#EEE', opacity: '0'}  
									});
}

function showLoaderAnimation()
{		
		$("#loadSpinnerLeft").show(
									"slide",
									{easing: "easeOutCirc", direction: "right"}, 
									350); 
}

function hideLoaderAnimation()
{
		$("#loadSpinnerLeft").hide(
									"slide",
									{easing: "easeOutCirc", direction: "right"}, 
									350); 
}
function changeSecHeight(nextSec)
{
	secHeight = $(nextSec).height() + "px";
}
function animateBanner(thePosition)
{
	var positionH = thePosition + "px 0px"
	$("#theBanner").animate(
							{backgroundPosition:positionH}, 
							1500, 
							"easeOutQuart");
}

// End Functions

/* ----------------- Events ----------------- */

// main Navigation Btns

$("#homeNavBtn").click(function() {
	showNewSection("#theHome");
	animateBanner(0);
});

$("#servicesNavBtn, #contactQuickLinkHome, #servicesQuickLinkHome, #servicesQuickLinkSales, #servicesQuickLinkAbout, ").click(function() {
	showNewSection("#theServices");
	animateBanner(-840);
});

$("#salesNavBtn").click(function() {
	showNewSection("#theSales");
	animateBanner(-1680);
});

$("#aboutNavBtn").click(function() {
	showNewSection("#theAbout");
	animateBanner(-2520);
});

$("#contactNavBtn").click(function() {
	showNewSection("#theContact");
	animateBanner(-3360);
});

// Services Sidebar Btns

$("#showConsultingHome, #showConsultingServices, #showConsultingSales, #showConsultingAbout").click(function() {
	showServiceSubSection("#servicesConsulting");
});
$("#showTrainingHome, #showTrainingServices, #showTrainingSales, #showTrainingAbout").click(function() {
	showServiceSubSection("#servicesTraining");
});
$("#showProCalHome, #showProCalServices, #showProCalSales, #showProCalAbout").click(function() {
	showServiceSubSection("#servicesProCal");
});
$("#showPhotoTutHome, #showPhotoTutServices, #showPhotoTutSales, #showPhotoTutAbout").click(function() {
	showServiceSubSection("#servicesPhotoTut");
});
$("#showPrinterHome, #showPrinterServices, #showPrinterSales, #showPrinterAbout").click(function() {
	showServiceSubSection("#servicesPrinters");
});

// Sales SideBar Btns

$("#showSalesPrinters").click(function() {
	showSalesSubSection("#salesPrinters");
});
$("#showSalesMedia").click(function() {
	showSalesSubSection("#salesMedia");
});
$("#showSalesRIPs").click(function() {
	showSalesSubSection("#salesRIPs");
});
$("#showSalesColor").click(function() {
	showSalesSubSection("#salesColor");
});
$("#showSalesLights").click(function() {
	showSalesSubSection("#salesLights");
});
$("#showSalesAccessories").click(function() {
	showSalesSubSection("#salesAccessories");
});

// show top btn

$('#contactQuickLinkServices, #contactQuickLinkSales, #contactQuickLinkAbout, #contactQuickLinkClient').click(function(){
	$.scrollTo( 
			   'body', 
			   1000, 
			   {easing:'easeOutCirc', offset:-80} 
	);
});

// End Events

});

/* jQuery Timer Function

window.setInterval(function() {
}, 8000);

setTimeout($.unblockUI, 2000);

*/
