﻿// Common Page Functions
function C_popup(pURL, pName, pHeight, pWidth, pScroll)
{
    NewWindow = window.open
    (
        pURL,
        pName,
        "toolbar=no,scrollbars=" + pScroll + ",height=" + pHeight + ",width=" + pWidth + ",directories=no,status=no,resizable=no,menubar=no"
    );
}


function C_popupFull(pURL, pName, pHeight, pWidth)
{
    NewWindow = window.open
    (
        pURL,
        pName,
        "height=" + pHeight + ",width=" + pWidth + ",toolbar=yes,scrollbars=yes,directories=yes,status=yes,resizable=yes,menubar=yes,location=yes"
    );
}


function C_isValidEmail(pValue)
{
    var re = /^([A-Za-z0-9_.-]+)\@([A-Za-z0-9_.-]+)\.(\w{2,})$/;
    
    return re.test(pValue);
}


function C_isNumeric(pValue)
{
    var re = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;

    return re.test(pValue);
}

function C_isTextOfLength(pValue,pLength)
{
    var re = /^[A-Za-z,\s]+$/;
    if(re.test(pValue))
    {
        if(pValue.length <= pLength)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}

function C_isAlphaNumericOfLength(pValue, pLength)
{
    var re = /^[A-Za-z0-9.\s]+$/;
    if(re.test(pValue))
    {
        if(pValue.length <= pLength)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }

}

function C_isZipCode(pValue)
{
    var re = /\d{5}$/;
	
	return re.test(pValue);
}

function C_isPhoneNumber(pValue)
{

    var re = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,3})|(\(?\d{2,3}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;
	
	return re.test(pValue);
}




function C_TrimAll(pValue) 
{
    pValue = new String(pValue);

    while (pValue.substring(0,1) == ' ')
    {
        pValue = pValue.substring(1, pValue.length);
    }
    
    while (pValue.substring(pValue.length-1, pValue.length) == ' ')
    {
        pValue = pValue.substring(0,pValue.length-1);
    }
    
    return pValue;
}