/*	
	CleanCorp - Business Template
*/

$(document).ready(function() {
	
	/*** Dropdown fade ***/
 	$("ul#navigation li").mouseenter(function(){
		$(this).find("ul").hide().slideDown(250);
    })

	/*------- Alternated row Colors -------*/
	$("tr:even").css("background-color", "#F7F7F7");

	/*** Search label  ***/
	htmlinput = $(".search input.text").val() /* picks the inital value of the input (in the html) */
	$(".search input.text").css('color','#aeaeae').css('font-style','italic');
	$(".search input.text").focus(function(){ /* on focus.. */
		curinput = $(this).val() /* picks the -current- value */
		if(curinput == htmlinput){ /* if the current value corrispond to the initial value (htmlinput var) */
			$(this).val(''); /* empty the input */
			$(this).css('color','black').css('font-style', 'normal');
		}
	});
	$(".search input.text").blur(function(){ /* on blur */
		curinput = $(this).val();
		if(curinput == ''){ /* if the current value is null .. */
			$(this).css('color','#aeaeae').css('font-style','italic');
			$(this).val(htmlinput); /* sets the value with its inital value (htmlinput var) */
		}
	});

	/*** Contact form validation  ***/
	/* On focus change input and textarea color */
    $("#contact-form input, #contact-form textarea").focus(function () {
		/* Style */
        $(this).css("background","#FDFFCA");
        $(this).css("border-color","#DBDF6F");
    });
	/* On blur */
    $("#contact-form input, #contact-form textarea").blur(function () {
		var inputVal = jQuery.trim($(this).val()); /* Grabs actual input value and removes white space before and after it! */
		$(this).val(inputVal); /* Re-add the input without spaces */
		
		/* Style */
		$(this).css("background","white");
        $(this).css("border-color","#b7ddf2");
		
		var checkReq = $(this).attr("title"); /* Grabs input title="" */
		if (checkReq == "required" && inputVal == "") { /* If the title correspond to "required" AND the input is blank */
			$(this).css("background","#ffc9c9");
        	$(this).css("border-color","#ff4f4f");
    	} else {
    		$(this).css('background','#C9FFD0'); 
			$(this).css("border-color","#4FFF56");
		}
	});
	
});
