/*
	4News template
	clickswitch.net
	Stefano Giliberti - kompulsive@gmail.com
*/

$(function(){
	inputToggle("input#header-search-input", "input#header-search-submit");
	
	inputLabels = new Object();
	$("input.label").each(function() {
		inputLabels[$(this).attr("id")] = $(this).val();
		$(this).addClass("label-color");
		$(this).focus(function(){
			x = $(this).val();
			y = inputLabels[$(this).attr("id")];
			if (x == y) {
				$(this).removeClass("label-color");
				$(this).val('');
			}
		}).blur(function(){	
			x = $(this).val();
			y = inputLabels[$(this).attr("id")];
			if(x == ''){
				$(this).addClass("label-color");
				$(this).val(y);
			}
		});
	});
	
	function inputToggle(input, submit) {
		$(input).blur(function(){
			x = $(this).val();
			if (x == '') $(this).parent().find(submit).removeClass("toggle")
		}).keypress(function(){
			if (!$(this).parent().find(submit).hasClass("toggle")) $(this).parent().find(submit).toggleClass("toggle")
		});	
	}
	
});
