﻿
function CheckNumericOnly(e) {
    //debugger;
    var key;
    key = e.which ? e.which : e.keyCode;
    if ((key >= 48 && key <= 57) || key == 40 || key == 46 || key == 41 || key == 44 || key == 8 || key == 45 || key == 9 || key == 37 || key == 38 || key == 39 || key == 40 || key == 36 || key == 35 || key == 13)
    { return true; }
    else {
        alert("Please Enter Numeric.");
        return false;
    }
}

function CheckNumericOnlyWithOutDecimal(e) {
    //debugger;
    var key;
    key = e.which ? e.which : e.keyCode;
    if ((key >= 48 && key <= 57) || key == 40 || key == 41 || key == 44 || key == 8 || key == 45 || key == 9 || key == 37 || key == 38 || key == 39 || key == 40 || key == 36 || key == 35 || key == 13)
    { return true; }
    else {
        alert("Please Enter Numeric.");
        return false;
    }
}



function blockNonNumbers(obj, e, allowDecimal, allowNegative) {
   // debugger;
    var key;
    var isCtrl = false;
    var keychar;
    var reg;

    if (window.event) {
        key = e.keyCode;
        isCtrl = window.event.ctrlKey
    }
    else if (e.which) {
        key = e.which;
        isCtrl = e.ctrlKey;
    }
    if (isNaN(key)) {
        // alert("lease Enter Numeric.");
        return true;
    }

    keychar = String.fromCharCode(key);

    // check for backspace or delete, or if Ctrl was pressed
    if (key == 8 || isCtrl) {
        //alert("please Enter Numeric.");
        return true;
    }

    reg = /\d/;
    var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
    var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;

    return isFirstN || isFirstD || reg.test(keychar);
}

////////////image rotator

/**************************End ToolTip******************************/
/*************************************************************************
Image Rotator
*************************************************************************/
dw_Rotator.restartDelay = 500; // delay onmouseout before call to rotate
dw_Rotator.col = [];

// arguments: image name, rotation speed, path to images (optional), 
// target, i.e. name of window to direct url's to onclick (optional)
function dw_Rotator(name, speed, path, tgt) {
    this.name = name; this.speed = speed || 4500; // default speed of rotation
    this.path = path || ""; this.tgt = tgt;
    this.ctr = 0; this.timer = 0; this.imgs = []; this.actions = [];
    this.index = dw_Rotator.col.length; dw_Rotator.col[this.index] = this;
    this.animString = "dw_Rotator.col[" + this.index + "]";
}

dw_Rotator.prototype.addImages = function() { // preloads images
    var img;
    for (var i = 0; arguments[i]; i++) {
        img = new Image();
        img.src = this.path + arguments[i];
        this.imgs[this.imgs.length] = img;
    }
}

dw_Rotator.prototype.addActions = function() {
    var len = arguments.length; // in case an argument's value is null
    for (var i = 0; i < len; i++)
        this.actions[this.actions.length] = arguments[i];
}

dw_Rotator.prototype.rotate = function() {
    clearTimeout(this.timer); this.timer = null;
    if (this.ctr < this.imgs.length - 1) this.ctr++;
    else this.ctr = 0;
    var imgObj = document.images[this.name];
    if (imgObj) {
        imgObj.src = this.imgs[this.ctr].src;
        this.timer = setTimeout(this.animString + ".rotate()", this.speed);
    }
}

// Start rotation for all instances 
dw_Rotator.start = function() {
    var len = dw_Rotator.col.length, obj;
    for (var i = 0; i < len; i++) {
        obj = dw_Rotator.col[i];
        if (obj && obj.name) // check for empty instance created by dw_random.js
            obj.timer = setTimeout(obj.animString + ".rotate()", obj.speed);
    }
}

// called onclick of images
dw_Rotator.doClick = function(n) {
    var obj = dw_Rotator.col[n];
    if (!document.images || !obj) return true;
    if (obj.actions && obj.actions[obj.ctr]) {
        if (typeof obj.actions[obj.ctr] == "string") { // url
            if (obj.tgt) { // open in separate window
                // add features here if you want, i.e., chrome, size, position, ...
                var win = window.open(obj.actions[obj.ctr], obj.tgt);
                if (win && !win.closed) win.focus();
            } else {
                window.location = obj.actions[obj.ctr];
            }
        } else { // function pointer 
            obj.actions[obj.ctr](); // execute function
        }
    }
    return false;
}

// for stopping/starting onmouseover/out
dw_Rotator.pause = function(n) {
    dw_Rotator.clearTimers(n);
}

dw_Rotator.clearTimers = function(n) {
    var obj = dw_Rotator.col[n];
    if (obj) {
        clearTimeout(obj.timer); obj.timer = null;
    }
}

dw_Rotator.resume = function(n) {
    dw_Rotator.clearTimers(n);
    var obj = dw_Rotator.col[n];
    if (obj) {
        obj.timer = setTimeout(obj.animString + ".rotate()", dw_Rotator.restartDelay);
    }
}
/**********End Image Rotator*************************/


/////////////////////
		   