/*
 * @author slackdade@gmail.com
 */

function getScrollingPosition()
{
   var position = [0, 0];

   if (typeof window.pageYOffset != 'undefined')
   {
      position = [ window.pageXOffset, window.pageYOffset ];
   } else if (typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0) {
      position = [ document.documentElement.scrollLeft, document.documentElement.scrollTop ];
   } else if (typeof document.body.scrollTop != 'undefined') {
      position = [ document.body.scrollLeft, document.body.scrollTop ];
   }

   return position;
}

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

function $S(v)
{
	return($(v).style);
}

function agent(v)
{
	return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0));
}

function isset(v)
{
	return((typeof(v)=='undefined' || v.length==0)?false:true);
}

function XYwin(v)
{
	var z=agent('msie')?Array(document.body.clientHeight,document.body.clientWidth):Array(window.innerHeight,window.innerWidth);
	return(isset(v)?z[v]:z);
}

function sexyTOG()
{
	document.onclick=function(){ $S('sexyBG').display='none';
	$S('sexyBOX').display='none';
	document.onclick=function(){}; };
}

function sexyBOX(v,b,colore)
{

	var spostamentoto = getScrollingPosition();
	
	if ( BrowserDetect.browser == 'Explorer') {
		var altezza = parseInt(document.body.clientHeight);
	} else {
		var altezza = parseInt(document.body.innerHeight);
	}
	
	var altezza = altezza + 20;
	
	
	var spostamentoto = spostamentoto[1] + 25;
	
	var larghezzafinestra = document.body.clientWidth;
	
	setTimeout("sexyTOG()",100);
	$S('sexyBG').height=altezza+'px';
	$S('sexyBG').display='block';
	$S('sexyBG').width=larghezzafinestra+'px';
	$S('sexyBG').background=colore;
	$('sexyBOX').innerHTML=v+'<div class="sexyX">(fai click al di fuori del box per chiudere)'+"<\/div>";
	$S('sexyBOX').left=Math.round((XYwin(1)-b)/2)+'px';
	$S('sexyBOX').width=b+'px';
	$S('sexyBOX').display='block';
	/* $S('sexyBOX').top=spostamentoto+'px'; */
}

