function mouseOverAction()
{
    if (document.getElementById("flashDiv") != null) 
    {
        var flashDivObj = document.getElementById("flashDiv");
        flashDivObj.style.display = 'none';
    }
}

function mouseOutAction()
{
    if (document.getElementById("flashDiv") != null) 
    {
        var flashDivObj = document.getElementById("flashDiv");
        flashDivObj.style.display = '';
    }
}

// Main iframe popup window handler
function modal_popup_init(popup_title, popup_url, custom_width, custom_height, show_Close, bQuirksMode, fnOnCloseCallBack) {
    modal_dialog(popup_title, "<iframe src='" + popup_url + "' width='100%' height='100%' scrolling='auto' frameborder='no' style='border: none; '></iframe>", custom_width, custom_height, null, fnOnCloseCallBack, false, show_Close);
}

// Main popup window handler
function modal_dialog(custom_title, custom_content, custom_width, custom_height, custom_button_text, custom_button_function, bShowCancel, bShowClose, custom_dialog_id, custom_z_index, custom_close_function, custom_button_class) {
    if (typeof bShowCancel == "undefined") bShowCancel = true;
    if (typeof bShowClose == "undefined") bShowClose = true;
    if (typeof custom_z_index == "undefined") custom_z_index = 100;
    if (typeof custom_dialog_id == "undefined") custom_dialog_id = "#modal-dialog";
    else custom_dialog_id = (custom_dialog_id || "#modal-dialog");

    // define the default button set
    var defaultButtons = [
        {
            text: (custom_button_text || "Close"),
            className: (custom_button_class || "positive"),
            click: function () {
                var closeDialog = true;
                if (custom_button_function) closeDialog = custom_button_function();
                if (closeDialog != false) {
                    $(this).parent().find(".positive:button").attr("disabled", true);
                    $(this).dialog("close");
                }
            }
        },
        {
            text: "Cancel",
            className: 'negative',
            click: function () { $(this).dialog("close"); }
        }
    ];

    if (!bShowClose && !bShowCancel) defaultButtons = null;
    else if (!bShowCancel) defaultButtons = [defaultButtons[0]];
    else if (!bShowClose) defaultButtons = [defaultButtons[1]];
    $("body").append("<div id=\"" + custom_dialog_id.replace("#", "") + "\" />");
    if (typeof(custom_content) == "object") $(custom_dialog_id).width((custom_width || 600)).append(custom_content);
    else $(custom_dialog_id).width((custom_width || 600)).html(custom_content);
    custom_width = Math.max($(custom_dialog_id).width() + 50, custom_width);

    // define the dialog, the close callback will destroy this dialog after use
    $(custom_dialog_id).dialog({
        modal: true,
        resizable: false,
        close: function () { if (custom_close_function) custom_close_function(); $(this).remove(); },
        minWidth: custom_width,
        minHeight: (custom_height ? custom_height + 100 : 400),
        title: (custom_title || "Message"),
        buttons: defaultButtons,
        zindex: custom_z_index
    });

    if ($(custom_dialog_id + " > iframe").length > 0)
        $(custom_dialog_id + " > iframe").height($(custom_dialog_id).height());
}

// Message popup
function message_popup_init(custom_text, custom_width, custom_height, bQuirksMode, fnOnCloseCallBack) {
    modal_dialog("Message", custom_text, custom_width, custom_height, null, null, false);
}

function message_popup_remove() {
    $("#modal-dialog").dialog("close");
}

// Email Validation
function validEmail(email) {
    // check & remove spaces if supported
    if (email.value) { email.value = email.value.replace(/\s/g, '').toLowerCase(); validateEmail = email.value; }
    else if (email.val()) { email.val(email.val().replace(/\s/g, '').toLowerCase()); validateEmail = email.val(); }
    else validateEmail = email;

    var isValid = (validateEmail.search(/^([a-z]+)([a-z0-9\-\_\.]{1,100})([a-z0-9]+)\@([a-z0-9]+)([a-z0-9\-\.]*)([a-z0-9]+)\.([a-z]{2,6})$/) != -1);

    if (email.val()) {
        var txtid = "validate-" + email.attr("name");
        $("#" + txtid).remove();
        if (!isValid) email.after("<span id=\"" + txtid + "\" style=\"color: red; font: normal 8pt; display: inline-block; padding-bottom: 2px; \">&nbsp; Invalid Email!</span>");
    }

    return isValid;
}

// Search Widget Function
function SearchWebsiteWidget(btnSearch) {
    // text input value
    var searchTerm = escape($(btnSearch).parent().find("input[name=txtSearchTerm]").val());

    // get the current page name
    var returnURL = window.location.href;
    returnURL = escape(returnURL.substring(returnURL.lastIndexOf('/') + 1));

    // redirect to website search
    window.location = "site_search_results.asp?widget_page=" + returnURL + "&search_term=" + searchTerm;
}


function checkKeyPressForSearchWidget(txtSearch, event) {

    var btnSearchJS = $(txtSearch).parent().find("input[name=btnSearch]")[0];
    var btnSearchJQ = $(txtSearch).parent().find("input[name=btnSearch]");

    if (event == 13) {
        //btnSearch = $(btnSearch)
        //SearchWebsiteWidget(btnSearchJS);
        btnSearchJQ.click();
    }
}


