$(function(){	

	$('.home_slider').bxSlider({
		alignment: 'horizontal',        // 'horizontal', 'vertical' - direction in which slides will move
		controls: false,                 // determines if default 'next'/'prev' controls are displayed
		speed: 1000,                     // amount of time slide transition lasts (in milliseconds)
		pause: 10000,                    // time between each slide transition (auto mode only)
		pager: false,                    // determines if a numeric pager is displayed (1 2 3 4...)
		pager_short: false,             // determines if a 'short' numeric pager is displayed (1/4)
		margin: 0,                      // if 'horizontal', applies a right margin to each slide, if 'vertical' a bottom margin is applied. example: margin: 50
		auto: true,                    // determines if slides will move automatically
		
		auto_direction: 'next',         // order in which slides will transition (auto mode only)
		auto_hover: true,               // determines if slideshow will pause while mouse is hovering over slideshow
		auto_controls: false,           // determines if 'start'/'stop' controls are displayed (auto mode only)
		ticker: false,                  // determines if slideshow will behave as a constant ticker
		ticker_controls: false,         // determines if 'start'/'stop' ticker controls are displayed (ticker mode only)
		ticker_direction: 'next',       // order in which slides will transition (ticker mode only)
		ticker_hover: true,             // determines if slideshow will pause while mouse is hovering over slideshow
		wrapper_class: 'bxslider_wrap'  // class name to be used for the outer wrapper of the slideshow
	});
	 
	/*$('ul#services').innerfade({
		animationtype:'fade',
		speed: 3000,
		timeout: 6000,
		type: 'sequence'
	});*/
	
	function populateElement(selector, defvalue) {
		$(selector).each(function() {
			if($.trim(this.value) == "") {
				this.value = defvalue;
			}
		});	  
		$(selector).focus(function() {
			if(this.value == defvalue) {
				this.value = "";
			}
		});		
		$(selector).blur(function() {
			if($.trim(this.value) == "") {
				this.value = defvalue;
			}
		});
	 }
	 
	 populateElement('#name', 'Enter your name');
	 populateElement('#company', 'Enter your company name');
	 populateElement('#phone', 'Enter your phone number');
	 populateElement('#altphone', 'Enter your alternate phone number');
	 populateElement('#email', 'Enter your email address');
	 populateElement('#comments', 'Enter your message here...');
	
	$('#contact_form').submit(function(){	
		var action = $(this).attr('action');
		
		$("#error").slideUp(750,function() {
		$('#error').hide();
		
 		$('#submit').attr('disabled','disabled');
		
			$.post(action, { 
				name: $('#name').val(),
				company: $('#company').val(),			
				phone: $('#phone').val(),
				altphone: $('#altphone').val(),
				email: $('#email').val(),
				comments: $('#comments').val()
			},
				function(data){	
					document.getElementById('error').innerHTML = data;
					$('#error').slideDown('slow');
					$('#contact_form #submit').attr('disabled',''); 
					if(data.match('success') != null){$('#contact_form').slideUp('slow');}								
				}
			);		
		});	
		return false; 	
	});
});
