var __heightDiv="";
var __metaHeightDiv="";
var positionOriginal;
var req=createXMLHttpRequest();var divID="";function createXMLHttpRequest(){var ua;if(window.XMLHttpRequest){try{ua=new XMLHttpRequest();}catch(e){ua=false;}}
else if(window.ActiveXObject){try{ua=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){ua=false;}}
return ua;}
function sendRequest(_url,_divID){toolTip();divID=_divID;req.open('get',_url+"&rand="+escape(Math.random()));req.onreadystatechange=handleResponse;req.send(null);}
function handleResponse(){
	if(document.getElementById('sitefolder')){
	var sitefolder=document.getElementById('sitefolder').value;
	} else {
		var sitefolder='/';
	}
	if(req.readyState==4){
		var response=req.responseText;
		var update=new Array();
		if(response.indexOf('||'!=-1)){
			update=response.split('||');
			toolTip();
			document.getElementById(divID).innerHTML=req.responseText;
		}
	} else{
		strloading="<center><img src='"+sitefolder+"img/ico/indicator_very.gif'></center>";
		toolTip();
		document.getElementById(divID).innerHTML=metaHeightDiv;
	}
}
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
function ajaxpage(url,containerid){toolTip();var page_request=false
if(window.XMLHttpRequest)
page_request=new XMLHttpRequest()
else if(window.ActiveXObject){try{page_request=new ActiveXObject("Msxml2.XMLHTTP")}
catch(e){try{page_request=new ActiveXObject("Microsoft.XMLHTTP")}
catch(e){}}}
else
return false
page_request.onreadystatechange=function(){loadpage(page_request,containerid)}
page_request.open('GET',url,true)
page_request.send(null)}
function loadpage(page_request,containerid){if(page_request.readyState==4&&(page_request.status==200||window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
toolTip();}
function loadobjs(){if(!document.getElementById)
return
for(i=0;i<arguments.length;i++){var file=arguments[i]
var fileref=""
if(loadedobjects.indexOf(file)==-1){if(file.indexOf(".js")!=-1){fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");fileref.setAttribute("src",file);}
else if(file.indexOf(".css")!=-1){fileref=document.createElement("link")
fileref.setAttribute("rel","stylesheet");fileref.setAttribute("type","text/css");fileref.setAttribute("href",file);}}
if(fileref!=""){document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" "}}}
function createXMLHttpRequest(){var ua;if(window.XMLHttpRequest){try{ua=new XMLHttpRequest();}catch(e){ua=false;}}
else if(window.ActiveXObject){try{ua=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){ua=false;}}
return ua;}
var req=createXMLHttpRequest();var divID="";function sendRequest(_url,_divID){ 
	
	if(jQuery){
		positionOriginal=$('#'+_divID).css("position");

	}
	
	var _url_, _divID;
	__heightDiv=document.getElementById(_divID).offsetHeight;
	__widthDiv=document.getElementById(_divID).offsetWidth;
	__metaHeightDiv=Math.round((__heightDiv/2)-25);
	if(__metaHeightDiv>130){
		__metaHeightDiv=120;
	}
	
toolTip();divID=_divID;req.open('get',_url+"&rand="+escape(Math.random()));req.onreadystatechange=handleResponse;req.send(null);}
function handleResponse(){if(document.getElementById('sitefolder')){var sitefolder=document.getElementById('sitefolder').value;} else {var sitefolder='/'}if(req.readyState==4){var response=req.responseText;var update=new Array();if(response.indexOf('||'!=-1)){
	update=response.split('||');
	toolTip();
	
	document.getElementById(divID).innerHTML=req.responseText; 
	if(positionOriginal){
		$('#'+divID).css('position',positionOriginal);
	}
	}
	
	}
else{
	if(!jQuery){
		strloading="";
		strloading="<center>";
			strloading+="<div style=\"padding-top:"+__metaHeightDiv+"px\">";
				strloading+="<img src=\""+sitefolder+"img/ico/indicator_very.gif\" style=\"height:45px\">";
			strloading+="</div>";
		strloading+="</center>";
		document.getElementById(divID).innerHTML=strloading;
	} else {
		if(positionOriginal!='absolute'){
			$('#'+divID).css("position","relative");
		}
		strloading="";
		strloading="<center>";
			strloading+="<div style=\"opacity:0.60;filter: alpha(opacity=60);z-index:800;background-color:white;top:0px; left:0px; width:100%; height:"+__heightDiv+"px; position:absolute\">";
				strloading+="<div style=\"padding-top:"+__metaHeightDiv+"px\">";
					strloading+="<img src=\""+sitefolder+"img/ico/indicator_very.gif\" style=\"top:"+__metaHeightDiv+"px\">";
				strloading+="</div>";
			strloading+="</div>";
		strloading+="</center>";	
		var htmlIdDiv=$('#'+divID).html();
		$('#'+divID).html(htmlIdDiv + strloading);
		//$('#'+divID).css("position",positionOriginal);
	}
	toolTip();		
	}}

function TOOLTIP() {
    this.width = 200;                     
    this.bgColor = '#F0F0DE';             
    this.textColor = '#336699';
	this.textSize = '11px';
	this.textAlign = 'center';
    this.borderColor = '#D6D6C1';         
    this.opacity = 90;                    
    this.cursorDistance = 5;             
    this.text = '';
    this.obj = 0;
    this.sobj = 0;
    this.active = false;
	this.imgName="_black";
    this.create = function() {
    if(!this.sobj) this.init();
	var t="";
	var left = mouseX;
	var marginTool=(this.width/2);
	if(this.text.indexOf("<img")==0){
		this.bgColor="white";
		this.imgName="_white";
		this.borderC='1px solid #DDDDDD';
	} else {
		this.bgColor="#292929";
		this.imgName="_black";
		this.borderC='none';
	}
	t+='<div style="width:'+this.width+'px; margin-left:-'+marginTool+'px; margin-top:14px" class="toolTipInt">';
	if (document.all){ // Explorer
		t+='<center><div class="pickUp-tt" style="margin-bottom:-2px; "><img onload="$(\'#toolTipV\').show()" style="width:18px" src="/img/tooltiparrow'+this.imgName+'.gif" /></div></center><div class="clear"></div>';
	} else { // Altri
		t+='<center><div class="pickUp-tt" style="margin-bottom:-7px; "><img onload="$(\'#toolTipV\').show()" style="width:18px" src="/img/tooltiparrow'+this.imgName+'.gif" /></div></center><div class="clear"></div>';		
	}
	t+='<div id="toolTipV" style="font-size:12px; background:'+this.bgColor+'; padding:7px; text-align:center; color:#DDDDDD; border:'+this.borderC+'">';
	t+=this.text;
	if(this.text.indexOf("<img")==0){
		t+='<img src="/img/ico/indicator_very.gif" class="gifloadingt" align="absmiddle">';
	}
	t+='</div>';
	t+='</div>';
	
/*      var t = '<table border=0 cellspacing=0 cellpadding=4 width=' + this.width + ' bgcolor=' + this.bgColor + '><tr>' +
      '<td align=' + this.textAlign + ' style=font-size:' + this.textSize + '><font color=' + this.textColor + '>' + this.text + '</font></td></tr></table>';
*/	  if(document.getElementById) document.getElementById('ToolTip').innerHTML = t;
		else document.all.ToolTip.innerHTML = t;
		this.show();
    }
    this.init = function() {
      if(document.getElementById) {
        this.obj = document.getElementById('ToolTip');
        this.sobj = this.obj.style;
      }
      else if(document.all) {
        this.obj = document.all.ToolTip;
        this.sobj = this.obj.style;
      }
      else if(document.layers) {
        this.obj = document.ToolTip;
        this.sobj = this.obj;
      }
    }
    this.show = function() {
      var ext = (document.layers ? '' : 'px');
      var left = mouseX;
    //  if(left + this.width + this.cursorDistance > winX) left -= this.width + this.cursorDistance;
      left += this.cursorDistance;
      this.sobj.left = left + ext;
      this.sobj.top = mouseY + this.cursorDistance + ext;
      if(!this.active) {
        this.sobj.visibility = 'visible';
		this.sobj.display = 'block';
        this.active = true;
      }
    }
    this.hide = function() {
		//$("#ToolTip").fadeOut(150);
      if(this.sobj) this.sobj.visibility = 'hidden';
	  if(this.sobj) this.sobj.display = 'none';
      this.active = false;
    }
    this.setOpacity = function() {
      this.sobj.filter = 'alpha(opacity=' + this.opacity + ')';
      this.sobj.mozOpacity = '.1';
      if(this.obj.filters) this.obj.filters.alpha.opacity = this.opacity;
      if(!document.all && this.sobj.setProperty) this.sobj.setProperty('-moz-opacity', this.opacity / 100, '');
    }
  }
  var tooltip = mouseX = mouseY = winX = 0;
  if(document.layers) {
    document.write('<layer id="ToolTip"></layer>');
    document.captureEvents(Event.MOUSEMOVE);
  }
  else document.write('<div id="ToolTip" style="position:absolute; z-index:99999"></div>');
  document.onmousemove = getMouseXY;
  function getMouseXY(e) {
    if(document.all) {
      mouseX = event.clientX + document.documentElement.scrollLeft;
      mouseY = event.clientY + document.documentElement.scrollTop;
    }
    else {
      mouseX = e.pageX;
      mouseY = e.pageY;
    }
    if(mouseX < 0) mouseX = 0;
    if(mouseY < 0) mouseY = 0;
    if(document.documentElement && document.documentElement.offsetWidth) winX = document.documentElement.offsetWidth - 25;
    else if(window.innerWidth) winX = window.innerWidth - 25;
    else winX = screen.width - 25;
    if(tooltip && tooltip.active) tooltip.show();
  }
function toolTip(text, width, opacity) {
    if(text) {
      tooltip = new TOOLTIP();
      tooltip.text = text;
      if(width) tooltip.width = width;
      if(opacity) tooltip.opacity = opacity;
      tooltip.create();
    }
    else if(tooltip) tooltip.hide();
}
