﻿// JScript File
//Create definition of trim() for String
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

function IsNumericNonoZero(fldName) {
    var theString = "123456789"
    var fldValue = fldName.value;
    var fldLength = fldValue.length;
    for (liCount = 0; liCount < fldLength; liCount++) {
        // Search through string's characters one by one.
        var fldChar = fldValue.charAt(liCount);
        if (theString.indexOf(fldChar) == -1) {
            return true;
        }
    }
}
function IsNumeric(fldName) {
    var theString = "1234567890"
    var fldValue = fldName.value;
    var fldLength = fldValue.length;
    for (liCount = 0; liCount < fldLength; liCount++) {
        // Search through string's characters one by one.
        var fldChar = fldValue.charAt(liCount);
        if (theString.indexOf(fldChar) == -1) {
            return true;
        }
    }
}
function IsNumericWithDot(fldName) {
    var theString = "1234567890."
    var fldValue = fldName.value;
    var fldLength = fldValue.length;
    for (liCount = 0; liCount < fldLength; liCount++) {
        // Search through string's characters one by one.
        var fldChar = fldValue.charAt(liCount);
        if (theString.indexOf(fldChar) == -1) {
            return true;
        }
    }
}
function IsAlfaNumeric(fldName) {
    var theString = "1234567890.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    var fldValue = fldName.value;
    var fldLength = fldValue.length;
    for (liCount = 0; liCount < fldLength; liCount++) {
        // Search through string's characters one by one.
        var fldChar = fldValue.charAt(liCount);
        if (theString.indexOf(fldChar) == -1) {
            return true;
        }
    }
}
function IsAlfaNumericWithSpace(fldName) {
    var theString = "1234567890.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
    var fldValue = fldName.value;
    var fldLength = fldValue.length;
    for (liCount = 0; liCount < fldLength; liCount++) {
        // Search through string's characters one by one.
        var fldChar = fldValue.charAt(liCount);
        if (theString.indexOf(fldChar) == -1) {
            return true;
        }
    }
}
function Clickheretoprint(e) {
   
    var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
    disp_setting += "scrollbars=yes,width=650, height=600, left=100, top=25";
    var content_vlue = document.getElementById(e).innerHTML;
    var docprint = window.open("", "", disp_setting);
    docprint.document.open();
    docprint.document.write('<html><head><title>HCMS</title><link rel="stylesheet" href="./tools/PopUpStyle.css">');
    docprint.document.write('</head><body onLoad="self.print();close();" style="background: url(./Images/logo.gif) left top no-repeat;margin:120px 10px 10px 10px;">');
    docprint.document.write(content_vlue);
    docprint.document.getElementById('divButtons').style.display = 'none';
    docprint.document.write('</body></html>');
    docprint.focus();
    docprint.document.close();
}
function SearchtextBox(e) {
    if (document.getElementById(e).value != "")
        document.getElementById(e).value = "";
}

function move_up() {
    document.getElementById('EventList').scrollTop = 400;
}

function checkFindPhysicianDetails(LastName, Practice, ddlGender, City, ZipCode, lstSpecialty, ShowMessage) {
    document.getElementById(ShowMessage).innerHTML = "";
    if ((document.getElementById(LastName).value.trim() == "") && (document.getElementById(Practice).value.trim() == "") && (document.getElementById(ddlGender).selectedIndex == 0) && (document.getElementById(City).value.trim() == "") && (document.getElementById(ZipCode).value.trim() == "") && (document.getElementById(lstSpecialty).selectedIndex < 1)) {
        document.getElementById(ShowMessage).innerHTML = "Please enter value for Search.";
        document.getElementById(LastName).focus();
        return false;
    }

}

function Focus(LastName, Practice, ddlGender, City, ZipCode, lstSpecialty, ShowMessage) {
    var keyCode = (document.layers) ? keyStroke.which : event.keyCode;
    if (keyCode != 9) {
        document.getElementById(ShowMessage).innerHTML = "";
        if ((document.getElementById(LastName).value.trim() == "") && (document.getElementById(Practice).value.trim() == "") && (document.getElementById(ddlGender).selectedIndex == 0) && (document.getElementById(City).value.trim() == "") && (document.getElementById(ZipCode).value.trim() == "") && (document.getElementById(lstSpecialty).selectedIndex < 1)) {
            document.getElementById(ShowMessage).innerHTML = "Please enter value for Search.";
            document.getElementById(LastName).focus();
            return false;

        }
        else {
            if (navigator.appName == "Microsoft Internet Explorer") {
                var t = window.event.srcElement.type;
                var keyCode = (document.layers) ? keyStroke.which : event.keyCode;
                var keyString = String.fromCharCode(keyCode).toLowerCase();
                if (keyCode == 13) {
                    document.getElementById("ctl00_contentPlaceHolder1_SavePage").focus();
                }
            }
            else {
                if (keyCode == 13) {
                    document.getElementById("ctl00_contentPlaceHolder1_SavePage").focus();
                }
            }
        }
    }
}

function LoadFocus() {
    if (navigator.appName == "Microsoft Internet Explorer") {
        var t = window.event.srcElement.type;
        var keyCode = (document.layers) ? keyStroke.which : event.keyCode;
        var keyString = String.fromCharCode(keyCode).toLowerCase();
        if (keyCode == 13) {
            document.getElementById("ctl00_contentPlaceHolder1_SavePage").focus();
        }
    }
    else {
        if (keyCode == 13) {
            document.getElementById("ctl00_contentPlaceHolder1_SavePage").focus();
        }
    }

}

function DateFrom_ValueChanged(wdSatrtDateID, wdEndDateID) {
    //get the DOM object for 'Check In' date control
    var wdSatrtDate = igdrp_getComboById(wdSatrtDateID);
    //get the DOM object for 'Check In' date control
    var wdEndDate = igdrp_getComboById(wdEndDateID);    

    //get the selected check-in date
    var selectedStartDate = wdStartDate.getValue();

    //set the check-out date (add 1 day to check in date)
    var endDate = new Date();
    endDate.setTime(selectedStartDate.getTime());
    endDate.setDate(endDate.getDate() + 1);
    wdEndDate.setValue(endDate);

}
