// Lily Of Light Global Javascript Document

//Featured Content Slider 
$(document).ready(function(){
	$("#feature > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 9000, true);
});

//Drop Down Menu
$(document).ready(function(){

	$("ul.children").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	$("ul.topnav li span").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.children").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.children").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

});

//Comment Form Highlighting Fields
$(document).ready(function(){
	$('input[type="text"]').addClass("idleField");
	$('input[type="text"]').focus(function(){
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){
			this.value = '';
		}
		if (this.value != this.defaultValue){
			this.select();
		}
	});
	$('textarea').addClass("idleField");
	$('textarea').focus(function(){
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){
			this.value = '';
		}
		if (this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="text"]').blur(function(){
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value == '')){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	$('textarea').blur(function(){
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value == '')){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
});

//Switch default field values
//Handles default text in input boxes
$(document).ready(function(){
	$('.default-value').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});
});
