function check_email(email_id)
{
	var v_mail = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
	if( !v_mail.test(document.getElementById(email_id).value) )
	{
		alert("The email address you entered does not appear to be a valid email. Please check that and submit again. Thank You.");
		return false;
	}
	return true;
}

function check_valid_phone(phone, type)
{
	var flag = 0;
	
	income = phone.toString( );

	var len = income.length;
	if(len == 0)
	{
		if(type == 'service')
			alert('A local Phone Number is required. Please enter a phone number and submit again. Thank You.');
		else
			alert('An Off Season Phone Number is required. Please enter a phone number and submit again. Thank You.');
			
		return false;
	}
	

	
	if(flag == 1)
	{
		if(type == 'service')
			alert('The Local Phone Number has the wrong format. Should be 10 digits, or (555) 333-4444. Please enter a phone number and submit again. Thank You. ');
		else
			alert('The Off Season Phone Number has the wrong format. Should be 10 digits, or (555) 333-4444. Please enter a phone number and submit again. Thank You. ');
			
		return false;
	}
	else
		return true;	
}

function check_zip(zip, type, country)
{
	var flag = 0;
	var len = zip.length;
	if(country == undefined)
		country = 'USA';
	
	var maxlen = 5;
	if(country == 'Canada')
		maxlen = 6;
	
	if(len == maxlen)
	{
		income = zip.toString( );
		
		var v_zip = /^[0-9]+$/;
		if(country == 'Canada')
			v_zip = /^[a-zA-Z]?[0-9]?[a-zA-Z]?[0-9]?[a-zA-Z]?[0-9]?$/;
			
		if( !v_zip.test(income) )
		{			
			flag = 1;
		}		
	}
	else
	{
		flag = 1;
	}
	
	if(flag == 1)
	{
		if(type == 'service')
			alert('Service Zip should be a 5-digit number');
		else
		{
			if(country == 'USA')
				alert('Billing Zip should be a 5-digit number');
			else
				alert('Billing Zip should be in K1A0B1 format');
		}
			
		return false;
	}
	else
		return true;	
}

function check_acc_number(num)
{
	var flag = 0;
	var len = num.length;
		
	if(len > 0)
	{
		income = num.toString( );
		
		var v_num = /^[0-9]+$/;
		if( !v_num.test(income) )
		{	
			alert('Account number should be digits only');
			return false;
		}		
	}
	else
	{
		alert('Account number should be in format 12345-123456-12-12');
		return false;
	}
	
	return true;	
}

function check_name(name)
{
	var flag = 0;
	
	income = name.toString( );

	var len = income.length;
	if(len == 0)
	{
		alert('The Name field is a required field. Please enter your full name and submit again. Thank You.');
		return false;
	}

	var v_str = /^[a-zA-Z \'\.]+$/;
	if( !v_str.test(income) )
	{
		flag = 1;
	}
	
	if(flag == 1)
	{
		alert('Only letters are allowed in the Name field. Please check that field and submit again. Thank You.');
		return false;
	}
	else
		return true;	
}

function check_address(address, type)
{
	var flag = 0;
	
	income = address.toString( );

	var len = income.length;
	if(len == 0)
	{
		if(type == 'service')
			alert('The Service Address field is a required field. Please check that and submit again. Thank You.');
		else
			alert('The Billing Address field is a required field. Please check that and submit again. Thank You.');
		return false;
	}
	
	var v_str = /^[a-zA-Z0-9 :;%!\#@\$&\/\,\(\)+\'\._-]+$/;
	if( !v_str.test(income) )
	{			
		flag = 1;
	}
	
	if(flag == 1)
	{
		if(type == 'service')
			alert('Only letters are allowed in the Service Address field. Please check that field and submit again. Thank You.');
		else
			alert('Only letters are allowed in the Billing Adddress field. Please check that field and submit again. Thank You.');
		return false;
	}
	else
		return true;	
}

function check_city(city, type)
{
	var flag = 0;
	
	income = city.toString( );

	var len = income.length;
	if(len == 0)
	{
		if(type == 'service')
			alert('The Service City field is a required field. Please check that and submit again. Thank You.');
		else
			alert('The Billing City field is a required field. Please check that and submit again. Thank You.');
		return false;
	}
	
	var v_str = /^[a-zA-Z \-\'\.]+$/;
	if( !v_str.test(income) )
	{			
		flag = 1;
	}
	
	if(flag == 1)
	{
		if(type == 'service')
			alert('Only letters are allowed in the Service City field. Please check that field and submit again. Thank You.');
		else
			alert('Only letters are allowed in the Billing City field. Please check that field and submit again. Thank You.');
		return false;
	}
	else
		return true;	
}

function check_isp(name)
{
	var flag = 0;
	
	income = name.toString( );

	var len = income.length;
	if(len == 0)
	{
		alert('The Internet Service Provider field is a required field. Please check that and submit again. Thank You.');
		return false;
	}
	
	var v_str = /[\"]+/;
	if( v_str.test(income) )
	{			
		flag = 1;
	}
	
	if(flag == 1)
	{
		alert('Only letters are allowed in the Internet Provider field. Please check that field and submit again. Thank You.');
		return false;
	}
	else
		return true;	
}