<!--
function trim(sTemp) {
    sTemp += '';
    return sTemp.replace(/^\s*|\s*$/g,"");
}

function right(str, n){
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else {
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}

function checkEmail(str) {
	//var emailPat = /^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/;
	var emailPat = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
	return !(str.match(emailPat) == null);
}

function checkUSPhone(str) {
	var phonePat = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
	return !(str.match(phonePat) == null);
}

function checkZipCode(str){
	var zipCodePat = /^\d{5}$|^\d{5}-\d{4}$/;
	return zipCodePat.test(str);
}

function validateUSDate( strValue ) {
/************************************************
DESCRIPTION: Validates that a string contains only
    valid dates with 2 digit month, 2 digit day,
    4 digit year. Date separator can be ., -, or /.
    Uses combination of regular expressions and
    string parsing to validate date.
    Ex. mm/dd/yyyy or mm-dd-yyyy or mm.dd.yyyy

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.

REMARKS:
   Avoids some of the limitations of the Date.parse()
   method such as the date separator character.
*************************************************/
  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
 
  //check to see if in correct format
  if(!objRegExp.test(strValue))
    return false; //doesn't match pattern, bad date
  else{
    var strSeparator = strValue.substring(2,3) 
    var arrayDate = strValue.split(strSeparator); 
    //create a lookup for months not equal to Feb.
    var arrayLookup = { '01' : 31,'03' : 31, 
                        '04' : 30,'05' : 31,
                        '06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,
                        '10' : 31,'11' : 30,'12' : 31}
    var intDay = parseInt(arrayDate[1],10); 

    //check if month value and day value agree
    if(arrayLookup[arrayDate[0]] != null) {
      if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
        return true; //found in lookup table, good date
    }
    
    //check for February (bugfix 20050322)
    //bugfix  for parseInt kevin
    //bugfix  biss year  O.Jp Voutat
    var intMonth = parseInt(arrayDate[0],10);
    if (intMonth == 2) { 
       var intYear = parseInt(arrayDate[2]);
       if (intDay > 0 && intDay < 29) {
           return true;
       }
       else if (intDay == 29) {
         if ((intYear % 4 == 0) && (intYear % 100 != 0) || 
             (intYear % 400 == 0)) {
              // year div by 4 and ((not div by 100) or div by 400) ->ok
             return true;
         }   
       }
    }
  }  
  return false; //any other values, bad date
}

function isDate(year, month, day) {
    var isDate1 = true;
    if (!isNumeric(year) || trim(year)=='' || !isNumeric(month) || trim(month)=='' || !isNumeric(day) || trim(day)=='') {
        isDate1 = false;
    } else {
        var dateTemp = new Date(year,--month,day);
        isDate1 = ((dateTemp.getFullYear() == year) && (dateTemp.getMonth() == month) && (dateTemp.getDate() == day)) ? true : false;
    }
    return isDate1;
}

function isNumeric(sTemp) {
	if (trim(sTemp) == '') return true;
	if (!sTemp) return false;
	
	var sValid = "0123456789.";
	var isNumber = true;
	var sChar;
	for(i=0;i<sTemp.length && (isNumber);i++) {
		sChar = sTemp.charAt(i);
		if (sValid.indexOf(sChar) == -1) isNumber = false;
	}
	return isNumber;
}

function stripNonNumeric(s, bAllowDecimals, bAllowNegative) 
{ 
	var out = new String(s);
	if (bAllowNegative) {
		if (bAllowDecimals) {
			out = out.replace(/[^0-9\.\-]/g, '');
		}
		else {
			out = out.replace(/[^0-9\-]/g, '');
		}
	} else {
		if (bAllowDecimals) {
			out = out.replace(/[^0-9\.]/g, '');
		}
		else {
			out = out.replace(/[^0-9]/g, '');
		}
	}
	return out;
}

function generalFormat(oExpr, iDecPlaces) {
// generic positive number decimal formatting function

	oExpr = stripNonNumeric(oExpr,true);
	if (trim(oExpr) == '') return 0;
	
	// raise incoming value by power of 10 times the
	// number of decimal places; round to an integer; convert to string
	var sResult;
	var iExpr = new Number(oExpr);
	
	sResult = new String(Math.round(iExpr * Math.pow(10,iDecPlaces)));

	// pad small value strings with zeros to the left of rounded number
	while (sResult.length <= iDecPlaces) 
	{
		sResult = "0" + sResult;
	}
	
	// establish location of decimal point
	var iDecPoint;
	iDecPoint = sResult.length - iDecPlaces;
	
	// assemble final result from: (a) the string up to the position of
	// the decimal point; (b) the decimal point; and (c) the balance
	// of the string. Return finished product.
	if (iDecPlaces == 0)
		sResult = sResult.substring(0,iDecPoint);
	else
		sResult = sResult.substring(0,iDecPoint) + "." + sResult.substring(iDecPoint,sResult.length);
	
	return sResult;
}

function formatCurrency(strValue, bAllowNegative) {
	//strValue = strValue.toString().replace(/\$|\,/g,'');
	strValue = stripNonNumeric(strValue,true,bAllowNegative);
	if (trim(strValue) == '') return 0.00;

	dblValue = parseFloat(strValue);

	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
		strCents = "0" + strCents;
	//for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
	//	dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+ dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-')  + dblValue + '.' + strCents);
}

var IE4 = document.all?true:false;
function findPosSize(obj) {
	var curLeft = 0
	var curTop = 0;
	var curWidth = obj.offsetWidth;
	var curHeight = obj.offsetHeight;
	if (obj.offsetParent) {
		curLeft = obj.offsetLeft
		curTop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curLeft += obj.offsetLeft
			curTop += obj.offsetTop
		}
	}
	return [curLeft,curTop,curWidth,curHeight];
}
function positionDiv() {
	var currentTime = new Date();
	var divOverlay = document.getElementById("divOverlay");
	if (divOverlay.style.visibility=="visible") {
		if (document.layers) {
			wWidth = window.innerWidth;
			wHeight = window.innerHeight;
			yOffset = window.pageYOffset;
			xOffset = window.pageXOffset;
		} else {
			wWidth = document.body.clientWidth;
			wHeight = document.body.clientHeight;
			yOffset = document.body.scrollTop;
			xOffset = document.body.scrollLeft;
		}
		divOverlay.style.left = eval(xOffset);
		divOverlay.style.top = eval(yOffset);
		divOverlay.style.width = wWidth + "px"; 
		divOverlay.style.height = wHeight + "px";
		setTimeout("positionDiv()",0);
	}
}
function displayLoading() {
	document.getElementById("divOverlay").style.visibility = "visible";
	positionDiv();
	if (IE4) IE4HideElements();
	objDiv = document.getElementById("divLoading");
	nWidth = 126;
	nHeight = 22;
	document.getElementById("divLoading").style.visibility = "visible";
	objDiv.style.width = nWidth;
	objDiv.style.height = nHeight;
	if (document.layers) {
		wWidth = window.innerWidth;
		wHeight = window.innerHeight;
	} else {
		wWidth = document.body.clientWidth;
		wHeight = document.body.clientHeight;
	}
	objDiv.style.left = ((wWidth-nWidth)<=0) ? "0px" : (wWidth-nWidth)/2+"px";
	objDiv.style.top = ((wHeight-nHeight)<=0) ? "0px" : (wHeight-nHeight)/2+"px";
	objDiv.style.display = "";
}
function hideLoading() {
	if (IE4) IE4ShowElements();
	document.getElementById("divOverlay").style.visibility = "hidden";
	document.getElementById("divLoading").style.visibility = "hidden";
}
function IE4HideElements() {
	objSelect = document.getElementsByTagName("select");
	objDiv = document.getElementById("divIE4");
	for(i=objSelect.length-1;i>=0;i--) {
		if (objSelect[i].style.visibility!="hidden" && objSelect[i].style.display!="none") {
			objSelect[i].style.visibility = "hidden";
		}
	}
}
function IE4ShowElements() {
	objSelect = document.getElementsByTagName("select");
	objDiv = document.getElementById("divIE4");
	for(i=objSelect.length-1;i>=0;i--) {
		if (objSelect[i].style.visibility=="hidden") {
			objSelect[i].style.visibility = "visible";
		}
	}
}

//get the selected value of a radio button group (required prototype library)
function $RF(el_name) {
	//var res = $(el).getInputs('radio', radioGroup).find(function(re) {return re.checked;});
	var res = $$('input[name='+el_name+']').find(function(re) {return re.checked;});
	if(res != null) {
		return $F(res);
	} else {
		return ""
	}
}
//-->
