﻿// JScript File

// Redirect a page
function getURL(strURL)
{
    try
    {
        window.location = strURL;
    }
    catch (e) {}
}

// Returns Numeric
function getNumeric(strString, allowChars)
{   
    var intRetValue = '';
    
    try
    {
        //debugger;
        var intCount = 0;
        var currentChar = '';
        
        for (intCount = 0; intCount < strString.length; intCount++)
        {
            currentChar = strString.charAt(intCount);
            if (allowChars.indexOf(currentChar) != -1)
            {
                intRetValue += currentChar;
            }
        }
    }
    catch (e) {}
    
    return intRetValue;
}

function taCount(visCnta) 
{ 
    debugger;
    var visCnt = document.getElementById(visCnta);
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	if (visCnt) visCnt.innerText=taObj.maxLength-taObj.value.length;
}

function countChars(txtBox, divId, maxCount) 
{ 
    //debugger;
    var txt = document.getElementById(txtBox);
    var txtvalue = '';
    var txtLength = 0;
    var txtRemaining = 0;
    var divbox = document.getElementById(divId);
    if (txt)
    {
        txtvalue = txt.value;
        txtLength = txtvalue.length;
        txtRemaining = maxCount - txtLength;
    }
    if (divbox)
    {
        divbox.innerText = txtRemaining + ' characters remaining.';
    }
    return true;
}


// Check for valid email address
function checkMail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email))
	{
	    return true;
	}
	else
	{
	    return false;
	}
}

