﻿// JScript File
function showAlert(msg, url) {
    alert(msg);
    if (url != '') {
        redirectURL(url);
    }
}

function redirectURL(url) {
    if (navigator.appName == 'Microsoft Internet Explorer') {
        location.href(url);
    }
    else if (navigator.appName == 'Netscape') {
        window.open(url, '_parent', 1);
        window.close();
    }
    else if (navigator.appName == 'Opera') {
    window.location(url);
    }
}

function deleteRecord(url) {
    if (confirm("Want to delete clicked record?")) {
        redirectURL(url);
    }
}

function Refresh() {
    window.reload();
}

function Trim(str) {
    while (str.charAt(0) == (" ")) {
        str = str.substring(1);
    }
    while (str.charAt(str.length - 1) == " ") {
        str = str.substring(0, str.length - 1);
    }
    return str;
}

function OpenPopupCenter(pageURL, title, w, h, scroll) {
    var left = (screen.width / 2) - (w / 2);
    var top = (screen.height / 2) - (h / 2);
    var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=' + scroll + ', resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}

function IsNumeric(strString) {
    var strValidChars = "0123456789.-";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    for (i = 0; i < strString.length && blnResult == true; i++) {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1) {
            blnResult = false;
        }
    }
    return blnResult;
}

function IsPriceNumeric(strString) {
    var strValidChars = "0123456789.";
    var strChar;
    var blnResult = true;

    for (i = 0; i < strString.length && blnResult == true; i++) {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1) {
            blnResult = false;
        }
    }
    return blnResult;
}

function dvControl(obj, val) {
    if (val == 'show') {
        document.getElementById(obj).style.display = "";
    } else if (val == 'hide') {
    document.getElementById(obj).style.display = "none";
    }
}

    
