// JavaScript Document


$(document).ready(function(){

var url = window.location.href;
var page = url.substring(url.lastIndexOf('/') + 1);

//UNHIDE CSS
	document.getElementById("aboutSub").style.visibility = "visible";
	document.getElementById("howSub").style.visibility = "visible";
	document.getElementById("benefitsSub").style.visibility = "visible";

//HIDE MENUS
	$("#aboutSub").hide();
	$("#howSub").hide();
	$("#benefitsSub").hide();
	
//MAIN NAV ROLLOVERS	

function keepBenefitsSubOn(){
    if(page == 'operations.aspx' || page == 'servers.aspx' || page == 'consumer-intelligence.aspx' || page == 'menu-control.aspx' || page == 'promotions.aspx' || page == 'team-performance.aspx'){
        $("#benefitsSub").show();
    }
}

function keepHowSubOn(){
    if(page == 'system.aspx' || page == 'integration-with-pos.aspx'){
        $("#howSub").show();
    }
}

function keepAboutSubOn(){
    if(page == 'company.aspx' || page == 'management-team.aspx'){
        $("#aboutSub").show();
    }
}

function hideAboutSub(){
    if(page != 'company.aspx' && page != 'management-team.aspx'){
		$("#aboutSub").hide();
		
    }
    
}

function hideHowSub(){
    if(page != 'system.aspx' && page != 'integration-with-pos.aspx'){
        $("#howSub").hide();
    }
}

function hideBenefitsSub(){
    if(page != 'operations.aspx' && page != 'servers.aspx' && page != 'consumer-intelligence.aspx' && page != 'menu-control.aspx' && page != 'promotions.aspx' && page != 'team-performance.aspx'){
        $("#benefitsSub").hide();
    }
}

	$("#about").hover(
			function(){	
				$("#aboutSub").show();
				$("#howSub").hide();
				$("#benefitsSub").hide();	
			},
			function(){
			  $("#aboutSub").hide();
				$("#howSub").hide();
				$("#benefitsSub").hide();	
				//keepBenefitsSubOn();
				//keepHowSubOn();					
		});
		$("#how").hover(
			function(){	
				$("#howSub").show();
				$("#aboutSub").hide();
				$("#benefitsSub").hide();
			},
			function(){
			  $("#aboutSub").hide();
				$("#howSub").hide();
				$("#benefitsSub").hide();
				//keepAboutSubOn();
				//keepBenefitsSubOn();
		});
		$("#benefits").hover(
			function(){	
				$("#benefitsSub").show();
				$("#howSub").hide();
				$("#aboutSub").hide();
			},
			function(){
			  $("#aboutSub").hide();
				$("#howSub").hide();
				$("#benefitsSub").hide();
				//keepAboutSubOn();
				//keepHowSubOn();
		});
		
//SUB NAV ROLLOVERS
$("#aboutSub").hover(
			function(){	
				$("#aboutSub").show();
				$("#howSub").hide();
				$("#benefitsSub").hide();
			    $("#about").addClass("onsub");
			},
			function(){
				$("#aboutSub").hide();
				$("#howSub").hide();
				$("#benefitsSub").hide();
				//keepBenefitsSubOn();
				//keepHowSubOn();
				$("#about").removeClass("onsub");
		});
$("#howSub").hover(
			function(){	
				$("#howSub").show();
				$("#aboutSub").hide();
				$("#benefitsSub").hide();
				$("#how").addClass("onsub");
			},
			function(){
			  $("#aboutSub").hide();
				$("#howSub").hide();
				$("#benefitsSub").hide();
				//keepAboutSubOn();
				//keepBenefitsSubOn();
				$("#how").removeClass("onsub");
		});
$("#benefitsSub").hover(
			function(){	
				$("#benefitsSub").show();
				$("#howSub").hide();
				$("#aboutSub").hide();
				$("#benefits").addClass("onsub");
			
			},
			function(){
				$("#aboutSub").hide();
				$("#howSub").hide();
				$("#benefitsSub").hide();
				//keepAboutSubOn();
				//keepHowSubOn();
				$("#benefits").removeClass("onsub");				
		});

	
// HIGHLGHT ON PAGE DISPLAYED
//$("a[href = '" + page + "']").addClass("subOn");

switch (page){
case "company.aspx":
$("#about").addClass("mainNavOn");
//$("#aboutSub").show();
break;

case "consumer-intelligence.aspx":
$("#benefits").addClass("mainNavOn");
//$("#benefitsSub").show();
break;

case "contact.aspx":
    $("#contact").addClass("mainNavOn");
    break;

case "default.aspx":
    $("#home").addClass("mainNavOn");
    break;

case "integration-with-pos.aspx":
    $("#how").addClass("mainNavOn");
    //$("#howSub").show();
    break;

case "management-team.aspx":
    $("#about").addClass("mainNavOn");
    //$("#aboutSub").show();
    break;

case "menu-control.aspx":
    $("#benefits").addClass("mainNavOn");
    //$("#benefitsSub").show();
    break;

case "operations.aspx":
    $("#benefits").addClass("mainNavOn");
    //$("#benefitsSub").show();
    break;

case "promotions.aspx":
    $("#benefits").addClass("mainNavOn");
    //$("#benefitsSub").show();
    break;

case "servers.aspx":
    $("#benefits").addClass("mainNavOn");
    //$("#benefitsSub").show();
    break;
    
case "system.aspx":
    $("#how").addClass("mainNavOn");
    //$("#howSub").show();
    break;

case "team-performance.aspx":
    $("#benefits").addClass("mainNavOn");
    //$("#benefitsSub").show();
    break;
}

//FANCYBOX

$("a.zoom").fancybox({
		'titleShow'		: 	false,
		'titlePosition' : 	'inside',
		'autoscale'		:	true,
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	400, 
		'speedOut'		:	400,
		'easingIn'      : 	'easeOutBack',
		'easingOut'     : 	'easeInBack',
		'overlayShow'	:	false
	});
 
});
