///////////////////////////////////////////////////
///POPBOX1.1 BY GADAWEB (Milano) www.gadaweb.com///
///////////////////////////////////////////////////
function popbox(widthu, heightu, html, bg, bgtop, border, colorborder, scrolling, title) { 
   var newdivbackground = document.createElement('div');
   newdivbackground.id = "popupboxidbackground";
   newdivbackground.style.position = "absolute";
   var heightvar=window.screen.height;
   var widthtvar=window.screen.width;
   var SCREENscrolltop = $(window).scrollTop();
   newdivbackground.style.width = widthtvar-23;
   newdivbackground.style.height = heightvar+SCREENscrolltop+500;
   newdivbackground.style.top = 0;
   newdivbackground.style.left = 0;
   
   document.body.appendChild(newdivbackground);
	
   var newdiv = document.createElement('div');
   newdiv.id = "popupboxid"; 
   
   newdiv.style.position = "absolute";
   if (widthu=="") 
   {
	   newdiv.style.width = 200+"px";
       var width = 200+"px"; 
   } 
   else 
   {
		newdiv.style.width = widthu+"px"; 
		var width = widthu; 
   }
   
   if (heightu=="") {
       newdiv.style.height = 300+"px";
	   var height = 300+"px";
   }   
   else 
   {
		newdiv.style.height = heightu+"px"; 
		var height = heightu; 
   }
	
	var heightvar=window.screen.height;
	var heightvar2=(heightvar-height)/2+SCREENscrolltop-140;
	if(heightvar2<=0)
	{
		heightvar2=10;	
	}
	var widthtvar=window.screen.width;
	var widthvar2=(widthtvar-width)/2;
	newdiv.style.left = widthvar2+"px";
	newdiv.style.border = border+"px solid #"+colorborder;
	newdiv.style.background = "#"+bg;
	newdiv.style.top = heightvar2+"px";   
	newdiv.style.zIndex = "10000";   
	
   if (html!="") {
       newdiv.innerHTML = html;
   } else {
       newdiv.innerHTML = "nothing";
   }   
   
   var heightframe=heightu-28;
   
   newdiv.innerHTML = "<div style='clear:both; background:#"+bgtop+"' id='popupbox_top' align='right'><div style='padding:2px; padding-left:6px; font-size:1px; float:left'><span style=\"color:#ffffff; font-size:18px\">"+title+"</span></div><div style='padding:2px; padding-right:6px; font-size:1px; float:right'><span onclick='popboxclose();' id='chiudidiv'><img src='http://www.bb-and-hotels.com/images/close.png' border='0'></span></div></div></div><iframe id='popupboxcontent' src='"+html+"' marginwidth='0' marginheight='0' width='100%' height='"+ heightframe+"' scrolling=\""+scrolling+"\" frameborder=\"0\" style=\"overflow-y:auto; overflow-x:hidden;\"></iframe>";
   document.body.appendChild(newdiv);
   
   Drag.init(document.getElementById("popupboxid"));
} 

function popbox_index(widthu, heightu, html, bg, bgtop, border, colorborder, scrolling, title) { 

   var newdivbackground = document.createElement('div');
   newdivbackground.id = "popupboxidbackground";
   newdivbackground.style.position = "absolute";
   var heightvar=window.screen.height;
   var widthtvar=window.screen.width;
   var SCREENscrolltop = $(window).scrollTop();
   newdivbackground.style.width = widthtvar-23;
   newdivbackground.style.height = heightvar+SCREENscrolltop+500;
   newdivbackground.style.top = 0;
   newdivbackground.style.left = 0;
   
   document.body.appendChild(newdivbackground);
	
   var newdiv = document.createElement('div');
   newdiv.id = "popupboxid"; 
   
   newdiv.style.position = "absolute";
   if (widthu=="") 
   {
	   newdiv.style.width = 200+"px";
       var width = 200+"px"; 
   } 
   else 
   {
		newdiv.style.width = widthu+"px"; 
		var width = widthu; 
   }
   
   if (heightu=="") {
       newdiv.style.height = 300+"px";
	   var height = 300+"px";
   }   
   else 
   {
		newdiv.style.height = heightu+"px"; 
		var height = heightu; 
   }
	
	var heightvar=window.screen.height;
	var heightvar2=(heightvar-height)/2+SCREENscrolltop-140;
	if(heightvar2<=0)
	{
		heightvar2=10;	
	}
	var widthtvar=window.screen.width;
	var widthvar2=(widthtvar-width)/2;
	newdiv.style.left = widthvar2+"px";
	newdiv.style.border = border+"px solid #"+colorborder;
	newdiv.style.background = "#"+bg;
	newdiv.style.top = heightvar2+"px";   
	newdiv.style.zIndex = "10000";   
	
   if (html!="") {
       newdiv.innerHTML = html;
   } else {
       newdiv.innerHTML = "nothing";
   }   
   var heightframe=heightu-28;
   newdiv.innerHTML = "<div style='clear:both; background:#"+bgtop+"' id='popupbox_top' align='right'><div style='padding:2px; padding-left:6px; font-size:1px; float:left'><span style=\"color:#ffffff; font-size:18px\">"+title+"</span></div><div style='padding:2px; padding-right:6px; font-size:1px; float:right'><span onclick='popboxclose_index();' id='chiudidiv'><img src='http://www.bb-and-hotels.com/images/close.png' border='0'></span></div></div></div><iframe id='popupboxcontent' src='"+html+"' marginwidth='0' marginheight='0' width='100%' height='"+ heightframe+"' scrolling=\""+scrolling+"\" frameborder=\"0\" style=\"overflow-y:auto; overflow-x:hidden;\"></iframe>";
   document.body.appendChild(newdiv);
   Drag.init(document.getElementById("popupboxid"));
} 


function popbox_gallery(widthu, heightu, html, bg, bgtop, border, colorborder, scrolling, title, file, target) { 
   var newdivbackground = document.createElement('div');
   newdivbackground.id = "popupboxidbackground";
   newdivbackground.style.position = "absolute";
   var heightvar=window.screen.height;
   var widthtvar=window.screen.width;
   var SCREENscrolltop = $(window).scrollTop();
   newdivbackground.style.width = widthtvar-23;
   newdivbackground.style.height = heightvar+SCREENscrolltop+500;
   newdivbackground.style.top = 0;
   newdivbackground.style.left = 0;
   document.body.appendChild(newdivbackground);

   var newdiv = document.createElement('div');
   newdiv.id = "popupboxid"; 
   
   newdiv.style.position = "absolute";
   if (widthu=="") 
   {
	   newdiv.style.width = 200+"px";
       var width = 200+"px"; 
   } 
   else 
   {
		newdiv.style.width = widthu+"px"; 
		var width = widthu; 
   }
   
   if (heightu=="") {
       newdiv.style.height = 300+"px";
	   var height = 300+"px";
   }   
   else 
   {
		newdiv.style.height = heightu+"px"; 
		var height = heightu; 
   }
	
	var heightvar=window.screen.height;
	var heightvar2=(heightvar-height)/2+SCREENscrolltop-140;
	if(heightvar2<=0)
	{
		heightvar2=10;	
	}
	var widthtvar=window.screen.width;
	var widthvar2=(widthtvar-width)/2;
	newdiv.style.left = widthvar2+"px";
	newdiv.style.border = border+"px solid #"+colorborder;
	newdiv.style.background = "#"+bg;
	newdiv.style.top = heightvar2+"px";   
	newdiv.style.zIndex = "10000";   
	
   if (html!="") {
       newdiv.innerHTML = html;
   } else {
       newdiv.innerHTML = "nothing";
   }   
   var heightframe=heightu-28;
  
   newdiv.innerHTML = "<div style='clear:both; background:#"+bgtop+"' id='popupbox_top' align='right'><div style='padding:2px; padding-left:6px; font-size:1px; float:left'><span style=\"color:#ffffff; font-size:18px\">"+title+"</span></div><div style='padding:2px; padding-right:6px; font-size:1px; float:right'><span onclick=\"popboxclose_ahah('"+file+"','"+target+"')\" id='chiudidiv'><img src='http://www.bb-and-hotels.com/images/close.png' border='0'></span></div></div></div><iframe id='popupboxcontent' src='"+html+"' marginwidth='0' marginheight='0' width='100%' height='"+ heightframe+"' scrolling=\""+scrolling+"\" frameborder=\"0\" style=\"overflow-y:auto; overflow-x:hidden;\"></iframe>";
   document.body.appendChild(newdiv);
   
   Drag.init(document.getElementById("popupboxid"));
} 

function popbox_iframe(widthu, heightu, html, bg, bgtop, border, colorborder, scrolling, title) { 

   var newdivbackground = document.createElement('div');
   newdivbackground.id = "popupboxidbackground";
   newdivbackground.style.position = "absolute";
   var heightvar=window.screen.height;
   var widthtvar=window.screen.width;
   var SCREENscrolltop = $(window).scrollTop();
   newdivbackground.style.width = widthtvar-23;
   newdivbackground.style.height = heightvar+SCREENscrolltop+500;
   newdivbackground.style.top = 0;
   newdivbackground.style.left = 0;
   document.body.appendChild(newdivbackground);

   var newdiv = document.createElement('div');
   newdiv.id = "popupboxid"; 
   
   newdiv.style.position = "absolute";
   if (widthu=="") 
   {
	   newdiv.style.width = 200+"px";
       var width = 200+"px"; 
   } 
   else 
   {
		newdiv.style.width = widthu+"px"; 
		var width = widthu; 
   }
   
   if (heightu=="") {
       newdiv.style.height = 300+"px";
	   var height = 300+"px";
   }   
   else 
   {
		newdiv.style.height = heightu+"px"; 
		var height = heightu; 
   }
	
	var heightvar=window.screen.height;
	var heightvar2=(heightvar-height)/2+SCREENscrolltop-140;
	if(heightvar2<=0)
	{
		heightvar2=10;	
	}
	var widthtvar=window.screen.width;
	var widthvar2=(widthtvar-width)/2;
	newdiv.style.left = widthvar2+"px";
	newdiv.style.border = border+"px solid #"+colorborder;
	newdiv.style.background = "#"+bg;
	newdiv.style.top = heightvar2+"px";   
	newdiv.style.zIndex = "10000";   
	
   if (html!="") {
       newdiv.innerHTML = html;
   } else {
       newdiv.innerHTML = "nothing";
   }   
   
   var heightframe=heightu-28;
   
   newdiv.innerHTML = "<div style='clear:both; background:#"+bgtop+"' id='popupbox_top' align='right'><div style='padding:2px; padding-left:6px; font-size:1px; float:left'><span style=\"color:#ffffff; font-size:18px\">"+title+"</span></div><div style='padding:2px; padding-right:6px; font-size:1px; float:right'><span onclick=\"popboxclose_iframe('bannerflash_iframe')\" id='chiudidiv'><img src='http://www.bb-and-hotels.com/images/close.png' border='0'></span></div></div></div><iframe id='popupboxcontent' src='"+html+"' marginwidth='0' marginheight='0' width='100%' height='"+ heightframe+"' scrolling=\""+scrolling+"\" frameborder=\"0\" style=\"overflow-y:auto; overflow-x:hidden;\"></iframe>";
   document.body.appendChild(newdiv);
   
   Drag.init(document.getElementById("popupboxid"));
} 

function popboxclose()
{
	var el = document.getElementById("popupboxid");
	el.parentNode.removeChild(el);
	var el2 = document.getElementById("popupboxidbackground");
	el2.parentNode.removeChild(el2);
};

function popboxclose_index()
{
	var el = document.getElementById("popupboxid");
	el.parentNode.removeChild(el);
	var el2 = document.getElementById("popupboxidbackground");
	el2.parentNode.removeChild(el2);
	window.location.href='index.php?m=1'
};

function popboxclose_ahah(file, target)
{
	var el = document.getElementById("popupboxid");
	el.parentNode.removeChild(el);
	var el2 = document.getElementById("popupboxidbackground");
	el2.parentNode.removeChild(el2);
	ahah(''+file+'', ''+target+'');
};

function popboxclose_title(title)
{
	var el = document.getElementById("popupboxid");
	el.parentNode.removeChild(el);
	var el2 = document.getElementById("popupboxidbackground");
	el2.parentNode.removeChild(el2);
	document.title=title; 
};

function popboxclose_iframe(target)
{
	var el = document.getElementById("popupboxid");
	el.parentNode.removeChild(el);
	var el2 = document.getElementById("popupboxidbackground");
	el2.parentNode.removeChild(el2);
    document.getElementById(target).contentWindow.location.reload();
};

function popboxclose_color(color,pos)
{
	var el = document.getElementById("popupboxid");
	el.parentNode.removeChild(el);
	var el2 = document.getElementById("popupboxidbackground");
	el2.parentNode.removeChild(el2);
	if( (pos=="idsx") || (pos=="iddx") )
	{
		targetcolor="idsx";	
	}
	else
	{
		targetcolor="idpage";	
	}
    document.getElementById(targetcolor).style.backgroundColor = ''+color+'';
	
	if(pos=='idsx')
	{
    	idsx.style.cssFloat = idsx.style.styleFloat = "left"
	}
	if(pos=='iddx')
	{
    	idsx.style.cssFloat = idsx.style.styleFloat = "right"
	}
	
	if( (pos=="idsx") || (pos=="iddx") )
	{
		if (document.getElementById("or") != null)                        
		{
			color=color.replace('#','');
			document.getElementById("or").contentWindow.location.href='orologio_frame.php?m=1&bgcolor='+color;
		}	
		if (document.getElementById("calendario") != null)                        
		{
			color=color.replace('#','');
			document.getElementById("calendario").contentWindow.location.href='calendario.php?m=1&bgcolor='+color;
		}	
	}	
};

function popboxplus()
{
	actualwidth=document.getElementById(popupboxid.id).style.width;
	actualwidth=parseInt(actualwidth);
	newwidth=(actualwidth+20);
	document.getElementById(popupboxid.id).style.width=newwidth+'px';
	
	actualheight=document.getElementById(popupboxid.id).style.height;
	actualheight=parseInt(actualheight);
	newheight=(actualheight+20);
	document.getElementById(popupboxid.id).style.height=newheight+'px';
};


function popboxclose_sfondoimg(sfondo, repeat, position)
{
	rand=Math.random()
	var el = document.getElementById("popupboxid");
	el.parentNode.removeChild(el);
	var el2 = document.getElementById("popupboxidbackground");
	el2.parentNode.removeChild(el2);
	document.getElementById('bodyid').style.background='url(sfondi/'+sfondo+'?r='+rand+')';
	if(repeat!='100')
	{
		document.getElementById('bodyid').style.backgroundRepeat=repeat;
		document.getElementById('bodyid').style.backgroundAttachment='fixed';
		document.getElementById('divsfondo').style.display='none';
		if(position!='')
		{
			document.getElementById('bodyid').style.backgroundPosition=position;
		}
	}
	else if(repeat=='100')
	{
		document.getElementById('divsfondo').style.display='block';
		document.getElementById('divsfondo').style.width=100+'%';
		document.getElementById('divsfondo').style.height=100+'%';
		document.getElementById('divsfondo').style.padding=0;
		document.getElementById('divsfondo').style.margin=0;
		document.getElementById('divsfondo').style.background='url(sfondi/'+sfondo+'?r='+rand+')';
	}
};

function copia_sfondo(sfondo, repeat, position)
{
	rand=Math.random()
	document.getElementById('bodyid').style.background='url(sfondi/'+sfondo+'?r='+rand+')';
	if(repeat!='100')
	{
		document.getElementById('bodyid').style.backgroundRepeat=repeat;
		document.getElementById('bodyid').style.backgroundAttachment='fixed';
		document.getElementById('divsfondo').style.display='none';
		if(position!='')
		{
			document.getElementById('bodyid').style.backgroundPosition=position;
		}
	}
	else if(repeat=='100')
	{
		document.getElementById('divsfondo').style.display='block';
		document.getElementById('divsfondo').style.width=100+'%';
		document.getElementById('divsfondo').style.height=100+'%';
		document.getElementById('divsfondo').style.padding=0;
		document.getElementById('divsfondo').style.margin=0;
		document.getElementById('divsfondo').style.background='url(sfondi/'+sfondo+'?r='+rand+')';
	}
};

function popboxclose_sfondocolor(sfondo)
{
	var el = document.getElementById("popupboxid");
	el.parentNode.removeChild(el);
	var el2 = document.getElementById("popupboxidbackground");
	el2.parentNode.removeChild(el2);
	document.getElementById('bodyid').style.background=sfondo;
	document.getElementById('divsfondo').style.display='none';
};


function popboxminus()
{
	actualwidth=document.getElementById(popupboxid.id).style.width;
	actualwidth=parseInt(actualwidth);
	newwidth=(actualwidth-20);
	document.getElementById(popupboxid.id).style.width=newwidth+'px';
	
	actualheight=document.getElementById(popupboxid.id).style.height;
	actualheight=parseInt(actualheight);
	newheight=(actualheight-20);
	document.getElementById(popupboxid.id).style.height=newheight+'px';
};


function heightsx()
{
	alert(document.getElementById('idpage').style.offsetHeight);
}

