﻿
$(document).ready(function() {
    //Setup HomeBox. Nothing will happen if the homepage box is not found
    HomeBox_Setup();
});

function NavBarLoad() {
    //check height of left side and adjust if needed
    var newHeight = $('.NavBar').height();
    var oldHeight = $('.NavBarLimit').height();
    if (newHeight > oldHeight) {
        var marginBottom = 53;
        $('.divLeftBottom').hide();
        $('.NavBarLimit').height((newHeight + marginBottom));
        $('.divLeftBottom').show();
    }
 }

function OnBeforeExpandToggle() {
    $('.divLeftBottom').hide();
}

function ExpandToggle() {
    var newHeight = $('.NavBar').height();
    var oldHeight = $('.NavBarLimit').height();
    var marginBottom = 53;
    if (newHeight > 390) {
        $('.iMission').hide();
    }
    else {
        $('.iMission').show();
    }

    $('.NavBarLimit').height((newHeight + marginBottom));
    $('.divLeftBottom').show();
}

//------------- HomeBox Methods START ------------------

var IsHoveringHomePageBox = false;
function HomeBox_Setup() {
    var isOnHomePage = $('#divHomePageBox').length > 0;
    if (isOnHomePage) {
        $('#divNavLeft').click(function() { MultiPage1.goPrevious(true); HomeBox_UpdateNumbers(); });
        $('#divNavRight').click(function() { MultiPage1.goNext(true); HomeBox_UpdateNumbers(); });
        $('#divNav1').click(function() { MultiPage1.setPageIndex(0); HomeBox_UpdateNumbers(0); });
        $('#divNav2').click(function() { MultiPage1.setPageIndex(1); HomeBox_UpdateNumbers(1); });
        $('#divNav3').click(function() { MultiPage1.setPageIndex(2); HomeBox_UpdateNumbers(2); });
        $('#divNav4').click(function() { MultiPage1.setPageIndex(3); HomeBox_UpdateNumbers(3); });
        $('#divHomePageBox').hover(
        function(e) { IsHoveringHomePageBox = true },
        function(e) { IsHoveringHomePageBox = false; });

        $('#divNav1').addClass("HN1Selected");
        HomeBox_QueueRotate();
    }
}
function HomeBox_Rotate() {
    //skip if hovering. 
    if (IsHoveringHomePageBox == false) {
        MultiPage1.goNext(true);
        HomeBox_UpdateNumbers();
    }
    HomeBox_QueueRotate();
}

function HomeBox_QueueRotate() {
    setTimeout('HomeBox_Rotate();', 8000);
}

function HomeBox_UpdateNumbers(index) {
    if (index == null) {
        index = MultiPage1.getPageIndex();
    }

    $('#divNavByNum div').removeClass();

    switch (index) {
        default:
        case 0: $('#divNav1').addClass("HN1Selected"); break;
        case 1: $('#divNav2').addClass("HN2Selected"); break;
        case 2: $('#divNav3').addClass("HN3Selected"); break;
        case 3: $('#divNav4').addClass("HN4Selected"); break;
    }
}

//------------- HomeBox Methods END ------------------


//Script to Disable Right Clicking START----------------------------
		var message="";
		///////////////////////////////////
		function clickIE()
		{
			if (document.all)
			{
				(message);
				return false;
			}
		}
		 
		function clickNS(e) 
		{
			if(document.layers||(document.getElementById&&!document.all))
			{
				if (e.which==2||e.which==3) 
				{
					(message);
					return false;
				}
			}
		}
		
		//Runs upon loading..with some specific page exceptions
		if(document.location.toString().toLowerCase().indexOf('affiliateprogram.aspx') == -1)
		{
			if (document.layers)
			{
				document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
			}
			else
			{
				document.onmouseup=clickNS;document.oncontextmenu=clickIE;
			}
		document.oncontextmenu=new Function("return false")
		}
//Script to Disable Right Clicking END----------------------------
