﻿/***********************************************************************
* Author:  even
* Purpose: 模式对话框
* CreatedTime:2010-9-8
* History:
***********************************************************************/
//验证Email地址
function RegexEmail(textput) {
    var search_str = /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/;
    if (!search_str.test(textput)) {
        return false;
    }
    return true;
}

$.fn.initDomDialog = function () {
    if ($(".mask").length == 0) {       
        $("<div class='mask'></div>").appendTo(document.body);
        $(".mask").hide();
    }
    this.addClass("dialog").hide();
};

function closeDomDialog(dialogId) {
    $(dialogId).hide();
    $(".mask").hide();
};

function showDomDialog(dialogId) {
    var scrollTop = window.pageYOffset
                || document.documentElement.scrollTop
                || document.body.scrollTop
                || 0;

    if ($(dialogId).height() > window.screen.availHeight) {
        $(dialogId).css("top", scrollTop);
    }
    else {
        $(dialogId).css("top", scrollTop + (window.screen.availHeight - $(dialogId).height()) / 4);
    }

    var scrollLeft = window.pageXOffset // netscape
                || document.documentElement.scrollLeft
                || document.body.scrollLeft
                || 0;

    $(dialogId).css("left", scrollLeft + (document.body.clientWidth - $(dialogId).width()) / 2);

    var maskHeight = (window.screen.availHeight > document.body.clientHeight) ? window.screen.availHeight : document.body.clientHeight;
    $(".mask").height(maskHeight).show();
    $(dialogId).show();
}


