function startPage(thePage)
	{
//	jQuery('#theTop').load('pageHeader.html').show();
//	jQuery('#theBottom').load('pageFooter.html').show();

	setTimeout(function(){	//	Give pageHeader time to complete

		jQuery("#theMenu ul li").removeClass("selected");
		jQuery("#theMenu li[thePage="+thePage+"]").addClass("selected");
//		jQuery('#theMenu ul li').each(function(index) {
//			if (jQuery(this).attr( 'thePage' ) == thePage)
//				jQuery(this).addClass('selected');
//			});
		}, 1000);
	
	}
function openPDF(theURI)
	{
	window.open("pdfs/" + theURI);
	}

function validateContactForm( frmContact ) 
	{
	var badFields = "";
	jQuery("#theContent " + frmContact + " input.required").each(function(i){
		var fldNam = jQuery(this).attr("name");
		var fldVal = jQuery(this).val();
		fireBugConsole("validateContactForm - " + fldNam);
			
		if (fldVal.length == 0) 
			{
			if (fldNam == "formmail_mail_email") 
				badFields = badFields + "  - Email \n";
			else 
				badFields = badFields + "  - " + fldNam + "\n";
			}
		});

	if (badFields.length != 0) {
		alert("Please complete the following fields:\n" + badFields);
		return false;
		}

	return true;
	}

function calcMortgagePayment() 
	{ 
	var L,P,n,c,dp; 
	L = parseInt( jQuery('#mcPrice').val() ); 
	n = parseInt( jQuery('#mcTerm').val() * 12 ); 
	c = parseFloat( jQuery('#mcRate').val()/1200 ); 
	dp = 1 - parseFloat( jQuery('#mcDown').val()/100 ); 
	L = L * dp; 
	P = (L*(c*Math.pow(1+c,n)))/(Math.pow(1+c,n)-1); 

	if(!isNaN(P))
		jQuery('#mcPayment').html( convertToCurrency(P) );
	else 
		jQuery('#mcPayment').html( 'There was an error' );  
	}
function convertToCurrency(n) 
	{
	// round off to nearest dollar
	var str = "" + Math.round(n)
	
	// add commas
	pos = str.length;  // str.indexOf(".");
	pos -= 4;
	while(pos >= 0) {
	str = str.substring(0,pos+1) + "," + str.substring(pos+1, str.length);
	pos -= 3;
	}
	
	return "$" + str;
	}
		
function fireBugConsole(logString)
	{
	if (window.console)
		console.info(logString);
	}
