


/// Il mio codice Javascript qui

//GLOBAL
function act(imgName)
{
	if (document.images){ document[imgName].src = eval("j_s_" + imgName + ".src"); }
}

function inact(imgName)
{
	if (document.images) { document[imgName].src = eval("j_m_" + imgName + ".src"); }
}

function validateDate(strValue) {
  var objRegExp = /^\d{2}(\-|\/|\.)\d{2}\1\d{4}$/
  var intDay;
  if(!objRegExp.test(strValue))
    return false; 
  else{
    var strSeparator = strValue.substring(2,3)
    var arrayDate = strValue.split(strSeparator);
    var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31}
	if (arrayDate[0].substr(0,1)=='0') { intDay = parseInt(arrayDate[0].substr(1,1)) } else { intDay = parseInt(arrayDate[0]); }
    if(arrayLookup[arrayDate[1]] != null) {
      if(intDay <= arrayLookup[arrayDate[1]] && intDay != 0)
        return true;
    }
    var intMonth = parseInt(arrayDate[1]);
    if (intMonth == 2) { 
       var intYear = parseInt(arrayDate[2]);
       if( ((intYear % 4 == 0 && intDay <= 29) || (intYear % 4 != 0 && intDay <=28)) && intDay !=0)
          return true;
       }
  }
  return false;
}

function validateMail(oggetto) {
        var s = oggetto.value;
        s = s.replace(/^\s*|\s*$/, "");
        if (s == "undefined" || s.length < 8) {
             alert("La lunghezza dell\'indirizzo EMAIL deve essere di almeno 8 caratteri");
             oggetto.focus();
             return false;
            }
        re = /\s+/
        if (re.test(s)) {
             alert("Gli spazi non sono ammessi all'interno dell\'indirizzo email.");
             oggetto.focus();
             return false;
            }
        re = /^[\w-][\w-]*((\.[\w-]+)+)*@([\w-]+\.)*([\w-]{2,}\.)+([a-zA-Z]{2,4})$/
        if (!re.test(s)) {
             alert("Indirizzo EMAIL non corretto.");
             oggetto.focus();
             return false;
            }
        re = /\.(a[c-gil-oq-uwz]|b[a-bd-jm-or-tvwyz]|c[acdf-ik-orsuvx-z]|d[ejkmoz]|e[ceghr-u]|f[i-kmorx]|g[abd-ilmnp-uwy]|h[kmnrtu]|i[delm-oq-t]|j[emop]|k[eg-imnprwyz]|l[a-cikr-vy]|m[acdghk-z]|n[ace-giloprtuz]|om|p[ae-hk-nrtwy]|qa|r[eouw]|s[a-eg-ort-vyz]|t[cdf-hjkm-prtvwz]|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[admrw]|com|edu|net|org|mil|gov|biz|pro|aero|coop|info|name|museum|int)$/i
        if (!re.test(s)) {
             alert("Suffisso di dominio inesistente per l'email indicata.");
             oggetto.focus();
             return false;
            }
  return (true);
}

function validateCF(cf)
{
	CF = cf.value.toString();
	CF = CF.toUpperCase();

	var valori = new Array("A","0","B","1","C","2","D","3","E","4","F","5","G","6","H","7","I","8","J","9","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
	var pari = new Array(0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25);
	var dispari = new Array(1,1,0,0,5,5,7,7,9,9,13,13,15,15,17,17,19,19,21,21,2,4,18,20,11,3,6,8,12,14,16,10,22,25,24,23);
	var resto = new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z")
	var somma = 0;

	for (i=0;i<15;i=i+2) {             
		for (j=0;j<36;j++) {
			if (CF.substr(i,1) == valori[j]) {
				somma = somma + dispari[j];
			}
		}   
	}	

	for (i=1;i<15;i=i+2) {             
		for (j=0;j<36;j++) {
			if (CF.substr(i,1) == valori[j]) {
				somma = somma + pari[j];
			}
		}   
	}	
	
	somma = somma % 26;

	if (CF.substr(15,1) == resto[somma]) {
		return true;
	} else {
		alert('Codice Fiscale errato');
		cf.focus();
		return false;
	}
}



function validatePI(piva)
{
    partita_iva=piva.value.toString();
    somma_dispari=0;

    for (I=0;I<=10;I=I+2)
      {            
      somma_dispari = somma_dispari +  parseInt(partita_iva.charAt(I));
      }
    

    somma_pari=0;
    valoreappoggio =0;
    
    for (I=1;I<=9;I=I+2)
      {            
      if ( parseInt(partita_iva.charAt(I))  < 5)
           {
            valoreappoggio =  parseInt(partita_iva.charAt(I)) * 2;
            }
      else 
            {
            valoreappoggio = ( parseInt(partita_iva.charAt(I)) * 2) - 9;
            }
      somma_pari = somma_pari + valoreappoggio;
      }

    sommadeidue = somma_dispari + somma_pari;
    if ((sommadeidue % 10) == 0)
            {

               return true;
            }
    else
            {
            alert('Partita IVA/Codice Fiscale errato.');
               piva.focus();
               return false;
            }
} 


//HTTPRequest 
var xmlhttp=false;
try
{
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) 
	{
	try 
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	catch (E) 
	{
		xmlhttp = false;
	}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	xmlhttp = new XMLHttpRequest();
}

//Effettua richiesta remota (id_elemento, pagina_richiesta)
function MakeRequest(show,query) {
	var myOldElement = false;
	xmlhttp.open("GET",query,true);
	xmlhttp.onreadystatechange=function() 
	{
	if (xmlhttp.readyState==4) {
		var obj = document.getElementById(show);
		obj.innerHTML =  xmlhttp.responseText;
		//changeOpac(50, show);
		obj.style.visibility = "visible";
		//opacity(show, 0, 100, 250);
	}
	}
	xmlhttp.send(null)
}



function opacity(id, opacStart, opacEnd, millisec) { 
	var speed = Math.round(millisec / 100); 
	var timer = 0; 
	if(opacStart > opacEnd) { 
	for(i = opacStart; i >= opacEnd; i--) { 
	setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
	timer++; 
	} 
	} else if(opacStart < opacEnd) { 
	for(i = opacStart; i <= opacEnd; i++) 
	{ 
	setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
	timer++; 
	} 
	} 
} 

function changeOpac(opacity, id) { 
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100); 
	object.MozOpacity = (opacity / 100); 
	object.KhtmlOpacity = (opacity / 100); 
	object.filter = "alpha(opacity=" + opacity + ")"; 
} 


function evaluatePosition(leftPos)
{
	if (document.body.clientWidth > 760) {
		var calibra = parseInt((document.body.clientWidth - 760) / 2);
		var posizione = leftPos + calibra;
		return posizione;
	}
	else
	{
		return leftPos;
	}
}


//HOME PAGE



if (document.images) {
	var j_m_uno = new Image();
	j_m_uno.src = "img/profile_off.gif";
	
	var j_s_uno = new Image();
	j_s_uno.src = "img/profile_on.gif";
	
	var j_m_due = new Image();
	j_m_due.src = "img/products_off.gif";
	
	var j_s_due = new Image();
	j_s_due.src = "img/products_on.gif";
	
	var j_m_tre = new Image();
	j_m_tre.src = "img/services_off.gif";
	
	var j_s_tre = new Image();
	j_s_tre.src = "img/services_on.gif";
	
	var j_m_quattro = new Image();
	j_m_quattro.src = "img/portfolio_off.gif";
	
	var j_s_quattro = new Image();
	j_s_quattro.src = "img/portfolio_on.gif";
	
	var j_m_cinque = new Image();
	j_m_cinque.src = "img/news_off.gif";
	
	var j_s_cinque = new Image();
	j_s_cinque.src = "img/news_on.gif";
	
	var j_m_sei = new Image();
	j_m_sei.src = "img/contacts_off.gif";
	
	var j_s_sei = new Image();
	j_s_sei.src = "img/contacts_on.gif";
	
	
	var j_m_m_uno = new Image();
	j_m_m_uno.src = "img/m_h_uno_off.gif";
	
	var j_s_m_uno = new Image();
	j_s_m_uno.src = "img/m_h_uno_on.gif";
	
	var j_m_m_due = new Image();
	j_m_m_due.src = "img/m_h_due_off.gif";
	
	var j_s_m_due = new Image();
	j_s_m_due.src = "img/m_h_due_on.gif";
	
	var j_m_m_tre = new Image();
	j_m_m_tre.src = "img/m_h_tre_off.gif";
	
	var j_s_m_tre = new Image();
	j_s_m_tre.src = "img/m_h_tre_on.gif";
	
	var j_m_m_quattro = new Image();
	j_m_m_quattro.src = "img/m_h_quattro_off.gif";
	
	var j_s_m_quattro = new Image();
	j_s_m_quattro.src = "img/m_h_quattro_on.gif";
	
	var j_m_m_cinque = new Image();
	j_m_m_cinque.src = "img/m_h_cinque_off.gif";
	
	var j_s_m_cinque = new Image();
	j_s_m_cinque.src = "img/m_h_cinque_on.gif";
	
	var j_m_m_uno = new Image();
	j_m_m_uno.src = "img/m_h_uno_off.gif";
	
	var j_s_m_uno = new Image();
	j_s_m_uno.src = "img/m_h_uno_on.gif";
}

function flashX() {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=8,0,22,0" id="head" width="302" height="170">' +
		        '<param name="movie" value="flash/pine_movie_home.swf">' +
		        '<param name="bgcolor" value="#FFFFFF">' +
		        '<param name="quality" value="high">' +
		        '<param name="wmode" value="transparent">' +
		        '<param name="allowscriptaccess" value="samedomain">' +
		        '<embed' +
		         ' type="application\/x-shockwave-flash"' +
		         ' pluginspage="http:\/\/www.macromedia.com\/go\/getflashplayer"' +
		         ' name="pine_home_movie"' +
		         ' width="302" height="170"' +
		         ' src="\/flash\/pine_movie_home.swf"' +
		         ' bgcolor="#FFFFFF"' +
		         ' quality="high"' +
		         ' wmode="transparent"' +
		         ' swliveconnect="true"' +
		         ' allowscriptaccess="samedomain">' +
		         '<noembed>' +
		         '<\/noembed>' +
		        '<\/embed>' +
		      '<\/object>');
}




//DOMAIN e SIGNUP

