﻿function checkMail(mailAddress) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,4})(\\]?)$";
    if (mailAddress.match(reg1str) == null &&
		    mailAddress.match(reg2str) != null) {
        return true;
    }
    return false;
}

function checkURL(url) {
    var urlPattern = /^(?:(?:ftp|https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^;"'<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^;"'<>()\[\]{}\s\x7f-\xff]+)*)?/;
    return urlPattern.test(url.toLowerCase());
}


function realPostBack(eventTarget, eventArgument) {
    __doPostBack(eventTarget, eventArgument);
}

function Grid_DoCallback(action, callBackControl, gridControl, selectionRequired) {
    if (selectionRequired) {
        if (gridControl.MasterTableView.SelectedRows.length > 0) {
            callBackControl.AjaxRequest(action);
        }
    }
    else {
        callBackControl.AjaxRequest(action);
    }
}

function OpenGridRowForUpdate(gridControl, action) {
    gridControl.AjaxRequest(action);
}

function AddToFavorite() {
    try {
        window.external.AddFavorite(location.href, 'מערכת ניהול האתר')
    }
    catch (ex) { }
}

function UpdatePictureClose() {
    try {
        if (document.getElementById("UpdatePictureButton") != null) {
            document.getElementById("UpdatePictureButton").click();
        }
    }
    catch (ex) { }
}
function SetWindowSize() {
    alert(window.dialogHeight)
    window.dialogHeight = 500;
}


function SetWindowSize(oWnd) {
    oWnd.SetSize(oWnd.GetWidth(), parseInt(oWnd.Height));
}

function CloseWindow() {
    window.close();
}

function attachOnloadEvent(func, obj) {
    if (typeof window.addEventListener != "undefined") {
        window.addEventListener("load", func, false);
    }
    else if (typeof document.addEventListener != "undefined") {
        document.addEventListener("load", func, false);
    }
    else if (typeof window.attachEvent != "undefined") {
        window.attachEvent("onload", func);
    }
    else {
        if (typeof window.onload == "function") {
            var oldonload = onload;
            window.onload = function() {
                oldonload();
                func();
            };
        }
        else {
            window.onload = func;
        }
    }
}

function OpenModalDialog(url) {
    var strDialogFeatures = "dialogWidth:1015px;"
    strDialogFeatures += "dialogHeight:730px;"
    strDialogFeatures += "channelMode:no;"
    strDialogFeatures += "directories:no;"
    strDialogFeatures += "resizable:no;"
    strDialogFeatures += "scroll:no;"
    strDialogFeatures += "status:no;"
    strDialogFeatures += "titleBar:no;"
    strDialogFeatures += "menuBar:no;"
    strDialogFeatures += "toolBar:no;"
    strDialogFeatures += "resizable:no;"

    showModalDialog(url, '', strDialogFeatures);

}