// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
} 

function openDivRicerca(element)
{
	//alert(element);
	document.getElementById(element).style.left=document.body.clientWidth/2 - 282 + "px";
	document.getElementById(element).style.visibility='visible';
	if (document.getElementById('divCombo')!=null) {document.getElementById('divCombo').style.visibility='hidden';}
}
function openDivServizi(element) 
{
	//alert(element);
	document.getElementById(element).style.left=document.body.clientWidth/2 - 202 + "px";
	document.getElementById(element).style.visibility="visible";
	if (document.getElementById('divCombo')!=null) {document.getElementById('divCombo').style.visibility='hidden';}
}
function openDivMessenger(element) 
{
	//alert(element);
	//document.getElementById(element).style.left=document.body.clientWidth/2 - 202 + "px";
	document.getElementById(element).style.visibility="visible";
}

function openDivLavagna(element) 
{
	//alert(element);
	//document.getElementById(element).style.left=document.body.clientWidth/2 - 202 + "px";
	document.getElementById(element).style.visibility="visible";
}

function openDivProgrammazione(element) 
{
	if (document.getElementById('divCombo')!=null) {document.getElementById('divCombo').style.visibility='hidden';}
	if (navigator.appName=='Microsoft Internet Explorer')
	{
		//document.getElementById(element).style.left=event.clientX + document.body.scrollLeft + 15;
		//document.getElementById(element).style.top=event.clientY + z + 15;
		document.getElementById(element).style.left="40%";
		document.getElementById(element).style.top="40%";
	}
	else
	{
		document.getElementById(element).style.left=document.body.clientWidth/2 - 252 + "px";
		document.getElementById(element).style.top="40%";
	}
	document.getElementById(element).style.visibility="visible"; 
}

function closeDiv(element)
{
	if (document.getElementById('divCombo')!=null) {document.getElementById('divCombo').style.visibility='visible';}
	document.getElementById(element).style.visibility="hidden";
	if (element!='divMessenger1') {document.getElementById(element).style.left=document.body.clientWidth/2 - 282 + "px";}
}

function SendAjaxForm(formname,destination,page)
{	
	//alert(formname);
	var numberObject = document.forms[formname].length;
	var stringa = "?"
	for (i=0; i<numberObject; i++) 
	{
		if (document.forms[formname].elements[i].type=='checkbox' || document.forms[formname].elements[i].type=='radio')
		{
			if (document.forms[formname].elements[i].checked && document.forms[formname].elements[i].type=='checkbox')
			{ stringa = stringa + document.forms[formname].elements[i].name + "=" + document.forms[formname].elements[i].value.replace(/ /g,"%20") + "&" }
			if (document.forms[formname].elements[i].checked && document.forms[formname].elements[i].type=='radio')
			{ stringa = stringa + document.forms[formname].elements[i].name + "=" + document.forms[formname].elements[i].value.replace(/ /g,"%20") + "&" }
		}
		else
		{
			stringa = stringa + document.forms[formname].elements[i].name + "=" + document.forms[formname].elements[i].value.replace(/ /g,"%20") + "&"
		}
		//alert(stringa);
	}
	//alert(stringa);
	var numero = Math.floor(Math.random() * 123456);
	var qstring = "random=" + numero;
	ajaxpage(page + stringa + qstring,destination);
}

function funMessage(t)
{
	var x=new Date();
	h=x.getHours();
	m=x.getMinutes();
	s=x.getSeconds();
	//ajaxpage('load_message.asp?ancora='+s+m+h+'&#down','divMessage',0);
	//alert(s+m+h);
	//ajaxpage('/inc_script_load_user_website.asp?timers='+s+m+h*s+m+h/2,'divUserWebsite');
	//ajaxpage('/inc_script_load_user_forum.asp?timers='+s+m+h*s+m+h/2,'divUserForum');
	ajaxpage('/inc_script_controllosessione.asp?timers='+s+m+h*s+m+h/2,'divSubmit');
	//ajaxpage('/inc_script_load_messaggi_privati.asp?timers='+s+m+h*s+m+h/2,'divSubmit2');
	setTimeout("funMessage(60000)",t); 
}

function stellina(voto)
{
	document.getElementById('spanVoto').innerHTML=voto.replace(/img/g,'')+'/5';
	var numero = voto.replace(/img/g,'');
	var num;
	for (i=1; i<numero+1; i++) 
	{
		//alert ('img' + i)
			if (i<=numero)
			{
				document.getElementById('img' + i).src='/images/stellaBordo.gif';
			}
			else
			{
				if (i<6) {document.getElementById('img' + i).src='/images/stellaBordo_off.gif';}
			}
	}
}

function sendVoto1(voto)
{
	//alert(voto);
	ajaxpage('/inc_interactive_i_sondaggi_controllo_tipo1.asp?timers='+Math.floor(Math.random() * 123456) + '&IDRisposta=' + voto.replace(/img/g,'') + '&IDSondaggi='+ document.getElementById('IDSondaggi').value,'divRisultati') ;
	//document.getElementById('divRisultati').innerHTML='';
}

function sendVoto2(voto)
{
	//alert(voto);
	ajaxpage('/inc_interactive_i_sondaggi_controllo_tipo2.asp?timers='+Math.floor(Math.random() * 123456) + '&voto=' + voto.replace(/img/g,'') + '&IDSondaggi='+ document.getElementById('IDSondaggi').value,'spanVotazione') ;
	document.getElementById('divRisultati').innerHTML='';
}

function copia(area) {
	var appoggio=document.getElementById(area);
	//alert(appoggio);
	appoggio.focus()
	appoggio.select()
	intervallo=appoggio.createTextRange()
	intervallo.execCommand("Copy")
}

function apriChat()
{
	window.open('/chat/chatxpert/chatxpert.asp','chatexpertwin37857', 'status=yes,toolbar=no,width=670,height=600,resizable=yes');
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
