<!--

//****************************************************
// Change the user's pointer to an hourglass
//****************************************************
function setPointer() { 
	if (document.all) 
		for (var i=0;i < document.all.length; i++) 
			document.all(i).style.cursor = 'wait'; 
} 

//****************************************************
// Change the user's pointer back to the defaults
//****************************************************
function resetPointer() { 
	if (document.all) 
		for (var i=0;i < document.all.length; i++) 
			document.all(i).style.cursor = 'auto'; 
} 

//****************************************************
// Format a number to the correct Currency format
//****************************************************
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}

//****************************************************
// Show an object... this doesn;t seem to work
//****************************************************
function show(object) { 
	if (document.layers && document.layers[object]) 
		document.layers[object].visibility = 'visible'; 
	else if (document.all) {
		document.all[object].style.zIndex = 100;
		document.all[object].style.visibility = 'visible'; 
		}
}

//****************************************************
// Hide an object... this doesn;t seem to work
//****************************************************
function hide(object) { 
	if (document.layers && document.layers[object]) 
		document.layers[object].visibility = 'hidden'; 
	else if (document.all) 
		document.all[object].style.visibility = 'hidden'; }


//****************************************************
// Trim the given string
//****************************************************
function ValidString(strString){

var intLength=0;
var intCnt=0;
var intChar=0;
var strSlice='';

intLength=strString.length;

for (var intCnt = 0; intCnt < intLength; intCnt++) {
	strSlice=strString.slice(intCnt,intCnt+1)
	if (strSlice!=' ') {
		intChar=intChar+1;
		}
	}

if (intChar>0) {
	return true;
	}
else {
	return false;
	}
}

//============================================================================================

function Replace(string,replacechar,replacewith) 
{
	var temp = "";
	var i;
	
	string = '' + string;
	splitstring = string.split(replacechar);
	for(i = 0; i < splitstring.length; i++)
	{
		if(i < (splitstring.length -1))
			temp += splitstring[i] + replacewith;
		else
			temp += splitstring[i];
	}
	return temp;
}

//======================= STANDARD HELPER FUNCTIONS BELOW =======================================

function IsNumeric(str)
{
	var i;
	for(i=0;i<str.length;i++)
	{
		if(!(	((str.charAt(i) <= '9') && (str.charAt(i) >= '0')) ||
				(str.charAt(i) == ' ') || (str.charAt(i) == '.') || (str.charAt(i) == '-')))
			return(false);
	}
	return(true);
}

//============================================================================================

function IsAlphaNumeric(str)
{
	var i;
	for(i=0;i<str.length;i++)
	{
		if(!(	((str.charAt(i) <= '9') && (str.charAt(i) >= '0')) ||
				((str.charAt(i) <= 'z') && (str.charAt(i) >= 'a')) ||
				(str.charAt(i) == ' ') || (str.charAt(i) == '-') ||
				(str.charAt(i) == 'ü') || (str.charAt(i) == 'ä') ||
				(str.charAt(i) == 'ö') || (str.charAt(i) == 'Ü') ||
				(str.charAt(i) == 'Ä') || (str.charAt(i) == 'Ö') ||
				(str.charAt(i) == 'é') || (str.charAt(i) == 'ß') ||
				((str.charAt(i) <= 'Z') && (str.charAt(i) >= 'A')) ))
			return(false);
	}
	return(true);
}

//============================================================================================

function IsAlpha(str)
{
	var i;
	
	for(i=0;i<str.length;i++)
	{
		if(!(	((str.charAt(i) <= 'z') && (str.charAt(i) >= 'a')) ||
				(str.charAt(i) == ' ') || (str.charAt(i) == '-') ||
				(str.charAt(i) == 'ü') || (str.charAt(i) == 'ä') ||
				(str.charAt(i) == 'ö') || (str.charAt(i) == 'Ü') ||
				(str.charAt(i) == 'Ä') || (str.charAt(i) == 'Ö') ||
				(str.charAt(i) == 'é') || (str.charAt(i) == 'ß') ||
				((str.charAt(i) <= 'Z') && (str.charAt(i) >= 'A')) ))
			return(false);
	}
	return(true);
}

//============================================================================================

function Trim(str)
{
	//trim leding spaces
	while(true)
	{
		if(str.charAt(0) == ' ')
			str = str.substr(1);
		else
			break;
	}
	
	//trim trailing spaces
	while(true)
	{
		if(str.charAt(str.length-1) == ' ')
			str = str.substr(0,str.length-1);
		else
			break;
	}
	return(str);	
}

//============================================================================================

function IsDate(argDate)
{
	var date_split;
	var i;
	var tdate, tmonth, tyear;
	
	date_split = argDate.split('/');
	
	//check for date parts
	if(date_split.length != 3)
		return(false);
	
	//check for zero values
	for(i=0;i<date_split.length;i++)
	{
		if(parseInt(StripZeros(date_split[i])) == 0)
			return(false);
	}
	
	//check for 4-digit year
	if(date_split[2].length != 4)
		return(false);
		
	//check for valid date, e.g. 02/29/1997
	tdate = parseInt(StripZeros(date_split[1]));
	tmonth = parseInt(StripZeros(date_split[0]));
	tyear = parseInt(StripZeros(date_split[2]));
	
	var date = new Date(parseInt(StripZeros(date_split[2])),parseInt(StripZeros(date_split[0]))-1,parseInt(StripZeros(date_split[1])));
	
	if(date.getDate() != tdate)
		return(false);
	
	if(date.getMonth() != (tmonth-1))
		return(false);
	
	if(date.getFullYear() != tyear)
		return(false);
		
	return(true);
}

function StripZeros(num){
	while (num.charAt(0) == "0") {
		newTerm = num.substring(1, num.length);
		num = newTerm;
	}
	if (num == "")
		num = "0";
	return num;
}



function GetDate(argDate)
{
	//use IsDate() first !!!!
	
	var date_split;	
	var tdate, tmonth, tyear;
	
	date_split = argDate.split('/');
	
		
	
	tdate = parseInt(StripZeros(date_split[1]));
	tmonth = parseInt(StripZeros(date_split[0]));
	tyear = parseInt(StripZeros(date_split[2]));
	
	return date = new Date(parseInt(StripZeros(date_split[2])),parseInt(StripZeros(date_split[0]))-1,parseInt(StripZeros(date_split[1])));
		
}

function DateDiff(interval, end, start, rounding ) {

    var iOut = 0;
    
    // Create 2 error messages, 1 for each argument. 
    var startMsg = "Check the Start Date and End Date\n"
        startMsg += "must be a valid date format.\n\n"
        startMsg += "Please try again." ;
		
    var intervalMsg = "Sorry the dateAdd function only accepts\n"
        intervalMsg += "d, h, m OR s intervals.\n\n"
        intervalMsg += "Please try again." ;

    var bufferA = Date.parse( start ) ;
    var bufferB = Date.parse( end ) ;
    	
    // check that the start parameter is a valid Date. 
    if ( isNaN (bufferA) || isNaN (bufferB) ) {
        alert( startMsg ) ;
        return null ;
    }
	
    // check that an interval parameter was not numeric. 
    if ( interval.charAt == 'undefined' ) {
        // the user specified an incorrect interval, handle the error. 
        alert( intervalMsg ) ;
        return null ;
    }
    
    var number = bufferB-bufferA ;
    
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'y': case 'Y':
			var startDate = GetDate(start);
			var endDate = GetDate(end);
			var startThisYear = new Date(parseInt(endDate.getFullYear()),parseInt(startDate.getMonth()),parseInt(startDate.getDate()));
			
			iOut = parseInt(endDate.getFullYear()) - parseInt(startDate.getFullYear());
			if (DateDiff('D', startThisYear, endDate, true) > 0) {
				iOut = iOut - 1;
				}
			break;	
        case 'd': case 'D': 
            iOut = parseInt(number / 86400000) ;
            if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
            break ;
        case 'h': case 'H':
            iOut = parseInt(number / 3600000 ) ;
            if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
            break ;
        case 'm': case 'M':
            iOut = parseInt(number / 60000 ) ;
            if(rounding) iOut += parseInt((number % 60000)/30001) ;
            break ;
        case 's': case 'S':
            iOut = parseInt(number / 1000 ) ;
            if(rounding) iOut += parseInt((number % 1000)/501) ;
            break ;
        default:
        // If we get to here then the interval parameter
        // didn't meet the y,d,h,m,s criteria.  Handle
        // the error. 		
        alert(intervalMsg) ;
        return null ;
    }
    
    return iOut ;
}

//-->