var currentpub = 0;
var publiste = [
					{"src":"/img/pub/vielibertine2.gif" , "alt":"Un autre site libertin a voir" , "link":"http://www.vie-libertine.com"}, 
					{"src":"/img/pub/banpub_10_01.gif" , "alt":"Plaisirs de femmes" , "link":"http://www.sexy-boutiques.com/fr/categories/10/femmes.html"}, 
					{"src":"/img/pub/banpub_60_02.gif" , "alt":"DVD Adultes" , "link":"http://www.sexy-boutiques.com/fr/categories/60/dvd.html"}, 
					{"src":"/img/pub/banpub_45_01.gif" , "alt":"Gadgets sexy, Adult Toys" , "link":"http://www.sexy-boutiques.com/fr/categories/45/bazar_sexy.html"}, 
					{"src":"/img/pub/banpub_4580_02.gif" , "alt":"Librairie, DB Adultes" , "link":"http://www.sexy-boutiques.com/fr/categories/4580/librairie_coquine.html"}, 
					{"src":"/img/pub/banpub_1030_01.gif" , "alt":"Lingerie Sexy" , "link":"http://www.sexy-boutiques.com/fr/categories/1030/lingerie_sexy.html"}, 
					{"src":"/img/pub/banpub_4530_02.gif" , "alt":"Sex Toys" , "link":"http://www.sexy-boutiques.com/fr/categories/4530/gadgets_humour.html"}, 
					{"src":"/img/pub/banpub_40_02.gif" , "alt":"Bijoux adultes" , "link":"http://www.sexy-boutiques.com/fr/categories/40/bijoux.html"}, 
					{"src":"/img/pub/ban22_468x.gif" , "alt":"Créer votre propre boutique sexy" , "link":"http://www.busyx.com/?pr_id=12745"}
				];

function $(e) { return document.getElementById(e);}
function GetSize()
{
	var scrollH = 0;var scrollW = 0;var windowH = 0;var windowW = 0;
	if (document.doctype == null || document.documentElement.clientHeight == 0)
	{
		if (window.innerWidth || (document.body.offsetHeight == document.documentElement.offsetHeight && document.body.offsetWidth == document.documentElement.offsetWidth)) { scrollH = document.body.scrollTop;scrollW = document.body.scrollLeft;windowH = document.body.clientHeight;windowW = document.body.clientWidth; }
		else { scrollH = document.documentElement.scrollTop;scrollW = document.documentElement.scrollLeft;windowH = document.documentElement.clientHeight;windowW = document.documentElement.clientWidth; }
	}
	else
	{
		if (document.doctype.publicId.search(/xhtml/i) != -1) { scrollH = document.documentElement.scrollTop;scrollW = document.documentElement.scrollLeft; }
		else { scrollH = document.body.scrollTop;scrollW = document.body.scrollLeft; }
	}
	if (window.innerWidth && window.innerHeight) { windowH = window.innerHeight; windowW = window.innerWidth; }
	return {"width":windowW,"height":windowH,"scrollW":scrollW, "scrollH":scrollW};
}

function Navigateur() 
{
 var ua, s, i;
  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;
  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) { this.isOP = true; this.version = parseFloat(ua.substr(i + s.length)); return; }
  s = "Netscape6/"; 
  if ((i = ua.indexOf(s)) >= 0) {this.isNS = true;this.version = parseFloat(ua.substr(i + s.length));return;}
  // Treat any other "Gecko" browser as Netscape 6.1.
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {this.isNS = true;this.version = 6.1;return;}
  s = "MSIE";
  if ((i = ua.indexOf(s))) {this.isIE = true;this.version = parseFloat(ua.substr(i + s.length));return;}
}


function App ()
{
	// Le type de browser utilisé par l'application
	this.browser = new Navigateur();
}

App.prototype.Build = function( ) 
{
	// Définition des éléments de l'application
	this.workspace = $("workspace");
	this.LeftPan = $("LeftPan");
		this.LeftPanSep = $("LeftPanSep");
		this.OnlineTitle =$("online_title");
		this.OnlineData =$("online_data");
	this.Header =  $("header");
		this.HeaderInfo =  $("info");
		this.HeaderPub  =  $("pub");
			this.HeaderBan  =  $("pub_banniere");
	this.Frame = $("Frame");
	this.mFrame = $("mFrame");
	this.MdiFrame = $("MdiFrame");
	this.BottomPan = $("BottomPan");

	// Gestion du panneau de gauche
	$("HidePanLeft").onclick = function()
	{
		if (site.LeftPan.style.display != "none") {site.LeftPan.style.display="none";site.Resize();this.src=slideon;}
		else {site.LeftPan.style.display="inline";site.Resize();this.src=slideoff;}
	};

	// Resize de la fenêtre entraine le resize du workspace
	window.onresize = function(){ site.Resize();};

}

App.prototype.Resize = function( ) 
{
	// Déterminer la Taille de la fenêtre	
	var FrameSize = GetSize();
	// Resize du worspace [largeur fenêtre -2*Marge)	
	this.workspace.style.width  = (FrameSize.width - 2 * this.workspace.offsetLeft - 25)+"px";
	this.workspace.style.height = (FrameSize.height- 2 * this.workspace.offsetLeft)+"px";
	// Resize Frame [Largeur fenêtre - 2*Marge - Largeur(LeftPan) -- Largeur(LeftPanSep)]
	this.Frame.style.width  = ( FrameSize.width - 2 * this.workspace.offsetLeft - this.LeftPan.offsetWidth - this.LeftPanSep.offsetWidth - 25) +"px";
	this.Frame.style.height = ( FrameSize.height- 2 * this.workspace.offsetLeft ) +"px";
	// Resize mFrame [Largeur fenêtre - 2*Marge - Largeur(LeftPan) -- Largeur(LeftPanSep)]
	this.mFrame.style.width = ( FrameSize.width - 2 * this.workspace.offsetLeft - this.LeftPan.offsetWidth - this.LeftPanSep.offsetWidth - 21 - 25) +"px";
	// Hauteur de la Frame [ Hauteur fenêtre - 2*Marge - Hauteur(menu) - Hauteur(bottompan)]
	this.MdiFrame.style.height  = ( FrameSize.height- 2 * this.workspace.offsetLeft - this.mFrame.offsetHeight - this.BottomPan.offsetHeight - this.Header.offsetHeight ) +"px";
	// Bottom Frame
	this.BottomPan.style.top  = ( FrameSize.height- 2 * this.workspace.offsetLeft - this.BottomPan.offsetHeight - this.Header.offsetHeight ) +"px";
	this.BottomPan.style.width = this.Frame.style.width;
	
	// debugger;
	this.Header.style.width  = this.Frame.style.width;
	this.HeaderPub.style.width = ( parseInt(this.Header.style.width)-  this.HeaderInfo.offsetWidth) +"px";
	this.HeaderBan.style.left  = ( (parseInt(this.HeaderPub.style.width) - 470 ) / 2 )  +"px";
	
	this.OnlineData.style.height  = ( FrameSize.height- 2 * this.workspace.offsetLeft - this.OnlineTitle.offsetHeight ) +"px";
	
}

App.prototype.Pub = function( ) 
{
	//return;
	if ( currentpub > 8) { currentpub=0; }
	$("banniere").src = publiste[currentpub].src; $("banniere").alt = publiste[currentpub].alt; $("pub_link").href = publiste[currentpub].link;
	currentpub+=1; ctrl = setTimeout("site.Pub()",30000);
}

var site = new App();
function run() 
{ 
$("Work").style.display="inline";
site.Build(); 
$("workspace").style.display="inline";
site.Resize(); 
site.Pub(); 
$("Work").style.display="none";
}
