////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//	GESTION DE LA NAVIGATION DANS UN SITE 1 MINUTESHOP
//
////////////////////////////////////////////////////////////////////////////////////////////////////////		

//////////////////////////////////////////////////////////////////////////////////////////////////////
// DECLARATION DES VARIABLES GLOBALES
//////////////////////////////////////////////////////////////////////////////////////////////////////

var MINUTE_BUFFER = new Array();
MINUTE_BUFFER["page"] = new Array();
MINUTE_BUFFER["menu"] = new Array();
MINUTE_BUFFER["pod"] = new Array();

// ////////////////////////////////////////////////////////////////////////////
// CLASSE D'UNE PAGE
// ////////////////////////////////////////////////////////////////////////////

function Page() {

	//MS_NewPage est la variable globale, contenant les informations de la page charg�e la premi�re fois
	//son contenu est calcul�e par ajax_JS_PageLoad.php au premier chargement (index.php)
	
	if (MS_NewPage.id != undefined)	this.id = MS_NewPage.id;
	else this.id = 0;
	
	this.id = MINUTE_PAGE_in_process; // identifiant de la page en cours au
										// premier chargement
	if (MS_NewPage.properties != undefined)	this.properties = MS_NewPage.properties;
	else this.properties = {};
	
	if (MS_NewPage.zones != undefined)	this.zones = MS_NewPage.zones;
	else this.zones = {};
	
	if (MS_NewPage.blocks != undefined)	this.blocks = MS_NewPage.blocks;
	else this.blocks = {};

	if (MS_NewPage.sizing != undefined)	this.sizing = MS_NewPage.sizing;
	else this.sizing = {};	

	if (MS_NewPage.role != undefined)	this.role = MS_NewPage.role;
	else this.sizing = {};	

	if (MS_NewPage.group != undefined)	this.group = MS_NewPage.group;
	else this.sizing = {};	

	if (MS_NewPage.uboxes != undefined)	this.uboxes = MS_NewPage.uboxes;
	else this.uboxes = {};		
	
	this.system = 0;
	this.editable = true;
}

// ////////////////////////////////////////////////////////////////////////////
// METHODES
// ////////////////////////////////////////////////////////////////////////////
Page.prototype.getZones = function() {
	// //////////////////////////////////////////////////////////////////////
	// RECUPERES LA LISTE DES ZONES ET LEURS BLOCKS DE LA PAGE
	// //////////////////////////////////////////////////////////////////////

	var myZones = new Object();

	$(".groupWrapper").each(function() {
		var myZoneId = this.id;
		myZones[myZoneId] = new Array();
		$(this).children(".groupItem").each(function() {
			var myBlockId = this.getAttribute("podz_block_id");
			myZones[myZoneId].push(myBlockId.toString());
		});
	});
	this.zones = myZones;
	return myZones;
}

/**
 * @method Charge une page
 * @param objet
 *            permettant de definir la page à charger
 */
/*
Page.prototype.historyLoad = function(hash) {

	// alert("pageload: " + hash);
	// hash doesn't contain the first # character.
	if(hash) {
		// restore ajax loaded state
		if($.browser.msie) {
			// jquery's $.load() function does't work when hash include special characters like aao.
			hash = encodeURIComponent(hash);
		}
		alert("History wants to load : "+hash);
		//$("#load").load(hash + ".html");
		var pageObject = JSON.parse(hash);
		pageObject.fromHistory = true;
		MS_Page.load(pageObject);
	} else {
		// start page
		alert("History Load Start Page");
		MS_Page.load();
		//$("#load").empty();
	}
}
*/



/**
 * @method Charge une page
 * @param objet
 *            permettant de definir la page à charger
 */

Page.prototype.load = function(pageObject,isFromHistory) {
	

	
	if (isFromHistory != true)isFromHistory = false;
	
	if (pageObject == undefined || pageObject == null)
	{
		pageObject = {id:null};
	}

	if (isFromHistory == true)
	{
		if (pageObject == "")pageObject = {id:null};
		else if (!isObject(pageObject))
		{
			if (pageObject.substr(0,1)=="#")pageObject = pageObject.substr(1);
			pageObject = JSON.parse(pageObject);
		}
	}

	//alert(podz_preview2(pageObject));
	if (pageObject.id != undefined)
	{
		if (PB_status == "designer" && pageObject.id != "designer") return false;
	}
	
	//Hide non common blocks
	$(".zone > .groupWrapper > div.groupItem[cmscommon=0]").animate( {
		"opacity" : 0
	}, "fast", "swing");

	// //////////////////////////////////////////////////////////////////////
	// REINITIALISATION
	// //////////////////////////////////////////////////////////////////////
	if (PB_status != null)
	{
		if (PB_block_selected != undefined &&  PB_block_selected != "")
		{
			//Si un block est selectionn� en edition, on vide l'info avant le chargement de la page
			if(PBTool_Edit_MyStyles_Close)PBTool_Edit_MyStyles_Close();
		}
	}
	
	// //////////////////////////////////////////////////////////////////////
	// INTERPRETE L'OBJET DE CHARGEMENT
	// //////////////////////////////////////////////////////////////////////
	if (pageObject == undefined) {
		pageObject = {
			id : null,
			menu : null,
			context : {}
		}
	} else {
		if (pageObject.id == undefined)
			pageObject.id = null;
		if (pageObject.id == 0)
			pageObject.id = null;
		if (pageObject.id == "")
			pageObject.id = null;

		if (pageObject.menu == undefined)
			pageObject.menu = null;
		else
			pageObject.menu = parseInt(pageObject.menu, 10);
		if (pageObject.menu == 0)
			pageObject.menu = null;
		if (pageObject.menu == "")
			pageObject.menu = null;

		if (pageObject.context == undefined)
			pageObject.context = {};

	}

	this.pageObject = pageObject; //Memorize pageObject
	
	// //////////////////////////////////////////////////////////////////////
	// GENERE LES PARAMETRES A POSTER
	// //////////////////////////////////////////////////////////////////////
	var sParams = "";
	// PARAMETRES DE LA PAGE ////////////////////////////////////////////////
	if (pageObject.id != null)
		sParams += "p=" + pageObject.id + "&";
	if (pageObject.menu != null)
		sParams += "m=" + pageObject.menu + "&";
	var sJSONContext = JSON.stringify(pageObject.context);
	if (sJSONContext != "")
		sParams += "c=" + sJSONContext + "&";
	if (isFromHistory == true)sParams += "fh=1&";
	else sParams += "fh=0&";
	
	//Recupere la liste des blocks communs
	var commonBlocks = {};
	$(".groupItem[cmscommon=1]").each(function(){
		var id = $(this).attr("podz_block_id");
		commonBlocks[id]=1;
	});
	var sCommons = JSON.stringify(commonBlocks);
	
	// PROPRIETES DE LA PILE POUR LA PAGE EN COURS A PLACER DANS LA SESSION ///////
	if (PB_Stack != null)
	{
		var myStackPage = PB_Stack.getPage();
		sParams += "pile="+encodeURIComponent(JSON.stringify(myStackPage))+"&";
		var myStackMenu = PB_Stack.getMenu();
		sParams += "pilem="+encodeURIComponent(JSON.stringify(myStackMenu))+"&";
	}

	sParams += "js=1&cb="+sCommons;
		
	// VERIFICATIONS (A CHECKER) ////////////////////////////////////////////////
	
	/*
	if (pageObject.menu == podz_menu_in_process.podz_id)
		return false;
	if (pageObject.id == podz_page_in_process.podz_id)
		return false;
	*/
	// //////////////////////////////////////////////////////////////////////
	// QUERY DE CHARGEMENT
	// //////////////////////////////////////////////////////////////////////

	//alert(sParams);	
	
	var ajaxQuery = new ajaxURL();
	ajaxQuery.setParameter("parameters", sParams);
	ajaxQuery.setParameter("callBack", "MS_Page.loaded");
	ajaxQuery.getURL("podz/1MinuteShop/Navigation/ajax_JS_PageLoad.php");

	return false;
}

//Dimensionne la page a son chargement
Page.prototype.size = function()
{
	//return false;
	
	if (MS_Page.sizing == null) {
		MS_Page.sizing = {};
	}	
	
	var pageSize = {};
	
	for (var zone in MS_Page.sizing)
	{
		switch(zone)
		{
			case "zoneMarginWest":
			case "zoneMarginEast":
				break;
			default:
				pageSize[zone] = {};
				for (var property in MS_Page.sizing[zone])
				{
					pageSize[zone][property] = MS_Page.sizing[zone][property];
				}
				break;
		}
	}
	
	//var pageSize = MS_Page.sizing;
	
	//Keep sizing info from the stack
	if (PB_Stack != null)
	{
		var pageInStack = PB_Stack.getPage();
		if (pageInStack != null)
		{
			var sizingStack = pageInStack.sizing;
			for(var zone in sizingStack) {
				switch(zone)
				{
					case "zoneMarginWest":
					case "zoneMarginEast":
						break;
					default:					
						pageSize[zone] = {};
						for(var property in sizingStack[zone])
						{
							switch(property){
								case "width":
								case "height":
									pageSize[zone][property] = sizingStack[zone][property];
									break;
								default:
									break;
							}
						}
				}
			}	
		}
	}
	
	//For each sizing that is not (in the stack or in the actual page)
	//we use the one define in the design
	var sDesign = MS_Page.getDesign();	
	
	var designConfig = MS_DESIGNS[sDesign];

	//alert(podz_preview2(designConfig));
	
	for(var zone in designConfig) {
		if (zone.substr(0,1)=="#")
		{
			var sZone = zone.substr(1);
			switch(sZone)
			{
				case "zoneMarginWest":
				case "zoneMarginEast":
					break;
				default:	
					if (pageSize[sZone] == undefined)
					{
						pageSize[sZone] = {};
						for(var property in designConfig[zone])
						{
							switch(property){
								case "width":
								case "height":
									pageSize[sZone][property] = designConfig[zone][property];
									break;
								default:
									break;
							}
						}
					}
					break;
			}
		}
	}	

	
	for(var zone in pageSize) {
		for(var property in pageSize[zone])
		{
			$("#"+zone).css(property,pageSize[zone][property]+"px");	
		}
	}

	
	MS_Page.resize();
	
}
//Retourne la largeur d'une zone
//se base sur les infos de sizing de la page ou de la stack du mode edition
// ou de la stack du designer
Page.prototype.getWidth = function(zone)
{
	var design = MS_Page.properties.design;
	var myWidth = null;
	
	if (MS_Page.sizing[zone] != undefined && MS_Page.sizing[zone].width != undefined)
	{
		//Info de sizing dans la config de la page
		myWidth = MS_Page.sizing[zone].width;
	}
	else
	{
		//Info de sizing du design
		myWidth = MS_DESIGNS[design][zone].width;
	}
	
	switch(PB_status)
	{
		case "designer": //En mode designer (largeur eventuellemnt presente dans la stack)
			if (PBTool_Designer_Stack != null)
			{
				if (PBTool_Designer_Stack[design])
				{
					if (PBTool_Designer_Stack[design][zone]!=undefined && PBTool_Designer_Stack[design][zone]["width"]!=undefined){
						myWidth = PBTool_Designer_Stack[design][zone].width;
					}
				}
			}
			break;
		case "edit"://En mode edition (largeur eventuellement presente dans la stack)
		case "updated":
			if (PB_Stack != null)
			{
				var pageInStack = PB_Stack.getPage();
				if (pageInStack != null)
				{
					if (pageInStack.sizing != undefined && pageInStack.sizing[zone] != undefined && pageInStack.sizing[zone].width){
						myWidth = pageInStack.sizing[zone].width;
					}
				}
			}
			break;
		default: 
			break;
	}	
	return myWidth;
}
/*
Page.prototype.setWidth = function(zone,width)
{
	var design = MS_Page.properties.design;
	var designConfig = MS_DESIGNS[design];	
	
	var zoneEastWidth = MS_Page.getWidth("zoneEast");
	var zoneWestWidth = MS_Page.getWidth("zoneWest");
	var zoneCenterEastWidth = MS_Page.getWidth("zoneCenterEast");
	var zoneCenterWestWidth = MS_Page.getWidth("zoneCenterWest");

	var zoneWestWithoutPadding = zoneWestWidth - designConfig["zoneWest"]["padding-left"] - designConfig["zoneWest"]["padding-right"];
	if (zoneWestWithoutPadding < 0)zoneWestWithoutPadding=0;
	
	var zoneEastWithoutPadding = zoneEastWidth - designConfig["zoneEast"]["padding-left"] - designConfig["zoneEast"]["padding-right"];
	if (zoneEastWithoutPadding < 0)zoneEastWithoutPadding=0;

	var zoneCenterWestWithoutPadding = zoneCenterWestWidth - designConfig["zoneCenterWest"]["padding-left"] - designConfig["zoneCenterWest"]["padding-right"];
	if (zoneCenterWestWithoutPadding < 0)zoneCenterWestWithoutPadding=0;

	var zoneCenterEastWithoutPadding = zoneCenterEastWidth - designConfig["zoneCenterEast"]["padding-left"] - designConfig["zoneCenterEast"]["padding-right"];
	if (zoneCenterEastWithoutPadding < 0)zoneCenterEastWithoutPadding=0;
		
	switch(zone)
	{
		case "zoneEast":
			$("#colright").css("margin-left",-(zoneWestWidth + zoneEastWidth)+"px");
			$("#col1pad").css("margin 0 0 0 "+(zoneWestWidth + zoneEastWidth)+"px");
			$("#zoneWest").css("left",(zoneEastWidth + designConfig["zoneWest"]["padding-left"])+"px");
			$("#zoneEast").css("width",zoneEastWithoutPadding+"px");
			break;
		case "zoneCenterEast":
			$("#in_colright").css("margin-left",-(zoneWestWidth + zoneEastWidth)+"px");
			$("#in_col1pad").css("margin 0 "+designConfig["zoneCenter"]["padding-left"]+"px 0 "+(zoneWestWidth + zoneEastWidth)+"px");
			$("#zoneCenterWest").css("left",(zoneEastWidth + designConfig["zoneWest"]["padding-left"])+"px");
			$("#zoneCenterEast").css("width",zoneCenterEastWithoutPadding+"px");
			break;
		case "zoneWest":
			$("#colmid").css("left",zoneWestWidth);
			$("#colright").css("margin-left",-(zoneWestWidth + zoneEastWidth)+"px");
			$("#col1pad").css("margin 0 0 0 "+(zoneWestWidth + zoneEastWidth)+"px");
			$("#zoneWest").css("width",zoneWestWithoutPadding+"px");
			break;
		case "zoneCenterWest":
			$("#in_colmid").css("left",zoneCenterWestWidth);
			$("#in_colright").css("margin-left",-(zoneCenterWestWidth + zoneCenterEastWidth));
			$("#in_col1pad").css("margin 0 0 0 "+(zoneCenterWestWidth + zoneCenterEastWidth)+"px");
			$("#zoneCenterWest").css("width",zoneCenterWestWithoutPadding+"px");
			break;
	}

	switch(PB_status)
	{
		case "designer": //En mode designer
			if (PBTool_Designer_Stack[design] == undefined)PBTool_Designer_Stack[design] = {};
			if (PBTool_Designer_Stack[design][zone] == undefined)PBTool_Designer_Stack[design][zone] = {};
			PBTool_Designer_Stack[design][zone]["width"] = width;
			break;
		default: //En mode edition
			// A FAIRE!!
			break;
	}		
	
}
*/

//Passing a DesignZoneConfig, returns cleaned flash properties of this zone
Page.prototype.getFlashConfig = function (zoneConfig)
{
	var values = {};
	
	if (zoneConfig["swfwidth"] == undefined)values["swfwidth"]="";
	else values["swfwidth"] = zoneConfig["swfwidth"];
	if (zoneConfig["swfheight"] == undefined)values["swfheight"]="";
	else values["swfheight"] = zoneConfig["swfheight"];
	if (zoneConfig["swffile"] == undefined)values["swffile"]="";
	else values["swffile"] = zoneConfig["swffile"];
	if (zoneConfig["swfbgcolor"] == undefined)values["swfbgcolor"]="";
	else values["swfbgcolor"] = zoneConfig["swfbgcolor"];
	if (zoneConfig["swfversion"] == undefined)values["swfversion"]="8";
	else values["swfversion"] = zoneConfig["swfversion"];
	if (zoneConfig["swfwmode"] == undefined)values["swfwmode"]="transparent";
	else values["swfwmode"] = zoneConfig["swfwmode"];
	if (zoneConfig["swfmenu"] == undefined)values["swfmenu"]="false";
	else values["swfmenu"] = zoneConfig["swfmenu"];

	return values;
}

Page.prototype.runFlashAction = function (sFlashId,sAction)
{
	//alert(podz_preview2(MS_Page.properties.flashactions));
	//Launch specific flash actions on each movie
	var flashMovies = this.getFlashMovies();
	
	var myFlash = getFlashMovieObject(sFlashId);
	var myFlashCall = flashMovies[sFlashId];
	if (myFlash != undefined && myFlashCall != undefined)
	{
		for(var i=0;i<myFlashCall.actions.length;i++)
		{
			if (myFlashCall.actions[i].name == sAction)
			{
				var sEval = "myFlash."+myFlashCall.actions[i].call+";"
				try
				{
					eval(sEval);
				}
				catch(e)
				{
					
				}
				break;
			}
		}
	}

}

Page.prototype.runFlashActions = function ()
{
	//alert(podz_preview2(MS_Page.properties.flashactions));
	//Launch specific flash actions on each movie
	var flashMovies = this.getFlashMovies();
	
	for(var flashId in this.properties.flashactions)
	{
		var myFlash = getFlashMovieObject(flashId);
		var myFlashAction = this.properties.flashactions[flashId];
		var myFlashCall = flashMovies[flashId];
		if (myFlash != undefined && myFlashCall != undefined)
		{
			for(var i=0;i<myFlashCall.actions.length;i++)
			{
				if (myFlashCall.actions[i].name == myFlashAction)
				{
					var sEval = "myFlash."+myFlashCall.actions[i].call+";"
					try
					{
						eval(sEval);
					}
					catch(e)
					{
						
					}
					break;
				}
			}
		}
	}
}

Page.prototype.getFlashMovies = function ()
{

	var aFlashMovies = {};
	
	// Flash defined in designConfig ////////////////////////////////////////////////////
	var designConfig = MS_Page.getDesignConfig();

	for(var zone in designConfig)
	{
		var $zone = $(zone);
		
		if (designConfig[zone]["swffile"] != undefined && designConfig[zone]["swffile"] != null)
		{
			//Check if an already flash needs an update
			var flConfig = MS_Page.getFlashConfig(designConfig[zone]);
			var flashId = "flash"+$zone.attr("id");
			var flashMovie = getFlashMovieObject(flashId);
			
			if (flashMovie != undefined)
			{			
				var flashActions = [];
				if (flashMovie.MS_getActions != undefined)
				{
					flashActions = flashMovie.MS_getActions();
				}
				
				var flashFound = {id:flashId,movie:flashMovie,actions:flashActions};
				aFlashMovies[flashId] = flashFound;
			}
			
		}
	}

	// Flash defined in blocks ////////////////////////////////////////////////////
	$("div.swf").each(function() {

		var swfWidth = this.getAttribute("swfwidth");
		var swfHeight = this.getAttribute("swfheight");
		var swfFile = this.getAttribute("file");
		var swfcolor = this.getAttribute("bgcolor");
		var swfversion = this.getAttribute("version");
		var swfvars = trim(this.getAttribute("swfvars"));
		
		var flashMovie = getFlashMovieObject(this.id);

		if (flashMovie != undefined)
		{
			var flashActions = [];
			
			if (flashMovie.MS_getActions != undefined)
			{
				flashActions = flashMovie.MS_getActions();
			}
			
			var flashFound = {id:flashId,movie:flashMovie,actions:flashActions};
			aFlashMovies[flashId] = flashFound;
		}
	});		
	return aFlashMovies;
}

Page.prototype.updateFlashMovies = function (sTargetZone,force)
{
	// Update HTML elements that need to contain flash movies

	if (sTargetZone == undefined)sTargetZone = null;
	if (force == undefined)force = false;
	if (force != true)force = false;
	
	if (sTargetZone == null)
	{
		// FLASH UPDATE OF ALL ZONES //////////////////////////////////////////////////////
		
		// Flash defined in designConfig ////////////////////////////////////////////////////
		var designConfig = MS_Page.getDesignConfig();

		for(var zone in designConfig)
		{
			var $zone = $(zone);
			
			if (designConfig[zone]["swffile"] != undefined && designConfig[zone]["swffile"] != null)
			{
				//Check if an already flash needs an update
				
				if (document.all) var $already = $zone.children("object");
				else var $already = $zone.children("embed");

				var needUpdate = true;
				
				if (force == false)
				{
					if ($already.length > 0)
					{
						
						if (document.all)
						{
							//Extract movie file for IE
							var html = $already.html();
							html=html.toLowerCase();
							var start=html.indexOf('"src" value="');
							var end=html.indexOf('"',start+13);
							var src = html.substring(start+13,end);
							var swfAlreadyThere = basename(src);
						}
						else var swfAlreadyThere = basename($already.attr("src"));
						
						var swfToUpdate = basename(designConfig[zone]["swffile"]);
						
						if (swfAlreadyThere == swfToUpdate)
						{
							needUpdate = false;
						}
					}
				}
				if (needUpdate == true)
				{
					var flConfig = MS_Page.getFlashConfig(designConfig[zone]);
					var flashId = "flash"+$zone.attr("id");
					var so = new SWFObject(flConfig["swffile"], flashId, flConfig["swfwidth"], flConfig["swfheight"], flConfig["swfversion"], flConfig["swfcolor"]);
					so.addParam("wmode", flConfig["swfwmode"]);
					/*
					if (swfvars!="")
					{
						so.addParam("FlashVars", swfvars);
					}
					*/
					so.write($zone.attr("id"));	
				}
			}
			else
			{
				//If a flash movie is in there, we need to remove it
				if (document.all) $zone.children("object").remove();
				else $zone.children("embed").remove();	

			}
		}

		// Flash defined in blocks ////////////////////////////////////////////////////
		$("div.swf").each(function() {
			var bOk = true;
			if (this.id == "boxMyMenu")
			{
				if (this.innerHTML != "")bOk=false;
			}
			if (bOk == true)
			{
				var swfWidth = this.getAttribute("swfwidth");
				var swfHeight = this.getAttribute("swfheight");
				var swfFile = this.getAttribute("file");
				var swfcolor = this.getAttribute("bgcolor");
				var swfversion = this.getAttribute("version");
				var swfvars = trim(this.getAttribute("swfvars"));
				var so = new SWFObject(swfFile, this.id, swfWidth, swfHeight, "8", swfcolor);
				so.addParam("wmode", "transparent");
				if (swfvars!="")
				{
					so.addParam("FlashVars", swfvars);
				}
				so.write(this.id);
				$(this).css("height",swfHeight+"px");
			}											
		});			
	}
	else
	{
		// FLASH UPDATE OF A TARGET ZONE //////////////////////////////////////////////////////
		
		var designConfig = MS_Page.getDesignConfig(null,sTargetZone);
		
		var $zone = $(sTargetZone);
		
		if (designConfig["swffile"] != undefined && designConfig["swffile"] != null)
		{
			//Check if an already flash needs an update
			
			if (document.all) var $already = $zone.children("object");
			else var $already = $zone.children("embed");
			
			var needUpdate = true;
			
			if (force == false)
			{			
				if ($already.length > 0)
				{
					if (document.all)
					{
						//Extract movie file for IE
						var html = $already.html();
						html=html.toLowerCase();
						var start=html.indexOf('"src" value="');
						var end=html.indexOf('"',start+13);
						var src = html.substring(start+13,end);
						var swfAlreadyThere = basename(src);
					}
					else var swfAlreadyThere = basename($already.attr("src"));
					
					var swfToUpdate = basename(designConfig["swffile"]);
	
					if (swfAlreadyThere == swfToUpdate)
					{
						needUpdate = false;
					}
				}
			}
			if (needUpdate == true)
			{
				var flConfig = MS_Page.getFlashConfig(designConfig);
				var flashId = "flash"+$zone.attr("id");
				var so = new SWFObject(flConfig["swffile"], flashId, flConfig["swfwidth"], flConfig["swfheight"], flConfig["swfversion"], flConfig["swfcolor"]);
				so.addParam("wmode", flConfig["swfwmode"]);
				/*
				if (swfvars!="")
				{
					so.addParam("FlashVars", swfvars);
				}
				*/
				so.write($zone.attr("id"));
				$("div.swf",$zone).css("height",flConfig["swfheight"]+"px");
			}
		}
		else
		{
			//If a flash movie is in there, we need to remove it
			if (document.all) $zone.children("object").remove();
			else $zone.children("embed").remove();	
		}
	}
	$("#boxMyMenu").css("display","block");
	
	//return this.getFlashMovies();
	
}

Page.prototype.updateFlashMovie = function (sBlockId,sFlashSRC,sFlashWidth,sFlashHeight)
{
	// Update defined 

	$zone = $("swf_"+sBlockId);
	sFlashSRC = decodeURIComponent(sFlashSRC);

	var flashId = "flash"+$zone.attr("id");
	
	if (document.all) $zone.children("object").remove();
	else $zone.children("embed").remove();		

	var so = new SWFObject(sFlashSRC, flashId, sFlashWidth, sFlashHeight, 8, "#FFFFFF");
	so.addParam("wmode", "transparent");
	so.write("swf_"+sBlockId);
	$("div.swf",$zone).css("height",sFlashHeight+"px");
	
}

// return the selected Design of the page
Page.prototype.getDesign = function()
{
	var pageClass = trim($("BODY").attr("class"));
	var design = "dzDefault";
	if (pageClass != undefined)
	{
		var classNames = pageClass.split(" ");
		var design = null;
		
		for(var i=0; i<classNames.length;i++)
		{
			var testingClass = classNames[i];
			if (testingClass.substr(0,2)=="dz")
			{
				design = testingClass;
				break;
			}
		}
	}
	return design;
}

//return the design config of a design or a zone or a property
//it takes care of the design config, the designer stack
Page.prototype.getSkinConfig = function (sProperty)
{
	if (sProperty == undefined)sProperty = null;
	
	var oValue = null;
	
	// Property asked //////////////////////////////////////////////////
	
	if (sProperty != null)
	{
		var tmpValue = MS_SKIN[sProperty];
		
		if (oValue == undefined)oValue = null;
		oValue = tmpValue;
		if (PB_status == "designer")
		{
			tmpValue = PBTool_Designer_StackGetValue("skin","properties",sProperty);
			if (tmpValue != null)oValue = tmpValue;
		}

		return oValue;
	}

	// Skin asked //////////////////////////////////////////////////

	oValue = {};

	for (var property in MS_SKIN)
	{
		oValue[property] = MS_SKIN[property];
	}

	if (PB_status == "designer")
	{
		var stackedProperties = PBTool_Designer_StackGetProperties("skin","properties");
		for (var property in stackedProperties)
		{
			oValue[property] = stackedProperties[property];
		}
	}
	return oValue;
}

//return the design config of a design or a zone or a property
// it takes care of the design config, the designer stack
Page.prototype.getDesignConfig = function (sDesign,sZone,sProperty)
{	
	
	//alert(podz_preview2(MS_DESIGNS));
	
	if (sDesign == undefined || sDesign == null)
	{
		sDesign = MS_Page.getDesign();
	}
	if (sZone == undefined)sZone = null;
	if (sProperty == undefined)sProperty = null;

	if (sDesign == null)sDesign = "dzDefault";
	
	var oValue = null;
	
	// Property asked //////////////////////////////////////////////////
	
	//alert(podz_preview2(MS_DESIGNS[sDesign][sZone]));
	
	if (sProperty != null)
	{
		if (MS_DESIGNS[sDesign][sZone] != undefined)
		{
			var tmpValue = MS_DESIGNS[sDesign][sZone][sProperty];
			if (oValue == undefined)oValue = null;
			oValue = tmpValue;
			if (PB_status == "designer")
			{
				tmpValue = PBTool_Designer_StackGetValue(sDesign,sZone,sProperty);
				if (tmpValue != null)oValue = tmpValue;
			}
		}
		return oValue;
	}
		

	// Zone asked //////////////////////////////////////////////////

	if (sZone != null)
	{
		oValue = {};

		if (MS_DESIGNS[sDesign][sZone] != undefined)
		{
			var zoneConfig = MS_DESIGNS[sDesign][sZone];
	
			for (var property in zoneConfig)
			{
				oValue[property] = zoneConfig[property];
			}
			if (PB_status == "designer")
			{
				var properties = PBTool_Designer_StackGetProperties(sDesign,sZone);
				for (var property in properties)
				{
					oValue[property] = properties[property];
				}					
			}
		}

		return oValue;
	}
	
	// Design asked //////////////////////////////////////////////////

	oValue = {};

	var designConfig = MS_DESIGNS[sDesign];
	
	if (designConfig != undefined)
	{
		for (var zone in designConfig)
		{
			if (oValue[zone] == undefined)oValue[zone] = {};
			var zoneConfig = designConfig[zone];
			for (var property in zoneConfig)
			{
				oValue[zone][property] = zoneConfig[property];
			}
		}
		if (PB_status == "designer")
		{
			var stackedZones = PBTool_Designer_StackGetZones(sDesign);
			for (var zone in stackedZones)
			{
				if (oValue[zone] == undefined)oValue[zone] = {};
				var zoneConfig = stackedZones[zone];
				for (var property in zoneConfig)
				{
					oValue[zone][property] = zoneConfig[property];
				}
			}
		}
	}
	return oValue;

}

Page.prototype.alignVertically = function ()
{
	//If Vertically centered
	var design = MS_Page.getDesign();

	var isVerticalCentered = MS_Page.getDesignConfig(design,"properties","verticalCentered");

	if (isVerticalCentered == "yes")
	{
		var windowHeight = $(window).height();
		var bodyHeight = MS_Page.getDesignConfig(design,"properties","bodyHeight");
		if (bodyHeight > windowHeight)bodyHeight = windowHeight;
		
		var margin = parseInt(((windowHeight - bodyHeight) / 2),10);
		if (margin < 0) margin = 0;
		
		$("#centeredMarginTop").height(margin);
		$("#centeredMarginBottom").height(margin);
		$("#zoneMain").css("height",bodyHeight+"px");
		$("#zoneBody").css("height",bodyHeight+"px");
		$("#zoneBody").css("overflow","hidden");
	}

}


// resize d'une page

Page.prototype.resize = function(sTargetId)
{
	
	if (sTargetId == undefined)
	{
		var design = MS_Page.getDesign();
		
		MS_Page.alignVertically(); //For Skins aligned in the center of the screen
	
		//Adapatation des marges du magic layout
		
		var zoneFrameWidth = $("#zoneFrame").width();
		var zoneWestWidth = $("#zoneWest").width();
		var zoneCenterMainWidth = (zoneFrameWidth - zoneWestWidth - $("#zoneEast").width())-1;
		var zoneCenterMainMargin = zoneWestWidth;
		var zoneWestMargin = zoneCenterMainWidth + zoneWestWidth;
		
		var zoneCenterWest = $("#zoneCenterWest").width();
		var zoneCenterEast = $("#zoneCenterEast").width();
		var zoneCenterWidth = (zoneCenterMainWidth - (zoneCenterWest + zoneCenterEast))-1;
		var zoneCenterMargin = zoneCenterWest;
		var zoneCenterWestMargin = zoneCenterWidth+zoneCenterWest;
	
		$("#zoneCenterMain").width(zoneCenterMainWidth);
		$("#zoneCenterMain").css("margin-left",zoneCenterMainMargin+"px");
		$("#zoneCenterWest").css("margin-left","-"+zoneCenterWestMargin+"px");

		$("#zoneCenter").css("margin-left",zoneCenterMargin+"px");
		$("#zoneCenter").width(zoneCenterWidth);		
		$("#zoneWest").css("margin-left","-"+zoneWestMargin+"px");
	
		//Redimensionne le centre si necessaire
		
		var mainHeight = $("#zoneWest").height();
		var centerHeight = $("#centerwrapper").height();
		
		if (centerHeight < mainHeight)
		{
			var zoneCenterTopHeight = $("#zoneCenterTop").height();
			//var zoneCenterBottomHeight = $("#zoneCenterBottom").height();
			var newHeight = mainHeight-zoneCenterTopHeight;
			$("#centerwrapper").css("min-height",newHeight+"px");
		}
		else
		{
			$("#centerwrapper").css("height","");
		}			
		
		// Cohesion des colonnes  ////////////////////////////////////////////////////////////
		var viewportHeight = $(window).height();
		
		if (PB_status == "designer")
		{

			var zoneHeaderMain = $("#zoneHeaderMain").height();
			var zoneFooterMain = $("#zoneFooterMain").height();
			var zoneHeader = $("#header").height();
			var zoneFooter = $("#zoneFooter").height();
			var extraHeight = zoneHeaderMain + zoneFooterMain + zoneHeader + zoneFooter;
			var bodyHeight = viewportHeight - extraHeight;
	
			$("#zoneSite").height(viewportHeight);
			$("#zoneScroll").height(viewportHeight);
			$("#zoneMain").height(bodyHeight);
			$("#wrapper").css("height","100%");
			$("#zoneCenterMain").css("height","100%");
			$("#zoneWest").css("height","100%");
			$("#zoneEast").css("height","100%");
			$("#centerwrapper_extra").css("height","100%");
	
			
			//$("#centerwrapper").css("height","100%");
			$("#zoneCenter").css("height","100%");
			$("#zoneCenterWest").css("height","100%");
			$("#zoneCenterEast").css("height","100%");
			
		}
		else
		{
			$("#zoneSite").css("min-height",viewportHeight+"px");
			$("#zoneMain").css("height","");
			$("#wrapper").css("height","");
			$("#zoneCenterMain").css("height","");
			$("#zoneWest").css("height","");
			$("#zoneEast").css("height","");
			
			//$("#centerwrapper").css("height","");
			$("#zoneCenter").css("height","");
			$("#zoneCenterWest").css("height","");
			$("#zoneCenterEast").css("height","");		
			
			if (!EZPOD.isIE7)
			{
				var isVerticalCentered = MS_Page.getDesignConfig(design,"properties","verticalCentered");
	
				if (isVerticalCentered == "yes")
				{
					$("BODY").css("overflow-y","hidden");
				}
				else
				{
					$("BODY").css("overflow-y","");
				}
			}
		}
	}
}

/**
 * @method Callback de la methode load
 * @param sJSON : reponse de la query Ajax
 * @param param : parametres passes a la query
 * @param headers : entetes de la reponse
 */
Page.prototype.loaded = function(sJSON, param, headers)
{
	ErrSnap("MS_Page.load_cb");
	

	/*
	try {
	*/
		// Gestion des erreurs
		if (headers != undefined && headers["error"] != undefined) {
			alert(headers["error"]);
			return false;
		}

		if (sJSON != undefined)
		{
			var tab = null;
			var fixed = null;
			// ////////////////////////////////////////////////////////////////////////////////////////////////
			// REDIMENSION DES ZONES (WEST ET EST)
			// ////////////////////////////////////////////////////////////////////////////////////////////////
			
			eval(sJSON);
			
			if (param["fh"] == "0")
			{
				//If page were not loaded from history, we need to put it in the history
				this.pageObject.url = MS_Page.url;
				this.pageObject.title = MS_Page.title;
				//alert(podz_preview2(this.pageObject));
				//$.historyLoad(JSON.stringify(this.pageObject));
				//Save the State
				jQuery(window).unbind('statechange',HistoryStateChange);
				History.pushState(this.pageObject, this.pageObject.title, this.pageObject.url);
				History.Adapter.bind(window,'statechange',HistoryStateChange);
			}
			
			//alert(podz_preview2(MS_Page));
			if (MS_Page.properties != undefined) {
				//Tracking Stats
				//On ne tracke pas en mode edition
				if (document.getElementById("PB_edit") == undefined)
				{
					if (MS_STATS.activate == true)
					{
						switch(MS_STATS.provider)
						{
							case "Google Analytics":
								_gaq.push(
									['_setAccount', MS_STATS.trackerId],
									//['_setDomainName', 'example.com'],
									//['_setCustomVar', 1, 'Section', 'Life & Style', 3],
									['_trackPageview']
								);							
								break;
							default:
								
								break;
						}
					}
				}
				
				// Changement de design
				
				//Does the design exist ? if not, force to default
				if (MS_Page.properties["design"] != "dzDesktop")
				{
					if (MS_DESIGNS[MS_Page.properties["design"]] == undefined)MS_Page.properties["design"] = "dzDefault";
				}
				
				if (!$("BODY").hasClass(MS_Page.properties["design"])) {
					$("BODY")
						.removeClass()
						.addClass(MS_Page.properties["design"]);
				}
				
				// REDIMENSIONNEMENT DES ZONES (Cumul proprietes du design et des specificite de la page)
				// //////////////////////////////////////////////

			}
			
			$("BODY").get(0).scrollTop = 0;
			
			// ??
			/*
			if (document.getElementById("PB_edit") != undefined)
			{
				PB_MediaResizeDisable();
			}
			*/	

			// ////////////////////////////////////////////////////////////////////////////////////////////////
			// UBOXES (REMOVE AND CREATION)
			// ////////////////////////////////////////////////////////////////////////////////////////////////
			
			var divZoneBoxes = $('#zoneBoxes').get(0);
			$(".userBox",divZoneBoxes).remove();
			for (var uboxId in MS_Page.uboxes)
			{
				var ubox = MS_Page.uboxes[uboxId];
				$('#zoneBoxes').append('<div class="userBox groupWrapper" droppable=yes id="'+ubox.id+'" style="width:'+ubox.width+'px;height:'+ubox.height+'px;left:'+ubox.left+'px;top:'+ubox.top+'px;"></div>');
			}
			
			// ////////////////////////////////////////////////////////////////////////////////////////////////
			// POSITIONNEMENT DES BLOCS
			// ////////////////////////////////////////////////////////////////////////////////////////////////
			
			if (tab == undefined) tab = MINUTE_BUFFER["page"];
			
			//$(".zone > [id^=drop]").html(""); //vide toutes les zones de drop (sauf celles des blocks tabs)
			
			var commonBlocks = JSON.parse(param["cb"]); //Get common blocks already in the page
			
			$(".zone > div > [id^=drop]").attr("u","0"); //unflag drop zones
			
			if (PB_status == "designer")
			{
				$(".fixedZone").html("");
				$(".groupWrapper").html("");
			}
			else
			{
				if (tab != null) {
					MINUTE_BUFFER["page"] = tab;
					
					//For each zone
					for ( var i = 0; i < tab.length; i++)
					{
						var sContent = unpack(tab[i].c);
	
						if (tab[i].k.length == 0)
						{
							//Don't need to keep commonBlocks
							//alert(tab[i].z+" don't keep");
							//if (document.all)alert("#"+tab[i].z);
							//if (document.all)alert(sContent);
							//alert(sContent);
							$("#"+tab[i].z)
								.html(sContent)
								.attr("u","1");
							}
						else
						{
							//We need to insert the new html
							//alert(podz_preview2(tab[i]));
							if (tab[i].i == "0")
							{
								//At the beginning of the zone
								//alert(tab[i].z+" insert at the beginning");
								
								var $myZone = $("#"+tab[i].z);
								
								//Delete all not common blocks 
								$(".groupItem[cmscommon=0]",$myZone).each(function(){
									var $parent = $(this).parent();
									//but one in tabs panel
									if ($parent.hasClass("ui-tabs-panel") == false)
									{
										$(this).remove();
									}
								});
								
								$("#"+tab[i].z).prepend(sContent).attr("u","1");
							}
							else
							{
								//First : Delete Common Blocks that are no longer in the zone
								//alert(tab[i].z+" insert at the end");
								for (var commonBlockId in commonBlocks)
								{
									var bFound = false;
									for (var j=0;j<tab[i].k.length;j++)
									{
										if (tab[i].k[j] == commonBlockId)
										{
											bFound = true;
											break;
										}
									}
									if (bFound == false)
									{
										$("#"+tab[i].z).remove("#b"+commonBlockId+"_block");
									}
								}
	
								//Delete all not common blocks 
								$(".groupItem[cmscommon=0]",$myZone).each(function(){
									var $parent = $(this).parent();
									//but one in tabs panel
									if ($parent.hasClass("ui-tabs-panel") == false)
									{
										$(this).remove();
									}
								});							
								
								//Insert After the last of the first common blocks
								$("#"+tab[i].z).append(sContent).attr("u","1");
							}
						}
					}
					
					//if (document.all)alert("2");
					
					//Put in cache the blocks that need to be cached
					$(".zone > div > [u=1] .groupItem[c=1]").each(function(){
						var blid = $(this).attr("podz_block_id");
						
						if (MS_BlocksCache[blid] == undefined)
						{
							//alert("put in cache : "+blid);
							var html = $('<div>').append($(this).clone()).remove().html();
							MS_BlocksCache[blid] = html;
						}
					});
	
					//Put in cache blocks inside user boxes
					$("#zoneBoxes > [u=1] .groupItem[c=1]").each(function(){
						var blid = $(this).attr("podz_block_id");
						
						if (MS_BlocksCache[blid] == undefined)
						{
							//alert("put in cache : "+blid);
							var html = $('<div>').append($(this).clone()).remove().html()
							MS_BlocksCache[blid] = html;
						}
					});				
					
					//Load blocks from cache
					$(".cached").each(function(){
						var blid = $(this).attr("blid");
						var isCommon = $(this).attr("common");
						$(this).replaceWith(MS_BlocksCache[blid]);
						$("#"+blid+"_block").attr("cmscommon",isCommon);
						$("#"+blid+"_block .block_group IMG").attr("class","block_common"+isCommon);
					})

					//Blocks That needs refreshing
					for ( var i = 0; i < tab.length; i++)
					{
						//Handling blocks that need refresh
						for(blockId in tab[i].r)
						{
							var sContent = unpack(tab[i].r[blockId]);
							$("#"+blockId+"_block .block_content").html(sContent);
						}
					}					
					
					
					//Empty zones that were not updated
					$(".zone > div > [u=0]").html("");				
	
					if ((PB_status == "edit") || (PB_status == "updated")) {
						PB_menu_toSelect(param["m"], MS_Page.id); // force la
																// selection du menu
																// dans l'arbre
						$(".richtext_separator").css("visibility", "visible");
						$(".richtext_img").css("cursor", "pointer");
						
						$(".userBox")
						.draggable({stop: PBTool_Edit_UBoxUpdate})
						.resizable({stop: PBTool_Edit_UBoxUpdate});
						
						PB_block_refresh();
					}
				}
	
				//Refresh des zones fixes
				$(".fixedZone").html("");
				if (fixed != null) {
					for ( var i = 0; i < fixed.length; i++) {
						var sContent = unpack(fixed[i].c);
						//sContent = sContent.replace(/\|\|/g, "//");
						$("#" + fixed[i].z).html(sContent);
					}
				}	
			}
		}
		
		//Activation of Tabs
		if (PB_status == "edit" || PB_status == "updated")
		{
			PBTool_Edit_TabsActivateEdition();	
		}
		else
		{
			$(".tabs").tabs({
				show:MS_TabShow
			});
		}		
		
		if (PB_status == "edit" || PB_status == "updated")
		{
			PB_Stack.clean(); //After loaded, stack page need to be cleaned (content might have change so we sync with the server side stack)
		}
		
		if(PB_status == "edit" || PB_status == "updated")PB_DesignBar_Reposition();

		// MISE A JOUR DE L'ONGLET MA PAGE SI EXISTE
		
		if (document.getElementById("PB_edit") != undefined)
		{
			PBTool_Edit_MyPage_LoadForm();
			PB_MediaResizeEnable();
			if (podz_menu_in_process.podz_id == "")
			{
				//No menu selected
				PBTool_Edit_HideMenuForm();
				var selectedNode = Ext.getCmp("menu_tree").getSelectionModel().getSelectedNode();
				if (selectedNode != undefined)
				{
					Ext.getCmp("menu_tree").getSelectionModel().unselect(selectedNode,true);
				}
				Ext.getCmp("menu_tree").getSelectionModel().clearSelections();
			}
		}

		// MEMORISE LES INFOS DE LA PAGE EN COURS (TEMPORAIRE)
		// MS_Page.getProperties(); //memorise
		MS_Page.getZones(); // memorise
		// MS_Page.geBlocks(); //memorise
		
		$("div.groupItem").animate( {
			"opacity" : 1
		}, "normal", "swing");
		
		//Update Flash Movies
		MS_Page.updateFlashMovies();
		MS_Page.runFlashActions();

		
		
		MS_Page.size();	//Size after flash loads IMPORTANT		
		
		//Define droppable zones
		$(".groupWrapper").each(function(){
			if ($(this).hasClass("userBox") == true)
			{
				$(this).attr("droppable","yes");
			}
			else
			{
				var parent = $(this).parent();
				if (parent.attr("class") == "padder")parent = parent.parent();
				var zoneId = "#"+parent.attr("id");
				if (zoneId != undefined)
				{
					var droppable = MS_Page.getDesignConfig(null,zoneId,"droppable");
					if (droppable == undefined)droppable = "yes";
					
					$(this).attr("droppable",droppable);
				}
			}
		});

		$("div[transition_code]").each(function() {
			if (parseInt(this.getAttribute("nbimages"), 10) > 1) {
				$(this).cycle( {
					fx : this.getAttribute("transition_code"),
					speed : this.getAttribute("transition_speed"),
					timeout : this.getAttribute("transition_timeout"),
					sync : 1,
					delay : -4000,
					cleartype : 1
				});
				this.setAttribute("launched", "1");
			}
		});

		
		$('.groupWrapper').each(function(){
			var zoneWidth = $(this).width();
			$('.slides',this).width(zoneWidth);
			$('.slides_container',this).width(zoneWidth);
			$('.slides .slides_container div.slide',this).width(zoneWidth);
			$('.slides .caption',this).width(zoneWidth);
		});
		
		//On lance les slides
		$('.slides').slides({
			preload: false,
			preloadImage: 'podz/1MinuteShop/css/slides/img/loading.gif',
			container: 'slides_container',
			generateNextPrev: false,
			fadeSpeed: 350,
			fadeEasing: "easeOutQuad",
			slideSpeed: 350,
			slideEasing: "easeOutQuad",
			start: 1,
			effect: 'slide, fade',
			randomize: false,
			crossfade: true,
			play: 5000,
			pause: 2500,
			hoverPause: true,
			autoHeight: false,
			autoHeightSpeed: 350,
			animationStart: function(){
				$('.caption').animate({
					bottom:-35
				},100);
			},
			animationComplete: function(current){
				$('.caption').animate({
					bottom:0
				},200);
				if (window.console && console.log) {
					// example return of current slide number
					//console.log(current);
				};
			}
		});
		
		// On lance les effets
		$("[effect]").each(function() {
			if (this.getAttribute("effect") != "null") {
				PB_image_effect_apply(this, this.getAttribute("effect"));
			}
		});

		if(!document.all)
		{
			MagicZoom_findZooms();
			MagicThumb.init();
			MagicThumb.refresh('zoom2');
		}
		else
		{
			//if (globalTest == 0)
			MagicZoom_findZooms();
			globalTest++;
			MagicThumb.init();
			MagicThumb.refresh('zoom2');		
		}		
		
		if (PB_status == "designer")
		{
			PB_DesignBar_Reposition();
		}
		

		
		
		
	/*
	} catch (err) {
		err.file = PODZ['installpath'] + "1MinuteShop/Navigation/main.js";
		err.triedoeval = "\n-----" + JSON + "-----";
		ErrSave(err);
	}
	*/
}

// Initialisation de la page en cours
MS_Page = new Page(); // Page en cours de navigation

//////////////////////////////////////////////////////////////////////////////
//CLASSE D'UN MENU
//////////////////////////////////////////////////////////////////////////////

function Menu() {
	
	this.id = 0;
	this.properties = {
		'libelle' : "",	
		'visible' : "",	
		'ext' : "",	
		'url' : "",	
		'script' : "",	
		'private' : "",
		'action' : ""
	}
}

MS_Menu = new Menu(); // Menu en cours de navigation






//////////////////////////////////////////////////////////////////////////////////////////////////////
// RAFRAICHI LE CONTENU D'UN BLOCK
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Role		: appel un script php afin de recharger le block (uniquement son contenu)
// Appels	: 
// Entrees 	: 	block_id (Entier) : identifiant du block

function MS_block_refreshContent(block_id)
{
	if (block_id == undefined || block_id == null)return false;
	
	if (!isDigit(block_id))
	{
		//Le type de block est pass� et non son id
		$("div.groupItem[podz_block_type='"+block_id+"']").each(function(){
			block_id = this.getAttribute("podz_block_id");
		});

		if (!isDigit(block_id.substr(1)))
		{
			return false;
		}
	}

	//Recup de son div "itemContent" ???
	var myBlock = $("#"+block_id+"_block");
	if (myBlock != undefined && myBlock != null)
	{
		$(".itemContent",myBlock).each(function(){this.id = block_id+"_itemContent"});	
		
		// Ajax query
		var ajaxQuery = new ajaxURL();
			ajaxQuery.setParameter("parameters","id="+block_id);
			ajaxQuery.setParameter("element",block_id+"_itemContent");
			ajaxQuery.setParameter("callback","MS_block_refreshContent_cb");
			ajaxQuery.getURL(PODZ['installpath']+"1MinuteShop/podzBar/Modules/Blocks/ajax_HTML_BlockRefreshContent.php");
	}	
}

//////////////////////////////////////////////////////////////////////////////////////////////////////
// RAFRAICHI LE CONTENU D'UN BLOCK (CallBack)
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Role		: affiche le contenu rafraichi d'un block
// Appels	: Callback de PB_block_refreshContent()
// Entrees 	: 	block_id (Entier) : identifiant du block

function MS_block_refreshContent_cb()
{

	// RAFRAICHISSEMENT DES DIAPORAMAS ////////////////////////////////////////////////////////
	
	$("div[transition_code]").each(function(){
		if (parseInt(this.getAttribute("nbImages")) > 1)
		{
			$(this).cycle({ 
			    fx:			this.getAttribute("transition_code"), 
			    speed:		this.getAttribute("transition_speed"), 
			    timeout:	this.getAttribute("transition_timeout"),
				sync:       1, 
				delay:		-4000,
				cleartype:  1
			});
			this.setAttribute("launched","1");
		}
	});
	
	// RAFRAICHISSEMENT DES EFFETS ////////////////////////////////////////////////////////
	
	$("div[effect]").each(function(){
		if (this.getAttribute("effect") != "null")
		{
			PB_image_effect_apply(this,this.getAttribute("effect"));
			//alert(this.getAttribute("effect"));
		}
	});

	// RAFRAICHISSEMENT LE WORKSPACE ////////////////////////////////////////////////////////

	PODZ_workspace_resize();
	
}

function MS_doAction(source)
{
	if (PB_status != "" && PB_status != null ) return false;
	if (source == null) return false;
	
	if (isString(source))
	{
		//Source est le code d'une action
		var actionType = "action";
		var actionVal = source;
	}
	else
	{
		//Source est un �l�ment HTML qui possede les attributs atype et aval
		if (isElement(source))
		{
			var actionType = source.getAttribute("atype");
			var actionVal = source.getAttribute("aval");
		}
		else
		{
			if (source.type == undefined)source.type = "action";
			if (source.val == undefined)source.val = null;
			
			var actionType = source.type;
			var actionVal = source.val;
		}
	}
	
	switch(actionType)
	{
		case "url":
			actionVal = actionVal.toLowerCase();
			if (actionVal.substr(0,7)=="http://")
			{
				actionVal = actionVal.substr(7);
			}
			window.open("http://"+actionVal);
			break;
		case "articles":
			MS_Page.load({id:actionVal});
			break;
		case "menu":
			actionVal = actionVal.toLowerCase();
			var infos = actionVal.split("_");
			MS_Menu_click(infos[0],infos[1]);
			break;
		case "overlay":
			
			break;
		case "action":
			//alert(podz_preview2(MS_SkinActions));
			if (actionVal != null)
			{
				for (i=0;i<MS_SkinActions.length;i++)
				{
					if (MS_SkinActions[i][0] == actionVal)
					{
						eval(MS_SkinActions[i][1]);
					}
				}
			}
			break;
		case "video":
			var width = 640;
			var height = 480;
			
			var sURL = actionVal;
			if (sURL.substr(0,7)=="http://")sURL = sURL.substr(7);
			if (sURL.substr(0,4)=="www.")sURL = sURL.substr(4);
			
			var sVideoOrigin = "local";
			if (sURL.substr(0,15)=="dailymotion.com")sVideoOrigin = "DailyMotion";
			if (sURL.substr(0,9)=="vimeo.com")sVideoOrigin = "Vimeo";
			
			switch(sVideoOrigin)
			{
				case "DailyMotion"://http://www.dailymotion.com/video/x8xd5h_one-minute-shop_fun
					if (sURL.substr(0,22)=="dailymotion.com/video/")sURL= sURL.substr(22);
					sVideoParts = sURL.split('_');
					sVideoID = sVideoParts[0];
					sSWFUrl = "http://www.dailymotion.com/swf/video/"+sVideoID+"?additionalInfos=0";
					var so = new SWFObject(sSWFUrl, "videoPop", width, height, "9", "#FFFFFF");
					so.addParam("wmode", "window");
					so.addParam("allowFullScreen", "true");
					so.addParam("allowScriptAccess", "always");
					so.write("videoPopContent");
					break;
				case "Vimeo":
					/*
					<object width="500" height="281">
					<param name="allowfullscreen" value="true" />
					<param name="allowscriptaccess" value="always" />
					<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5367093&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00adef&fullscreen=1" />
					<embed src="http://vimeo.com/moogaloop.swf?clip_id=5367093&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00adef&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="281"></embed>
					</object>
					*/	
					if (sURL.substr(0,10)=="vimeo.com/")sURL= sURL.substr(10);
					//sVideoParts = sURL.split('_');
					sVideoID = sURL;
					sSWFUrl = "http://vimeo.com/moogaloop.swf?clip_id="+sVideoID+"&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00adef&fullscreen=1";
					var so = new SWFObject(sSWFUrl, "videoPop", width, height, "9", "#FFFFFF");
					so.addParam("wmode", "window");
					so.addParam("allowFullScreen", "true");
					so.addParam("allowScriptAccess", "always");
					so.write("videoPopContent");
					
					break;
				default: //Local
					var so = new SWFObject("podz/1MinuteShop/Navigation/Modules/Video/JCPlayer.swf", "videoPop", width, height, "9", "#FFFFFF");
					so.addParam("wmode", "window");
					so.addParam("allowFullScreen", "true");
					so.addParam("FlashVars", "videoURL="+actionVal+"&autoPlay=true&scaleMode=exactFit");
					so.write("videoPopContent");
					break;
			}

			$("#videoPop")
				.width(width)
				.height(height)
				.overlay({ 
				    expose: { 
				        loadSpeed: 600, 
				        opacity: 0.6 
				    },
				    effect: 'apple',
				    closeOnClick: true, 
				    api: true 
				}).load();			
			break;
		default:
			return false;
	}
}

function unpack(s)
{
	if (s.length == 0)return "";
	var result = function (p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}(s[0],s[1],s[2],s[3].split('|'),0,{});
	result = result.replace(/\|\|/g, "//");
	result = result.replace(/##USCORE##/g, "_");
	return result;
}

function MS_overlay(config)
{
	if (config == null)config = {};
	if (config.width == undefined) config.width = 640;
	if (config.height == undefined) config.height = 480;
	if (config.top == undefined) config.top = null;
	if (config.url == undefined) config.url = "podz/1MinuteShop/blank.html";
	if (config.cls == undefined) config.cls = "";
	if (config.secure == undefined) config.secure = false;
	if (config.details == undefined) config.details = "";
	if (config.closeOnClick == undefined) config.closeOnClick = true;
	if (config.close == undefined) config.close = null;
	if (config.onClose == undefined) config.onClose = null;
	
	$("#overlayContent").attr("src",config.url)
	$("#overlayDetails").html(config.details);
	if (config.secure == true)$("#overlayDetails").addClass("secure");
	else $("#overlayDetails").removeClass("secure");
	
	if(config.cls != "")$("#overlay").addClass(config.cls);
	else $("#overlay").attr("class","apple_overlay");
	
	$("#overlay")
	.width(config.width)
	.height(config.height)
	.overlay({ 
	    expose: { 
	        loadSpeed: 600, 
	        opacity: 0.6 
	    },
	    top : config.top,
	    effect: 'apple',
	    close : config.close,
	    closeOnClick: config.closeOnClick, 
	    onClose : config.onClose,
	    api: true 
	}).load();	
}


