

function toggle(id){
	
	if (document.getElementById) { // DOM3 = IE5+, NS6+, FF
		if (document.getElementById(id).style.display == 'none'){
			document.getElementById(id).style.display = 'block';            
	    } else 
			document.getElementById(id).style.display = 'none';
	}
	
}

function closeByTagAndClassName(tagName,className){
	var arr = document.getElementsByTagName(tagName);
	for(var i=0;i<arr.length;i++)
		if(arr[i].className==className)
			arr[i].style.display = "none";
}

function selectFaq(id){
	if (document.getElementById) { // DOM3 = IE5+, NS6+, FF
	
		//closeByTagAndClassName('span','faq');
		var el = id.parentNode.getElementsByTagName('span')[0];
		if(el.className=='faq' && el.style.display=='none'){
		 	 el.style.display='block';
		} else 
			 el.style.display='none';
	
	}	
}

function initialize(){
	if (document.images){
		var arr = new Array(
			"microcellulare.png",
			"ipaq.gif",
			"inpuBevute_j2me.gif",
			"inpuBevute_ppc.gif",
			"inputCalcola_j2me.gif",
			"inputCalcola_ppc.gif",
			"inputGenere_j2me.gif",
			"inputGenere_ppc.gif",
			"inputPeso_J2me.gif",
			"inputPeso_ppc.gif",
			"inputStomaco_j2me.gif",
			"inputStomaco_ppc.gif"
		);
		for(var i=0;i<arr.length;i++){
			var temp = new Image();
			temp.src=arr[i];
		}

   }
}

function check(x,y){
	
	 if (document.getElementById("antispam").value == x+y){
			  var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
			  if(!pattern.test(document.getElementById("email").value)){         
					alert("Email non corretta!");   
		    }else{
					if(document.getElementById("body").value.length==0){
						alert("Testo del messaggio mancante!");
					} else {
						document.getElementById("send_form").submit();
					}		 
		    }	
  }else alert("Inserire il codice di controllo (somma di "+ x +" + " + y + " = " + (x+y) + ")!");  
}

function Point(x, y) {
    this.x = x;
    this.y = y;
}

function getRealPos(o) {
    var oX = 0;
    var oY = 0;
    if (o.offsetParent) {
        while (1) {
            oX+=o.offsetLeft;
            oY+=o.offsetTop;
                if (!o.offsetParent) {
                    break;
                }
            o=o.offsetParent;
        }
    } else if (o.x) {
        oX+=o.x;
        oY+=o.y;
    }    
    return new Point(oX, oY);
}

function $(id){
	return document.getElementById(id);
}

function set(palmare,nota,image){
	$('divfotocellulare').innerHTML='<img id="fotocellulare" src="'+(palmare?"ipaq.gif":"microcellulare.png")+'" />';
	var x = getRealPos($('fotocellulare')).x;
	var y = getRealPos($('fotocellulare')).y;
	$('divshow').style.left = (x+(palmare?32:38))+'px';
	$('divshow').style.top = (y+(palmare?65:52))+'px';
	$('divshow').innerHTML='<img src="'+image+'" id="show" />';
	$('divshow').style.visibility = 'visible';
}