var $j = jQuery.noConflict();

$j(document).ready(function() {
  $j("#nav").css("z-index","100000");
});

function reIndex(){

	zi = 89;

	cn = document.getElementsByTagName('div');
	for (n=0;n<cn.length;n++){
cn[n].style.zIndex=zi--;
}
}
$j(document).ready(function() {
  reIndex();
});

function submitContactForm() {
	var url = '/scripts/mail.php';
	var rand = Math.random(9999);
	var queryString = $j('#contactForm').formSerialize() + '&rand=' + rand;
	$j.post(url, queryString, function(response) {	
		var json = eval('(' + response + ')');
		if (json.error == true)	{
			showErrors(json.errorFields);
			$j('#contactFormMessage').html(json.message);
		} else {
			$j('#contactFormConfirmation').show();
			$j('#contactFormContainer').hide();	
		}
	});
}

function closeConfirmation() {
	$j('#contactFormMessage').html('');
	$j(":input").removeClass('required');
	$j('#contactFormConfirmation').hide();
	$j('#contactFormContainer').show();
	$j('#contactForm').clearForm();
}

function showErrors(fields) {
	// first reset class for all fields
	$j(":input").removeClass('required');
	for (var j = 0; j < fields.length; j++) {
		$j('#'+ fields[j]).addClass('required');
	}
}

