$(document).ready(function() {
	/* homepage slider parameters */
	if ($('.home-slider').length) {
		$('.home-slider').after('<div id="nav">').cycle({ 
			fx:     'fade', 
			speed:  2000, 
			timeout: 5000, 
			pager:  '#nav' 
		});
	}

	/* entire block clickable for latest news */						   
	$(".ln-list li").click(function(){
    	window.location=$(this).find("a").attr("href");
		return false;
	});

	$(".ln-list li").mouseover(function(){
		$(this).addClass('ln-active');
		$(this).find("a").attr("class", "ln-link");
		
    }).mouseout(function(){
	    $(this).removeClass('ln-active');
		$(this).find("a").attr("class", "");
    });
	
	
	/* entire block clickable for header contact box(present in all interior pages) */	
	$(".header-contact").click(function(){
    	window.location=$(this).find("a").attr("href");
		return false;
	});	
	
});

function callLoginAjax(idTarget, idForm, url) {
	var fields = $('#'+idForm).serializeArray();
	
	$.ajax({
		url: url,
		type: "post",
		cache: false,
		data: fields,
		async: true,
		global: true,
		beforeSend: function() {
			$('#'+idTarget).html('<img src="/images/indicator.gif" style="width: 16px; height: 16pxM" alt="Loading" title="Loading" />');		
		},
		success: function(html){
			if (html == "ok") {				
				top.location.href = '/it/admin/index';
			} else {
				$('#'+idTarget).show().html(html).fadeOut(5000);
			}
		}
	});
}


// Utile per postare valori di una form
function postAjax(idTarget, idForm) {
	var fields = $('#'+idForm).serializeArray();
	var url = '/?';
	
	$.ajax({
		url: url,
		cache: false,
		data: fields,
		type: 'POST',
		beforeSend: function() {},
		success: function(html){
			$('#'+idTarget).html(html);
		}
	});
}


function callAjaxValue(idTarget, url) {
	$.ajax({
		url: url,
		cache: true,
		beforeSend: function() {
			$('#'+idTarget).val('updating in progress');
		},
		success: function(html){
			$('#'+idTarget).val(html);
		}
	});
	//$('#'+idTarget).val('');
	//$('#'+idTarget).load(url);
}
