

// This javascript will take a hidden panel on a html page and when a certain link is
// clicked it shows the panel in the middle of the screen with the rest of the screen
// grayed out and disabled.  The modal panel is to be used for any warnings about
// leaving the current website and will have a link to the website the orginally
// clicked link was set for
//
// linkid is the id of the hyperlink that when clicked will trigger the modalpanel
// to show up
// 
// modalpanelID is the id of the panel to be shown when the link is clicked.
//  this function needs to be set up on the document load using a script like this.
//
// <script type="text/javascript" language="JavaScript">
//    $(document).ready(function() {
//        var GoogleMapPanelID = 'pnlGoogleMap';
//        var districtOneMapLink = '<%= hlDistrict1MapDrivingDirections.ClientID %>';
//        ShowModalLinkForwardingPanel(districtOneMapLink, GoogleMapPanelID);        
//    });
//  </script>
//
// somewhere in the page a hidden div needs to be place with a id of "mask"
// <div id="mask"></div>
//  the css needs to be set to include these attributes
// #mask {   
//  position:absolute;   
//  z-index:9000;   
//  background-color:#000; 
//  display:none;
//}
//
// the css of the div (modal panel) to be shown should be include these attributes
//     
//#modalpanel {   
//  position:absolute;   
//  display:none;   
//  z-index:9999;
//}
//
// the link to be forwarded to should have the class "ForwardedLink"
// any button or link that will cancel the modal panel should have the class "close"
function ShowModalLinkForwardingPanel(linkid, modalpanelID) {

    var s;

    //select all the a tag with name equal to modal
    $(jq(linkid)).click(function(e) {
        //Cancel the link behavior   
        e.preventDefault();
        //Get the A tag   
        var id = $(jq(modalpanelID));
        $('.ForwardedLink').attr("href", $(jq(linkid)).attr("href"));

        //Get the screen height and width   
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set height and width to mask to fill up the whole screen
        $('#mask').css({ 'width': maskWidth, 'height': maskHeight, 'top': 0, 'left': 0 });


        //transition effect        
        $('#mask').fadeIn(500);
        $('#mask').fadeTo("fast", 0.5);

        //Get the window height and width   
        var winH = $(window).height();
        var winW = $(window).width();

        //Set the popup window to center   
        $(id).css('top', winH / 2 - $(id).height() / 2);
        $(id).css('left', winW / 2 - $(id).width() / 2);

        //transition effect
        $(id).fadeIn(2000);

        s = setInterval("scrollingModalLinkForwardingPanelDetector(" + modalpanelID + ")", 500);

    });

    //if close button is clicked
    $('#' + modalpanelID + ' .close').click(function(e) {
        //Cancel the link behavior   
        e.preventDefault();
        $('#mask').hide();
        $(jq(modalpanelID)).hide();
        clearInterval(s);
    });

    //if mask is clicked   
    $('#mask').click(function() {
        $(this).hide();
        $(jq(modalpanelID)).hide();
        clearInterval(s);
    });

};

// sets the elements top/left position to place it in the center of the browser
//  no matter the size or where the scroll is on the page.
function scrollingModalLinkForwardingPanelDetector(modalpanelID) {
    if ($(jq(modalpanelID.id)).css("display") != 'none') {
        var id = $(jq(modalpanelID.id));

        //Get the window height and width   
        var winH = $(window).height();
        var winW = $(window).width();

        var scrOfX = 0, scrOfY = 0;
        if (typeof (window.pageYOffset) == 'number') {
            scrOfY = window.pageYOffset; scrOfX = window.pageXOffset;
        } else if (document.body && (document.body.scrollLeft ||
             document.body.scrollTop)) {
            scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft;
        } else if (document.documentElement && (document.documentElement.scrollLeft ||
                 document.documentElement.scrollTop)) {
            scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft;
        }


        $(id).css('top', winH / 2 - $(id).height() / 2 + scrOfY);
        $(id).css('left', winW / 2 - $(id).width() / 2 + scrOfX);
    }
}





function updateLastUpdatedTip()
{
    $("#lastupdatedisplay").qtip('api').updateContent($('#lastupdated').html(), false);
}

//function setLastUpdatedTip()
//{
//    $("#lastupdatedisplay").qtip({

//        content: { text: $('#lastupdated').html(),
//            title: {
//                text: 'Florida House of Representatives',
//                button: '<img src="' + closeURL + '" />'
//            }
//        },
//        hide: { when: 'mouseout', fixed: true },
//        position: { corner: { tooltip: 'topRight'} },
//        style: {
//            'font-size': 13,
//            width: 400,
//            border: {
//                width: 5,
//                radius: 0,
//                color: '#c4d3e8'
//            },
//            name: 'energy' // Inherit from preset style
//        }
//    });
//}
function secondOnHover()   {
//    $("#rotate ul span").hover(
//  function () {
//    $(this).animate({ 
//        "width" : "+=5",
//        "font" : "+=17px"
//      }, 500 );
//  },
//  function () {
//    
//    $(this).animate({ 
//        "width" : "-5"
//      }, 500 );
//  }
//);

  var navDuration = 150; //time in miliseconds
  var navJumpHeight = "0.45em";

  $('#rotate ul a').hover(function() {
      $(this).animate({ top: "-=" + navJumpHeight }, navDuration);
  }, function() {
  $(this).animate({ top: "+=" + navJumpHeight }, navDuration);
  });
}

function SetScreenForProcessing(imgURL) {
    setTimeout('document.images["imgProcessing"].src="' + imgURL + '"', 200);
    var divProcessing = "divProcessing"
    document.getElementById(divProcessing).style.visibility = 'visible';
    var id = $(jq("divProcessing"));
    $('.ForwardedLink').attr("href", $(jq(linkid)).attr("href"));

    //Get the window height and width   
    var winH = $(window).height();
    var winW = $(window).width();

    //Set the popup window to center   
    $(id).css('top', winH / 2 - $(id).height() / 2);
    $(id).css('left', winW / 2 - $(id).width() / 2);

    //transition effect
    $(id).fadeIn(100);

    s = setInterval("scrollingModalLinkForwardingPanelDetector(" + document.getElementById(divProcessing) + ")", 500);

}


