﻿/// <reference path="jquery-1.3.2-vsdoc2.js"/>

var currentMenuId = "";
function SetCurrentMenu(menuHolderId) {
    var mypath=$(location).attr('href');
    if (menuHolderId=='home')
    {
     if (mypath.match('/environment/')) {menuHolderId = 'environment';}
     else if (mypath.match('/bariatrics/')) {menuHolderId = 'bariatrics';}
     else if (mypath.match('/surgical-affiliates/')) {menuHolderId = 'affiliates';}
    }
    $("#" + menuHolderId).attr("class", "navHolderSelected");
    $("#" + menuHolderId + "Box").attr("class", "navOrangeBox");
    $("#ctl00_siteBottomNav_" + menuHolderId).addClass("selected");
    currentMenuId = menuHolderId;
}

function MenuOn(menuHolderId) {
    if (currentMenuId != menuHolderId) {
        $("#" + menuHolderId).attr("class", "navHolderOn");
    }
}

function MenuOff(menuHolderId) {
    if (currentMenuId != menuHolderId) {
        $("#" + menuHolderId).attr("class", "navHolder");
    }
    if (menuHolderId != 'info') {
        HideSubmenu();
    }
}

function ScrollToFirstError() {
    $.scrollTo($(".errorDisplay"), "slow");
}

function FormComplete() {
    $.scrollTo($("#thankYou"), "slow", function() {
        $(".stateList").hide();
        $("#thankyouHolder").fadeIn("slow");
    });
}

function CloseThankYou() {
    $("#thankyouHolder").fadeOut("slow", function() {
        $(".stateList").show();
        $('html, body').animate({ scrollTop: 0 }, 'slow');
    });
}

function Console(message) {
    $("#console").html(message);
}

//function SetPositionToCenter(objectId, objectWidth, objectHeight) {
//    var topPosition = ($(window).scrollTop() + ($(window).height() / 2) | 0) - objectHeight;
//    var leftPosition = ($(window).scrollLeft() + ($(window).width() / 2) | 0) - objectWidth;
//    document.getElementById(objectId).style.top = topPosition + "px";
//    document.getElementById(objectId).style.left = leftPosition + "px";
//}

function ShowLargeImage(imageId) {
    SetPositionToCenter(imageId, 0, 50);
    $("#" + imageId).fadeIn("slow", function() {
        $("#outerHolder").fadeTo("normal", 0.3);
    });
}

function HideLargeImage(callerObject) {
    $("#" + callerObject.id).fadeOut("slow", function() {
        $("#outerHolder").fadeTo("normal", 1);
    });
}

//menuitems---------------------------------------------------------------
var currentlyVisibleMenu = "";
var timeOut = null;
function ShowMenu(menuId, object) {
    CancelHide();
    if (currentlyVisibleMenu != "")
        $("#" + currentlyVisibleMenu).hide();
    $("#" + menuId).show();
    currentlyVisibleMenu = menuId;
}

function HideSubmenu() {
    if (currentlyVisibleMenu != "") {
        $("#" + currentlyVisibleMenu).fadeOut("slow", function() {

        });
        currentlyVisibleMenu = "";
    }
}

function StartHide() {
    if (timeOut == null)
        timeOut = setTimeout("HideSubmenu();", 1500);
}

function CancelHide() {
    if (timeOut != null) {
        clearTimeout(timeOut);
        timeOut = null;
    }
}

//careers sliders
var currentJobID = "";
function ShowJob(jobID) {
    if (currentJobID != "") {
        HideJob(currentJobID);
    }
    if (currentJobID == jobID) {
        currentJobID = "";
    }
    else {
        $("#" + jobID).slideDown("fast");
        currentJobID = jobID;
    }
}

function HideJob(jobID) {
    $("#" + jobID).slideUp("fast");
}

//featured physician
function ShowPopUp(popUpId) {
    $("#bottomNavOuterHolder").hide();
    $(popUpId).fadeIn("fast");
}

function HidePopUp(popUpId) {
    $(popUpId).fadeOut("fast", function() {
        $("#bottomNavOuterHolder").show();
    });
}

//---------------------------------------------------------------------

$(document).ready(function() {
    $("#barImageHolderTable").fadeTo(0, 0);
    var randomnumber = Math.floor(Math.random() * 12)
    if (randomnumber == 0)
        randomnumber = 1;
    SetStartPosition(randomnumber);

   jQuery('.js-slide-down-rest-of-story').click(function(){
      jQuery(this).parents('p:first').next('.js-rest-of-story').slideDown();
      jQuery(this).hide();
      return false;
   });
});

