// JavaScript Document
<!--
window.onload = start_cart;

function start_cart(){
	carrello("dimore",0);
	setTimeout("carrello(\"acib\",0)",2000);
	
}

function opacita(oggetto,opacity)
{
   if (typeof(oggetto)!="object")
   {oggetto = document.getElementById(oggetto);}
	if(document.all) 
		{oggetto.style.filter = "alpha(opacity=" + opacity + ")";}
	  else
		{oggetto.style.opacity = opacity / 100;}
}



function feed(messaggio,target)
	{window.document.getElementById(target).innerHTML="<br>" + messaggio;}

function noCache(uri){return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567)};

function ahah(url, method, targ, chiudi,par_a) {
	if (chiudi==undefined) chiudi = "";
	if (par_a==undefined)  par_a = "";

  if ( (method == "GET") || (method == "get") )
  {
	  if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	  } else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");

	  }
	  if (req) {
		req.onreadystatechange = function() {
			ahahDone(url, method, targ,chiudi);
		};
		req.open(method, noCache(url), true);
		req.send("");
	  }
  }
   
   if ( (method == "POST") || (method == "post") )
  {
	  if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	  } else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  var parameters = "";
	  gr = par_a.split(",")
	    for (var i = 0; i <  gr.length; i++){
			 parameters += gr[i] + "="  +escape(document.getElementById(gr[i]).value)+"&";
			}
	  if (req) {
		req.onreadystatechange = function() {
			ahahDone(url, method, targ,chiudi);
		};
		req.open(method, noCache(url), true);
		req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		req.send(parameters);
	  }
  }


}  

function ahahDone(url, method, targ,chiudi) 
{
  if (req.readyState == 4)
  { 
    if (req.status == 200)
	  {window.document.getElementById(targ).innerHTML=chiudi+unescape(req.responseText)+chiudi; ahahEvalJS(targ);}
	else
	 {window.document.getElementById(targ).innerHTML=escape(req.responseText);alert("Errore:\n"+req.statusText);}
  }
}	

function ahahEvalJS(elementId) {
    var scripts = document.getElementById(elementId).getElementsByTagName('script');
    var code;
    for (var i = 0; i < scripts.length; i++) {
        code =    scripts[i].innerHTML ? scripts[i].innerHTML :
            scripts[i].text ? scripts[i].text :
            scripts[i].textContent;
        try {
            eval(code);
        } catch(e) {
            alert(e);
        }
    }
}
// FINE FUNZIONI AJAX ---------------------------------------------------------------


function ALERT(MSG,from_id,cosa){
	if (cosa==undefined) cosa="body"
	oscura(cosa)
        $("body").append("<div class=\"alert\" id=\"all\"><h1>"+MSG+"</h1></div>");
		
		 var x_disco = getCoords(document.getElementById(from_id)).x;
		 var y_disco = getCoords(document.getElementById(from_id)).y;
		 $("#all").css({left: x_disco, top: y_disco });
		 $("#OSCURO").bind("click",function (event) {
		ritorna();
});
}

function crea(tipo,id,dove){
	// 	crea un elemento di tipo "tipo"
		if (document.getElementById(id)==null){
				if (dove){
				var crea_body = dove;
				var crea_div = document.createElement(tipo);
				crea_div.setAttribute("id", id);
				crea_body.appendChild(crea_div);
			}
		}
}
function getCoords(el){
	// 	restituisce le coordinate X e Y di un oggetto
		var c={x: 0, y: 0};
		while (el) {
				c.x+=el.offsetLeft;
				c.y+=el.offsetTop;
				el=el.offsetParent;
		}
		return c;
}

function oscura(cosa){
	if (cosa.toLowerCase()=="body")
		 {cl = document.body;}
	else {cl = document.getElementById(cosa);}
	
	if (!document.getElementById("OSCURO")){
		crea("div","OSCURO",cl)
		//$(cosa).append("<div id=\"OSCURO\">AKJHKLSHALKHSALKHSALKJH</div>");
	}
	os = document.getElementById("OSCURO");
	if (browser().IE()) {add=-1;} else {add=0}
	os.style.top         = (getCoords(cl).y) + "px";
	os.style.left        = (getCoords(cl).x+add) + "px";

	os.style.height      = (cl.offsetHeight) + "px";
	os.style.width       = (cl.offsetWidth) + "px";
	os.className = "osc"
	$("#OSCURO").show("slow",function () {
	$("#OSCURO").fadeTo("slow",0.8,function(){setTimeout("ritorna();",2000);});
});
	
}

function rimuovi(ob){
	// 	rimuove un eggetto
		del = document.getElementById(ob)
		if (del!=null) {del.parentNode.removeChild(del)}
}

function ritorna(){
$("#OSCURO").fadeOut("slow",function () {
	rimuovi("OSCURO");
	rimuovi("all")
});}

function browser(){
	// 	che browser stiamo usando?
		brow$ = navigator.userAgent.toLowerCase();
		arr_brow$ = "msie,firefox,safari,opera,chrome".split(",");
	
		return{
			IE:		function()	{return (brow$.match("msie") 	!= null);},
			FF:		function() 	{return (brow$.match("firefox") != null);},
			SAFARI:	function() 	{return ((brow$.match("safari") != null)&&(brow$.match("chrome")== null));},
			OPERA:	function() 	{return (brow$.match("opera") 	!= null);},
			CHROME:	function()	{return (brow$.match("chrome") 	!= null);},
			UNKNOW:	function()	{
									ret = true;
									for (br$ in arr_brow$){
											if (brow$.match(arr_brow$[br$])!=null) ret = false;
										}
										return ret;
								}
	}
}



if (document.all){
document.write("<link rel='stylesheet' href='style_ex.css' type='text/css'>"); }

function xcarrello(album,num){
		
		$.ajax({
		url : "ajax_carrello.asp?album="+album+"&num="+num,
		success : function (data,stato) {
		   document.getElementById("copie_"+album).innerHTML = data;
		},
		error : function (richiesta,stato,errori) {
			alert("E' evvenuto un errore. Il stato della chiamata: "+stato);
		}
	});	
	
}


function carrello(album,num){
	feed("<img src='ajax-loader.gif'>","copie_"+album)
ahah("ajax_carrello.asp?album="+album+"&num="+num, "get", "copie_"+album, "")
}
function commenta(tab,campo_id,id_ref,div_id,cont){
	
		$.ajax({
		url : "ajax_commenti.asp?tab="+tab+"&campo_id="+campo_id+"&id_ref="+id_ref+"&div_id="+div_id+"&cont="+cont,
		success : function (data,stato) {
		   document.getElementById("comm"+div_id).innerHTML = data;
		},
		error : function (richiesta,stato,errori) {
			alert("E' evvenuto un errore. Il stato della chiamata: "+stato);
		}
	});
}

function pubblica_comm(f,div_id){
	//alert("ajax_pubblica_commenti.asp?tab="+f.tab.value+"&campo_id="+f.campo_id.value+"&id_ref="+f.id_ref.value+"&testo="+f.testo.value);
	$.ajax({
		url : "ajax_pubblica_commenti.asp?tab="+f.tab.value+"&campo_id="+f.campo_id.value+"&id_ref="+f.id_ref.value+"&testo="+f.testo.value+"&nome="+f.nome.value,
		success : function (data,stato) {
		   commenta(f.tab.value,f.campo_id.value,f.id_ref.value,div_id,1);
		   return false
		},
		error : function (richiesta,stato,errori) {
			alert("E' evvenuto un errore. Il stato della chiamata: "+errori);
			return false
		}
	});
}

function show_dt(){
document.getElementById("sotto1").style.height	= document.getElementById("sotto1").rel+"px"
}
function show_all(id){
	document.getElementById("bsotto"+id).style.height = document.getElementById("bsotto"+id).rel+"px";
	document.getElementById("b"+id).style.height = "auto"
	document.getElementById("s"+id).style.display = "none";
	 //var hh = document.getElementById("agg"+id).rel+"px"
	 //$("#agg"+id).animate({"height" : hh},1900);
	}

$(function (){

$(":text, textarea").bind("focus blur", {"border-color" : "#67bfdc"}, function (event) {
	if (event.type == "focus") {
		$(this).css(event.data);
	} else {
		$(this).css("border-color","");
	}
});


 var x_dimore = $("#dimo").offset().left;
 var y_dimore = $("#dimo").offset().top+132;
 $("#copie_dimore").css({left: x_dimore, top: y_dimore });
 $("#copie_dimore").fadeTo("slow",0.7)
 
 var x_dimore = $("#acib").offset().left;
 var y_dimore = $("#acib").offset().top+132;
 $("#copie_acib").css({left: x_dimore, top: y_dimore });
 $("#copie_acib").fadeTo("slow",0.7)
 
 var x_disco = $("#lnk_disco").offset().left;
 $("#over_disco").css({left: x_disco });
	 
	 $(".discoz").hover(
	 
		function () {
			
			var n_div = $("#"+this.id+" > div").length
			 $("#"+this.id+" > div").css("height" , ((165/n_div)-(n_div-1))+"px");
			 $("#"+this.id+" > div").slideToggle("slow");
			 
		},
		function () {
			 $("#"+this.id+" > div").fadeOut("slow");
		}
	);
	 
	 
	 
	 
	 $("#lnk_disco").bind("mouseenter",function (event) {
		$("#over_disco").fadeIn("slow");
});
	 



$("#nav_top a:not(#lnk_disco)").bind("mouseover",function (event) {
		$("#over_disco").fadeOut("slow");
});

$("body").bind("click",function (event) {
		$("#over_disco").fadeOut("slow");
});


});




-->
