
var tippop = {};
var scrollDiff = 0;

function showTip(Obj,url) 
{
	if (!Obj)
	{
		Obj = {};
	}
	if (typeof(Obj.opacity)=="undefined") Obj.opacity = 6;
	if (!Obj.height) Obj.height	= 300;
	if (!Obj.width)	Obj.width = 500;
	if (url) Obj.url = url;
	//if (!Obj.url) Obj.url = 'http://www.google.fr';
  tippop = Obj;
	showInnerTip();
	return tippop;
}

function showInnerTip()
{
	document.body.style.overflow = 'hidden';
	document.getElementsByTagName('html')[0].style.overflow = 'hidden';
	window.scrollTo(0,0);
	var tippopup = document.getElementById("tippopup");
	tippopup.style.visibility = 'visible';
	tippopup.style.top='50px'; 
  tippopup.style.left='30px';
  var tip_background = document.getElementById("tip_background");
  tip_background.style.opacity = tippop.opacity/10;
  tip_background.style.filter = 'alpha(opacity=' + tippop.opacity*10 + ')';
	var tippopup_iframe = document.getElementById("tippopup_iframe");
	tippopup_iframe.src = tippop.url;
	tippopup_iframe.style.width 	= tippop.width+"px";
	tippopup_iframe.style.height = tippop.height+"px";
  tippopup_iframe.style.visibility = 'visible';
  var tiptable = document.getElementById("tiptable");
	tiptable.style.width 	= (tippop.width+tippop.border)+"px";
	tiptable.style.height = (tippop.height+tippop.border)+"px";
	var os=document.getElementsByTagName('select');
	for (var i=0,o;o=os[i];i++) o.parentNode.style.visibility = 'hidden';
	movetip();
  window.onresize=function(){
	   movetip();
  };
}

function hideInnerTip()
{
  document.body.style.overflow = 'auto';
  document.getElementsByTagName('html')[0].style.overflow = 'auto';
	var tippopup = document.getElementById("tippopup");
	tippopup.style.visibility = 'hidden';
	tippopup.style.width 	= "1px";
	tippopup.style.height = "1px";
	tippopup.style.top='-50px'; 
  tippopup.style.left='-30px';
	var tippopup_iframe = document.getElementById("tippopup_iframe");
	tippopup_iframe.style.width 	= "1px";
	tippopup_iframe.style.height = "1px";
  tippopup_iframe.style.visibility = 'hidden';
  var os=document.getElementsByTagName('select');
	for (var i=0,o;o=os[i];i++) o.parentNode.style.visibility = 'visible';
  window.onresize=function(){
  };
}	
	
function movetip()
{
	var d 		= dimension_detect();
	var newTop 	= (d.viewH-tippop.height)/2 ;
	var newLeft = (d.viewW-tippop.width)/2;
	
	var tip = document.getElementById("tip");
	tip.allowTransparency = true;
	tip.style.top 	= parseInt(newTop)+"px";
	tip.style.left 	= parseInt(newLeft)+"px";
	var back = document.getElementById("tip_background");
  back.style.width = (d.docW>d.viewW)?d.docW+'px':d.viewW+'px';
  back.style.height = (d.docH>d.viewH)?d.docH+'px':d.viewH+'px';
	scrollDiff = d.viewW-d.docW;
	if (scrollDiff<1) document.body.style.width=d.viewW;
};

function dimension_detect(){
	var d={'viewW':0,'viewH':0,'docH':0,'docW':0,'left':0,'top':0};
	if (document.body.scrollHeight>document.body.offsetHeight){
		d.docW=document.body.scrollWidth;
		d.docH=document.body.scrollHeight;
	} else {
		d.docW=document.body.offsetWidth;
		d.docH=document.body.offsetHeight;
	}
	if (self.innerWidth){
		d.viewW=self.innerWidth;
		d.viewH=self.innerHeight;
		d.left=window.pageXOffset;
		d.top=window.pageYOffset;
	} else {
		var ie=(document.compatMode&&document.compatMode!='BackCompat')?document.documentElement:document.body;
		d.viewW=ie.clientWidth;
		d.viewH=ie.clientHeight;
		d.left=ie.scrollLeft;
		d.top=ie.scrollTop;
	}
	return d;
};

