function submitcontactform()
{
	// form validation
	var error = false;
	
	$('span.error').html('&nbsp;');

	if ( $('input[name="name"]').val() == '') 
	{
		$("#contactname").html('*');
		error=true;
	}
	if ( $('select[name="type"]').val() == '') 
	{
		$("#contacttype").html('*');
		error=true;
	}
	if ( $('select[name="how"]').val() == '') 
	{
		$("#contacthow").html('*');
		error=true;
	}
	if ( !validEmail($('input[name="email"]').val()) )
	{
		$("#contactemail").html('*');
		error=true;
	}

	if (!error) {
		postData();
		displaySending();
	}
}

function change_tab(obj, identifier) 
{
	$(".tabs .tab a").each(function() {
		$(this).removeClass("active");
	});

	$(obj).addClass("active");
	
	$(".tab-pg").hide();
	$(".tab-content-" + identifier).show();
}

function postData()
{
	var data = {
		name:document.enquiryForm.name.value,
		company:document.enquiryForm.company.value,
		type:document.enquiryForm.type.value,
		town:document.enquiryForm.town.value,
		email:document.enquiryForm.email.value,
		phone:document.enquiryForm.phone.value,
		website:document.enquiryForm.website.value,
		how:document.enquiryForm.how.value,
		services:[],
		form_name:$('input[name="form_name"]').val(),
		comments:document.enquiryForm.comments.value
	};
	$('input[name="services[]"]:checked').each(function(){
		data.services.push($(this).val());
	});
	$.post("/ajax/contact", data, delayDisplayComplete);
}

function delayDisplayComplete()
{
	setTimeout("displayComplete()", 1000);
}

function displayComplete()
{
	$("#contact-form").html('<div class="padding"><div class="header"><div class="title">Your query has been Sent. Thank You.<br /><br /></div></div></div>');
	//pageTracker._trackPageview("/contact/step3.html");
	setTimeout("closePanel()", 2000);
}

function closePanel()
{
	$('#contact-form').slideUp("slow");
	//$("#getintouchbutton").css('background-image','url(/images/getintouch-sent.gif)');
}

function displaySending()
{
	$("#contact-form").html('<div class="padding"><div class="header"><div class="title">Sending ...<br /><br /></div></div></div>');
	//$("#getintouchbutton").css('background-image','none');
}

function validEmail(s)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(s) == false) {
		return false;
	} else {
		return true;
	}
}


// ----------------------------------------------------------------------------
// HasClassName
//
// Description : returns boolean indicating whether the object has the class name
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function HasClassName(objElement, strClass)
{

	// if there is a class
	if ( objElement.className )
	{

		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');

		// get uppercase class for comparison purposes
		var strClassUpper = strClass.toUpperCase();

		// find all instances and remove them
		for ( var i = 0; i < arrList.length; i++ )
		{

			// if class found
			if ( arrList[i].toUpperCase() == strClassUpper )
			{

				// we found it
				return true;

			}

		}

	}

	// if we got here then the class name is not there
	return false;

}
// 
// HasClassName
// ----------------------------------------------------------------------------


// ----------------------------------------------------------------------------
// AddClassName
//
// Description : adds a class to the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to add
//
function AddClassName(objElement, strClass, blnMayAlreadyExist)
{

	// if there is a class
	if ( objElement.className )
	{

		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');

		// if the new class name may already exist in list
		if ( blnMayAlreadyExist )
		{

			// get uppercase class for comparison purposes
			var strClassUpper = strClass.toUpperCase();

			// find all instances and remove them
			for ( var i = 0; i < arrList.length; i++ )
			{

				// if class found
				if ( arrList[i].toUpperCase() == strClassUpper )
				{

					// remove array item
					arrList.splice(i, 1);

					// decrement loop counter as we have adjusted the array's contents
					i--;

				}

			}

		}

		// add the new class to end of list
		arrList[arrList.length] = strClass;

		// add the new class to beginning of list
		//arrList.splice(0, 0, strClass);

		// assign modified class name attribute
		objElement.className = arrList.join(' ');

	}
	// if there was no class
	else
	{

		// assign modified class name attribute      
		objElement.className = strClass;

	}

}
// 
// AddClassName
// ----------------------------------------------------------------------------


// ----------------------------------------------------------------------------
// RemoveClassName
//
// Description : removes a class from the class attribute of a DOM element
//    built with the understanding that there may be multiple classes
//
// Arguments:
//    objElement              - element to manipulate
//    strClass                - class name to remove
//
function RemoveClassName(objElement, strClass)
{

	// if there is a class
	if ( objElement.className )
	{

		// the classes are just a space separated list, so first get the list
		var arrList = objElement.className.split(' ');

		// get uppercase class for comparison purposes
		var strClassUpper = strClass.toUpperCase();

		// find all instances and remove them
		for ( var i = 0; i < arrList.length; i++ )
		{

			// if class found
			if ( arrList[i].toUpperCase() == strClassUpper )
			{

				// remove array item
				arrList.splice(i, 1);

				// decrement loop counter as we have adjusted the array's contents
				i--;

			}

		}

		// assign modified class name attribute
		objElement.className = arrList.join(' ');

	}
	// if there was no class
	// there is nothing to remove

}
// 
// RemoveClassName
// ----------------------------------------------------------------------------
