function setupContactForm() {
	var options = { 
        beforeSubmit:  validateFields,  
		success:       formDone
		}
	$("#ContactForm").ajaxForm(options);
	$("input").focus(function(){
		$(this).select();
	});
	$("textarea").focus(function(){
		$(this).select();
	});
}


function formDone(responseText, statusText) {
	$('#ContactForm div.container1').html(responseText);
}
function validateFields(formData, jqForm, options) {

	var formOK=true;
	
	n=$("#ContactForm input#name").val();
	e=$("#ContactForm input#email").val();
	p=$("#ContactForm input#phone").val();
	m=$("#ContactForm #message").val();
	
	
	if(n=="" || n=="Name: ") {
		formOK=false;
		$("#ContactForm input#name").css("background-color","#ffaaaa");
	} else {
		$("#ContactForm input#name").css("background-color","#ffffff");
	}
	
	if(e=="" || e=="E-mail: ") {
		formOK=false;
		$("#ContactForm input#email").css("background-color","#ffaaaa");
	} else {
		$("#ContactForm input#email").css("background-color","#ffffff");
	}
	
	
	if(p=="" || p=="Phone: ") {
		formOK=false;
		$("#ContactForm input#phone").css("background-color","#ffaaaa");
	} else {
		$("#ContactForm input#phone").css("background-color","#ffffff");
	}
	
	if(m=="" || m=="Message: ") {
		formOK=false;
		$("#ContactForm #message").css("background-color","#ffaaaa");
	} else {
		$("#ContactForm #message").css("background-color","#ffffff");
	}
	
	return formOK;
	}



/*function setupSubForm() {
	var options = { 
        beforeSubsend:  SubvalidateFields,  
		success:       subformDone
		}
		$("#SubForm").ajaxForm(options);
	$("input").focus(function(){
		$(this).select();
	});
}


function subformDone(responseText, statusText) {
	$('#SubForm div.container1').html(responseText);
}
function SubvalidateFields(formData, jqForm, options) {

	var formOK=true;
	
	s=$("#SubForm input#subscription").val();
	
	
	if(s=="" || s=="Email: ") {
		formOK=false;
		$("#SubForm input#subscription").css("background-color","#ffaaaa");
	} else {
		$("#SubForm input#subscription").css("background-color","#ffffff");
	}
	
	return formOK;
	}*/







function loadPage(url) {
	$("#thePG").load(url+" #thePGdiv",function() {
		setupContactForm();
		initialize();
		$("#thePGdiv a.hotLink").click(function() {
			loadPage($(this).attr("href"));
/*			alert("load page worked");*/
			return false;
		});
	});
}

$(function() {
	$("#footer a").click(function() {
		loadPage($(this).attr("href"));
		return false;
	});
	$("a.hotLink").click(function() {
		loadPage($(this).attr("href"));
		return false;
	});
	
	setupContactForm();
	initialize();


});


/*$(document).ready(function(){
		initialize();
});*/