function testJS()
{
	alert('js Validator Version 1.77 working fine!!');
}

function testEmail(email_address)
{
	re = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[a-zA-Z]$"
	var regex = new RegExp(re);
	if(regex.test(email_address.value))
		return true;
	else
	{
		email_address.select()
		email_address.focus()
		alert('The email address field is invalid. It should be in a *@*.* or similar format. Pls try again.');
		return false
	}
}		

function areAllDigits(contact)
{	
	re = "[^0-9]"
	var regex = new RegExp(re,'g');
	if(!regex.test(contact.value))
		return true;
	else
	{
		contact.select()
		contact.focus()
		alert('The field is invalid. It should only contain numbers. Pls try again.');
		return false
	}
}		


function isFloat(field1, displayName)
{
	str1 = field1.value
	if (isNaN(parseFloat(str1)))
	{
		field1.select()
		field1.focus()
		alert(displayName + ' field must be a numeric field.')
		return false
	}
	field1.value = parseFloat(str1);
	return true

}

function nonefield(field1, displayName)
{
	str1 = field1.value
	if (str1=='none' || str1=='')
	{
		field1.focus()
		alert(displayName + ' field must be selected.')
		return false
	}
	return true
}

function nonefield2(field1, field2, displayName)
{
	str1 = field1.value
	if (str1=='none' || str1=='')
	{
		field2.focus()
		alert(displayName + ' field must be selected.')
		return false
	}
	return true
}


function compare2PasswordFields(field1, field2)
{
		if (field1.value != field2.value)
		{
			field1.select()
			field1.focus()
			alert('Pls reconfirm ur password.')
			return false
		}
		else
			return true
}

//Generic -- from UploadDoc
function IsTextLongEnough(formObj, displayName,len)
{
	var str1
	str1 = formObj.value
	if (str1 == "")
	{
		formObj.select()
		formObj.focus()
		alert(displayName + ' cannot be blank.')
		return false
	}
	else if (str1.length < len)
	{
		formObj.select()
		formObj.focus()
		alert(displayName + 'must have more than ' + len + ' letters.')
		return false
	}
	else
		return true
}
//Generic -- from UploadDoc
function IsTextTooLong(formObj, displayName,len)
{
	var str1
	str1 = formObj.value
	if (str1 == "")
	{
		formObj.select()
		formObj.focus()
		alert(displayName + ' cannot be blank.')
		return false
	}
	else if (str1.length > len)
	{
		formObj.select()
		formObj.focus()
		alert(displayName + ' must not have more than ' + len + ' characters.')
		return false
	}
	else
		return true
}
function IsValidChoice(selectObj, displayName) // Choice must be not less than or equal to 0
{
	var objVal = selectObj.value
	if (objVal <= 0)
	{
		selectObj.focus()
		alert('Please select an valid value for the ' + displayName + '.')
		return false
	}
	else
		return true
}

// End of Generic Upload Functions

function blankfield(field, displayName)
{
		str1 = field.value
		if ((str1  == '') || (str1	== ' '))
		{
			field.select()
			field.focus()
			alert(displayName + ' field cannot be blank.')
			return false;
		}
		return true
}

function areYouOlderThan2(fyear)
{	
	d = new Date();
	s = d.getYear();
	if(parseInt(fyear.value) >= (parseInt(s) - 1))
	{
		fyear.focus()
		alert('The date you have entered seems to be invalid.')
		return false;
	}
	return true;
}

function isPastToday(fday, fmonth, fyear, fhour, fpm)
{	
	var apptdate = new Date(fyear.value,fmonth.value-1,fday.value)

	var appttime = fhour.value;
	var s='',d= new Date();
	if(fpm.value=='pm')
	{	
		appttime = (parseInt(appttime) + 12);
		if(appttime==24)
			appttime=0;
	}
	if(appttime<8 || appttime>21)
	{
		fhour.focus()
		alert('The appointment time must be between 8am to 9pm .');
		return false;
	}
	if(apptdate < d)
	{
		fyear.focus()
		alert('The appointment date must be after today.')
		return false;
	}	
	return true;
}

function isOneWeekAdvanced(fday, fmonth, fyear)
{	
	var today= new Date(), sevendays_later;
	var delivery_date = new Date(fyear.value,fmonth.value-1,fday.value)
	i = Date.parse(today);
	i = i + (7*24*60*60*1000);
	sevendays_later = new Date(i);
	if(delivery_date < sevendays_later)
	{
		fday.focus()
		alert('The delivery date must be at least 1 week later. The delivery date should be after ' + sevendays_later.toLocaleString());
		return false;
	}	
	return true;
}