<!--
//***********************************************************************************************

function DateDiff(date1, date2) 
{
	var bufferA = Date.parse( date1 ) ;
    var bufferB = Date.parse( date2 ) ;
    // check that the start parameter is a valid Date. 
    if ( isNaN (bufferA) || isNaN (bufferB) ) {
        return null ;
    }
    
    var number = bufferB-bufferA;
    var iOut = parseInt(number / 86400000) ;
    return iOut += parseInt((number % 86400000)/43200001) ;

}// end of DateDiff

//***********************************************************************************************

 function returnradiovalue(els, radioname) {
	 var radiochk = false;
	 for (var n = 0; n < els.length; n++ ) {
			el = els[n];
			if (el.name == radioname) {
				radiochk = radiochk || el.checked;
				if (el.checked) {
					return el.value;
				}
			}	
	 }
	 
	if ( !radiochk ) {
		return null;
	}

}

//***********************************************************************************************
function IsNumeric(theString)
{
	var strNumbers="0123456789"
	for (var i=0; i<theString.length; i++)
	{
		if (strNumbers.indexOf(theString.charAt(i))<0)
		{
			return false;
		}
	}
	return true;
}

//======================================================================================================================
/*
This function is used to check the CC Number
strCCNo - Credit Card Number
*/
function ValidateCC(strCCNo)
{
	var strErrMsg
	var checkOK = "0123456789";
	var checkStr = strip(strCCNo) + '';
	var CrValid = true;
	var checksum=0;
	var ddigit=0;
	var kdig = 0;
	
	if (checkStr.length < 13) 
	{
		strErrMsg = 'You have not entered enough digits on your credit card number.  Please re-enter.';
		return strErrMsg
	}
	for (i = checkStr.length-1;  i >= 0;  i--) 
	{
		kdig++;
		ch = checkStr.charAt(i);
		if ((kdig % 2) != 0) 
		{
			checksum=checksum+parseInt(ch)
		}
		else 
		{
			ddigit=parseInt(ch)*2;
			if (ddigit >= 10)
				checksum=checksum+1+(ddigit-10)
			else
				checksum=checksum+ddigit;
		}
		for (j = 0;  j < checkOK.length;  j++) 
		{
			if (ch == checkOK.charAt(j)) 
			{
				break;
			}
			if (j == checkOK.length) 
			{
				strErrMsg = 'Please enter only digits. No dashes or non-numeric characters.';
				return strErrMsg
			}
		}
	}
	  
	if ((checksum % 10) != 0) 
	{
		strErrMsg = 'You have entered an invalid credit card number. Please check the number for errors.';
		return strErrMsg
	}
	
	strErrMsg = "";
	
	return strErrMsg
	
	
}
//======================================================================================================================
function strip(number) 
{
	var sOut = '';
	mask = '1234567890';
	for(count = 0; count <= number.length; count++) 
	{
 		if(mask.indexOf(number.substring(count, count+1),0) != -1 ) sOut += number.substring(count,count+1);
 	}
	return sOut;
	
} 		
//==================================================================================================
function ValidateEmail(strEmail)
{
	var strErrMsg
	
	if (strEmail == "") 
	{
		strErrMsg = "Please enter a value for the \"E-Mail Address\" field.";
		return strErrMsg	 
	}
	
	if (strEmail.length < 5) 
	{
		strErrMsg = "Please enter at least 5 characters in the \"E-Mail Address\" field.";
		return strErrMsg;
	}

	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ0123456789-@.-_";
	var checkStr = strEmail;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
	}
  
	if (!allValid) 
	{
		strErrMsg = "Please enter only letter, digit and \"@.-_\" characters in the \"E-Mail Address\" field.";
		return strErrMsg
	}
	
	reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
	reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
	reg1 = new RegExp(reg1str);
	reg2 = new RegExp(reg2str);


	if (!(!reg1.test(strEmail) && reg2.test(strEmail)) )
	{
		strErrMsg = "Please enter a valid email address.";
	   	return strErrMsg;
	}	
  
	strErrMsg = ""
	return strErrMsg

}
//=================================================================================================================
var dtCh= "/";

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
//=================================================================================================================
function IsDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	
	//var strDay=dtStr.substring(0,pos1)
	//var strMonth=dtStr.substring(pos1+1,pos2)
	
	var strMonth = dtStr.substring(0,pos1)
	var strDay = dtStr.substring(pos1+1,pos2)
	
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0){
		alert("Please enter a valid 4 digit year");
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || IsNumeric(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}
//======================================================================================================
function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
//======================================================================================================
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
//======================================================================================================
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
//======================================================================================================
//-->	