// JavaScript Document
jQuery.fn.DefaultValue = function(text){
    return this.each(function(){
		//Make sure we're dealing with text-based form fields
		if(this.type != 'text' && this.type != 'password' && this.type != 'textarea')
			return;
		
		//Store field reference
		var fld_current=this;
		
		//Set value initially if none are specified
        if(this.value=='') {
			this.value=text;
		} else {
			//Other value exists - ignore
			return;
		}
		
		//Remove values on focus
		$(this).focus(function() {
			if(this.value==text || this.value=='')
				this.value='';
		});
		
		//Place values back on blur
		$(this).blur(function() {
			if(this.value==text || this.value=='')
				this.value=text;
		});
		
		//Capture parent form submission
		//Remove field values that are still default
		$(this).parents("form").each(function() {
			//Bind parent form submit
			$(this).submit(function() {
				if(fld_current.value==text) {
					fld_current.value='';
				}
			});
		});
    });
};
$(document).ready(function () {
    $('#nav li').hover(
        function () {
            //show its submenu
            $('ul', this).slideDown(100);
        },
        function () {
            //hide its submenu
            $('ul', this).slideUp(100);        
        }
    );
	$("#nav img, #featured img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = $(this).attr("data-hover")
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#nav a, #featured a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = $(this).children("img").attr("data-hover"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#nav a, #featured a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});	
		$("#imageField").mouseover(function(){
			imgsrc2 = $(this).attr("src");
			imgsrcON2 = $(this).attr("data-hover");
			$(this).attr("src",imgsrcON2);
		});
		$("#imageField").mouseout(function(){
			$(this).attr("src", imgsrc2);
		});
		$("#name_all").DefaultValue("Enter your name..");
		$("#phone_all").DefaultValue("Enter your phone..");
		$("#email_all").DefaultValue("Enter your email address..");
		$("#comments_all").DefaultValue("Talk to us...");
});
