﻿var rhtt = 0;

var showBigImage = function(img) {
    var index = img.src.substring(img.src.length - 10, img.src.length - 9);
    var d = $("#divBigImage");
    d.css("display", "none");
    $("#imgBig").attr("src", "images/BLANK.GIF");
    $("#imgBig").attr("src", img.src.substring(0, img.src.length - 9) + "_big.jpg");
    d.fadeIn("slow");
}

var showSmallImage = function() {
    $("#divBigImage").fadeOut("slow");
}

var showInfoIconContent = function (contentElementId) {
    clearTimeout(rhtt);
    $("#infoBoxContent").html($("#" + contentElementId).html());
}

var loadBRImage = function(imageName) {
    $("#roomImage").attr("src", "images/"+imageName);
}

//may be helpTitle and helpText?
//onfocus - load help text, then onblur - show default text
//onblur may mean that user goes to the next select
var sht = function(element) {
    var s = $("." + element);
    if (typeof (s) != "undefined") {
        $("#infoBoxContent").html(s.html());
    }
    clearTimeout(rhtt);
}

var hht = function() {
    var divInfoBox = $("#infoBox")[0];
    if (divInfoBox.scrollHeight <= divInfoBox.clientHeight) {
        rhtt = setTimeout("rht()", 500);
    }

}

var rht = function() {
    $("#infoBoxContent").html($("#infoBoxContentOriginal").html());
}

//Author: http://peps.ca/blog/easy-image-rollover-script-with-jquery/

PEPS = {};

PEPS.rollover =
    {
        init: function() {
            this.preload();

            $(".ro").hover(
             function() { $(this).attr('src', PEPS.rollover.newimage($(this).attr('src'))); },
             function() { $(this).attr('src', PEPS.rollover.oldimage($(this).attr('src'))); }
          );
        },

        preload: function() {
            $(window).bind('load', function() {
                $('.ro').each(function(key, elm) { $('<img>').attr('src', PEPS.rollover.newimage($(this).attr('src'))); });
            });
        },

        newimage: function(src) {
            return src.substring(0, src.search(/(\.[a-z]+)$/)) + '_over' + src.match(/(\.[a-z]+)$/)[0];
        },

        oldimage: function(src) {
            return src.replace(/_over\./, '.');
        }
    };
