// JavaScript Document personalizzato

$(document).ready(function() {
						   
	$('#container-1').tabs();
	$(".column").disableSelection();

});	

function getOrder() {
	// save custom order to cookie
	$.cookie(setCookieName, $(setSelector).sortable("toArray"), { expires: setCookieExpiry, path: "/" });
}

// function that restores the list order from a cookie
function restoreOrder() {
	var list = $(setSelector);
	if (list == null) return
	
	// fetch the cookie value (saved order)
	var cookie = $.cookie(setCookieName);
	if (!cookie) return;
	
	// make array from saved order
	var IDs = cookie.split(",");
	
	// fetch current order
	var items = list.sortable("toArray");
	
	// make array from current order
	var rebuild = new Array();
	for ( var v=0, len=items.length; v<len; v++ ){
		rebuild[items[v]] = items[v];
	}
	
	for (var i = 0, n = IDs.length; i < n; i++) {
		
		// item id from saved order
		var itemID = IDs[i];
		
		if (itemID in rebuild) {
		
			// select item id from current order
			var item = rebuild[itemID];
			
			// select the item according to current order
			var child = $("#listsortable").children("#" + item);
			
			// select the item according to the saved order
			var savedOrd = $("#listsortable").children("#" + itemID);
			
			// remove all the items
			child.remove();
			
			// add the items in turn according to saved order
			// we need to filter here since the "ui-sortable"
			// class is applied to all ul elements and we
			// only want the very first!  You can modify this
			// to support multiple lists - not tested!
			$("#listsortable").filter(":first").append(savedOrd);
		}
	}
}
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}
function hidediv(id) {
	
	$("#"+id+"").fadeOut(2000, function() {
   $("#"+id+"").remove();
 });
}
function ScambiaCampo(idpost,idcampo,idsel){
               jQuery( function($) {								
				 var valsend = $('#'+idsel+'-VAL-'+idpost).attr('value');
				   var pageURL = 'http://' + document.domain;
                   var url = pageURL+'/agenzie/processi/ajax-scambia.asp';
                   var urlblog =  pageURL;
				   var postData = "idcampo="+idcampo+"&idsend="+idpost+"&valsend="+valsend+"&idsel="+idsel;
                       $.ajax({
                            type: "POST",
                            url: url,
                            data: postData,
                            success: function(datos){
                                $("#"+idsel+"htm-"+idpost).html(datos);
                          		}
      						});
});
  }
function CancellaCampo(idpost,idcampo){
               jQuery( function($) {								
				   var pageURL = 'http://' + document.domain;
                   var url = pageURL+'/agenzie/processi/ajax-cancella.asp';
                   var urlblog =  pageURL;
				   var postData = "idcampo="+idcampo+"&idpost="+idpost;
                       $.ajax({
                            type: "POST",
                            url: url,
                            data: postData,
                            success: function(datos){
								$("#post-"+idpost).fadeOut(500, function() { $(this).remove(); });
								$("#post-"+idpost+"-1").fadeOut(500, function() { $(this).remove(); });
								$("#post-"+idpost+"-2").fadeOut(500, function() { $(this).remove(); });
								$("#post-"+idpost+"-3").fadeOut(500, function() { $(this).remove(); });
								$("#post-"+idpost+"-4").fadeOut(500, function() { $(this).remove(); });
								$("#post-"+idpost+"-5").fadeOut(500, function() { $(this).remove(); });
								$("#post-"+idpost+"-6").fadeOut(500, function() { $(this).remove(); });
								$("#msg-container").fadeTo("slow",1.0).html(datos);
								$("#saved-added").fadeTo(0,0);
								$("#saved-added").fadeTo("slow",1.0);
                          		}
      						});
});
  }
function CancellaFoto(idpost,idcampo,iddiv){
               jQuery( function($) {								
				   var pageURL = 'http://' + document.domain;
                   var url = pageURL+'/agenzie/processi/ajax-cancella-foto.asp';
                   var urlblog =  pageURL;
				   var postData = "idcampo="+idcampo+"&idpost="+idpost;
                       $.ajax({
                            type: "POST",
                            url: url,
                            data: postData,
                            success: function(datos){
								$("#"+iddiv+idpost).fadeOut(500, function() { $(this).remove(); });
								$("#msg-container").fadeTo("slow",1.0).html(datos);
								$("#saved-added").fadeTo(0,0);
								$("#saved-added").fadeTo("slow",1.0);
								setTimeout(function() {$('#saved-added').fadeOut(1500, function(){ $("#saved-added").remove();});}, 2500);
                          		}
      						});
});
  }

