/**********************************************************************************   
PopupDescriptions 
*   Copyright (C) 2001 <a href="/dhtmlcentral/thomas_brattli.asp">Thomas Brattli</a>
*   This script was released at DHTMLCentral.com
*   Visit for more great scripts!
*   This may be used and changed freely as long as this msg is intact!
*   We will also appreciate any links you could give us.
*
*   Made by <a href="/dhtmlcentral/thomas_brattli.asp">Thomas Brattli</a> 
*********************************************************************************/
var deltay=-266;
var deltax=0;

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()


fromX = 0 //How much from the actual mouse X should the description box appear?
fromY = 0 //How much from the actual mouse Y should the description box appear?

//To set the font size, font type, border color or remove the border or whatever,
//change the clDescription class in the stylesheet.

//Makes crossbrowser object.
function makeObj(obj){								
   	this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
	if(!this.evnt) return false
	this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;	
   	this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;		
	this.writeIt=b_writeIt;																
	return this
}

// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?"":"px";

function b_writeIt(text){
	if (bw.ns4){this.wref.write(text);this.wref.close()}
	else this.wref.innerHTML = text
}

//Capturing mousemove
var descx = 0
var descy = 0
function popmousemove(e){descx=bw.ns4||bw.ns6?e.pageX:event.x; descy=bw.ns4||bw.ns6?e.pageY:event.y}

var oDesc;
var iImg;

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function popup(num, tipo, cache, immagine, dx, dy){
    if(oDesc){
    	var posx=findPosX(immagine)
    	var posy=findPosY(immagine)
    	
		if (tipo == 0) {
			 if (bw.ie5||bw.ie6) {
			    oDesc.writeIt('<div class="clDescription2"><table valign="center" align="center" cellspacing="0" bgcolor=white cellpadding="0" width="136" HEIGHT="110"><tr><td align="center"><img border="0" src="/simages/' + cache + 'imgm_' + num + '.jpg"></td></tr></table></div>')
			 } else {
			 		oDesc.writeIt('<div class="clDescription"><img border="0" src="/simages/' + cache + 'imgm_' + num + '.jpg"></div>')
			 }
		} else {
			 if (bw.ie5||bw.ie6) {
			 		oDesc.writeIt('<div class="clDescription2"><table valign="center" align="center" cellspacing="0" bgcolor=white cellpadding="0" width="136" HEIGHT="121"><tr><td align="center"><img border="0" src="/simages/' + cache + 'imgm_' + num + '.jpg"></td></tr><tr><td align="center"><img src="/images/cliccaqui.gif" width="107" HEIGHT="15"></td></tr></table></div>')
			 } else {
			 		oDesc.writeIt('<div class="clDescription" align="center"><img border="0" src="/simages/' + cache + 'imgm_' + num + '.jpg"><br><img src="/images/cliccaqui.gif" width="107" HEIGHT="15"></div>')
			 }
		}
		
		if(bw.ie5||bw.ie6) descy = descy+document.body.scrollTop
		
		oDesc.css.left = (posx+dx)+px
		oDesc.css.top = (posy+dy)+px
		
		oDesc.css.visibility = "visible"
    }
}

function popup_tel(num, immagine, dx, dy){
    if(oDesc){
    	var posx=findPosX(immagine)
    	var posy=findPosY(immagine)
    	
		if(bw.ie5||bw.ie6) descy = descy+document.body.scrollTop
			
		if (bw.ie5||bw.ie6) {
			oDesc.writeIt('<div class="clDescription2"><table valign="center" align="center" cellspacing="0" bgcolor=white cellpadding="0" width="95" HEIGHT="36"><tr><td align="center"><img border="0" src="' + num + '"></td></tr></table></div>')
			oDesc.css.left = (posx-dx-65)+px
			oDesc.css.top = (posy-6)+px
		} else {
			oDesc.writeIt('<div class="clDescription"><img border="0" src="' + num + '"></div>')
			oDesc.css.left = (posx-dx-73)+px
			oDesc.css.top = (posy-5)+px
		}
		
		oDesc.css.visibility = "visible"
    }
}

function popup2(num, status){
    if(oDesc){
			oDesc.writeIt('<div class="clDescription"><img src="/appunti/?oid=' + num + '&status=' + status + '"></div>')
    }
}
function popimg2(num, idfoto) {
	iImg2 = new makeObj('foto2');
	if (iImg2) { iImg2.writeIt('<div align="center" valign="center" class="climgs"><img border="0" src="/dbaimages/img_' + num + '_' + idfoto + '.jpg>"></div>')
		if (bw.ie5||bw.ie6||bw.ie7) { iImg2.css.top = (deltay)+px; iImg2.css.left = deltax+px;	}	iImg2.css.visibility = "visible"
	}
}
function popout(){
	if (oDesc) oDesc.css.visibility = "hidden"
}
function setPopup(){
   	if(bw.ns4)document.captureEvents(Event.MOUSEMOVE)
    document.onmousemove = popmousemove;
	oDesc = new makeObj('divDescription')
}
function openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}
function setColor(chkb, theRow, normalcol, col)
{
		var tocolor;
		
		if (chkb.checked) {
			tocolor=col;
		} else {
			tocolor=normalcol;
		}
		
    for (var c = 0; c < theRow.cells.length; c++) {
        theRow.cells[c].bgColor = tocolor;
    }
    return true;
}

function getDoc(doc) {if(doc == null) doc= window.document;	return doc;}

function switchAllBoxes(doc) {	
	doc = getDoc(doc); 	
	with (doc.selezionaripeti) { 
		for (i = 1; i < elements.length; i++) {
			if ((!elements[i].disabled) && (elements[i].type == "checkbox")) {
				if (elements[i].checked) {
					elements[i].checked = false;	
				} else {
					elements[i].checked = true;	
				}
			}
		}
	}
}

function openCentered (url, width, height, windowName, featureString) {
  if (!windowName)
    windowName = '';
  if (!featureString)
    featureString = '';
  else
    featureString = ',' + featureString;
  var x = Math.round((screen.availWidth - width) / 2);
  var y = Math.round((screen.availHeight - height) / 2);
  featureString = 'left=' + x + ',top=' + y + ',width=' + width + ',height=' + height + featureString;
  return open (url, windowName, featureString);
}

function appuntalo2(e, theImg, oid) {
	if (theImg.src.indexOf("on") >= 0) { 
		theImg.src = "/img/salva-off.png";
		theImg.alt = "Inseriscilo negli appunti";
		popup2(oid, "off");
		return false;
	}	else if (theImg.src.indexOf("off") >= 0) { 
		theImg.src = "/img/salva-on.png";
		theImg.alt = "Rimuovilo";
		popup2(oid, "on");	
		return true;
	}
}
if (document.images) {
  var pripeti = new Image();
  pripeti.src = '/images/pripeti.gif';
}