jQuery().ready(function() {

    //Homepage quick search
    $("#toggle").click(function(e) {
        e.preventDefault();
        this.blur();
        var method1 = 'easeOutBounce';
        var method2 = 'jswing';
        $('#qsBoxSub').animate({ height: 160 }, { duration: 1200, easing: method1 });
    });

    $("#closePane").click(function(e) {
        e.preventDefault();
        this.blur();
        var method1 = 'easeOutBounce';
        var method2 = 'jswing';
        $('#qsBoxSub').animate({ height: 77 }, { duration: 100, easing: method2 });
    });

});

//Open a popup window for the editor
function openPopup(url) {
    width = 520;
    height = 550;
    x = parseInt(screen.width / 2.0) - (width / 2.0);
    y = parseInt(screen.height / 2.0) - (height / 2.0);

    var win = window.open(url, "editorPopup", "top=" + y + ",left=" + x + ",scrollbars=no,dialog=yes,minimizable=no,modal=yes,width=" + width + ",height=" + height + ",resizable=no");
}

jQuery.preloadImages = function() {
    for (var i = 0; i < arguments.length; i++) {
        jQuery("<img>").attr("src", arguments[i]);
    }
}

function roll(img_name, img_src) {
    document[img_name].src = img_src;
}

function swapImg(imgUrl) {
    document.getElementById("ctl00_content_detailInfo_ctrl0_detailImg").src = imgUrl;
}

//Open a popup window
function openPopup2(url) {
    width = 800;
    height = 600;
    x = parseInt(screen.width / 2.0) - (width / 2.0);
    y = parseInt(screen.height / 2.0) - (height / 2.0);

    var win = window.open(url, "editorPopup", "top=" + y + ",left=" + x + ",scrollbars=yes,dialog=yes,minimizable=no,modal=yes,width=" + width + ",height=" + height + ",resizable=no");
}

//Homepage popup

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function checkCookie() {
    hidden = getCookie('hidden');
    if (hidden == null && hidden == "") {
        setCookie('hidden', 'hidden', 7);
        var r = confirm("Would you like to receive future, suitable property information?");
        if (r == true) {
            window.location = "http://www.holidayhometobuy.com/user/login.aspx";
        }
    }
}