$(document).ready(function(){

/* =================================================
 * CALL TO ACTION ROTATION
 * =================================================
 * Script for cycle plug-in.
 * =================================================*/
 
 	$('#image_rotation').cycle({ 
 		timeout: 15000,
 		speed: 2000
 	});

/* =================================================
 * SEACH FORM INPUT VALUE
 * =================================================
 * Remove "value" attribute for background image.
 * =================================================*/
 
 	$('#site-header form#searchform label.screen-reader-text').html('Search this site...');
 	$('input#searchsubmit').attr('value', ' ');
 

/* =================================================
 * BLOG ENTRY - ROLLOVER EFFECT
 * =================================================
 * Inserts an 'blog_active' class to the blog entry 
 * that is currently rolled over. Active class changes background url.
 * =================================================*/

	
	//add class to first blog item by default.
	//$('div.blog_entry:first').addClass('blog_active');	
	
	//add class to blog entry upon rollover
	$('div.blog_entry').hover(function(){
		$(this).addClass('blog_active');
		$(this).children().addClass('entry_content_active');
	},function(){
		$(this).removeClass('blog_active');
		$(this).children().removeClass('entry_content_active');
	});
 
 
/* =================================================
 * FORM VALIDATION
 * =================================================
 * Validate forms using jQuery Validation Plugin.
 * =================================================*/ 
 
	$('form.form_contact, form.form_request').validate({
		rules:{
			full_name: 'required',
			first_name: 'required',
			last_name: 'required',
			email:{
				required: true,
				email: true
			},
			comments: 'required'
		}
	});

	/*$('form#form_signup').validate({
		rules:{
			full_name: 'required',
			email:{
				required: true,
				email: true
			}
		}
	});*/
	 

/* =================================================
 * FORM LABELS ON/OFF
 * =================================================
 * Removes labels upon clicking on input elements.
 * =================================================*/ 
 
 
	//gather the length of input values
	text_inputs = $('form.form_contact input[type="text"], form.form_contact textarea, form.form_request, input[type="text"], form.form_request textarea, form#form_signup input[type="text"]');
					 
	text_inputs_length = $('form.form_contact input, form.form_contact textarea, form.form_request input, form.form_request textarea, form#form_signup input').val().length;
	
	$(text_inputs).each(function(i){
		if($(this).val().length > 0){
			$(this).prev().css('display', 'none');
		}
	});
	
	$(text_inputs).focus(function(){
		
		//change color to light grey
		$(this).prev().css({'color' : '#ccc'});
		
		//upon inserting values...
		$(this).keydown(function(){
			$(this).prev().css({'display' : 'none'});
		});
			
	});
	
	$(text_inputs).blur(function(){
		
		if($(this).val().length == 0){
			$(this).prev().css({'display' : 'block', 'color' : '#333' });
		}
		
	});

 
});
