
var frame_mode=0;

function OpenIB(pad_level)
{

	wid=screen.availWidth;
	hei=screen.availHeight-30;
    if (document.layers)
	{
		//window.OpenCloseMenu(0);
		window.open("../IB/index.php","adagpIB","left=0,top=0,outerWidth="+wid+",outerHeight="+hei);
	}
	else
	{     
        window.open("../IB/index.php","adagpIB","titlebar=1,left=0,top=0,width="+wid+",height="+hei);
    }
}
function OpenDemande(pad_level)
{
	wid=579;
	hei=screen.availHeight-30;
	if (document.layers)
	{
		wid+= window.top.outerWidth-window.top.innerWidth;
		//alert(wid);
		window.open("acheter.php?sel=x","acheter","fullscreen=no,left=0,top=0,scrollbars=1,outerWidth="+wid+",outerHeight="+hei);
	}
	else
	{     
        window.open("acheter.php?sel=x","acheter","fullscreen=no,left=0,top=0,scrollbars=1,width="+wid+",height="+hei);
	}
}


function OpenMentions(pad_level)
{
	wid=529;
	hei=420;
	if (document.layers)
	{
		wid+= window.top.outerWidth-window.top.innerWidth;
		//alert(wid);
		window.open("mentions.htm","mention","fullscreen=no,left=0,top=0,scrollbars=1,outerWidth="+wid+",outerHeight="+hei);
	}
	else
	{     
        window.open("mentions.htm","mention","fullscreen=no,left=0,top=0,scrollbars=1,width="+wid+",height="+hei);
	}
}



function OnContentStart()
{
	
	window.HW = GetHomeWnd();
	if (frame_mode) return;
	
	if (document.anchors.length>0 && document.anchors[document.anchors.length-1]) //resize layer and iframe
	{
		if (document.layers) //ns4
		{
			posy = document.anchors[document.anchors.length-1].y;
			var lay = window.document.layers.ContentLay;
			
			if 	(lay)
			{  //alert("OnContentStart()");	
				lay.resizeTo(lay.clip.width,posy);
                window.document.height= Math.max(window.document.anchors[window.document.anchors.length-1].y,posy+lay.top);
			}
			else
			   alert("no layer");

		}
		else //ie, NS6
		{
			
			posy = document.anchors[document.anchors.length-1].offsetTop;
			if (document.all) //ie
				window.parent.document.all["ContentLay"].style.height= (posy+20)+"px";
			else	  //ns6
				window.parent.document.getElementById("ContentLay").style.height = (posy+20)+"px";
		}
	}
	return;
	
}

function LoadContent(url,pad_level)
{
	var src = url;
	if (frame_mode)
	{
		top.frMain.location = url;
		return ;
	}
	
	if (document.layers) //ns4 support
	{
		
		parent.top.CurrentContentURL = src;
		var wnd= window;
		//pad_level?window:window.parent;
		wnd.ScrollToAnchor("TOP")
		if (wnd.GetLayer("ContentLay",wnd.document))
			wnd.GetLayer("ContentLay",wnd.document).load(src,169); 
		else
			wnd.document.location = "static_home.php?ct="+escape(url);
	}
	else
	{
		var wnd= pad_level?window:window.parent;
		wnd.ScrollToAnchor("TOP")
		if (document.all)
		{
		   if (wnd.frames.ContentLay)
            wnd.frames.ContentLay.location = src; 
		   else
			wnd.document.location = "static_home.php?ct="+escape(url);
		}
		else
		{

			if (wnd.document.getElementById("ContentLay"))
			{

				if (src == wnd.document.getElementById("ContentLay").src) 
				{
					if (src.indexOf('?')<0) src += "?";
					else src += "&";
				}
                wnd.document.getElementById("ContentLay").src = src;
			}
			else
			wnd.document.location = "static_home.php?ct="+escape(url);	
		}
	}
	
}


function LoadContentDepuisFenetreExterne(url,pad_level)
{
	var src = url;
	if (frame_mode)
	{
		top.frMain.location = url;
		return ;
	}
	
	if (document.layers) //ns4 support
	{
		
		parent.top.CurrentContentURL = src;
		var wnd= window;
		//pad_level?window:window.parent;
		wnd.ScrollToAnchor("TOP")
		if (wnd.GetLayer("ContentLay",wnd.document))
			wnd.GetLayer("ContentLay",wnd.document).load(src,169); 
		else
			wnd.document.location = "static_index.php?ct="+escape(url);
	}
	else
	{
		var wnd= pad_level?window:window.parent;
		wnd.ScrollToAnchor("TOP")
		if (document.all)
		{
		   if (wnd.frames.ContentLay)
            wnd.frames.ContentLay.location = src; 
		   else
			wnd.document.location = "static_index.php?ct="+escape(url);
		}
		else
		{

			if (wnd.document.getElementById("ContentLay"))
			{

				if (src == wnd.document.getElementById("ContentLay").src) 
				{
					if (src.indexOf('?')<0) src += "?";
					else src += "&";
				}
                wnd.document.getElementById("ContentLay").src = src;
			}
			else
			wnd.document.location = "static_index.php?ct="+escape(url);	
		}
	}
	
}



function GetHomeWnd()
{
	if (frame_mode)
		return window;

	if (document.layers) 
		return window;
	else 
		return window.parent;
}



function findAnchorPos(obj,odl,type)
{
	
   if(type == "x")
      odl = odl + obj.offsetLeft;
   else if(type == "y")
      odl = odl + obj.offsetTop;
   else
      return odl;

	if(obj.offsetParent)
		odl = findAnchorPos(obj.offsetParent,odl,type);
	return odl;
}

function ScrollToAnchor(name)
{
	
	if (document.layers) //NS4
	{
		if (name=="TOP")
		{   
			window.scrollTo(window.pageXOffset, 0 );
			return;
		}
		
		var anch = window.document.anchors;
        for (var i = 0 ;i<anch.length;i++)
			if ( name == anch[i].name )
			{
                window.scrollTo(window.pageXOffset, anch[i].y - 8 )
				return;
			}
		window.top.status= "Anchor not found.";
	}
	else //IE ,MOZILLA 5
	{
        if (name=="TOP")
		{
			window.scrollTo(window.document.body.scrollLeft,0);
			return;
		}
		if (document.all) //ie;
		{
			var anch = window.document.anchors;
			//alert(anch);
			for (var i = 0 ; i< anch.length;i++)
			{
				if (anch[i].name == name)
				{
					window.location.hash = name;
					return;
				}
			}
			
		}
		else
		{	
			var anch = window.document.anchors;			
			for (var i = 0 ; i< anch.length;i++)
			{
				if (anch[i].name == name)
				{
					anch_pos = findAnchorPos(anch[i],0,"y");
					var pos = anch_pos-10; //findAnchorPos(document.anchors[i],0,"y");
					window.scrollTo(window.document.body.scrollLeft,pos);
					return;
				}
			}
			
		}
	}
	window.top.status= "Anchor not found.";
	return;
}

