
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  arguments.callee = arguments.callee.caller;  
  if(this.console) /*console.log( Array.prototype.slice.call(arguments) )*/;
};
// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});


// place any jQuery/helper plugins in here, instead of separate, slower script files.

$(function(){
	
	$('#contactform').submit(function(){
	
		var action = $(this).attr('action');
		
		$('#contactform #submit').attr('disabled','disabled').after('<img src="assets/ajax-loader.gif" class="loader" />');
		
		$("#message").slideUp(750,function() {
		$('#message').hide();	
		
var checkbox_value = '';
if (jQuery('input#checkbox').is(':checked')) checkbox_value = 1; else checkbox_value = 0;

var checkbox_value2 = '';
if (jQuery('input#checkbox2').is(':checked')) checkbox_value2 = 1; else checkbox_value2 = 0;

var checkbox_value3 = '';
if (jQuery('input#checkbox3').is(':checked')) checkbox_value3 = 1; else checkbox_value3 = 0;
			
		
		$.post(action, { 
			name: $('#name').val(),
			businessname: $('#businessname').val(),
			companyname: $('#companyname').val(),
			email: $('#email').val(),
			subject: $('#subject').val(),
			address1: $('#address1').val(),
			address2: $('#address2').val(),
			city: $('#city').val(),
			county: $('#county').val(),
			postcode: $('#postcode').val(),
			phone: $('#phone').val(),
			package: $('#package').val(),
			description: $('#description').val(),
			turnover: $('#turnover').val(),
			additionalservices: $('#additionalservices').val(),
			reference: $('#reference').val(),
			comments: $('#comments').val(),
			//vat: $('#vat').val()
			vat: $('#vat:checkbox:checked').val(),
			self: $('#self:checkbox:checked').val(),	
			payroll: $('#payroll:checkbox:checked').val(),
			checkbox: checkbox_value,
			checkbox2: checkbox_value2,
			checkbox3: checkbox_value3
			
			

		},
			function(data){
				document.getElementById('message').innerHTML = data;
				$('#message').slideDown('slow');
				$('#contactform img.loader').fadeOut('fast',function(){$(this).remove()});
				$('#contactform #submit').attr('disabled',''); 
				if(data.match('success') != null) $('#contactform').slideUp('slow');
				
			}
		);
		
		});
		
		return false; 
	
	});
	
});

$(function(){
	
	$('#contactform2').submit(function(){
	
		var action = $(this).attr('action');
		
		$('#contactform #submit').attr('disabled','disabled').after('<img src="assets/ajax-loader.gif" class="loader" />');
		
		$("#message").slideUp(750,function() {
		$('#message').hide();			
		
		$.post(action, { 
			name: $('#name').val(),
			email: $('#email').val(),
			phone: $('#phone').val(),
			subject: $('#subject').val(),
			comments: $('#comments').val(),
			verify: $('#verify').val()
		},
			function(data){
				document.getElementById('message').innerHTML = data;
				$('#message').slideDown('slow');
				$('#contactform img.loader').fadeOut('fast',function(){$(this).remove()});
				$('#contactform #submit').attr('disabled',''); 
				if(data.match('success') != null) $('#contactform').slideUp('slow');
				
			}
		);
		
		});
		
		return false; 
	
	});
	
});
