$(document).ready( function(){ 
	$('.fade').innerfade({ 
		speed: 'slow', 
		timeout: 5000, 
		type: 'random', 
		containerheight: '2.5em' 
	}); 
} );


$(function() {
	$('a.newWindow').click(function() {
		window.open(this.href);
		return false;
	});
});


// makes the call to the CF Ajax beastie, one day i'll replace this with a much nicer jquery version.
function ajaxCall(elName, phone, elEmail, state, enquiry, message, regarding, ajaxFuncLoc)
{
	DWREngine._execute (ajaxFuncLoc, false, 'processForm', elName, phone, elEmail, state, enquiry, message, regarding, isSuccessfull);	
}

function isSuccessfull(retVal)
{
	// make form class disappear
	$(".formView").addClass("formViewOff");
	$(".formView").removeClass("formViewOn");
	// make thankyou class visible
	$(".thanksView").addClass("formViewOn");
	$(".thanksView").removeClass("formViewOff");
	if (retVal == 1 ) // success
	{
		$(".thanksView").html("Thanks for your interest, we&rsquo;ll be in touch shortly.");
	} 
	else 
	{
		$(".thanksView").html("Sorry it seems we are have a technical hiccup and your message could not be sent. Please try again later.");
	}
}


/* 
 * 	[highlightEnquiryField]
 * 	Populates the enquiry field of the contact form 
 * 	on the right of the page with the value of the
 * 	productName variable passed.
 * 	Highlights the border of the enquiry field and
 * 	focuses on the name field to draw the users
 * 	attention to the form.
 */
function highlightEnquiryField ( enquiryMsg )
{
	contactNameField = document.getElementById ( 'contactName' );
	enquiryField = document.getElementById ( 'contactEnquiry' );
	enquiryField.value = "Regarding " + enquiryMsg;
	enquiryField.style.border = 'solid 2px red';
	enquiryField.focus();
}
