﻿
var bName = navigator.appName;
//Reflection
function TextChangeReflection(taObj, Reflector) {

    objReflector = createObject(Reflector);
    objVal = taObj.value;

    if (objReflector) {
        if (bName == "Netscape") {
            objReflector.textContent = objVal;
        }
        else 
        {
            objReflector.innerText = objVal;
        }
    }
    return true;
}

//Create Object
function createObject(objId) {
    if (document.getElementById) return document.getElementById(objId);
    else if (document.layers) return eval("document." + objId);
    else if (document.all) return eval("document.all." + objId);
    else return eval("document." + objId);
}

function limitChars(textid, limit, infodiv) {
    var text = $('#' + textid).val();
    var textlength = text.length;
    if (textlength > limit) {
        $('#' + infodiv).html('Max ' + limit + ' characters.');
        $('#' + textid).val(text.substr(0, limit));
        return false;
    }
    else {
        $('#' + infodiv).html('Max ' + limit + ' characters.');
        return true;
    }
}

//Get Random Name
function uniqid() {

    var newDate = new Date;
    return newDate.getTime();
}


//Check Uncheck checkbox of girdview
function SelectAll(id, girdviewid) {
    //get reference of GridView control
    var grid = document.getElementById(girdviewid);
    //variable to contain the cell of the grid
    var cell;

    if (grid.rows.length > 0) {
        //loop starts from 1. rows[0] points to the header.
        for (i = 1; i < grid.rows.length; i++) {
            //get the reference of first column
            cell = grid.rows[i].cells[0];

            //loop according to the number of childNodes in the cell
            for (j = 0; j < cell.childNodes.length; j++) {
                //if childNode type is CheckBox                 
                if (cell.childNodes[j].type == "checkbox") {
                    //assign the status of the Select All checkbox to the cell checkbox within the grid
                    cell.childNodes[j].checked = document.getElementById(id).checked;
                }
            }
        }
    }
}


//Enter key click event
function doClick(buttonName, e) {
    var key;
    if (window.event)
        key = window.event.keyCode;
    else
        key = e.which;

    if (key == 13) {
        var btn = document.getElementById(buttonName);
        if (btn != null) {
            btn.click();
            window.event.keyCode = 0
        }
    }
}

// Loading


// Loading
