$(document).ready(function(){
	toggleText('guideSearch', 'cerca nelle guide');
	toggleText('articleSearch', 'cerca negli articoli');
	toggleText('yourEmail', 'la tua email');
	
	$('#imageContainer').colorbox();
	// $(".newsSingle p a").colorbox({transition:"fade", scrolling:"false"});
	$(".home #content tr a").colorbox({transition:"fade", scrolling:"false"});
	// $(".home .latestNews li a").colorbox({transition:"fade", scrolling:"false"});
	$(".lavoro #content tr a").colorbox({transition:"fade", scrolling:"false"});
	$(".formazione #content tr a").colorbox({transition:"fade", scrolling:"false"});
	$(".cultura-e-tempo-libero #mainContent tr a").colorbox({transition:"fade", scrolling:"false"});
	$(".cultura-e-tempo-libero #content tr a").colorbox({transition:"fade", scrolling:"false"});
	$(".casa #content tr a").colorbox({transition:"fade", scrolling:"false"});
	$(".associazione a").colorbox({transition:"fade", scrolling:"false"});
	$(".faq .content").hide();
	$(".faq h3").click(function(){
		$(this).parent().children(".content").slideToggle();
		$(this).parent().siblings().children(".content").slideUp();		
	});
	
	$('#mainContent .subsections input[type="text"]').focus(function() {  
		$(this).addClass("focus");
	});  
	$('#mainContent .subsections input[type="text"]').blur(function() {  
		$(this).removeClass("focus");
	});
	
	$('#startDate').DatePicker({
		format:'Y-m-d',
		date: $('#startDate').val(),
		current: $('#startDate').val(),
		starts: 1,
		position: 'r',
		onBeforeShow: function(){
			$('#startDate').DatePickerSetDate($('#startDate').val(), true);
		},
		onChange: function(formated, dates){
			$('#startDate').val(formated);
			$('#startDate').DatePickerHide();
		}
	});
	
	$('#endDate').DatePicker({
		format:'Y-m-d',
		date: $('#endDate').val(),
		current: $('#endDate').val(),
		starts: 1,
		position: 'r',
		onBeforeShow: function(){
			$('#endDate').DatePickerSetDate($('#endDate').val(), true);
		},
		onChange: function(formated, dates){
			$('#endDate').val(formated);
			$('#endDate').DatePickerHide();
		}
	});
	
});

function toggleText(p1, p2){
    $('input'+'#'+p1).focus(function () {
        if (this.value == p2) {this.value = '';}
    });
    $('input'+'#'+p1).blur(function () {
        if (this.value == '') {this.value = p2;}
    });
}
