﻿function doRedirect() {
    
    window.location.href = siteVirtualPath;

}

function htmlEncode(value) {
    return $('<div/>').text(value).html();
}

function htmlDecode(value) {
    return $('<div/>').html(value).text();
}

function showErrorMessage(message) {
    jQuery("#modal-error").dialog("destroy");
    jQuery("#errorMessage", "#modal-error").html(message);
    jQuery("#modal-error").dialog({
        draggable: false,
        resizable: false,
        minHeight: 100,
        zIndex: 10003,
        modal: true
    });
}

function showMessage(message, title) {
    jQuery("#modal-error").dialog("destroy");
    jQuery("#errorMessage", "#modal-error").html(message);
    jQuery("#modal-error").dialog({
        draggable: false,
        resizable: false,
        minHeight: 100,
        zIndex: 10003,
        modal: true,
        title: title
    });
}

function ResizeImage(image1, thumbWidth, thumbHeight) {
    var image = new Image();

    image.onload = function (evt) {
        var ratio = 0;
        var thumbRatio = thumbWidth / thumbHeight;
        var width = image.width;
        var height = image.height;

        ratio = width / height;

        if (thumbRatio == ratio) {
            jQuery(image1).css("width", thumbWidth);
            jQuery(image1).css("height", thumbWidth);
            jQuery(image1).show();
            return;
        }

        if (ratio > thumbRatio) {
            jQuery(image1).css("width", thumbWidth);
            jQuery(image1).css("height", (height / width) * thumbWidth);
        }
        else {
            jQuery(image1).css("height", thumbHeight);
            jQuery(image1).css("width", (width / height) * thumbHeight);
        }
        jQuery(image1).show();
    }

    image.onerror = function (evt) {
        jQuery(image1).show();
    }
    image.src = image1.src;
}

function ImageError(image, errorImageSrc) {
    jQuery(image).attr("src", errorImageSrc);
}
