function getWinWidth()
	{
	return (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || self.innerWidth || document.body.clientWidth; 
	}

function ouvrirPOP(iWhat,iW,iH)
	{
	iW=(typeof iW=="undefined")?800:iW;
	iH=(typeof iH=="undefined")?500:iH;
	var oPopup=window.open('/popup.php?p='+iWhat,'poproseau','width='+iW+',height='+iH+',left='+parseInt((screen.width-iW)/2)+',top='+parseInt((screen.height-iH)/2-40)+'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
	if (window.focus) { oPopup.focus(); }
	}

function ouvrirIMAGE(iWhat,iW,iH)
	{
	iW=(typeof iW=="undefined")?800:iW;
	iH=(typeof iH=="undefined")?500:iH;
	var oGallerie=window.open('/gallerie.php?p='+iWhat,'poproseau','width='+iW+',height='+iH+',left='+parseInt((screen.width-iW)/2)+',top='+parseInt((screen.height-iH)/2-40)+'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
	if (window.focus) { oGallerie.focus(); }
	}

function ouvrirACTU(iWhat,iW,iH)
	{
	iW=(typeof iW=="undefined")?800:iW;
	iH=(typeof iH=="undefined")?500:iH;
	var oGallerie=window.open('/actualite.php?p='+iWhat,'poproseau','width='+iW+',height='+iH+',left='+parseInt((screen.width-iW)/2)+',top='+parseInt((screen.height-iH)/2-40)+'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
	if (window.focus) { oGallerie.focus(); }
	}

//// ------------ CCStudio ------------ ////

var iwin=
	{
	o:function(a)
		{
		this.id=a.id;
		this.loop=a.loop||false;
		this.duration=a.duration||0.6;
		this.transition=a.transition||'none';
		this.shortcuts=a.shortcuts||false;
		this.mouseover=a.mouseover||false;
		this.startto=a.startto||0;
		this.onswitch=a.onswitch||function() {};
		this.onclick=a.onclick||function() {};
		this.sccln=[];
		this.o=_$$("ol",_$(a.id))[0];
		var li=_$$c("li",this.o);
		this.m=li.length;
		var oc=_$(this.id);
		this.liw=parseInt(_o.getStyle(oc,"width"));this.lih=parseInt(_o.getStyle(oc,"height"));
		this.ofl=[];for (var i=0;i<this.m;i++) { this.ofl.push(li[i]);	}		
		this.c=a.startfrom||0;
		_o.set(this.o,{visible:0});
		
		switch(this.transition)
			{
			case "fade":case "flashfade":
				for (var i=0;i<this.m;i++)	{	_o.set(this.ofl[i],{opacity:((i==this.startto)?100:0)});	}
				this.o.style.left=(-this.c*this.liw)+"px";
			break;
			case "overlay":case "flashoverlay":
				this.of=_o.create("div",{o:oc,id:this.id+"_overlay",display:0,opacity:0});
				this.o.style.left=(-this.c*this.liw)+"px";
			break;
			case "scrollx":
				this.o.style.width=Math.round(this.liw*(this.m+0.5))+"px";
				this.o.style.left=(-this.c*this.liw)+"px";
				this.lih=0;
			break;
			case "scrolly":
				this.o.style.top=(-this.c*this.lih)+"px";
			break;
			case "scrollxy":
				this.cols=a.cols||2;
				this.o.style.width=Math.round(this.liw*(this.cols+0.5))+"px";
				_o.set(this.o,{top:-Math.floor(this.c/this.cols)*this.lih,left:-Math.floor(this.c%this.cols)*this.liw});
			break;
			default:
				this.transition="none";
				this.o.style.width=Math.round(this.liw*(this.m+0.5))+"px";
				this.o.style.left=(-this.c*this.liw)+"px";
				this.lih=0;
			break;
			}
		for (var i=0;i<this.m;i++)	{	_o.set(this.ofl[i],{width:this.liw,float:"left"});if (this.lih) { _o.set(this.ofl[i],{height:this.lih});  }	}
		
		return (this);
		},
	create:function(o)
		{
		var n=_$(o.id+'_prev');if (n) { n.onclick=function() { iwin.sw(o,this,-1);return false; };n.style.visibility="visible"; }
		var n=_$(o.id+'_next');if (n) { n.onclick=function() { iwin.sw(o,this,1);return false; };n.style.visibility="visible"; }
		if (o.shortcuts)
			{
			for (var i=0;i<o.m;i++)
				{ 
				var n=_$(o.id+'_sc'+i);var c='';
				if (n) { c=n.className;n.style.visibility="visible";n.onclick=function() { iwin.swto(o,this);return false; };if (o.mouseover) { n.onmouseover=n.onclick; } }
				o.sccln.push(c);
				}
			}
		_o.set(o.o,{position:"relative",visible:1});
		iwin.move(o,o.startto);
		},
	sw:function(o,t,v)
		{
		o.sco=t;o.nc=Math.round(o.c+v);
		if (o.loop) { if (o.nc>=o.m) o.nc=0;if (o.nc<0) o.nc=o.m-1; }
		o.onclick(o);
		iwin.move(o,o.nc);
		},
	swto:function(o,t)
		{
		o.sco=t;var a=t.id.split(/\_sc/);o.nc=parseInt(a[a.length-1]);
		o.onclick(o);
		iwin.move(o,o.nc);
		},
	move:function(o,v)
		{
		o.nc=v;
		if (o.shortcuts)
			{
			var n=_$(o.id+'_sc'+o.c);if (n) n.className=o.sccln[o.c];
			var n=_$(o.id+'_sc'+o.nc);if (n) n.className=o.sccln[o.nc]+" on";
			}	
		if (v!=o.c)
			{
			var p=o.c;
			o.onswitch(o);
			o.c=v;
			switch(o.transition)
				{
				case "fade":
				_fx.fstart("iwin_"+o.id,[{fx:'animELT',o:o.ofl[p],opacity:0,duration:(o.duration/2)},{fx:'setELT',o:o.o,left:(-o.c*o.liw)},{fx:'animELT',o:o.ofl[o.c],opacity:100,duration:(o.duration/2)}]);				
				break;
				case "flashfade":
				_fx.fstart("iwin_"+o.id,[{fx:'setELT',o:o.ofl[p],opacity:0},{fx:'setELT',o:o.o,left:(-o.c*o.liw)},{fx:'animELT',o:o.ofl[o.c],opacity:100,duration:(o.duration)}]);				
				break;
				case "overlay":
				_fx.fstart("iwin_"+o.id,[{fx:'setELT',o:o.of,display:1},{fx:'animELT',o:o.of,opacity:100,duration:(o.duration/2)},{fx:'setELT',o:o.o,left:(-o.c*o.liw)},{fx:'animELT',o:o.of,opacity:0,duration:(o.duration/2)},{fx:'setELT',o:o.of,display:0}]);				
				break;
				case "flashoverlay":
				_fx.fstart("iwin_"+o.id,[{fx:'setELT',o:o.of,display:1,opacity:100},{fx:'setELT',o:o.o,left:(-o.c*o.liw)},{fx:'animELT',o:o.of,opacity:0,duration:(o.duration)},{fx:'setELT',o:o.of,display:0}]);				
				break;
				case "scrollx":
				_fx.fstart("iwin_"+o.id,[{fx:'animELT',o:o.o,left:(-o.c*o.liw),duration:o.duration}]);
				break;
				case "scrolly":
				_fx.fstart("iwin_"+o.id,[{fx:'animELT',o:o.o,top:(-o.c*o.lih),duration:o.duration}]);
				break;
				case "scrollxy":
				_fx.fstart("iwin_"+o.id,[{fx:'animELT',o:o.o,top:-Math.floor(o.c/o.cols)*o.lih,left:-Math.floor(o.c%o.cols)*o.liw,duration:o.duration}]);
				break;
				default:
				_fx.fstart("iwin_"+o.id,[{fx:'setELT',o:o.o,left:(-o.c*o.liw)}]);
				break;
				}
			}
		}
	};

function actu()
	{
	if (_$('actu'))	{	iwin.create(new iwin.o({id:'actu',loop:1,transition:'scrollx',shortcuts:true,duration:0.4}));	}	
	}
