jQuery(function() {
	
	jQuery('.slideshow-button').click(function(e){
	
		e.preventDefault();
		
	});
	
	jQuery('#billingInfo input').click(function(){
		togglePayment();
	});
	
	togglePayment();
	
	function togglePayment()
	{
		if (!jQuery('#billingInfo input').attr('checked')) {
			
			jQuery('#billingTable').show();
			
		} else {
			jQuery('#billingTable').hide();
		}
	}
	
	var tabs_content = jQuery('.tabs-content');
	
	jQuery('.tabs-title a').click(function(e){ 
		e.preventDefault();
		
		var sel = this.hash;
		tabs_content.find('.tab').stop().fadeTo('fast',0,function(){
			
			jQuery(this).hide();
			tabs_content.find(sel).fadeTo(100,1);
			
		});
		
	});
	
	var fields = [ '#name','#email','#phone' ];
	
	jQuery('#inquiry-form form').submit(function(e){
		
		
		
		var c = 0;
		
		jQuery.each( fields, function(index, value)
		{
						
			var self = jQuery(value);
						
			if (check_placeholder(self) == false) {	
				c++;
			}	
		});
		
			if ( c == 0 ) {
				//console.log('sent');
			} else {
				alert('PLEASE COMPLETE ALL REQUIRED FIELDS');
				e.preventDefault();
			}
		
	});
	
	
	jQuery.each(fields,function(index,value)
	{
		var self = jQuery(value);
		
		self.click(function()
		{
			this.select();
		});
		
		check_placeholder(self)
		
	})
	
	function check_placeholder(self)
	{
		var val = self.val();
		var plh = self.attr('placeholder');
		
		if ( val != "" && val != plh ) {
			return true;
		} else {
			self.val(plh);
			return false;
		}
	}
	
	if ( jQuery('#slideshow').length > 0) {	
	
	jQuery('#slideshow').cycle({ 
	    prev:   '#slideshow-left', 
	    next:   '#slideshow-right', 
	    timeout: 4000,
		speed: 3000
	});
	
	}
  
});
