﻿// JavaScript File
function submitSearch(id,pn)
{
    document.getElementById("id").value = id;
    document.getElementById("pn").value = pn;
    document.forms[0].submit();
}
function isValidEmail(sText)
{
    if(sText != "")
    {
        var reEmail = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
        if(!reEmail.test(sText))
        {
            alert("Email address is not valid!");
        }
    }
}
function isOver300(sText)
{
    if(sText.length > 300)
    {
        alert("Description cannot contain more than 300 characters!");
    }
}
var sUserAgent = navigator.userAgent;
var isIE = sUserAgent.indexOf("compatible") > -1 && sUserAgent.indexOf("MSIE") > -1;
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var EventUtil = new Object();
EventUtil.formatEvent = function(oEvent)
{
    if (isIE && isWin)
    {
        oEvent.charCode = (oEvent.type == "keypress") ? oEvent.keyCode : 0;
        oEvent.eventPhase = 2;
        oEvent.isChar = (oEvent.charCode > 0);
        oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
        oEvent.pageY = oEvent.clientY + document.body.scrollTop;
        oEvent.preventDefault = function()
        {
            this.returnValue = false;
        }
        if (oEvent.type == "mouseout")
        {
            oEvent.relatedTarget = oEvent.toElement;
        }
        else if (oEvent.type == "mouseover")
        {
            oEvent.relatedTarget = oEvent.fromElement;
        }
        oEvent.stopPropagation = function()
        {
            this.cancelBubble = true;
        }
        oEvent.target = oEvent.scrElement;
        oEvent.time = (new Date).getTime();
    }
    return oEvent;
}
var TextUtil = new Object();
TextUtil.allowChars = function (oTextBox, oEvent)
{
    oEvent = EventUtil.formatEvent(oEvent);
    var sValidChars = oTextBox.getAttribute("validchars");
    var sChar = String.fromCharCode(oEvent.charCode);
    var bIsValidChar = sValidChars.indexOf(sChar) > -1;
    if ((document.all) && (9 == event.keyCode))
    {
        bIsValidChar = true;
    }
    else if (oEvent.keyCode == 9 || oEvent.keyCode == 8 || oEvent.keyCode == 46)
    {
        bIsValidChar = true;
    }
    return bIsValidChar; // || oEvent.ctrlKey;
}
TextUtil.isNotMax = function(oTextArea)
{
    return oTextArea.value.length != oTextArea.getAttribute("maxlength");
}