jQuery(document).ready(function(){
	// Adding the 'last' class to the last element of the menu
	jQuery('.sf-menu li:last-child').addClass('last');
	
	// Linking the homepage images to the appointments page.
	jQuery('.cycle-item').click(function() {
		val = "http://alabasterchess.com/appointments/";
		window.location.replace(val);
	});	
	
	//Adding the value to the Gravity Form inputs
	jQuery('.gform_wrapper li').each(function(){
		var label = jQuery('label', this).text();
		jQuery('input', this).attr('value', label);
		jQuery('input', this).live('focus', function(){
			if (jQuery(this).attr('value') == label){
				jQuery(this).attr('value', '');
			}
		});
		jQuery('input', this).live('blur', function(){
			if (jQuery(this).attr('value') == ''){
				jQuery(this).attr('value', label);
			}
		});
		
		jQuery('textarea', this).live('focus', function(){
			if (jQuery(this).text() == label){
				jQuery(this).text('');
			}
		});
		jQuery('textarea', this).live('blur', function(){
			if (jQuery(this).text() == ''){
				jQuery(this).text(label);
			}
		});			
		jQuery('textarea', this).text(label);
	});
	
});

function init() {
 var inputs = document.getElementsByTagName('input');
 for(var i=0; i < inputs.length; i++) {
  inputs[i].setAttribute('rel',inputs[i].defaultValue);
  inputs[i].onfocus = function() {
   if (this.value == this.getAttribute('rel') && this.getAttribute('type') != 'submit' && this.getAttribute('type') != 'reset') {
    this.value = '';
   } else {
    return false;
   }
  }
  inputs[i].onblur = function() {
   if(this.value=='' && this.getAttribute('type') != 'submit' && this.getAttribute('type') != 'reset') {
    this.value = this.getAttribute('rel');
   } else {
    return false;
   }
  }
  inputs[i].ondblclick = function() {
   this.value = this.getAttribute('rel')
  }
 }
}
 
if(document.childNodes) {
 window.onload = init;
}




