﻿// JScript File
var div2print;

// 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 validEmail(email)
{
	var filter  = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	if (filter.test(email))
	{
	    return true;
	}
	else
	{
	    return false;
	}
}

// Print function for admin pages
function adminPrintMe(id)
{
    //debugger;
    var links = document.getElementById(id);
    if ((links != null) && (links != 'undefined'))
    {
        links.style.display = 'none';
    }
    window.print();
    if ((links != null) && (links != 'undefined'))
    {
        links.style.display = 'block';
    }
}

function PrintDiv(strText, relativePath){
	var a = window.open('','','width=300,height=300');
	a.document.open("text/html");
	a.document.write(strText);
	a.print();
    a.document.write('<a onclick="window.close();" style="background-image:url(' + relativePath + '_images/closeprint.jpg); display: block; width: 50px; cursor: pointer; float: right;">&nbsp;</a>');
	a.document.close();
}