

function creatediv(id, html, width, height, left, top,z, ref_col) {
	
   var newdiv = document.createElement('div');
   newdiv.setAttribute('id', id);   
   if (width) {
       newdiv.style.width = width;
   }   
   if (height) {
       newdiv.style.height = height;
   }   
   if ((left || top) || (left && top)) {
       newdiv.style.position = "absolute";
       
       if (left) {
           newdiv.style.left = left;
       }
       
       if (top) {
           newdiv.style.top = top;
       }
   }   
   newdiv.style.background ="" /* "#00C"; */
   newdiv.style.border = "" /*"4px solid #000";   */
   newdiv.style.zIndex=z;
   
   //var xx = "sometexthere";
  //   newdiv.innerHTML += xx; 
   if (html) {
       newdiv.innerHTML += "<a style='display:block; border:none;' title=\"\" href='javascript:apri_dettagli_punto("+(left+8)+","+(top+8)+","+(ref_col)+")'>" + html+ "</a>";
   } else {
       newdiv.innerHTML = "nothing";
   }   
 
  document.body.appendChild(newdiv);
      // document.getElementById('immagine').appendChild(newdiv);
} 

function clicco(e,ref_col, regione){

w=450
h=400
	if(!e) e=window.event
	var eX = (e.layerX) ? e.layerX : e.offsetX | 0
	var eY = (e.layerY) ? e.layerY : e.offsetY | 0


creatediv( "Punto_"+eX+"_"+eY, "<img style='border:none' id='imm_Punto_"+eX+"_"+eY+"' src='images/stop.png'>", 16, 16, eX-8, eY-8,5, ref_col)

	
//zona="<span id='\"Punto_"+ eX +"_"+ eY +"\"'>Punto_"+ eX +"_"+ eY +" - <a onmouseover='javascript:evidenzia(\"Punto_"+ eX +"_"+ eY +"\");' onmouseout='javascript:disevidenzia(\"Punto_"+ eX +"_"+ eY +"\");' href='javascript:cancella(\"Punto_"+ eX +"_"+ eY +"\");'>Canc</a></span><br />"
	//parent.document.getElementById('coordinate').innerHTML+=zona
	ajax('Punto_'+ eX +'_'+ eY , 'add',ref_col, regione)
}

function apri_dettagli_punto(x,y,ref_col){
	
	
	if(document.getElementById('dettagli_punto')){
		
		   obj = document.getElementById("dettagli_punto");
		   document.body.removeChild(obj);
		}
	
creatediv( "dettagli_punto", "", 160, 160, x, y ,5, ref_col);


ajax('dett_punto_'+x +'_'+ y , 'details',ref_col);

	}
	
function apri_dettagli_punto_view(x,y,ref_col){
	
	
	if(document.getElementById('dettagli_punto')){
		
		   obj = document.getElementById("dettagli_punto");
		   document.body.removeChild(obj);
		}
	
creatediv( "dettagli_punto", "", 160, 160, x, y ,5, ref_col);


ajax('dett_punto_'+x +'_'+ y , 'details_view',ref_col);

	}
function distruggi_div(iddiv){
	if(document.getElementById(iddiv)){
		
		   obj = document.getElementById(iddiv);
		   document.body.removeChild(obj);
		}
	
	}

function evidenzia(punto){
parent.intestino.document.getElementById(punto).style.border="2px solid red"
}
function disevidenzia(punto){
parent.intestino.document.getElementById(punto).style.border="none"
}


// Pop-up code for case study pop-ups

var myRequest = null;
function CreateXmlHttpReq(handler) {
	//alert(navigator.userAgent.toLowerCase());
  var agt = navigator.userAgent.toLowerCase();
  var is_ie5 = (agt.indexOf('msie 5') != -1);
  var is_ie7 = (agt.indexOf('msie 7') != -1);
  var mozilla = (agt.indexOf('mozilla') != -1);
  
  var xmlhttp = null;
  
  
  try {
    xmlhttp = new XMLHttpRequest();
    try {
        // Fix for some version of Mozilla browser.
        http_request.overrideMimeType('text/xml');
    } catch(e) { if(is_ie7)  new ActiveXObject(control);}
    xmlhttp.onload = handler;
    xmlhttp.onerror = handler;
  } catch(e) {
	
    var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";
	
	
    xmlhttp = new ActiveXObject(control);//funziona con ie7
    xmlhttp.onreadystatechange = handler;
 }
  
  return xmlhttp;
}

function myHandler2() {


    if (myRequest.readyState == 4 && myRequest.status == 200) {
       document.getElementById("contenuto").innerHTML = myRequest.responseText;
    }
	
}



function ajax(p,op) {
	
    var r = Math.random();

		if(op=="pagina") {
   			myRequest = CreateXmlHttpReq(myHandler2); 
			myRequest.open("GET","include/ajax.func.php?op="+escape(op)+"&p="+escape(p)+"&rand="+escape(r));
			
			
		}
		
	


    myRequest.send(null);
}






function regione(str){
	if(str=='Schema_colon_1.gif') er=1;
	if(str=='Schema_colon_2.gif') er=2;
	if(str=='Schema_colon_3.gif') er=3;
	if(str=='Schema_colon_4.gif') er=4;
	if(str=='Schema_colon_5.gif') er=5;
	if(str=='Schema_colon_6.gif') er=6;
	if(str=='Schema_colon_7.gif') er=7;
	if(str=='Schema_colon_8.gif') er=8;

document.getElementById('select_regione').options[er].selected=true;
	document.getElementById("colon").src="images/colon/regioni/"+str;
	}


function isnum(obj, nomecampo) {
if (isNaN(obj.value) || parseInt(obj.value)<0 || parseInt(obj.value) > 9999)
{
alert('Nel campo '+ nomecampo +' è possibile immettere solo numeri!');
obj.value="";
obj.focus();
}
}







