function deleteProcedure(num,str) {
	var proc=window.confirm("Sei sicuro di rimuovere l'utente "+str+"?");
	if(proc)
	{
		var rpc_options = {
		        url: "inc/deleteuser.php",
		        type: "post",
		        cache: false,
		        dataType: "html",
		        data: {id: ""+num},
				success: function(res) {
					$("#D"+num).hide();
					$("#"+num).find("td").fadeOut("slow");
					$("#signed").text(parseInt($("#signed").text())-1);
					if($("#im"+num).find("img").attr("src")=="images/icondisabled.jpg")
						$("#toappr").text(parseInt($("#toappr").text())-1);
					else
						$("#appr").text(parseInt($("#appr").text())-1);
				}
			};
		jQuery.ajax(rpc_options);
	}
    else
		return;
}

function deleteProcedureCat(num,str) {
	var proc=window.confirm("Sei sicuro di rimuovere il catalogo: "+str+"?");
	if(proc)
	{
		var rpc_options = {
		        url: "inc/deletecatalog.php",
		        type: "post",
		        cache: false,
		        dataType: "html",
		        data: {id: ""+num},
				success: function(res) {
					$("#entry"+num).find("td").fadeOut("slow");
				}
			};
		jQuery.ajax(rpc_options);
	}
    else
		return;
}

function deleteProcedureSubCat(num,str,tagin,famin) {
	var proc=window.confirm("Sei sicuro di rimuovere la sottocategoria: "+str+"?\nI cataloghi marcati con essa saranno ora marcati come \"Vari\".");
	if(proc)
	{
		var rpc_options = {
		        url: "inc/deletesubcat.php",
		        type: "post",
		        cache: false,
		        dataType: "html",
		        data: {id: ""+num, tag: ""+tagin, fam: ""+famin},
				success: function(res) {
					$("#entry"+num).find("td").fadeOut("slow");
				}
			};
		jQuery.ajax(rpc_options);
	}
    else
		return;
}

function userApprovation(state,num,str) {
	if(state==0) {
		var proc=window.confirm("Sei sicuro di voler abilitare l'utente "+str+"?");
		if(proc)
		{
			var rpc_options = {
			        url: "inc/userstate.php",
			        type: "post",
			        cache: false,
			        dataType: "html",
			        data: {id: ""+num, todo: "enab"},
					success: function(res) { 
						$("#im"+num).fadeOut("fast"); 
						$("#im"+num).find("img").attr("src", "images/iconenabled.jpg");
						$("#im"+num).find("img").attr("title", "UTENTE ATTIVO - Clicca per disabilitarlo");
						$("#im"+num).find("img").attr("onClick", "userApprovation(\"1\",\""+num+"\",\""+str+"\");");
						$("#im"+num).fadeIn("fast");
						$("#appr").text(parseInt($("#appr").text())+1);
						$("#toappr").text(parseInt($("#toappr").text())-1);
					}
				};
			jQuery.ajax(rpc_options);
		}
	}
	else {
		var proc=window.confirm("Sei sicuro di voler disabilitare l'utente "+str+"?");
		if(proc)
		{
			var rpc_options = {
			        url: "inc/userstate.php",
			        type: "post",
			        cache: false,
			        dataType: "html",
			        data: {id: ""+num, todo: "disab"},
					success: function(res) {  
						$("#im"+num).fadeOut("fast"); 
						$("#im"+num).find("img").attr("src", "images/icondisabled.jpg");
						$("#im"+num).find("img").attr("title", "UTENTE NON ATTIVO - Clicca per abilitarlo");
						$("#im"+num).find("img").attr("onClick", "userApprovation(\"0\",\""+num+"\",\""+str+"\");");
						$("#im"+num).fadeIn("fast");
						$("#appr").text(parseInt($("#appr").text())-1);
						$("#toappr").text(parseInt($("#toappr").text())+1);
					}
				};
			jQuery.ajax(rpc_options);
		}
	}
}

function initialize(num,str) {
	$("img[@src$=.png]").ifixpng();
	return;
}

function menuAppear(str) {
	$("#step2").empty();
	$("#step3").empty();
	$("#step4").hide();
	//$("#step2").prepend(str);
        
        if(str=="ORO" || str=="ARGENTO")
		$("#step2").prepend("Tipologia: <select name='cat' id='cat' onChange='menuAppear2($(\"#cat\").val(),\""+str+"\");'><option>---</option><option>anelli</option><option>accessori</option><option>bracciali</option><option>collane</option><option>ciondoli</option><option>orecchini</option></select>");
	else if(str=="ACCIAIO")
		$("#step2").prepend("Tipologia: <select name='cat' id='cat' onChange='menuAppear2($(\"#cat\").val(),\""+str+"\");'><option>---</option><option>accessori</option><option>bracciali</option><option>collane</option><option>ciondoli</option><option>orecchini</option></select>");
	$("#step2").fadeIn("slow");
	return;
}

function refreshCount(str) {
    $("#counter").empty();
    var rpc_options = {
      url: "inc/countlan.php",
      type: "post",
     cache: false,
     dataType: "html",
     data: {lang:""+str},
    success: function(res) {
        $("#counter").prepend("<b>"+res+"</b>");                                                                                                                                                                   }
                                   };
                    jQuery.ajax(rpc_options);
return;
}
function menuAppear2(fam,type) {
	$("#step3").empty();
	if(fam!="---")
	{
		var rpc_options = {
		        url: "inc/getsubcat.php",
		        type: "post",
		        cache: false,
		        dataType: "html",
		        data: {fam: ""+fam, type: ""+type},
				success: function(res) {
					$("#step3").prepend(res);
					$("#step3").fadeIn("slow");
					$("#step4").fadeIn("slow");
				}
			};
		jQuery.ajax(rpc_options);
	}
	else
		$("#step4").hide();
	return;
}


function switcher(num) {
	$(".active").hide();
	$(".active").attr("class","hid");
	$("#ct"+num).fadeIn("slow");
	$("#ct"+num).attr("class","active"); 
}

function switcherCat(num,str) {
	$(".h").hide();
	$("#"+str+num).fadeIn("slow");
}

function catMenu(str) {
        $(".h").hide();
        if(str!="-1")
            $("#sub"+str).fadeIn("slow");
}

function showPreview(cont,tit,l) {

//grab the div in the html w/o the header & footer text
////open a blank window
w=window.open('about:blank','Anteprima_newsletter','width=620,height=400,status=no,toolbar=no,scrollbars=1');
w.document.open();

var rpc_options = {
        url: "inc/formprev.php",
        type: "post",
    cache: false,
    dataType: "html",
    data: {title: tit, content: cont, lang: l},
success: function(res) {
                w.document.write(res);        
}
};
               jQuery.ajax(rpc_options);
//w.document.write(str);

//w.document.write("<html>"+ str);
////write some javascript to make the newly opened window print itself.
//w.document.writeln("<script>window.print()</"+"script>");
//w.document.writeln("</html>");
w.document.close();
return;
}

