// JavaScript Document
function popuppic(fle,pic)
{
	var wide, tall;
	var img = new Image();
	img.src = pic;
	wide=img.width+26;
	tall=img.height+95;
	window.open(fle + "?pic=" + pic,"Popup_Picture","width="+wide+",height="+tall+",status=no,menubar=no,toolbar=no,scrollable=no,resizable=yes");
}

function checkMailing(frm)
{
	var emptyErrors, formatErrors;
	emptyErrors = '';
	formatErrors = '';
	if(frm.first_name.value == '')
		emptyErrors += "Your first name\n";
	if(frm.last_name.value == '')
		emptyErrors += "Your last name\n";
	if(frm.email.value == '')
		emptyErrors += "Your email address\n";
	/*if(frm.city.value == '')
		emptyErrors += "Your city\n";
	if(frm.postal_code.value == '')
		emptyErrors += "Your postal code\n";*/

if(emptyErrors != '')
	{
		alert("Please fill out the following fields:\n\n" + emptyErrors);
		return false;
	}
	else//format errors
	{
		//re = /^\s*[a-ceghj-npr-tvxy]\d[a-z](\s)?\d[a-z]\d\s*$/i;
		re = /^[a-ceghj-npr-tvxy]\d[a-z](\s)?\d[a-z]\d$/i;
		if(frm.postal_code.value != "")
		{
			if(!re.test(frm.postal_code.value))
				formatErrors += "The Postal Code should be in the following format: M3M 3M3\n";
		}
		re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
		if(frm.email.value != "")
		{
			if(!re.test(frm.email.value))
				formatErrors += "The Email Address should be in the following format: xxx@yyy.zzz\n";
		}
		
		re = /^(\d){3}-(\d){3}-(\d){4}$/;
		if(frm.home_phone.value != "")
		{
			if(!re.test(frm.home_phone.value))
				formatErrors += "The Home Phone Number should be in the following format: 416-555-1212\n";
		}
		if(frm.daytime_phone.value != "")
		{
			if(!re.test(frm.daytime_phone.value))
				formatErrors += "The Daytime Phone Number should be in the following format: 416-555-1212\n";
		}
		
		if(formatErrors != '')	
		{
			alert("There are the following formatting errors:\n\n" + formatErrors);
			return false;
		}
	}
}

