function loadList(pURL)
{
	idContent.location.href=pURL;
}

function setTitle(strTitle)
{
	if(document.getElementById('Page_Title'))
	{
		document.getElementById('Page_Title').innerHTML = strTitle;
	}
}

function isEmail(strEMail)
{
	var strEMailValid = "";
	
	re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
	re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	
	if (!strEMail.match(re) && strEMail.match(re_two))
	{
		return ("-1")
	} 
}

function isDate(dateStr,fieldName) 
{
	var strDateValid = "";
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	
	if (matchArray == null) 
	{
		strDateValid = strDateValid + fieldName+" date format must be mm/dd/yyyy format!\n";
    }
	else
	{
		month = matchArray[1]; // parse date into variables
		day = matchArray[3];
		year = matchArray[5];
		
		if (month < 1 || month > 12) 
		{ // check month range
			strDateValid = strDateValid + fieldName+" month must be between 1 and 12! (mm/dd/yyyy)\n";
	    }
		
		if (day < 1 || day > 31) 
		{
		    strDateValid = strDateValid + fieldName+" day must be between 1 and 31! (mm/dd/yyyy)\n";
		}
		
		if ((month==4 || month==6 || month==9 || month==11) && day==31) 
		{
		    strDateValid = strDateValid + fieldName+" month "+month+" does not have 31 days! (mm/dd/yyyy)\n";
		}
		
		if (month == 2) 
		{ // check for february 29th
		    var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		    if (day > 29 || (day==29 && !isleap)) 
			{
			    strDateValid = strDateValid + fieldName+" February " + year + " does not have " + day + " days!\n";
			}
		}
	}
	return strDateValid;
}

function setCountry(province_field,country_field)
// Set the country name based on province selected
{
	var prov = eval(province_field+".value;")
	
	if((prov == "AB")||(prov == "BC")||(prov == "NB")||(prov == "MB")||(prov == "BC")||(prov =="NF")||(prov == "NT")||(prov == "NS")||(prov == "NU")||(prov == "ON")||(prov == "PE")||(prov == "QC")||(prov == "SK")||(prov == "YT"))
	{
		eval(country_field+".value='Canada'");
	}
	else
	{
		if(prov != "00")
		{
			eval(country_field+".value='United States'");
		}
	}
}

function setProvince(province_field,country_field)
{
	var country = eval(country_field+".value")
	
	if(country != "Canada" && country != "United States")
	{
		eval(province_field+".value='00'");
	}
}
function isPhone(phoneStr,fieldName)
{
	// verify phone number is in ###-###-#### format
	// \d is the same as [0-9] and checks any digit
	var strPhoneValid = "";
	var phonePat = /^\d\d\d\-\d\d\d-\d\d\d\d$/;
	
	var matchArray = phoneStr.match(phonePat); // is the format ok?
	if (matchArray == null) 
	{
		strPhoneValid = strPhoneValid + fieldName+" phone must be ###-###-#### format!\n";
	}
	return strPhoneValid;
}

function isURL(urlStr,fieldName)
{
	var strURLValid = "";
	var URL=/^[A-Za-z0-9]([\w-.]+[A-Za-z0-9]\.)+([A-Za-z]){2,4}$/i;
	
	var matchArray = urlStr.match(URL); // is the format ok?
	if (matchArray == null) 
	{
		strURLValid = strURLValid + fieldName+" URL format must be ???.??????.??? format!\n";
	}
	return strURLValid;
}

function showRow(rowID)
{
	if(document.getElementById(rowID))
	{
		if(document.getElementById(rowID).className == "rowList")
		{
			document.getElementById(rowID).className = "rowListOver";
		}
		else
		{
			document.getElementById(rowID).className = "rowList";
		}
	}
}

function openCalendar(form_name,field_name)
{ 
	curent_date = eval("document."+form_name+"."+field_name+".value");
	window.open("includes/inc-calendar.asp?form_name="+form_name+"&field_name="+field_name+"&curent_date="+curent_date,'Calendar',"top=300,left=400,width=260,height=260,menubar=no,scrollbars=no,resizable=yes,status=no");
}
