/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

jQuery(document).ready(function($) {
    

    // hide the iframe movie under certain conditions
    $('#navigation > li').hover( function()
    {
        $('#womens-virtual-tour .ipix-wrapper iframe').hide();
    },
    function()
    {
        $('#womens-virtual-tour .ipix-wrapper iframe').show();
    });

    $('ul.tour-gallery a').click(function()
    {
        $('#womens-virtual-tour .ipix-wrapper iframe').hide();
    });

    // Activate PrettyPhoto Lightbox handle
    $("a[rel^='gallery']").prettyPhoto({
        theme: 'light_square',
        callback: function(){$('#womens-virtual-tour .ipix-wrapper iframe').show();}
    });

    //initWomensTour();
    
});

jQuery(window).load(function($)
{
    initWomensTour();
});


function initWomensTour()
{
    // look for tour specified in query string
    var querytour = getParameterByName('tour');
    if ( querytour != "")
        showWomensTour(querytour);
    else
        showWomensTour('womentour1');
}


function showWomensTour(id)
{
    var url;
    if (id=='womentour1') url='/wp-content/plugins/uh-womens-virtual-tour/ipx/TUHwomensWaitingroomA2.html';
    else if (id=='womentour2') url='/wp-content/plugins/uh-womens-virtual-tour/ipx/TUHpatientRoom3a2.html';
    else if (id=='womentour3') url='/wp-content/plugins/uh-womens-virtual-tour/ipx/TUHexamRooma2.html';
    else if (id=='womentour4') url='/wp-content/plugins/uh-womens-virtual-tour/ipx/TUHpatientroom1a2.html';
    else if (id=='womentour5') url='/wp-content/plugins/uh-womens-virtual-tour/ipx/TUHpatientRoom2a2.html';
    else if (id=='womentour6') url='/wp-content/plugins/uh-womens-virtual-tour/ipx/TUHmonitoringRooma2.html';
    else if (id=='womentour7') url='/wp-content/plugins/uh-womens-virtual-tour/ipx/TUHnicu.html';

    // hide all the items
    $('#womens-virtual-tour div.touritem').hide();
    // show the selected item
    $('#womens-virtual-tour #'+id).show();
    $('#womens-virtual-tour .ipix-wrapper iframe').attr("src", url);

    checkheight();
}

function getParameterByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

