﻿// FUNZIONE PER APRIRE I POPUP

var stile = "top=10, left=10, width=700, height=500, status=no, menubar=no, toolbar=no, scrollbars=yes";
function Popup(apri) {
    window.open(apri, "", stile);
   }

   function CustomPath(list)
   {
   		var tmp = list.split('|');
   		for (var i = 0; i < tmp.length; i++)
   		{
   			var obj = $("#ctl00_map a:contains('" + tmp[i] + "')");
   			if (obj.html() == null)
   				obj = $("#ctl00_map span:contains('" + tmp[i] + "')");
   			else
   				obj.attr("href", (tmp[i + 3] == '' ? obj.attr("href") : tmp[i + 3]) + tmp[i + 2]);

   			obj.html(tmp[i + 1]);

   			i += 3;
   		}
   }

   function MostraIndice(ddlfinalita, ddltasso, ddlIndice)
   {
   		var finalita = $("#" + ddlfinalita + " option:selected").val();
   		var tasso = $("#" + ddltasso + " option:selected").text();
   		
   		if (finalita != '' && tasso.toLowerCase() == 'variabile')
   		{
   			$.ajax
			({
				type: "POST",
				url: "/resources/webmethod.aspx/MostraIndice",
				data: "{'idfinalita':'" + finalita + "'}",
				dataType: "json",
				contentType: "application/json; charset=utf-8",
				error: function(xhr, error) { alert("error"); },
				success: function(res)
				{
					if (eval(res.d))
					{
						$(".indice:first").show();
						$("#tipoTasso").addClass("row tasso");
					}
					else
					{
						$(".indice:first").hide();
						$("#tipoTasso").removeClass("tasso");
					}
				}
            });
   		}
   		else
   		{
   			$(".indice:first").hide();
   			document.getElementById(ddlIndice).selectedIndex = 0;
			$("#tipoTasso").removeClass("tasso");
   		}
   }