﻿function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}


/// <summary>
/// Launches the DatePicker page in a popup window,
/// passing a JavaScript reference to the field that we want to set.
/// </summary>
/// <param name="strField">String. The JavaScript reference to the field that we want to set,
/// in the format: FormName.FieldName
/// Please note that JavaScript is case-sensitive.</param>
function calendarPicker(strField, strDefault) {
    var userWidth = screen.availWidth;
    var userHeight = screen.availHeight;

    var leftPos;
    var topPos;
    var popW = 140;   //set width here
    var popH = 190;   //set height here

    var settings = 'modal,scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,';

    leftPos = (userWidth - popW) / 2,
    topPos = (userHeight - popH) / 2;
    settings += 'left=' + leftPos + ',top=' + topPos + ',width=' + popW + ', height=' + popH + '';

    window.open('DatePicker.aspx?field=' + strField + '&default=' + strDefault, 'calendarPopup', settings);
}


function checkComboSelection(sender, args) {
    if (args.Value == "0") {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
    return;
}


function fixMenuSize() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    var adiv;
    adiv = document.getElementById("left");

    if ((myHeight - 139 - 22) > 0)
        adiv.style.height = myHeight - 139 - 22;
    else
        adiv.style.height = 0;
    //adiv.style.top = 139;

}


function Measure() {
    if (document.getElementById("content").clientHeight > window.clientHeight) {
        document.body.style.paddingRight = "0px";
    } else {
        document.body.style.paddingRight = "15px";
        document.getElementById("head").paddingRight = "15px";
    }
}


function PageIsValid() {
    var result = true;
    if (typeof (Page_ClientValidate) == 'function') {
        result = Page_ClientValidate();
    }
    return result;
}


function ButtonOn(myImgName) {
    var img = document.getElementById(myImgName);
    if (img != null)
        img.src = 'images/' + myImgName + '_glow.png';
}

function ButtonOff(myImgName) {
    var img = document.getElementById(myImgName);
    if (img != null)
        img.src = 'images/' + myImgName + '.png';
} 

