// JavaScript Document
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}
//
function validate_required (field, alerttxt)
{
with(field)
{
if (value==null || value=="")
	{alert(alerttxt); return false}
else {return true}
}
}
//
function validate_username (field, alerttxt)
{
with(field)
{
var charpos = value.search("[^A-Za-z0-9]")

if (value==null || value=="")
	{alert(alerttxt); return false}
else if (charpos >= 0)
	{alert("Username: No spaces. Only alpha-numeric characters allowed."); return false}
else {return true}
}
}
//

function validate_email(field, alerttxt)
{
with(field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1 || dotpos-apos<2 || value == null || value=="")
	{alert(alerttxt); return false}
else {return true}
}
}
//
function validate_zip(field, alerttxt)
{
with(field)
{
var charpos = value.search("[^0-9]")
	
if(value.length!=5) {
	alert(alerttxt); return false}
else if (charpos >= 0) {
	alert("Zip Code is invalid"); return false}
else {return true}
}
}
//
function validate_member(field, alerttxt)
{
with(field)
{
if (value=="#")
	{alert(alerttxt); return false}
else {return true}
}
}
//
function validate_number(field, alerttxt)
{
with(field)
{
if (value.length != 10 || value == null || value == "")
	{alert(alerttxt); return false}
else {return true}
}
}
//
function validate_join(thisform)
{
with(thisform)
{
if(validate_required(tname, "Name is not valid.")==false)
	{tname.focus(); return false}
if(validate_required(password, "Password is not valid.")==false)
	{password.focus(); return false}
if(validate_required(confirm_password, "Confirm password is not valid.")==false)
	{confirm_password.focus(); return false}
if(validate_email(email, "Email Address is not valid.")==false)
	{email.focus(); return false}
if(validate_required(tos, "You must agree to our Terms of Service to register.")==false)
	{tos.focus(); return false}
}
}
//
function validatePackage(thisform)
{
with(thisform)
{
if(validate_required(package, "Package is not valid.")==false)
	{package.focus(); return false}
}
}
//
function validate_contact(thisform) {
	with(thisform)
	{
		if(validate_required(tname, "Name is not valid.")==false)
		{tname.focus(); return false}
		if(validate_email(email, "Email Address is not valid.")==false)
		{email.focus(); return false}
	}
}

//
function validate_listing_contact(thisform) {
	with(thisform)
	{
		if(validate_required(contact_name, "Name is not valid.")==false)
		{contact_name.focus(); return false}
		if(validate_email(contact_email, "Email Address is not valid.")==false)
		{contact_email.focus(); return false}
	}
}

//
//
function checkListing(thisform)
{
	with(thisform)
	{
		if(validate_required(tname, "Name is not valid.")==false)
		{tname.focus(); return false}
		if(validate_required(category, "Please select a Category.")==false)
		{category.focus(); return false}
		if(validate_email(email, "Email Address is not valid.")==false)
		{email.focus(); return false}
		if(validate_required(country, "Country is not valid.")==false)
		{country.focus(); return false}
		if(validate_required(province, "State/Province is not valid.")==false)
		{province.focus(); return false}
		if(validate_required(city, "City is not valid.")==false)
		{city.focus(); return false}
	}
}
//
function confirmDelete()
{
var agree=confirm("Are you sure you wish to delete?");
if (agree)
	return true ;
else
	return false ;
}
//
function confirmUpgrade()
{
var agree=confirm("Are you sure you wish to upgrade?");
if (agree)
	return true ;
else
	return false ;
}
//
function printpage() {
window.print();  
}
//
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = "";
} 
// -->
