var CloseConnect=function(){ MyBoxClose(); };

// Box
var refMyBox;
var MyBox=function(){
        if( $("#MyBox").length>0 ) return false;
        refMyBox = $(this);
        var html='<div id="MyBoxOverflow" style="position:absolute;top:0;left:0;background:#0791CE;z-index:10099">&nbsp;</div><div id="MyBox" style="position:absolute;top:0;left:0;background:#0791ce;z-index:10100;-moz-border-radius:8px;"></div>';
        $("body").append(html); var src=refMyBox.attr('href');
        html='<div style="position:relative;top:10px;margin:0 10px;background:#fff;"><iframe height="100%" width="100%" frameborder="0" border="0" src="'+src+'"></iframe></div>';
        html+='<div style="position:absolute;top:-13px;right:-15px;"><a href="javascript:;" onclick="MyBoxClose()"><img src="images/close.png" alt="Fermer" border="0" /></a></div>';
        $("#MyBox").html(html);
        MyBoxResize();
        return false;
};
var MyBoxClose=function(){ $("#MyBox,#MyBoxOverflow").remove(); };
var MyBoxResize=function(){
        if( $("#MyBox").length==0 ) return false;
        
        var Width=$(window).width(), Height=$(window).height();
        var scroll=$(window).scrollTop();
        if(refMyBox.attr('rev')!='' && refMyBox.attr('rev')!=null){
        	eval(refMyBox.attr('rev'));
				}else{
	       	var height=265;
					var width=475;
				} 
				if(height>Height-35) height=Height-35;
        var top = (Height/2)-(height/2)+scroll;
        var left = ((Width-width)/2);
  
        $("#MyBox").css({top:top+'px',left:left+'px',height:height+'px',width:width+'px'});
        $("#MyBox > div").height( Number(height-20) );
  
        var Height=$(document).height();
        $("#MyBoxOverflow").height(Height).width(Width).css('opacity',0.5);
  
};
$(function(){ $(".openBox").click(MyBox); });
$(window).scroll(MyBoxResize);
$(window).resize(MyBoxResize);
