// JavaScript Document


var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY;

var tempX = 0
var tempY = 0

function check(e)
{
	filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/; 
	if (!filtro.test(e.value))	{
		alert("Inserire un indirizzo E-MAIL valido."); e.focus(); return false;} 
	else{
		 
		
ahah("/myhome_files/OK_NL.asp?campo="+e.value, "get", "bob", "")
		return false;}	
}

function iscri2(parm){
	el = document.frm_iscriz;
	var ret = true;
	if (el.nome.value.length<2){
		alert("Digitare nome");
		el.nome.focus();
		ret = false;
	}
	if (el.cognome.value.length<2){
		alert("Digitare cognome");
		el.cognome.focus();
		ret = false;
	}
	if (el.data_n.value.length<6){
		alert("Digitare data di nascita");
		el.data_n.focus();
		ret = false;
	}
	if (el.cap.value.length!=5){
		alert("Digitare CAP valido");
		el.nome.focus();
		ret = false;
	}
	if (el.cod_fisc.value.length!=16){
		alert("Digitare Codice fiscale valido");
		el.cod_fisc.focus();
		ret = false;
	}
	
	filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/; 
	if (!filtro.test(el.email.value))	{
		alert("Inserire un indirizzo E-MAIL valido.");
		el.email.focus();
		ret = false;
		} 
	
	if (ret){
		divchiudi =  "<div align=\'right\'><img src=\'images/closelabel.gif\' style=\'cursor:pointer;\' onclick=\"scoppia2(\'bob\');\"></div>"
		ahah("/card_txt/iscriz_corso2.asp?provincia="+el.provincia.value, "post", "bob", divchiudi,parm)
	}
}

function play(url,tipo,w_vid,id_video){
	var ob_vid = document.getElementById("box_vid");
	var v_html = ""
	if (tipo=="YT"){
		v_html =  "<object width=\'"+w_vid+"\' height=\'"+(w_vid*0.8235)+"\'>";
		v_html += "<param name=\"movie\" value=\"http://www.youtube.com/v/"+url+"&hl=it_IT&fs=1&\"><\/param>";
		v_html += "<param name=\"allowFullScreen\" value=\"true\"><\/param>";
		v_html += "<param name=\"allowscriptaccess\" value=\"always\"><\/param>";
		v_html += "<embed src=\"http://www.youtube.com/v/"+url+"&hl=it_IT&fs=1&\"";
		v_html += " type=\"application\/x-shockwave-flash\" allowscriptaccess=\"always\"";
		v_html += " allowfullscreen=\"true\" width=\'"+w_vid+"\' height=\'"+(w_vid*0.8235)+"\'>";
		v_html += "<\/embed><\/object>"
	}
		
	if (tipo=="WMP"){
		v_html =  "<object id=\"WMPlay\" classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\"";
		v_html += "codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\"";
		v_html += "standby=\"Loading Microsoft Windows Media Player components...\" type=\"application/x-oleobject\"";
		v_html += "height=\'"+(w_vid*0.8235)+"\' width=\'"+w_vid+"\'>";
		v_html += "<param name=\"URL\" value=\'"+url+"\'><param name=\"AllowChangeDisplaySize\" value=\"True\">";
		v_html += "<param name=\"ShowControls\" value=\"1\"><param name=\"ShowDisplay\" value=\"1\">";
		v_html += "<param name=\"ShowStatusBar\" value=\"1\"><param name=\"AutoStart\" value=\"TRUE\">";
		v_html += "<param name=\"InvokeURLS\" value=\"FALSE\">";
		v_html += "<embed name=\"WMplay\" type=\"application\/x-mplayer2\"";
		v_html += " pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/\"";
		v_html += " src=\'"+url+"\' autostart=\"true\" showcontrols=\"1\" displaysize=\"4\"";
		v_html += " showstatusbar=\"1\" height=\'"+(w_vid*0.8235)+"\' width=\'"+w_vid+"\'>";
		v_html += "<\/embed><\/object>"
	}
	
	if (tipo=="MOV"){
		v_html =  "<EMBED SRC=\""+url+"\"  width=\'"+w_vid+"\' height=\'"+(w_vid*0.8235)+"\' AUTOPLAY=true";
		v_html += " LOOP=false HREF=\'"+url+"\'>";
	}
	
	if (tipo=="FLV"){
		v_html =  "<object id=\"player\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" name=\"player\"";
		v_html += " width=\'"+w_vid+"\' height=\'"+(w_vid*0.8235)+"\'>";
		v_html += "<param name=\"movie\" value=\"/mediaplayer-viral/player-viral.swf\" />";
		v_html += "<param name=\"allowfullscreen\" value=\"true\" />";
		v_html += "<param name=\"allowscriptaccess\" value=\"always\" />";
		v_html += "<param name=\"flashvars\" value=\"file="+url+"&image=/mediaplayer-viral/preview.jpg\" />";
		v_html += "<embed type=\"application/x-shockwave-flash\" id=\"player2\"	name=\"player2\"";
		v_html += " src=\"/mediaplayer-viral/player-viral.swf\"	width=\'"+w_vid+"\' height=\'"+(w_vid*0.8235)+"\'";
		v_html += "	allowscriptaccess=\"always\" allowfullscreen=\"true\"";
		v_html += "	flashvars=\"file="+url+"&image=/mediaplayer-viral/preview.jpg\" /></object>";
	}
ob_vid.innerHTML = v_html;

ahah("/myhome_files/campi_video.asp?campo=descrizione&id_video="+id_video, "get", "video_selezionato", "")

}

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  return true
}



function scoppia(div,ooo)
{
	dd = document.getElementById(div)
	if (dd!=null)
	{
		
	
		HHH = dd.offsetHeight;
		WWW = dd.offsetWidth;
		
		add = 5; //px in altezza e in larghezza
		dd.style.height = HHH+add;
		dd.style.width  = WWW+add;
		
		pr = document.getElementById("prova")		
		HHP = pr.offsetHeight;
		WWP = pr.offsetWidth;
		pr.style.height = HHP-(add*2);
		pr.style.width  = WWP-(add*2);
		centra_div("prova")
		centra_div(div)
		if (ooo>0)
			{
				ooo = ooo-5;
				opacita(dd,ooo)
				setTimeout("scoppia('"+div+"',"+ooo+")",40);
				opacita("prova",ooo-20)
			}
		else
			{
			dd.style.display = "none";
			opacizza(0);
			}	
	}
}


function scoppia2(div){
	dd = document.getElementById(div);
	dd.style.display = "none";
	opacizza(0);
}

function tempo(val,limite,act,azione,loading)
{
	if (act=="opa")
	{val = val + 2;
	eval("opacita(ob,"+val+")")}
	else
	{
	val = val + 30;
	eval(act+"="+val);
	}

	centra_div("bob")
	
	if (val<limite)
		{
		setTimeout("tempo("+val+","+limite+",\""+act+"\",\""+azione+"\",\""+loading+"\")",40)
		return eval(loading)
		}
	else
		{
			/*if (act=="ob.style.width")
				{tempo(1,900,"ob.style.height","","ob.innerHTML = "+loading);}*/
			return eval(azione);
		}
}


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 centra_div(div)
{
	div_c = document.getElementById(div)
	div_c.style.left    = "50%"
	div_c.style.top     = "750px"
	div_c.style.display ="block";
	div_c.style.margin  = "-"+(div_c.offsetHeight)/2+"px 0 0 -"+(div_c.offsetWidth)/2+"px"

	div_c.style.position="absolute";
}


function feed(messaggio,target)
	{window.document.getElementById(target).innerHTML="<br><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 commenta()
   	   {feed("Caricamento...","commenti");ahah("commenti_arg.asp", "post", "commenti");}

function return_id(id_att,PRE_NEX){
	
}
	   
function mostra(src,desc,h,w,controllo,id_img)
{
	if (controllo.toLowerCase()!="http://www.ultimavera.it/noimmagine.jpg")
	{
	opacizza(1);
	divchiudi = "<div align='right' class=\"CLS_LBL\"><img src='images/closelabel.gif' style='cursor:pointer;' onclick=\"scoppia2('bob');\"></div>"
	ob           =  document.getElementById('bob');
	ob.className =  "bob_v";
	
	ob.style.height = 0;
	contenuto_loading = "<img src='/indicator3.gif'>";
	lnk_prev = "<div id=\'prev\' style=\"text-align:left;\"><a href=\"javascript:go_img("+(id_img-1)+",\'prev\');\">&lt;-Indietro</a></div>";
	lnk_next = "<div id=\'next\' style=\"text-align:right;\"><a href=\"javascript:go_img("+(id_img+1)+",\'next\');\">Avanti-&gt;</a></div>";
	if (!document.getElementById('img_gall_'+(id_img-1))) lnk_prev = "<div id=\'prev\' style=\"text-align:left;\"></div>"
	if (!document.getElementById('img_gall_'+(id_img+1))) lnk_next = "<div id=\'next\' style=\"text-align:right;\"></div>"
	
	contenuto_finale  = divchiudi + "<img src='"+src+"' width='"+w+"'><br>"+lnk_prev+lnk_next+divchiudi

   // tempo(1,h+40,"ob.style.height","ob.innerHTML = contenuto_finale","ob.innerHTML = contenuto_loading");
   // tempo(1,w+20,"ob.style.width","ob.innerHTML = contenuto_finale","ob.innerHTML = contenuto_loading");
	//tempo(80,100,"opa","ob.innerHTML = contenuto_finale","ob.innerHTML = contenuto_loading");
	ob.innerHTML = contenuto_finale;
	ob.overflow = "none";
	ob.style.height = h + 70;
	ob.style.width = w + 20;
	centra_div("bob");

	//ob.innerHTML =  ;
	}
	else
	{alert("L\'immagine non è al momento di sponibile");}
}

function go_img(id_img,P_N){
	imm = document.getElementById("img_gall_"+id_img)
	if (imm) {
		src = imm.name;
		desc = imm.title;
		divchiudi = "<div align='right' class=\"CLS_LBL\"><img src='images/closelabel.gif' style='cursor:pointer;' onclick=\"scoppia2('bob');\"></div>"
		lnk_prev  = "<div id=\'prev\' style=\"text-align:left;\"><a href=\"javascript:go_img("+(id_img-1)+",\'prev\');\">&lt;-Indietro</a></div>";
		lnk_next  = "<div id=\'next\' style=\"text-align:right;\"><a href=\"javascript:go_img("+(id_img+1)+",\'next\');\">Avanti-&gt;</a></div>";
		if (!document.getElementById('img_gall_'+(id_img-1))) lnk_prev = "<div id=\'prev\' style=\"text-align:left;\"></div>"
		if (!document.getElementById('img_gall_'+(id_img+1))) lnk_next = "<div id=\'next\' style=\"text-align:right;\"></div>"

		contenuto_finale  = divchiudi + "<img src='"+src+"'><br>"+lnk_prev+lnk_next+divchiudi

		document.getElementById('bob').innerHTML = contenuto_finale;
			
	}
}

function cambia_foto(id){
	if(id !="0"){
	feed('<img src=\'progress2.gif\'>','solo_foto2');
	ahah("/myhome_files/ajax_foto.asp?id="+id, "get", "solo_foto2", "")
	}
}

function cambia_video(id){
		if(id !="0"){

	mostra_TXT("/myhome_files/ajax_video.asp?id="+id,550,"1000px");return false;
		}
}

function mostra_TXT(src,h,w,top)
{
	if (top==undefined) top="20px";
	opacizza(1);
	ob           =  document.getElementById('bob');
	ob.style.display = "block";
	ob.className =  "bob_txt";
	ob.style.position="absolute";
	ob.style.height = h;
	ob.style.margin  = "30px 30px 30px 30px "
	var diffe = 0;
	ob.style.width = w;
	ob.style.left = "5%";
	var scr = 0
	if (IE) scr = document.body.scrollTop;
	else scr =  document.body.scrollTop;
	
	ob.style.top = ((scr - 0) + 50 )+"px";
	ob.style.overflow = "auto";
	divchiudi =  "<div align='right'><img src='images/closelabel.gif' style='cursor:pointer;' onclick=\"scoppia2('bob');\"></div>"
	feed('<img src=\'progress2.gif\'>','bob');
	ahah(src, 'get','bob',divchiudi);
}



function opacizza(opa)
{
	var v = document.getElementById("prova");

if (opa == 1)
{
	v.style.top     = "0%"
	v.style.left    = "0%"
	v.style.height  = "1300px"
	v.style.width   = "100%"
	v.style.display = "block";
	v.style.margin  = "0% 0 0 0%"

	var opacity = 80
	if(document.all) 
		{v.style.filter = "alpha(opacity=" + opacity + ")";
		v.style.position="absolute";}
	  else
		{
		v.style.opacity = opacity / 100;
		v.style.position="fixed";
		}
	}
	else
	{
	v.style.height=0
	v.style.width=0
	v.style.display="none";
	}
}







