﻿
/**************** Common Javascript Functions ****************/


function windowOpen(url) {
    var width = 1000;
    var height = 700;
    var left = (screen.width - width) / 2;
    var top = ((screen.height - height) / 2) - 50;
    window.open(url, '', 'toolbar=no,location=no,directories=yes,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,width=1000, height=700,top=' + top + ', left=' + left)
}

function windowOpenwithSize(url, width, height) {
    var width = width;
    var height = height;
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    var params = 'width=' + width + ', height=' + height;
    params += ', top=' + top + ', left=' + left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=no';
    params += ', scrollbars=yes';
    params += ', status=no';
    params += ', toolbar=no';
    newwin = window.open(url, 'windowname5', params);
    if (window.focus) { newwin.focus() }
}

function popup(url) {
    params = 'width=' + screen.width;
    params += ', height=' + screen.height;
    params += ', top=0, left=0'
    params += ', fullscreen=no';
    params += ', scrollbars=yes';

    newwin = window.open(url, '', params);
    if (window.focus) { newwin.focus() }
    // return false; 
}

function checkTextAreaMaxLength(textBox, e, length) {

    var mLen = textBox["MaxLength"];
    if (null == mLen)
        mLen = length;

    var maxLength = parseInt(mLen);
    if (!checkSpecialKeys(e)) {
        if (textBox.value.length > maxLength - 1) {
            if (window.event)//IE
                e.returnValue = false;
            else//Firefox
                e.preventDefault();
        }
    }
}
function checkSpecialKeys(e) {
    if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40)
        return false;
    else
        return true;
}  
