////////////////////////////////////////////////////////////////////
// static class MediaBox - v2.0 - Clair et Net 2008 (gc)
////////////////////////////////////////////////////////////////////

MediaBox = function(){
		this.xml;
		this.flashPadding = 5;
		this.size = "normal";
		this.fw = 235;
		this.fh = 180;
		this.fullW = 900;
		this.fullH = 530;
		this.currentItemId = 0;
		
		document.write("<div id='MediaBoxContainer'><div id='MediaBoxOuter'><div id='MediaBox'>Media Box</div></div><div id='MediaBoxBg'></div></div>");
		this.container 	= document.getElementById('MediaBoxContainer');
		this.flash	 	= document.getElementById('MediaBox');
		this.bg 		= document.getElementById('MediaBoxBg');	
		this.outer 		= document.getElementById('MediaBoxOuter');			
		
		opacity = 70;
		bg.style.display			= "none";
		bg.style.height				= "100%";
		bg.style.width 				= "100%";
		bg.style.backgroundColor 	= "#000";		
		/*bg.style.opacity 			= (opacity / 100);
    	bg.style.MozOpacity 		= (opacity / 100);
    	bg.style.KhtmlOpacity 		= (opacity / 100);
    	bg.style.filter 			= "alpha(opacity=" + opacity + ")";*/
		
		bg.onclick = function(){
			MediaBox.switchSize();
		}
		
}
MediaBox();


MediaBox.init = function(xmlUrl,colorsObject){
	xml = xmlUrl;
	
	var so = new SWFObject("/extension/smilelgadesign/design/lga/images/swf/MediaBox.swf", "f_MediaBox", "100%", "100%", "8");	
	so.addParam("wmode","transparent");
	so.addVariable("w",fw);
	so.addVariable("h",fh);
	so.addVariable("xmlUrl",xml);
	so.addVariable("currentSize",size);
	if(colorsObject){
		so.addVariable("txtColor",colorsObject.txtColor);
		so.addVariable("bgColor",colorsObject.bgColor);	
	}
	so.write("MediaBox");
	
}

MediaBox.fullSize = function(){	
	size = "full";
		
	if(document.documentElement){
		var h = document.documentElement.clientHeight;
		var w = document.documentElement.clientWidth;	
	}else{
		var h = document.body.clientHeight;	
		var w = document.body.clientWidth;	
	}
	
	
	container.style.width 		= w + "px";
	container.style.height 		= h + "px";	
	
	var swf = document.getElementById("f_MediaBox");
	if(swf.src){//bugFF
		swf.height = fullH;
		swf.width = fullW;
		swf.src = "/extension/smilelgadesign/design/lga/images/swf/MediaBox.swf?fullW="+fullW+"&fullH="+fullH+"&id="+currentItemId+"&currentSize="+size;
	}	
	
	if(navigator.userAgent.indexOf("MSIE") > -1){
		container.style.position 	= "absolute";
		container.style.top 		= getScrollXY().top + "px";
		container.style.left 		= 0;
		window.onscroll = function(){
			container.style.top = getScrollXY().top + "px";
		}
	}else{
		container.style.position 	= "fixed";
		container.style.left 		= 0;
		container.style.top 		= 0;
	}
	
	bg.style.display			= "block";
		
	outer.style.position 		= "absolute";
	outer.style.padding 		= flashPadding + "px";
	outer.style.background		= "#FFF";
	outer.style.width			= fullW + "px";
	outer.style.height			= fullH + "px";
	outer.style.top				= Math.floor((h - outer.offsetHeight)/2) + "px";
	outer.style.left			= Math.floor((w - outer.offsetWidth)/2) + "px";
	
	
	
}

MediaBox.normalSize = function(){
	size = "normal";
	window.onscroll = null;

	var swf = document.getElementById("f_MediaBox");
	if(swf.src){//bugFF
		swf.height = fh;
		swf.width = fw;
		swf.src = "/extension/smilelgadesign/design/lga/images/swf/MediaBox.swf?fullW="+fw+"&fullH="+fh+"&id="+currentItemId+"&currentSize="+size;
	}
	
	container.style.position 	= "static";
	container.style.width 		= "auto";
	container.style.height 		= "auto";
	bg.style.display			= "none";
	
	outer.style.position		= "relative";
	outer.style.padding			= 0;
	outer.style.background		= "none";
	outer.style.width			= fw + "px";
	outer.style.height			= fh + "px";
	outer.style.top				= 0;
	outer.style.left			= 0;
}

MediaBox.switchSize = function(id){
	currentItemId = id;
	if(size == "normal"){		
		MediaBox.fullSize();
		return fullW + "|" + fullH + "|" + currentItemId + "|" + size;
	}else{
		MediaBox.normalSize();
		return fw + "|" + fh + "|" + currentItemId + "|" + size;
	}
	//var swf = document.getElementById("f_MediaBox");
	//swf.MediaBox.updateSize();
	//MediaBox.updateSize
}



function getScrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		scrOfY = window.pageYOffset;
		scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		scrOfY = document.body.scrollTop;
		scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		scrOfY = document.documentElement.scrollTop;
		scrOfX = document.documentElement.scrollLeft;
	}
	return {left:scrOfX, top:scrOfY};
}

////////////////////////////////////////////////////////////////////

