// JavaScript Document
	var previousDiv = 'ContactInfo';
	function hide(previousDiv)
	{
		document.getElementById(previousDiv).style.display='none';
	}
	function showContact(divId)
	{
		if(divId!='ContactUs')
		{
			$('.formError').find('div').each(function(){
				$(this).fadeOut('fast');
			});
		}else
		{
			$('.formError').find('div').each(function(){
				$(this).fadeIn('fast');
			});
		}
		
		$('#'+previousDiv).fadeOut('slow',hide(previousDiv));
		$('#'+divId).fadeIn('slow');
		previousDiv = divId;
	}
	function getInterest()
	{
		var checkedOptions = "";
		var int = document.getElementsByName('int[]');
		var j=0; 
		for (var i = 0; i < int.length; i++) {
				if(int[i].checked){
					checkedOptions += "&int[]="+escape(int[i].value);
				}
			}
	return checkedOptions;
	}
	function SuccessFunction()
	{
		var company = 'company='+escape($('#company').val().replace(/<\/?[^>]+>/gi, ''));
		var fullname = '&fullname='+escape($('#fullname').val().replace(/<\/?[^>]+>/gi, ''));
		var email = '&email='+escape($('#email').val().replace(/<\/?[^>]+>/gi, ''));
		var telephone = '&telephone='+escape($('#telephone').val().replace(/<\/?[^>]+>/gi, ''));
		var mobile = '&mobile='+escape($('#mobile').val().replace(/<\/?[^>]+>/gi, ''));
		var fax   = '&fax='+escape($('#fax').val().replace(/<\/?[^>]+>/gi, ''));
		var country = '&country='+escape($('#country').val().replace(/<\/?[^>]+>/gi, ''));
		var subject =  '&subject='+escape($('#subject').val().replace(/<\/?[^>]+>/gi, ''));
		var message =  '&message='+escape($('#message').val().replace(/<\/?[^>]+>/gi, ''));
		var intrest = getInterest();
		
		var queryString = company+fullname+email+telephone+mobile+country+subject+message+intrest;
		    $.ajax({
					  type: "POST",
					  url: "contactAction.php",
					  data: queryString,
					  success: function() 
					  {
						$('#ContactUs').html("<div id='mess'></div>");
						$('#mess').html("<h2>Contact Form Submitted!</h2>")
						.append("<p>We will contact you soon</p>")
						.hide()
						.fadeIn(1500, function() {
						$('#mess').append("<img id='checkmark' src='images/check.png' />");
        				});
      				  }
    			   });
    return false;
	}
	$(document).ready(function() {
		// SUCCESS AJAX CALL, replace "success: false," by:     success : function() { callSuccessFunction() }, 
		$("[class^=validate]").validationEngine({
			success : function() { SuccessFunction() },
			failure : function() {}
		});
	});