function isFloat(s) {
	var i;
    var seenDecimalPoint=false;
	var decimalPointDelimiter="."
    if (s==decimalPointDelimiter) return false;
	for (i=0; i<s.length; i++){   
		var c = s.charAt(i);
        if ((c==decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint=true;
        else if (!isDigit(c)) return false;
    }
    return true;
}
function isMoney(pd,pc) {
	if (isEmpty(pd) || (isEmpty(pc))) return false;
	if (!isFloat(pd+"."+pc)) return false;
	return true;
}
function daysInFebruary(year) {   
    return (((year%4==0) && ((!(year%100==0)) || (year%400==0))) ? 29:28);
}
function isDate(day, month, year) {
	if ((isEmpty(day)) || (isEmpty(month)) || (isEmpty(year))) return false;
	var intYear=parseInt(year);
    var intMonth=parseInt(month);
    var intDay=parseInt(day);
	if (intMonth>12) return false;
	var daysInMonth=new Array(12);
	daysInMonth[1]=31;
	daysInMonth[2]=29;
	daysInMonth[3]=31;
	daysInMonth[4]=30;
	daysInMonth[5]=31;
	daysInMonth[6]=30;
	daysInMonth[7]=31;
	daysInMonth[8]=31;
	daysInMonth[9]=30;
	daysInMonth[10]=31;
	daysInMonth[11]=30;
	daysInMonth[12]=31;
    if (intDay>daysInMonth[intMonth]) return false; 
    if ((intMonth==2) && (intDay>daysInFebruary(intYear))) return false;
	return true;
}
function isLetter(c) {
	return ((c>="A") && (c<="Z"))
}
function isDigit(c) {   
	return ((c>="0") && (c<="9"))
}
function isAlphanumeric(s) { 
    for (var i=0; i<s.length; i++)   {   
        var c=s.charAt(i);
        if (!(isLetter(c) || isDigit(c)))
        return false;
    }
    return true;
}
function isWhitespace(s) {
	for (var i=0; i<s.length; i++) {
		var c=s.charAt(i);
		if ((c!=" ") && (c!='\n') && (c!='\t') && (c!='\r')) return false;
	}
	return true;
}
function StripWhiteSpace(s) {
	var whitespace=" \t\n\r";
    var returnString="";
    for (var i=0; i<s.length; i++) {   
        var c=s.charAt(i);
        if (whitespace.indexOf(c)==-1) returnString += c;
    }
    return returnString;
}
function isEmail(s) {
	if (isEmpty(s)) return false;
    var i=1;
    var sLength=s.length;
    while ((i<sLength) && (s.charAt(i)!="@")) {
		i++
    }
    if ((i>=sLength) || (s.charAt(i)!="@")) return false;
    else i+=2;
    while ((i<sLength) && (s.charAt(i)!=".")){
		i++
    }
    if ((i>=sLength-1) || (s.charAt(i)!=".")) return false;
    else return true;
}
function isEmpty(s) {	
	if ((s==null) || (s=="") || isWhitespace(s) || (s.length==0 ))	return true;
	return false;
}
function isPostcode(s) {
	if (isEmpty(s)) return false;
	var pcode=StripWhiteSpace(s);
	var size=pcode.length;	
	if (size<2 || size>9) return false;
	if (!(isLetter(pcode.charAt(0)))) return false;
	if (!(isAlphanumeric(pcode))) return false;
	return true;
}
function ShowErrors(empty_fields,btn) {
	var msg;
	msg = "===========================   \n"
	msg += " Before you can continue please ensure\n";
	msg += " you have entered values in these fields.\n";
	msg += "===========================   \n"
	msg += empty_fields + "\n";
	msg += "\nCorrect the field(s) and click "+btn+ " again.\n";
	msg += "===========================   \n"
	alert(msg);

}
function replace(fm,fld)
{
	var f=eval("document."+fm+"."+fld);
	ct = f.value
	re =/(\n){1}/g
	r = ct.replace(re,"<p>")
	re =/(\r){1}/g
	r = r.replace(re,"")
	f.value=r
}
function isRadioSelected(e) {
	for (i=0; i<e.length; i++) {
		if (e[i].checked) return true;
	}
	return false;
}
function isOptionSelected(e) {
	if ((e.selectedIndex<0) || (e.value=="") || (e.value=="NULL")) return false;
	return true;
}
function isCheckboxSelected(e) {
	if (!e.checked) return false;			
	return true;	
}
function isCheckboxSelectedMultiple(e) {
	for (i=0; i<e.length; i++) {
		if (e[i].checked) return true;
	}
	return false;
}
function ConvertCase(STRING){
	var strReturn_Value="";
	var iTemp=STRING.length;
	if(iTemp==0){
		return"";
	}
	var UcaseNext = false;
	strReturn_Value+=STRING.charAt(0).toUpperCase();
	for(var iCounter=1;iCounter<iTemp;iCounter++){
		if(UcaseNext==true){
			strReturn_Value+=STRING.charAt(iCounter).toUpperCase();
		}
		else{
			strReturn_Value+=STRING.charAt(iCounter).toLowerCase();
		}
		var iChar=STRING.charCodeAt(iCounter);
		if(iChar==32 || iChar==45 || iChar==46){
			UcaseNext=true;
		}
		else{
			UcaseNext=false
		}
		if(iChar==99 || iChar==67){
			if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
				UcaseNext = true;
			}
		}	
	} //End For	
	return strReturn_Value;
}
function isNumeric(aString) {
	if (aString.length == 0) {
		return (false);
	}
	var refString = "1234567890";
	for (count=0; count < aString.length; count++) {
		chkChar = aString.substring (count, count+1);
		if (refString.indexOf (chkChar, 0) == -1)
			return (false);
	}
	return (true)
} 
