
// navigators identification
var IE=(document.all)?1:0;
var SAF=navigator.userAgent.indexOf("Safari")>=0;
var NS=navigator.userAgent.indexOf('Netscape')>0;
var OP=navigator.userAgent.indexOf('Opera')>0;

// Menu variables
var showNewMod=false;
var showBoxStatus=false;
var showHdr=false;
var noteSize=0;
var newModH;

// Newspaper variables
var searchControl;

var dirOptSelId=[];
var ourSel="";
var ourSelSub=[];
//var maxUniq=0;
var useMod;
//var cols=[];
var tab=[];
var dumtab;
//var module=[];
var mDivObj=null;
var indef;
var pfolder="";
var allowSave=false;
var isPortal=true;
var rand=Math.round(Math.random()*100);
var rssNoCache=false;
var leftMenuWidth=240; //left menus width
var p_version=__POSHVERSION;

//================================================================================================================
//==                                      COMMON FUNCTIONS
//================================================================================================================

// Get object with its ID
function _gel(v_id){return document.getElementById?(document.getElementById(v_id)?document.getElementById(v_id):null):document.all[v_id];}
// Get objects with their tag name
function _gelstn(v_t){return document.getElementsByTagName?document.getElementsByTagName(v_t):new Array();}
/* Change HTML content of an object
	inputs
		v_id : id of the object
		v_s : string to display in the object
		v_add : if true, add v_s to the current content of the object
*/
function navPrint(v_id,v_s,v_add){
	var l_obj=_gel(v_id);
	if (v_add!=indef && v_add) v_s=l_obj.innerHTML+v_s;
	if (l_obj) l_obj.innerHTML=v_s;
}
// Change CSS Class of an object
function navClass(v_id,v_class){
	var l_obj=_gel(v_id);
	if (l_obj) l_obj.className=v_class;
}
// Show/Hide object
function navShow(v_id,v_disp){
	var l_obj=_gel(v_id);
	if (l_obj) l_obj.style.display=v_disp;
}
function navIsShown(v_id){
	var l_obj=_gel(v_id);
	if (l_obj) {
		return (l_obj.style.display=='block'?true:false);
	} else {return false;}l_obj.style.display=v_disp;
}
function navWait(v_id){
	navPrint(v_id,img("ico_waiting.gif",16,16));
}
// Encode string
function _esc(v_s){return window.encodeURIComponent?encodeURIComponent(v_s):escape(v_s);}
// Decode string
function _unesc(v_s){
	return window.decodeURIComponent?decodeURIComponent(unescape(v_s).replace(/%/g,'%25')):unescape(v_s);
}
// uppercase transformation
function _uc(v_s){return v_s.toUpperCase();}
// lowercase transformation
function _lc(v_s){return v_s.toLowerCase();}
// return minimum of 2 values
function _min(v1,v2){return Math.min(v1,v2);}
// return maximum of 2 values
function _max(v1,v2){return Math.max(v1,v2);}
// change style property value
function changeStyle(v_class,v_prop,v_value){
	var l_items=_gelstn("*");
	for(var l_item=0;l_item<l_items.length;l_item++){
		if(l_items[l_item].className==v_class){l_items[l_item].style[v_prop]=v_value}
	}
}
// Change object ID
function navId(v_id,v_newid){
	var l_obj=_gel(v_id);
	if (l_obj) l_obj.id=v_newid;
}
// Change object height
function navHeight(v_id,v_h){
	var l_obj=_gel(v_id);
	l_obj.style.height=v_h+"px";
}
// Change object width
function navWidth(v_id,v_w){
	var l_obj=_gel(v_id);
	l_obj.style.width=v_w+"px";
}
// Return the absolution Left or Top position of a node
function getPos(v_node,v_ref){
	var l_ret=0;
	while(v_node!=null){
		l_ret+=v_node["offset"+v_ref];
		v_node=v_node.offsetParent;
	}
	return l_ret
}
// Get image script
function img(v_file,v_w,v_h,v_alt,v_cl,v_id){
	if (v_file=="-") return "";
	if (v_file==indef || v_file=="") v_file="s.gif";
	var l_width=v_w?" width='"+v_w+"'":"";
	var l_height=v_h?" height='"+v_h+"'":"";
	if (v_alt==indef) v_alt="";
	if (v_cl==indef) v_cl=".";
	if (v_id==indef){v_id="";}else{v_id=" id='"+v_id+"'";}
	return "<img src='"+pfolder+"../images/"+v_file+"' alt='"+suppressCot(v_alt)+"'"+l_width+l_height+" class='"+v_cl+"'"+v_id+" />";
}
// Generate the horizontal menus
function box(v_h,v_title,hideFct,v_content,v_hdr){
	var l_s=(v_hdr==indef?"":v_hdr)+"<table cellpadding='10' cellspacing='0' width='100%'><tr><td"+(v_h>0?" height="+v_h:"")+"><table class='menubox' cellpadding='0' cellspacing='0' border='0' width='100%'>";
	l_s+="<tr><td class='menuhdr'><table width='100%'><tr><td class='menutitle'><b>"+v_title+"</b></td>";
	if (hideFct!="") l_s+="<td class='menuclose'><a class='w' href='#' onclick='"+hideFct+";return false;'>"+img("s.gif",13,13,lg("lblClose"),"imgmid")+" "+lg("lblClose")+"</a></td>";
	l_s+="</tr></table></td></tr>";
	l_s+="<tr><td valign='top' class='menucont'>";
	l_s+=v_content;
	l_s+="</td></tr></table></td></tr></table>";
	return l_s;
}
//Generate the menus
var p_menu={
	leftShown:false,
	/* display the menu
		inputs :
			v_h: menu height (0 if height = content height)
			v_title : menu title
			hideFct : function called when user close the menu (optional. If not defined, default close menu function)
			v_content : HTML content of the menu
			v_hdr : menu header (optional)
	*/
	init:function(){
		if (__menuposition=="h"){
		} else {
			(_gel("menus")).style.marginLeft=leftMenuWidth+"px";
			(_gel("modules")).style.marginLeft=leftMenuWidth+"px";
			navShow("leftmenu","block");
		}
	},
	display:function(v_h,v_title,v_icon,hideFct,v_content,v_hdr){
		if (hideFct==indef) hideFct="p_menu.hide()";
		var l_s=(v_hdr==indef?"":v_hdr);
		if (__menuposition=="h"){
			l_s+="<table cellpadding='10' cellspacing='0' width='100%'><tr><td"+(v_h>0?" height="+v_h:"")+"><table class='menubox' cellpadding='0' cellspacing='0' border='0' width='100%'>";
			l_s+="<tr><td class='menuhdr'><table width='100%'><tr><td class='menutitle'><b>"+v_title+"</b></td>";
			if (hideFct!="") l_s+="<td class='menuclose'><a class='w' href='#' onclick='"+hideFct+";return false;'>"+img("s.gif",13,13,lg("lblClose"),"imgmid")+" "+lg("lblClose")+"</a></td>";
			l_s+="</tr></table></td></tr>";
			l_s+="<tr><td valign='top' class='menucont'>";
			l_s+=v_content;
			l_s+="</td></tr></table></td></tr></table>";
			return l_s;
		} else {
			l_s+="<div class='leftmenuheader'><table cellpadding='0' cellspacing='0' width='100%'><tr><td width='36'>"+(v_icon==""?"":img(v_icon,28,28))+"</td><td>"+_uc(v_title)+"</td><td style='text-align:right;padding-right:6px;'><a href='#' onclick='"+hideFct+"'>"+img("ico_close.gif",9,9)+"</a></td></tr></table></div>";
			l_s+="<div class='leftmenucontent'"+(v_h==0?"":" height='"+v_h+"'")+">";
			l_s+=v_content;
			l_s+="</div>";
			navPrint("leftmenu",l_s);
			p_menu.leftShown=true;
		}
	},
	// hide menu
	hide:function(){
		if (__menuposition=="h"){
			hideBox();
		} else {
			if (_gel("menus")!=null){
				navShow("leftmenu","none");
				(_gel("menus")).style.marginLeft="0px";
				(_gel("modules")).style.marginLeft="0px";
			}
			p_menu.leftShown=false;
			p_area.resize();
		}
	},
	showItem:function(v_itemId){
		navShow(v_itemId,"block");
	},
	hideItem:function(v_itemId){
		navShow(v_itemId,"none");
	}
}
/*
** Display popup in the middle of the page
** Inputs
** - v_content (string) : HTML content of the popup
** - v_width (integer) : popup width
** - v_height (integer) : popup height
** - v_title (string) : title displayed in the popup header
** - v_closeBtn (boolean) : define if close button is displayed or not
*/
function popup(v_content,v_width,v_height,v_title,v_closeBtn){
	p_cache.shadow();
	//var l_obj=_gel("cache");
	var l_popup=document.createElement("div");
	l_popup.id="popup";
	document.body.appendChild(l_popup);
	l_popup.style.width=v_width+"px";
	l_popup.style.height=v_height+"px";
	//l_popup.style.zIndex=10000;
	//l_popup.style.backgroundColor="#D4D0C8";
	//l_popup.style.position="absolute";
	//l_popup.style.border="2px outset #ffffff";
	//l_popup.style.padding="8px";
	//l_popup.style.top="50%";
	//l_popup.style.left="50%";
	l_popup.style.marginTop="-"+(v_height/2)+"px";
	l_popup.style.marginLeft="-"+(v_width/2)+"px";
	var l_s="";
	if (v_closeBtn==indef) v_closeBtn=true;
	if (v_title!=indef || v_closeBtn) l_s+="<table class='popuphdr'><tr>";
	if (v_title!=indef) l_s+="<td style='vertical-align:center;padding-left:8px;'>"+v_title+"</td>";
	if (v_closeBtn) l_s+="<td style='text-align:right;padding-right:8px;'><a href='#' onclick='hidepopup()'>"+img("ico_close.gif",9,9)+"</a></td>";
	if (v_title!=indef || v_closeBtn) l_s+="</tr></table>";
	l_s+="<div style='width:100%;height:"+(l_s==""?v_height:(v_height-30))+"px;' id='popupcontent'>"+v_content+"</div>";
	l_popup.innerHTML=l_s;
}
function hidepopup(){
	document.body.removeChild(_gel("popup"));
	p_cache.hideShadow();
}
function tooltip(v_msg){
	return "<a href='#' onclick='return false' onmouseover=\"mouseBox(lg('"+v_msg+"'),event)\" onmouseout=\"mouseBox('')\">"+img("ico_help_s.gif",12,12,"","imgmid")+"</a>";
}
/*
** Display text in tooltip box, next to mouse pointer
** Inputs
** - v_s (string) : text to display
** - e(event) : event object
*/
function mouseBox(v_s,e){
	if (__displayrssdesc){
		if (v_s==""){
			navShow("mousebox","none");
		} else {
			if (_gel("mousebox")==null){
				var l_div=document.createElement("div");
				l_div.id="mousebox";
				document.body.appendChild(l_div);
			} else {l_div=_gel("mousebox");}
			navPrint("mousebox",v_s);
			if (e==indef)e=window.event;
			//if(typeof e.layerX=="undefined")e.layerX=e.offsetX;
			//if(typeof e.layerY=="undefined")e.layerY=e.offsetY;
			//var e=window.event;
			var posLeft=(IE?(e.clientX + document.documentElement.scrollLeft):e.pageX+10);
			var posTop=(IE?(e.clientY + document.documentElement.scrollTop):e.pageY+10);

			l_div.style.left=posLeft+"px";
			l_div.style.top=posTop+"px";
			
			navShow("mousebox","block");
			var l_boxWidth=l_div.offsetWidth;
			var l_boxHeight=l_div.offsetHeight;
			if (posLeft > (getWindowWidth()+document.documentElement.scrollLeft-l_boxWidth)){l_div.style.left=(getWindowWidth()+document.documentElement.scrollLeft-l_boxWidth-20)+"px";}
			if (posTop > (getWindowHeight() + document.documentElement.scrollTop-l_boxHeight)){l_div.style.top=(getWindowHeight()+document.documentElement.scrollTop-l_boxHeight-20)+"px";}			
		}
	}
}
//Check that cookies are accepted
function checkcook(){
	if (__showHomeBar>0){
		if ((__showHomeBar==1 && document.cookie.indexOf("homebar")==-1) || __showHomeBar==2) homebar();
	}
	if (__showHomeBar==1) writeCookie("homebar=1");
	accepteCookies = (navigator.cookieEnabled) ? true : false;
	if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
		writeCookie("homebar=1");
		accepteCookies = (document.cookie.indexOf("homebar")==-1)?false:true;
	}
	if (!accepteCookies) link("cookies_restriction.html",false,true);
}
// Cookies management functions
function writeCookie(v_vars,v_delay){
	var l_date=new Date;
	if (v_delay==indef) v_delay=10;
	l_date.setFullYear(l_date.getFullYear()+v_delay);
	document.cookie=v_vars+"; path=/; expires="+l_date.toGMTString()+";";
}
function getCookie(v_name){
	var l_ret="";
	if (document.cookie.length > 0){
		var l_arr=document.cookie.split(/;/);
		for (var i=0;i<l_arr.length;i++){
			if (l_arr[i].indexOf((v_name+"="))!= -1){
				l_ret=l_arr[i].substring((v_name.length+2),l_arr[i].length);
			}
		}
	}
	return l_ret;
}
// Format the search string
function formatSearch(v_s){
	v_s=_lc(v_s);
	v_s=_trim(v_s);
	v_s=supAccent(v_s);
	v_s=v_s.replace(/\+/gi,",");
	v_s=v_s.replace(/;/gi,",");
	v_s=v_s.replace(/"/gi," ");
	v_s=v_s.replace(/\./gi," ");
	v_s=v_s.replace(/'/gi," ");
	v_s=v_s.replace(/, /gi,",");
	v_s=v_s.replace(/  /gi," ");
	return v_s;
}
// Replace accentuated signs
function supAccent(v_s){
	v_s=v_s.replace(/[àâä]/gi,"a");
	v_s=v_s.replace(/[éèêë]/gi,"e");
	v_s=v_s.replace(/[îï]/gi,"i");
	v_s=v_s.replace(/[ôö]/gi,"o");
	v_s=v_s.replace(/[ùûü]/gi,"u");
	v_s=v_s.replace(/[ç]/gi,"c");
	return v_s;
}
function suppressCot(v_s){
	return v_s.replace(/\'/g," ").replace(/\"/g," ")
}
function formatString(v_s){
	return v_s.replace(/\'/g," ");
}
function doubleToSimpleCot(v_s){
	return v_s.replace(/"/g,"'");
}
function setExternalLink(v_s){
	return v_s.replace(/<a /g,"<a target='_blank' ");
}
// check email validity
function checkEmail(v_email){
	var l_ret=true;
	var l_reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
	if (l_reg.exec(v_email)==null){l_ret=false;}
	return l_ret;
}
// Get var value in a string
function getVar(v_s,v_var){
	var l_ret="",l_items=v_s.split("&");
	for (var i=0;i<l_items.length;i++) {
		var l_arr=l_items[i].split("=");
		if (l_arr[0]==v_var) {
			l_ret=_unesc(l_arr[1]);
		}
	}
	return l_ret;
}
//suppress a var
function supVar(v_s,v_var){
	var l_items=v_s.split("&");
	for (var i=0;i<l_items.length;i++) {
		var l_arr=l_items[i].split("=");
		if (l_arr[0]==v_var) {
			l_items.splice(i,1);
		}
	}
	return l_items.join("&");
}
function textToHtml(v_s){
	v_s=v_s.replace(/\&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/  /g,"&nbsp; ").replace(/\r/g,"");
	v_s=(IE)?v_s.replace(/\n/g,"<BR>"):v_s.replace(/\n/g,"<br>");
	return v_s;
}
function htmlToText(v_s){
	v_s=v_s.replace(/\&amp;/g,"&").replace(/\&lt;/g,"<").replace(/&gt;/g,">").replace(/\&nbsp;/g," ").replace(/<BR>/g,"\r\n").replace(/<br>/g,"\r\n");
	return v_s;
}
function textToXml(v_s){
	var l_xml;
	if (document.implementation.createDocument){ 
		// Firefox XML object creation 
		var parser = new DOMParser(); 
		l_xml = parser.parseFromString(v_s, "text/xml"); 
	} else if (window.ActiveXObject){ 
		// IE XML object creation
		l_xml = new ActiveXObject("Microsoft.XMLDOM"); 
		l_xml.async="false";
		l_xml.loadXML(v_s);
	}
	return l_xml;
}
//parse text as html //experimental
function parseTextToHtml(v_s){
	var l_html;
	if (document.implementation.createDocument){ 
		// Firefox XML object creation 
		var parser = new DOMParser(); 
		l_html = parser.parseFromString(v_s, "text/html"); 
	} else if (window.ActiveXObject){ 
		// IE XML object creation
		l_html = new ActiveXObject("Microsoft.XMLDOM"); 
		l_html.async="false";
		l_html.loadXML(v_s);
	}
	return l_html;
}
// simulate getElementsByTagName action on a text
function p_getElementsByTagName(v_s,v_tag){
	v_s=_lc(v_s);
	v_tag=_lc(v_tag);
	var l_starttag=0,l_endtag,l_endprop,l_resArray=[];
	while (v_s.indexOf("<"+v_tag,l_starttag)!=-1){
		var l_nocontent=false;
		l_starttag=v_s.indexOf("<"+v_tag,l_starttag)+(v_tag.length+1);
		l_endprop=v_s.indexOf(">",l_starttag);
		if (v_s.substr(l_endprop-1,1)=="/"){l_endprop--;l_nocontent=true;}
		var l_property={};
		//get tag properties
		l_propStr=v_s.substring(l_starttag,l_endprop);
		//l_propElmt=l_propStr.split(/(["'] )/);
		l_propElmt=l_propStr.split(/[("|')][ ]/);
		for (var i=0;i<l_propElmt.length;i++){
			var pair=l_propElmt[i].split(/[=][("|')]/);
			if (pair[1]) l_property[pair[0]]=(pair[1].slice(-1)=='"' || pair[1].slice(-1)=="'")?pair[1].substr(0,(pair[1].length-1)):pair[1];
		}		
		// get tag content
		if (v_s.indexOf("<",l_endprop)!=-1 && !l_nocontent){
			l_endtag=v_s.indexOf("<",l_endprop);
			if (v_s.substr(l_endtag,(v_tag.length+2))=="</"+v_tag){
				l_property["content"]=v_s.substr(l_endprop+1,l_endtag);
			} else {l_property["content"]="";}
		} else {l_property["content"]="";l_endtag=l_endprop;}
		l_resArray.push(l_property);
		l_starttag=l_endtag;
	}
	return l_resArray;
}
function _hesc(v_s){return htmlToText(v_s);}
function _args(v_s){
	v_s=(v_s)?v_s:window.location.search;
	if (v_s.substr(0,1)=='&'||v_s.substr(0,1)=='?') v_s=v_s.substr(1);
	var l_arr=v_s.split('&');
	var l_ret=[];
	for (var i=0;i<l_arr.length;i++){
		var pair=l_arr[i].split('=');
		l_ret[pair[0]]=pair[1];
	}
	return l_ret;
}
// Suppress unused blanks before string
function _trim(v_s){
	var l_ws=new String(" \t\n\r");
	var l_ret=new String(v_s);
	if (l_ws.indexOf(l_ret.charAt(0))!=-1){
		var l_i=0,l_l=l_ret.length;
		while (l_i<l_l && l_ws.indexOf(l_ret.charAt(l_i))!=-1){
			l_i++;
		}
		l_ret=l_ret.substring(l_i,l_l);
	}
	return l_ret;
}
//suppress HTML tags
function removeTags(v_s){
	return v_s.replace(/<\/?[^>]+(>|$)/g, "");
}
// Sort dates
function sortDate(a,b){
	if (a.date>b.date) return -1;
	if (a.date<b.date) return 1;
	return 0;
}
function sortId(a,b){
	if (a.id>b.id) return -1;
	if (a.id<b.id) return 1;
	return 0;
}
// Sorting function for bloc showing type
function blocSort(v_a,v_b){
	if (v_a.newcol<v_b.newcol) return -1;
	if (v_a.newcol>v_b.newcol) return 1;
	if (v_a.newpos<v_b.newpos) return -1;
	if (v_a.newpos>v_b.newpos) return 1;
	return 0;
}
// Sorting function for newspaper showing type
function newspaperSort(v_a,v_b){
	if (v_a.posj<v_b.posj) return -1;
	if (v_a.posj>v_b.posj) return 1;
	return 0;
}
// Activate a style sheet
function setActiveStyleSheet(v_css) {
	var l_link;
	for(var i=0;(l_link=document.getElementsByTagName("link")[i]);i++) {
		if(l_link.getAttribute("rel").indexOf("style") != -1 && l_link.getAttribute("title")) {
			l_link.disabled = true;
			if (l_link.getAttribute("title")=="style "+v_css) l_link.disabled = false;
		}
	}
	p_app.style=v_css;
	p_edit.oldStyle=v_css;
}
// Select the next style sheet
function nextstyle(){
	if (NS){p_alert.show(lg("msgOptNS"));}
	else {
		if (tab[p_tabs.sel].style==__themeNb) tab[p_tabs.sel].style=0;
		tab[p_tabs.sel].style++;
		setActiveStyleSheet(tab[p_tabs.sel].style);
		if (document.forms["option"] && document.forms["option"].selstyle) document.forms["option"].selstyle.value="style "+tab[p_tabs.sel].style;
	}
}
// Select the previous style sheet
function prevstyle(){
	if (NS){p_alert.show(lg("msgOptNS"));}
	else {
		if (tab[p_tabs.sel].style==1) tab[p_tabs.sel].style=__themeNb+1;
		tab[p_tabs.sel].style--;
		setActiveStyleSheet(tab[p_tabs.sel].style);
		if (document.forms["option"] && document.forms["option"].selstyle) document.forms["option"].selstyle.value="style "+tab[p_tabs.sel].style;
	}
}
// redirect to correct link depending on folder
function link(v_url,v_newpage,v_uselang){
	if (v_url==indef) v_url=window.location.href;
	if (v_uselang) v_url="../l10n/"+__lang+"/"+v_url;
	if (!ishttp(v_url)) v_url=pfolder+v_url;
	if (v_newpage){
		window.open(v_url);
	} else {
		window.location=v_url;
	}
	return false;
}
// simplified URL
function simpleUrl(v_url){
	if (v_url.indexOf("?")>0){v_url=v_url.substr(0,v_url.indexOf("?"));}
	if (v_url.indexOf("#")>0){v_url=v_url.substr(0,v_url.indexOf("#"));}
	return v_url;
}
function ishttp(url){
	return (url.substr(0,7)=="http://" || url.substr(0,8)=="https://");
}
function noinclusion(){
//	if (parent.frames.length!=0) top.location.href=document.location.href;
	if (parent.frames.length!=window.frames.length) top.location.href=document.location.href;
}
// Add to the bookmarks
function addFav(){
	var l_url=__LOCALFOLDER;
	//var l_url=simpleUrl(window.location.href);
	window.external.addfavorite(l_url,lg("msgFav"));
}
// Add URL as the starting page
function addHome(){
	var l_url=__LOCALFOLDER;
	document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(l_url);
}
// show new user help
function homebar(){
	var l_s="<table cellpadding='0' cellspacing='0' width='100%'><tr>";
	l_s+="<td valign='top' width='20%'><b class='tiphd'>1. Create Your Homepage</b><br /><br /> "+lg("lblAddMenuhelp")+"</td>";
	l_s+="<td class='lefthr' valign='top'  width='20%'><b class='tiphd'>2.  Remove Unwanted Modules</b><br /><br /> "+lg("lblEditMenu")+"</td>";
	l_s+="<td class='lefthr' valign='top'  width='20%'><b class='tiphd'>3. Add Modules You Want</b><br /><br /> "+lg("lblPosition")+"</td>";
	l_s+="<td class='lefthr' valign='top'  width='20%'><b class='tiphd'>4. Set Position of Modules</b><br /><br /> "+lg("lblSavehelp")+"<br /><br />"+"<a href='help.html' class='lightwindow page-options' params='lightwindow_type=external'><b>Learn how to customize your homepage</b></a>"+"</td>";
	l_s+="<td class='lefthr' valign='top'  width='20%'><b class='tiphd'>5. Access from Any Computer</b><br /><br /> "+lg("lblAccessAnywhere")+"</td>";
	l_s+="</tr></table>";
	navPrint("box",box(0,lg("lblBeginningWith")+"MySurfPad.com" +" - Your FREE Customizable Homepage!","hideBox()",l_s));
	navShow("box","block");
}
// Valid the input value
function validKeys(v_form){
	var l_value=v_form.searchtxt.value;
	if (l_value.substr(0,3)=='ex:' || l_value==''){p_alert.show(lg("msgKWInput"));return false;}
	else {
		var i=0,l_pos=0,l_newpos;
		while (l_value.indexOf(',',l_pos)!=-1){
			l_newpos=l_value.indexOf(',',l_pos);
			if (l_value.substring(l_pos,l_newpos)!='' && l_value.substring(l_pos,l_newpos)!=' '){i++;}
			l_pos=l_newpos+1;
		}
		if (l_value.substr(l_pos)!='' && l_value.substr(l_pos)!=' '){i++;}
		if (i<5){p_alert.show(lg("msgKWError"));return false;}
		else {
			v_form.searchtxt.value=formatSearch(l_value);
			return true;
		}
	}
}
// Show help messages
function help(v_id){
	var msg;
	switch(v_id){
		case 1:msg=lg("msgHelp1");break;
	}
	p_alert.show(msg);
	return false;
}
// open help box
function openHelp(){
	link("firstusage.html",true,true);
	return false;
}
function errorMsg(v_id){
	return lg("msgError"+v_id);
}
// format rss date
function rssDate(v_date){
	v_date=_trim(v_date);
	v_date=v_date.replace("CEST","CST");
	var l_formatedDate,l_try,l_date=new Date(v_date);
	if (isNaN(l_date)) {l_try=v_date.substr(0,12)+"20"+v_date.substr(12);l_date=new Date(l_try);}
	if (isNaN(l_date)) {l_try=v_date.substr(0,7)+"20"+v_date.substr(7);l_date=new Date(l_try);}
	if (isNaN(l_date)) {l_date=new Date(parseInt(v_date.substr(0,4),10),(parseInt(v_date.substr(5,7),10)-1),parseInt(v_date.substr(8,10),10),parseInt(v_date.substr(11,13),10),parseInt(v_date.substr(14,16),10),0);}
	if (isNaN(l_date)) {l_date=new Date(parseInt(v_date.substr(0,4),10),(parseInt(v_date.substr(5,7),10)-1),parseInt(v_date.substr(8,10),10));}
	if (isNaN(l_date)) {l_date=new Date(parseInt(v_date.substr(6,10),10),(parseInt(v_date.substr(3,5),10)-1),parseInt(v_date.substr(0,2),10));}
	//if not a valid date, date = yesterday
	if (isNaN(l_date)) {var l_nDate=new Date();l_formatedDate=new Date(l_nDate.getDate()-7,l_nDate.getMonth(),l_nDate.getYear());}
	else l_formatedDate=l_date;
	return l_formatedDate;
}
//format a javascript date
function formatDate(v_date){
	if (v_date==indef) return;
	var l_day=v_date.getDate();
	var l_month=v_date.getMonth()+1;
	var l_year=v_date.getFullYear();
	return (__lang=="fr"?l_day+"/"+l_month+"/"+l_year:l_month+"/"+l_day+"/"+l_year);
}
// Compute delai between a date and now
function dateDelai(v_date){
	if (v_date==indef) return;
	var now=new Date();
	var l_delai=(now.getTime()-v_date.getTime())/1000;
	if (l_delai<-1000) l_delai=864000;
	return l_delai;
}
// Format date range
function formatDelai(v_t){
	var l_ret="";
	if (!isNaN(v_t)){
		if (v_t<=60){ret=lg("lblThereIs")+"1 "+lg("lblMinute");}
		else if (v_t<=3600){l_ret=lg("lblThereIs")+Math.floor(v_t/60)+" "+lg("lblMinute");}
		else if (v_t<=86400){l_ret=lg("lblThereIs")+Math.floor(v_t/3600)+" "+lg("lblHour");}
		else {l_ret=lg("lblThereIs")+Math.floor(v_t/86400)+" "+lg("lblDay");}
	}
	return l_ret;
}
function dbDateFormat(v_day,v_month,v_year){
	v_month=("00").substr(0,2-v_month.length)+v_month;
	v_day=("00").substr(0,2-v_day.length)+v_day;
	return v_year+"-"+v_month+"-"+v_day;
}
function convertDateFromDb(v_date,v_useTime){
	var l_date=lg("onThe")+" "+(__lang=="fr"?v_date.substr(8,2)+"/"+v_date.substr(5,2):v_date.substr(5,2)+"/"+v_date.substr(8,2))+"/"+v_date.substr(0,4);
	if (v_useTime && v_date.substr(11,8)!="00:00:00")l_date+=" "+lg("at")+" "+v_date.substr(11,2)+"h"+v_date.substr(14,2);
	return l_date;
}
function openPage(v_p){
	if (v_p){
		p_pages.setCurrent(v_p);
		link("../portal/mypage.php?s="+v_p);
		//link("../portal/mypage.php?start="+v_p);
	}
}
function logout(){link(__LOCALFOLDER+"portal/scr_authentif.php?act=logout");}
// Return to connected homepage
function goIndex(){
	//window.location=((window.location.href).substr(0,((window.location.href).indexOf(".php")-1)))+"0.php";
	//link("../portal/mymodules.php");
	p_factory.init();
	return false;
}
function goArchive(){
	p_article.load();
	return false;
}
// Get session variable
function getSession(){
	var url=window.location.href;
	var l_p1=url.indexOf("page_")+5;
	var l_p2=url.indexOf("_",l_p1);
	return url.substring(l_p1,l_p2);
}
// Format user identifier
function shortName(v_n){
	if (v_n.indexOf("@")>0) {v_n=v_n.substr(0,(v_n.indexOf("@")));}
	return v_n;
}
function helpMove(){
	return img("ico_right_arrow.gif",6,9,"","imgmid")+lg("lblhelpMove");
}
function changePageTitle(v_title){
	if (v_title==indef) {v_title=p_tabs.currName+(tab[p_tabs.sel].nbUnread==0?"":" ("+tab[p_tabs.sel].nbUnread+")");}
	document.title=__apname+' :: '+v_title;
}
function getRadioValue(v_element){
	for (var i=0; i<v_element.length;i++) {
		if (v_element[i].checked) return v_element[i].value;
	}
	return false;
}
function getDebugCookie(){
	writeCookie('debug=Y',1);
	alert("Cookie installed !");
}
function debug(v_msg,v_type){
	if (__debugmode){
		if (getCookie("debug")=="Y"){
			if (_gel("debug")!=null){
				l_msg=textToHtml(v_msg);
				var l_style="";
				if (v_type==indef) v_type="info"
				switch(v_type){
					case "error":l_style="color: #ff0000";break;
					case "warning":l_style="color: orange";break;
				}
				var l_obj=_gel("debug");
				var l_date=new Date();
				l_obj.style.display="block";
				l_obj.innerHTML="<table cellpadding='0' cellspacing='0'><tr><td width='80' valign='top'>"+l_date.getHours()+":"+l_date.getMinutes()+":"+l_date.getSeconds()+"></td><td style='"+l_style+"'> "+l_msg+"</td></tr></table>"+l_obj.innerHTML;
			}
		}
	}
}
function getWindowWidth(){
	if(typeof(window.innerWidth)=='number'){
	    return window.innerWidth;
	} else if( document.documentElement && document.documentElement.clientWidth){
		return document.documentElement.clientWidth;
	  } else if( document.body && document.body.clientWidth){
		return document.body.clientWidth;
	}
}
function getWindowHeight(){
	if(typeof(window.innerHeight)=='number'){
	    return window.innerHeight;
	} else if(document.documentElement && document.documentElement.clientHeight){
		return document.documentElement.clientHeight;
	  } else if(document.body && document.body.clientHeight){
		return document.body.clientHeight;
	}
}
function addCssFile(v_css,v_title,v_rel){
	var l_head=document.getElementsByTagName("head")[0];
	if (l_head==indef) debug("no <head> tag in this page !");
	var l_css=document.createElement("link");
	l_css.href=v_css;
	l_css.rel=v_rel==indef?"stylesheet":v_rel;
	l_css.title=v_title==indef?"css":v_title;
	l_css.type="text/css";
	l_head.appendChild(l_css);
}
function inArray(v_arr,v_searched){
	for (var i=0;i<v_arr.length;i++){
		if (v_arr[i]==v_searched) return true;
	}
	return false;
}
function appIsWorking(v_status){
	if (v_status==indef) v_status=true;
	if (_gel("ajaxwork")==null && v_status){
		var l_obj=document.createElement("div");
		l_obj.id="ajaxwork";
		document.body.appendChild(l_obj);
		navWait("ajaxwork");
	}
	navShow("ajaxwork",(v_status?"block":"none"));
}
function clearTimer(v_timer){
	clearTimeout(v_timer);
	v_timer=0;
}
function correctMailEncoding(v_s){
	if (v_s.indexOf("?utf-8?")!=-1 || v_s.indexOf("?UTF-8?")!=-1){
		v_s=v_s.replace(/\=\?utf\-8\?Q\?/g,"");
		v_s=v_s.replace(/\=\?UTF\-8\?Q\?/g,"");
		v_s=v_s.replace(/\?\= /g,"");
		v_s=v_s.replace(/=C3=A9/g,"é");
		v_s=v_s.replace(/\_/g," ");
		v_s=v_s.replace(/\?\=/g,"");
	}
	if (v_s.indexOf("-8859-1?")!=-1){
		v_s=v_s.replace(/\=\?ISO-8859-1\?Q\?/g,"");
		v_s=v_s.replace(/\=\?iso-8859-1\?Q\?/g,"");
		v_s=v_s.replace(/\?\= /g,"");
		v_s=v_s.replace(/\=E9/g,"é");
		v_s=v_s.replace(/\=E0/g,"à");
		v_s=v_s.replace(/\=E8/g,"è");
		v_s=v_s.replace(/\=28/g,"(");
		v_s=v_s.replace(/\=29/g,")");
		v_s=v_s.replace(/\=20/g," ");
		v_s=v_s.replace(/\=3A/g,":");
		v_s=v_s.replace(/\=25/g,"€");
		v_s=v_s.replace(/\=BA/g,"°");
		v_s=v_s.replace(/\_/g," ");
		v_s=v_s.replace(/\?\=/g,"");
	}
	return v_s;
}

//======================================================================================================================
//==                            AJAX STUFF
//======================================================================================================================

/* Get XML results
** Inputs :
** - v_url (string) : url of the XML page containing data to retrieve
** - fct(function) : callback function that will treat the results. responseXML and fct_vars are the arguments sent to this function.
** - v_fctvars (string) : arguments sent to the callback function
** - v_type (string) : "xml"=return xml, "html"=return text
** - v_vars(string) : variables sent to the xml page
** - v_method (string) : "post"=send v_vars as post variables, "get" ...
** - v_escapefct (function) : function called if XML page loading does not work
** Returns : error number
*/
function getXml(v_url,fct,v_fctvars,v_type,v_vars,v_method,v_escapefct){
	var xmlhttp=null;
	if (v_type==indef) v_type="xml";
	if (v_method==indef) v_method="GET";
	if (!pfolder) {pfolder="";}

	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {debug(lg("msgXMLmissing"));}
	
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {// only if req shows "loaded"
			if (xmlhttp.status >= 400) {
				debug("Xml file not read : "+v_url+" (status "+xmlhttp.status+")","error");
				debug("Content read : "+xmlhttp.responseText,"error");
				if (v_escapefct!=indef) v_escapefct();
				else p_connection.errorTest();
			} else {
				var l_ret=(v_type=="xml")?xmlhttp.responseXML:xmlhttp.responseText;
				fct(l_ret,v_fctvars);
			}
		}
	}

	//if rss feed, check proxy settings
	if (v_vars!=indef && getVar(v_vars,"rssurl")!="" && __proxypacfile!=""){
		v_vars+="&proxy="+getProxy(getVar(v_vars,"rssurl"));
	}

	// if url not on the same domain, use tunnel
	if (ishttp(v_url)){
		//if file is located on the current server
		if (v_url.substr(7,(location.hostname).length)==location.hostname) {l_feed=v_url;}
		else {
			if (__useproxy){
				if (__proxypacfile=="")	l_feed=pfolder+"../tools/xmltunproxy.php?url="+v_url;
				else {
					if (getProxy(v_url)==""){
						l_feed=pfolder+"../tools/xmltun.php?type="+v_type+"&url="+v_url;
					} else {
						l_feed=pfolder+"../tools/xmltunproxypac.php?url="+v_url+"&proxy="+getProxy(v_url);
					}
				}			
			} else {
				if (v_vars==indef || getVar(v_vars,"auth")==""){
					l_feed=pfolder+"../tools/xmltun.php?type="+v_type+"&url="+v_url;
				} else {
					l_feed=pfolder+"../tools/xmltunauth.php?type="+v_type+"&auth="+getVar(v_vars,"auth")+"&url="+v_url;
				}
			}
		}
	} else {
		l_feed=v_url.substr(0,3)=="../"?v_url:pfolder+v_url;
	}
	xmlhttp.open(v_method,l_feed, true);
	if (v_method=="GET"){
		xmlhttp.send(null);
	} else {
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.send(v_vars);
	}
	//debug (need to activate debug mode)
	debug("read "+v_type+" : "+l_feed+" (variables: "+v_vars+")");
}
/* Execute PHP script with XML file
** Inputs :
** - v_scr (string) : php script (located by default on /portal folder
** - v_vars (string) : post variables sent to the scripts
** - v_alarm(boolean) : define if the alert return by script is displayed in the user page
** - v_forced (boolean) : define if the script is executed when user is not connected
** - fct (function) : callback function, called at the end of the script processing
** Returns : error number
*/
function executescr(v_scr,v_vars,v_alarm,v_forced,fct){
	var l_noerror=true,l_msg,l_err;
	if (allowSave||v_forced){
		appIsWorking();
		var xmlhttp=null;
		if (window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else {p_alert.show(lg("msgXMLnav"));l_noerror=false;}
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {// only if req shows "loaded"
				if (xmlhttp.status >= 400) {
					debug("Xml file not read : "+v_scr,"error");
					p_connection.errorTest();
					l_noerror=false;
				} else {
					if (xmlhttp.responseXML.getElementsByTagName("status")[0]){
						if (xmlhttp.responseXML.getElementsByTagName("msg")[0]) var l_msg=getXMLval(xmlhttp.responseXML,"msg","str",false,lg("msgXMLerror")+"(1)");
						if (xmlhttp.responseXML.getElementsByTagName("err")[0]) var l_err=getXMLval(xmlhttp.responseXML,"err","str",false,lg("msgXMLerror")+"(2)");
						if (xmlhttp.responseXML.getElementsByTagName("ret")[0]) var l_ret=xmlhttp.responseXML.getElementsByTagName("ret")[0].firstChild.nodeValue;
						if (v_alarm&&l_msg){p_alert.show(lg(l_msg),1)}
						if (v_alarm&&l_err){p_alert.show(lg(l_err),3)}
						if (fct && !l_err) {if (l_ret){fct(l_ret);}else{fct();};}
					} else {
						debug("Xml file not correct : "+v_scr,"error");
						debug("Content read or status tag missing : "+xmlhttp.responseText,"error");
						l_noerror=false;
					}
				}
				appIsWorking(false);
			}
		}
		var l_feed=pfolder+v_scr;
//if (!IE) {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");}
		xmlhttp.open("POST",l_feed, true);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//alert(l_feed+" : "+v_vars);
		xmlhttp.send(v_vars);
	} else {var l_feed=pfolder+v_scr;}
	//debug
	debug("execute : "+l_feed+" (variables: "+v_vars+")");
	return l_noerror;
}
function getXMLprop(v_item,v_name,v_type,v_required,v_default){
	if (v_default==indef) v_default="";
	if (v_required&&!v_item.getAttribute(v_name)){p_alert.show(lg("msgModuleIssue"));return v_default;}
	var l_prop=(v_item.getAttribute(v_name))?v_item.getAttribute(v_name):v_default;
	if (v_type=="int") l_prop=parseInt(l_prop,10);
	return l_prop;
}
function getXMLval(v_item,v_name,v_type,v_required,v_default){
	if (v_default==indef) v_default="";
	var l_node=v_item.getElementsByTagName(v_name)[0];
	if (!l_node||!l_node.firstChild||!l_node.firstChild.nodeValue){
		if (v_required) p_alert.show(lg("msgModuleIssue"));
		return v_default;
	} else {
		//if there is a space between xml tag and xml value
		var inc=0;
//		while (l_node.firstChild!=null&&l_node.firstChild.nodeType==3&&(l_node.firstChild.nodeValue.charCodeAt(0)==10 || l_node.firstChild.nodeValue.charCodeAt(0)==67)&&inc<20) {(l_node.firstChild.nodeValue).substr(1);inc++;}
		while (l_node.firstChild!=null&&l_node.firstChild.nodeType==3&&l_node.firstChild.nodeValue.charCodeAt(0)==10&&inc<5) {l_node.removeChild(l_node.firstChild);inc++;}
		if (l_node.firstChild==null){var l_val="";}
		else {
			var l_val=(l_node.firstChild.nodeValue)?l_node.firstChild.nodeValue:v_default;
			if (v_type=="int") l_val=parseInt(l_val,10);
		}
		return l_val;
	}
}

//=============================================================================================================
//==					OBJECTS CREATION & METHODS
//=============================================================================================================

// Pages Tab class
function tabObj(id,label,type,fct,lock,seq,editable,movable,icon,loadstart){
	if (lock==indef) lock="";
	this.id=id;
	this.label=label;
	this.type=type;
	this.fct=fct;
	//lock = the tab is lockable or not ?
	this.lock=lock;
	this.seq=seq;
	this.editable=editable;
	this.movable=movable;
	this.icon=icon;
	this.loadstart=(loadstart==indef?0:loadstart);
	//added 1.4 to manage these information at tab level
	this.isLoaded=indef;
	this.maxUniq=0;
	this.root={};
	this.controls="Y";
	this.moduleAlign=__moduleAlignDefault;
	this.style=1;
	this.showType=0;
	this.colnb=3;
	this.newspapernb=20;
	this.usereader=(__usereader?1:0);
	this.moveIsInit=false;
	this.nbUnread=0;
	//locked = current lock status of a tab
	this.locked=false;
	this.module=[];
	this.feeds=[];
	this.cols=[];
}

// Module class (col=column / pos=position in the column / minModSize=size mini of the module / updModSize=is the module resizable / x=left position / y=top position / rank=uniq id of the module)
function moduleObj(col,pos,posj,height,id,link,name,vars,minModSize,updModSize,size,url,x,y,uniq_db,format,nbvars,tab,blocked,minimize,usereader,autorefresh,icon,isLoaded,header,footer,auth){
	this.col=col;
	this.pos=pos;
	this.posj=posj;
	this.height=height;
	this.size=size;
	this.id=id;
	this.link=link;
	this.name=name;
	this.vars=vars;
	this.minModSize=minModSize;
	this.updModSize=updModSize;
	this.url=url;
	this.y=y;
	this.x=x;
	this.uniq=uniq_db;
	this.format=format;
	this.newcol=col;
	this.newpos=pos;
	this.newposj=posj;
	this.newx=x;
	this.newy=y;
	this.nbvars=nbvars;
	this.tab=(tab==indef)?0:tab;
	this.blocked=(blocked && blocked==1)?true:false;
	this.minimized=(minimize && minimize==1)?true:false;
	this.usereader=(usereader && usereader==1)?true:false;
	this.autorefresh=(autorefresh && autorefresh==1)?true:false;
	this.icon=(icon==indef)?"box0_"+this.id+".ico":icon;
	this.isLoaded=isLoaded;
	this.header=header;
	this.footer=footer;
	this.create=create;
	this.destruct=destruct;
	this.show=showMod;
	this.hide=hideMod;
	this.refresh=refreshMod;
	this.changeVar=changeVar;
	this.placeinCol=placeinCol;
	this.placeonTop=placeonTop;
	this.setHeight=modSetHeight;
	this.hdrColor=modHdrColor;
	this.getIcon=modGetIcon;
	this.nbunread=0;
	this.auth=auth;
}
// RSS article class
function feedObj(id,modId,modUniq,modName,title,link,image,date,desc,read){
	this.id=id;
	this.modId=modId;
	this.modUniq=modUniq;
	this.modName=modName;
	this.title=title;
	this.link=link;
	this.image=image;
	this.date=date;
	this.desc=desc;
	this.read=(read==indef?0:read);
}

// Module creation method
function create(){
	var l_tabPos=idToPos(this.tab);
	var l_obj=null;
	l_obj=document.createElement("div");
	l_obj.style.display="none";
	//place new modules
	if (this.uniq==0) {tab[l_tabPos].maxUniq++;this.uniq=tab[l_tabPos].maxUniq;changeUniq(uniqToId(this.uniq,l_tabPos),this.uniq);}
	//use tab.id because it do not change even if the tab is moved
	l_obj.id="module"+this.tab+"_"+this.uniq;
	l_obj.className="module";
	if (tab[l_tabPos].moduleAlign){
		l_obj.style.position="relative";
	} else {
		l_obj.style.position="absolute";
		l_obj.style.width=this.minModSize+"px";
		l_obj.style.left=this.x+"px";
		l_obj.style.top=this.y+"px";
	}
	//attach DIV to the corresponding column. if new module this.col=0 => col[0] need to be created
	if (tab[l_tabPos].moduleAlign){
		if (this.col!=-1){
			if (tab[l_tabPos].showType==0 || this.col==0){tab[l_tabPos].cols[this.col].appendChild(l_obj);} else {tab[l_tabPos].cols[1].appendChild(l_obj);}
		} else {(_gel("col1")).appendChild(l_obj);}
	} else {(tab[l_tabPos].root).appendChild(l_obj);}
	var l_s="<table id='bmod"+this.tab+"_"+this.uniq+"' class='bmod' cellspacing='0' cellpadding='0' width='100%'><tbody><tr><td class='headmod' onmouseover='showmodoptions("+this.uniq+",true)' onmouseout='showmodoptions("+this.uniq+",false)'>";
	l_s+="<table id='hmod"+this.tab+"_"+this.uniq+"' class='hmod' cellpadding='0' cellspacing='0' width='100%'><tr><td width='100%'><div class='titmod' id='module"+this.tab+"_"+this.uniq+"_h'>"+this.name+"</div></td>";
	//l_s+="<td class='optmod' id='module"+this.uniq+"_o' nowrap='nowrap'>";
	l_s+="<td class='optmodhide' id='module"+this.tab+"_"+this.uniq+"_o'><div class='optmoda' id='module"+this.tab+"_"+this.uniq+"_o' nowrap='nowrap'>";
	if (this.nbvars>0 || __barcolnb>1) l_s+="<a href='#' onclick='return p_param.show("+this.uniq+");'>"+lg("lblConfigure")+"</a>&nbsp;";
	if (jsid!=0&&__useSharing) l_s+="<a href='#' onclick='p_friends.menu(3,uniqToId("+this.uniq+"))'>"+img("ico_bar_share.gif",11,9,lg("lblShareModule"))+"</a>&nbsp;";
	l_s+="<a href='#' onclick='return tab[p_tabs.sel].module[uniqToId("+this.uniq+")].refresh(0);'>"+img("ico_refresh.gif",13,9,lg("lblRefresh"))+"</a>&nbsp;";
	if (!this.blocked) l_s+="<a href='#' onclick='p_area.module.minimize("+this.uniq+");return false'>"+img((this.minimized?"ico_maximize.gif":"ico_minimize.gif"),11,9,"minimize","","imgminimize"+this.uniq)+"</a>&nbsp;";
	if (!this.blocked) l_s+="<a href='#' onclick='p_area.module.suppress("+this.uniq+",true);return false'>"+img("ico_close.gif",9,9,lg("lblSuppress"))+"</a>&nbsp;";
	l_s+="&nbsp;</div></td><td class='righttopcornermod'>&nbsp;</td></tr></table>";
	l_s+="<div id='editbar"+this.tab+"_"+this.uniq+"' class='editbox'></div>";
	l_s+="</td></tr><tr><td class='contentborder'><div class='content' id='module"+this.tab+"_"+this.uniq+"_i'>";
	l_s+="<table border='0' cellpadding='0' cellspacing='0' align='center' width='100%'><tr><td id='module"+this.tab+"_"+this.uniq+"_c'"+(this.minimized?" style='display:none'":"")+">";
	if (this.format=="I") l_s+="<iframe id='modfram"+this.tab+"_"+this.uniq+"' src='"+this.url+"pid="+jsid+"&prof="+this.tab+"&p="+this.uniq+"&"+this.vars+"' frameborder='no' marginwidth='0' marginheight='0' scrolling='no' style='height:"+this.height+"px;width:100%;z-index:auto;'>Issue with module display.<a href='../portal/contact.php' target='_blank'>Contact us</a></iframe><br />";
//	if (this.format=="H") l_s+="<IFRAME id='modfram"+this.uniq+"' src='"+pfolder+"empty_module.html' frameborder=NO marginwidth=0 marginheight=0 scrolling=NO style='height:"+this.height+"px;width:100%;z-index:auto;'>Issue with module display.<A href='../portal/contact.php' target='_blank'>Contact us</A></IFRAME><BR />";
	if (this.format=="H") l_s+="<iframe id='modfram"+this.tab+"_"+this.uniq+"' src='' frameborder='no' marginwidth='0' marginheight='0' scrolling='no' style='height:"+this.height+"px;width:100%;z-index:auto;'>Issue with module display.<a href='../portal/contact.php' target='_blank'>Contact us</a></iframe><br />";
	if (this.format=="R"||this.format=="M") l_s+=lg("lblLoading");
	//force module minimal width
	l_s+="<div style='height:1px'>"+img("s.gif",this.minModSize,1)+"</div>";
	l_s+="</td></tr></table>";
	if (__useNotation&&jsid>0) l_s+=p_notation.buildBlock(this.uniq);
	l_s+="</td></tr></tbody></table>";
	//be carefull : if the module is generated in a <FORM> tag, there will be a bug in the next line
	l_obj.innerHTML=l_s;

	//check if authentified feed or not
	var l_vars=this.vars;
	this.auth=(l_vars.indexOf("auth=")!=-1 || (l_vars.indexOf("user=")!=-1 && l_vars.indexOf("pass=")!=-1))?true:false;
		
	//load the content
	if (this.format=="R") p_rss.refresh(uniqToId(this.uniq,l_tabPos),l_tabPos);
	if (this.format=="M") refreshModCont(uniqToId(this.uniq,l_tabPos),l_tabPos);
//	if (this.format=="H") refreshHtmlCont(uniqToId(this.uniq));
	if (this.format=="I"){
		if (this.nbvars>0) p_param.getModuleParam(uniqToId(this.uniq,l_tabPos),l_tabPos);
		else if (__barcolnb>1) p_param.fillEditBox(indef,this.uniq,l_tabPos);
	}
	this.hdrColor();
	this.getIcon();
}
// Destruct a module
function destruct(){
	var l_obj=document.getElementById("module"+this.tab+"_"+this.uniq);
	var l_col=this.newcol,l_tabPos=idToPos(this.tab);
	if (tab[l_tabPos].showType==1 && this.newcol!=0) l_col=1;
	if (tab[l_tabPos].moduleAlign){
		tab[l_tabPos].cols[l_col].removeChild(l_obj);
	} else {
		tab[l_tabPos].root.removeChild(l_obj);
	}
}
// Module refresh method
function refreshMod(v_act){
	var l_tabPos=idToPos(this.tab);
	var l_id=uniqToId(this.uniq,l_tabPos);
	tab[l_tabPos].module[l_id].isLoaded=false;
	if (this.format=="I"){var l_obj=_gel("modfram"+tab[l_tabPos].id+"_"+this.uniq);l_obj.src=tab[l_tabPos].module[l_id].url+"pid="+jsid+"&prof="+tab[l_tabPos].id+"&p="+tab[l_tabPos].module[l_id].uniq+"&"+tab[l_tabPos].module[l_id].vars;}
	if (this.format=="R"){p_area.module.supFeed(this.uniq,l_tabPos);p_rss.refresh(l_id,l_tabPos);}
	if (this.format=="M"){refreshModCont(l_id,l_tabPos);}
	return false;
}
// Place a module on top of a column
function placeonTop(){
	//change the position of the modules that are placed in the destination column
	var l_tabPos=idToPos(this.tab);
	for (var i=0;i<tab[l_tabPos].module.length;i++){
		if (tab[l_tabPos].module[i].newcol==this.newcol) tab[l_tabPos].module[i].newpos+=1;
		if (this.format!='R' && tab[l_tabPos].module[i].format!='R') tab[l_tabPos].module[i].newposj++;
	}
	//set the position of the module added (usefull ?? treated before ??)
	this.newpos=1
	
	if (tab[l_tabPos].showType==0){var l_col=this.newcol;}else{var l_col=1;}
	if (_gel("module"+this.tab+"_"+this.uniq)!=null){
		var l_movedMod=_gel("module"+this.tab+"_"+this.uniq);
		if (tab[l_tabPos].moduleAlign){
			var l_firstInCol=tab[l_tabPos].cols[l_col].firstChild;
			if (tab[l_tabPos].showType==0 || this.format!='R'){
				tab[l_tabPos].cols[l_col].insertBefore(l_movedMod,l_firstInCol);
				initMove(l_movedMod,"module",tab[l_tabPos].cols,"multidim",true,l_tabPos);
			}
			else {p_newspaper.show(true);}
		} else {
			tab[l_tabPos].root.appendChild(l_movedMod);
			initMove(l_movedMod,"module",tab[l_tabPos].root,"multidim",true,l_tabPos);
		}
	}
}
// Place a module on top of a column
function placeinCol(v_col,v_tab){
	if (v_tab==indef) v_tab=p_tabs.sel;
	if (!maxModReached()) {
		this.newcol=v_col;
		this.placeonTop();
		if (tab[v_tab].controls=='Y') {p_area.module.showHdr(v_tab);}
//p_area.resize();
		var l_vars=[];
		l_vars[0]=v_col;
		saveChanges(l_vars,indef,v_tab);
	}
}
//set module height
function modSetHeight(v_height){
	navHeight("modfram"+this.tab+"_"+this.uniq,v_height);
}
function _IG_AdjustIFrameHeight(){
	var l_height;
	if (document.height){
		l_height=document.height;
	} else if (document.all) {
		if (document.compatMode && document.compatMode != 'BackCompat') {
			l_height=document.documentElement.scrollHeight + 5;
		} else {
			l_height = document.body.scrollHeight + 5;
		}
	} 
	if (navigator.appName=="Netscape")
	{	 top.outerHeight=l_height;} 
	else top.resizeTo(400,l_height);
}
// Change a module or all module variable
function changeVar(v_var,v_value){
	var l_oldVars=this.vars;
	if (v_var==""){l_newVars=v_value;}
	else {
		var l_oldValue=getVar(l_oldVars,v_var);
		var l_newVars=l_oldVars.replace(v_var+"="+l_oldValue+"&","").replace("&"+v_var+"="+l_oldValue,"").replace(v_var+"="+l_oldValue,"");
		l_newVars=(l_newVars=="")?(v_var+"="+v_value):(l_newVars+"&"+v_var+"="+v_value);
	}
	this.vars=l_newVars;
	//record changes in DB
	if (l_oldVars!=l_newVars) executescr("scr_savevar.php","prof="+jsprof+"&un="+this.uniq+"&vars="+_esc(l_newVars),false);
}
// Module display - called when modules are loaded
function showMod(){navShow('module'+this.tab+"_"+this.uniq,"block");}
function hideMod(){navShow('module'+this.tab+"_"+this.uniq,"none");}
//change module header color
function modHdrColor(v_uniq,v_style){
	if (!v_uniq) v_uniq=this.uniq;
	if (!v_style) v_style=getVar(this.vars,"bcolor");
	var l_obj=_gel("module"+this.tab+"_"+v_uniq);
	l_obj.className="module"+v_style;
}
function modGetIcon(){
	if (getVar(this.vars,"icon")!=""){
		this.icon=getVar(this.vars,"icon");
	}
//	else {
//		this.icon"box0_"+this.id+".gif";
//	}
}
// show / hide modules options  BUG: let the function name in lowercase
function showmodoptions(v_uniq,v_status){
	var l_obj=_gel("module"+tab[p_tabs.sel].id+"_"+v_uniq+"_o");
	if (l_obj) l_obj.className=(v_status?"optmoda":"optmodhide");
}

// Modules preferences
function _IG_Prefs(uniq){
	this.uniq=uniq;
	this.id=uniqToId(uniq);
	this.vars=tab[p_tabs.sel].module[this.id].vars;
	this.getString=getString;
	this.getInt=getInt;
	this.getBool=getBool;
	this.set=setPrefVal;
	this.open=openPref;
}
function getString(v_var){
	return getVar(this.vars,v_var);
}
function getInt(v_var){
	return parseInt(getVar(this.vars,v_var),10);
}
function getBool(v_var){
	return (getVar(this.vars,v_var)==1?true:false);
}
function setPrefVal(v_var,v_value){
	tab[p_tabs.sel].module[this.id].changeVar(v_var,v_value);
	//avoid this process in testmodule
	if ((window.location.href).indexOf("testmodule.php")==-1) p_param.getModuleParam(this.id);
//	module[this.id].refresh();
}
function openPref(){}
//tabs management
function _IG_Tabs(v_id,v_selTab){
	this.moduleId=v_id;
	this.selTab=v_selTab;
	this.addTab=addTab;
	this.addDynamicTab=addDynamicTab;
	this.setSelectedTab=setSelectedTab;
	this.moveTab=moveTab;
	this.tabsContainer=null;
	this.ulObj=null;
}
function addTab(v_name,v_divId,v_fct){
	//define default tab if not already defined
	if (this.selTab==indef) this.selTab=v_name;
	//create tabs div if not already existing
	if (this.tabsContainer==null){
		this.tabsContainer=document.createElement("div");
		this.tabsContainer.id="tabsdiv";
		document.body.appendChild(this.tabsContainer);
	}
	//create content div if not already existing
	if (v_divId==indef) v_divId="contentdiv";
	if (_gel(v_divId)==null){
		var l_obj=document.createElement("div");
		l_obj.id=v_divId;
		document.body.appendChild(l_obj);
	} else {var l_obj=_gel(v_divId);}
	//create ul obj if not already existing
	if (this.ulObj==null){
		this.ulObj=document.createElement("ul");
		this.ulObj.className="tablist";
		this.tabsContainer.appendChild(this.ulObj);
	}
	//add the new tab
	var l_liObj=document.createElement("li");
	l_liObj.className=(this.selTab==v_name)?"tabsel":"tab";
	l_liObj.id=v_name;
	
	//l_liObj.innerHTML="<a href='#' onclick=\"changeSelectedTab('',)\">"+v_name+"</a>";
	l_aObj = document.createElement("a");
    l_aObj.appendChild(document.createTextNode(v_name));
    l_aObj.href = "javascript:void(null);";
    l_aObj.title = v_name;
	l_aObj.main = this;
	l_aObj.selDiv = v_divId;
	l_aObj.fct = v_fct;
    l_aObj.onmouseup = function(){changeSelectedTab(this.title,this.main);this.fct(this.selDiv);};
	//l_aObj.click=v_fct;
	l_liObj.appendChild(l_aObj);
	this.ulObj.appendChild(l_liObj);
	
	if (this.selTab==v_name) v_fct(v_divId);
	
	return l_obj;
}
function addDynamicTab(v_name,v_fct){
	addTab(v_name,indef,v_fct);
}
function setSelectedTab(v_index){
	//define selected tab
	for (var i=0;i<this.ulObj.childNodes.length;i++){
		var l_node=this.ulObj.childNodes[i];
		l_node.className=(i==v_index?"tabsel":"tab");
	}
}
function changeSelectedTab(v_name,v_obj){
	v_obj.selTab=v_name;
	for (var i=0;i<v_obj.ulObj.childNodes.length;i++){
		var l_node=v_obj.ulObj.childNodes[i];
		if (l_node.id==v_name) v_obj.setSelectedTab(i);
	}
}
function moveTab(){}

//Callback function
function _IG_Callback(v_fct,v1,v2,v3,v4,v5){
	var args=arguments;
	return function(){
		var l_vars=[];
		for(var i=0;i<arguments.length;i++){
			l_vars[l_vars.length]=arguments[i];
		}
		for(var i=1;i<args.length;i++){
			l_vars[l_vars.length]=args[i];
		}
		v_fct.apply(null,l_vars);
	}
}

//=============================================================================================================
//==					PORTAL MANAGEMENT
//=============================================================================================================

// Manage portal objects
var p_app={
	style:0,
	/*
		init : init the application
	*/
	init:function(){
		// load all themes of the application
		p_app.loadStyles();
		p_app.loadTabs();
		p_app.footer();
	},
	/*
		loadStyles : load available css (depending on themeNb define in adm_config table)
	*/
	loadStyles:function(){
		for (var i=1;i<=__themeNb;i++){
			addCssFile("../styles/main"+i+".css","style "+i,"alternate stylesheet");
		}
	},
	loadTabs:function(v_prof,v_locked){
		var l_tabXml=(jsid==0)?"selections/tabs.xml":"xmltabs.php";
		if (dumtab!=indef) l_tabXml+="?dumtab="+dumtab.label+"&dumicon="+dumtab.icon;
		var l_locked=v_locked?true:false;
		getXml(l_tabXml,p_app.initTabs,jsprof);
	},
	initTabs:function(response,vars){
	//var checkProf=-1;
		p_tabs.init(response);
		//check if selected profile is existing -> if not set the first one as selected
	//if (checkProf==-1){
	//	if (tab[0]){vars[1]=tab[0].id;}
	//	else {p_tabs.sel=-1;vars[1]=-1;}
	//}
//		if (p_tabs.sel!=indef){p_tabs.create(p_tabs.sel,vars[0]);}else{p_tabs.create();}
	//p_tabs.create(p_tabs.sel,vars[0],false,vars[1]);
		if (p_tabs.sel==indef) p_tabs.sel=-1;
		//if new tab, get the id
		if (p_tabs.sel==999) p_tabs.sel=p_tabs.getId(vars);
		p_tabs.create(p_tabs.sel);
		if (p_tabs.sel==-1){p_app.openHome(vars);}
		else {p_pages.change(vars);}
		if (tab.length!=0){
	//if (jsid==0 || tab[p_tabs.sel].id==0 || tab[p_tabs.sel].id>=1000){
	//	p_area.load("selections/page"+jsprof+".xml");
	//} else if (jsprof!=0){
	//	p_area.load("xmlmodules.php","id="+jsprof,idToPos(jsprof));
	//}
			setTimeout("p_pages.loadOnStart()",2000);
		} else {loading(false);setActiveStyleSheet(1);}
	},
	openHome:function(v_prof){
		var l_div=[];
		//get tab id
		p_tabs.sel=p_tabs.getId(v_prof);
		//action depend on if the user is connected or not 
		if (jsid==0 || tab[p_tabs.sel].id==0 || tab[p_tabs.sel].id>=1000){
			for (var i=0;i<__homeDivs.length;i++){
				if (__homeDivs[i]["anonymous"])	l_div.push(i);
			}
			if (l_div.length>0){
				p_app.displayFeaturedHome(l_div);
			} else {
				if (p_tabs.sel==-1 && tab[0]) p_tabs.sel=0;
				p_area.load("selections/page"+jsprof+".xml");
			}
		} else {
			for (var i=0;i<__homeDivs.length;i++){
				if (__homeDivs[i]["connected"])	l_div.push(i);
			}
			if (l_div.length>0){
				jsprof=0;
				p_app.displayFeaturedHome(l_div);
			} else {
				if (p_tabs.sel==-1 && tab[0]) p_tabs.sel=0;
				if (jsprof!=0) p_area.load("xmlmodules.php","id="+jsprof,idToPos(jsprof));
			}
		}
		return false;
	},
	displayFeaturedHome:function(v_div){
		var l_s="<table width='100%'><tr>"
		for (var i=0;i<v_div.length;i++){
			l_s+="<td id='homediv"+i+"' valign='top'></td>";
			if (i>0 && __homeDivs[v_div[i-1]]["pos"]!=__homeDivs[v_div[i]]["pos"]) l_s+="</tr><tr>";
		}
		l_s+="</tr></table>";
		p_plugin.open();
		p_plugin.init();
		p_plugin.menu(new Array({"id":1,"title":"home","icon":"","fct":"","isLink":false}));
		p_plugin.content(l_s);
		navShow("loading","none");
		setActiveStyleSheet(1);
		changePageTitle(lg("home"));
		for (var i=0;i<v_div.length;i++){
			navPrint("homediv"+i,eval(__homeDivs[v_div[i]]["fct"]));
		}
	},
	footer:function(){
		navPrint("footer",__footer);
	}
}
var p_tabs={
	isInit:false,
	sel:indef,
	currName:"",
	overtabid:-1,
	currHeadLink:{},
	locked:false,
	/*
		init : create the tabs objects
		inputs :
			response : xml response containing tabs information
	*/
	init:function(response){
		var i=0,result;
		while (response.getElementsByTagName("tab")[i]){
			if (i>=tab.length || tab[i].isLoaded==indef){
				result=response.getElementsByTagName("tab")[i];
				tab[i]=new tabObj(getXMLval(result,"number","int",false,0),getXMLval(result,"name","str",false,"..."),getXMLval(result,"type","str",false,"P"),getXMLval(result,"action","str",false,""),getXMLval(result,"locked","int",false,0),getXMLval(result,"seq","int",false,0),getXMLval(result,"edit","int",false,0),getXMLval(result,"move","int",false,0),getXMLval(result,"icon","str",false,""),getXMLval(result,"loadstart","int",false,0));
			}
			i++;
		}
	},
	select:function(v_tab){
		p_tabs.create(v_tab);
	},
	refresh:function(v_tab){
		p_tabs.create(v_tab);
	},
	create:function(v_id,v_locked,v_stopMove,v_prof){
		// Create the pages tab
		if (v_locked==indef) v_locked=p_tabs.locked;
		var l_movable=!v_stopMove;
		var l_s="";
//		if (jsid>=0) l_s+="<div style='height:27px;margin:4px;' width='100%' align='right' valign='center'>";
		l_s+="<div id='headlink'>";
		if (jsid>0) l_s+=lg("lblHello")+" <a class='u' href='#' onclick='"+(v_locked?"":"p_network.myprofile()")+"'>"+shortName(jsusername)+"</a> | ";
		if (jsid<0) l_s+="<b>"+lg("admin")+"</b> | ";
		//for (var i=0;i<headlinks.length;i++){
		//	if ((headlinks[i].anonymous && jsid==0) || (headlinks[i].connected && jsid>0) || (headlinks[i].admin && jsid==-1)){l_s+='<a class="'+headlinks[i].clss+'" title="'+headlinks[i].comment+'" href="#"'+(headlinks[i].options.length==0?' onclick="'+headlinks[i].fct+'" onmouseover="p_tabs.showHeadMenu(false)"':' onmouseover="p_tabs.initHeadMenu(this,'+i+')"')+'>'+(headlinks[i].image==''?'':img(headlinks[i].image,false,false,headlinks[i].comment,"imgmid")+' ')+headlinks[i].label+'</a> | ';}
		//}
		for (var i=0;i<__headmenu.length;i++){
			if ((__headmenu[i]["anonymous"] && jsid==0) || (__headmenu[i]["connected"] && jsid>0) || (__headmenu[i]["admin"] && jsid==-1)){l_s+='<a class="'+__headmenu[i]["clss"]+'" title="'+lg(__headmenu[i]["comment"])+'" href="#"'+(__headmenu[i]["options"].length==0?' onclick="'+__headmenu[i]["fct"]+'" onmouseover="p_tabs.showHeadMenu(false)"':' onmouseover="p_tabs.initHeadMenu(this,'+i+')"')+'>'+(__headmenu[i]["images"]==''?'':img(__headmenu[i]["images"],false,false,lg(__headmenu[i]["comment"]),"imgmid")+' ')+lg(__headmenu[i]["label"])+'</a>  ';}
		}
		//suppress ending separator
		if (__headmenu.length>0) l_s=l_s.substr(0,(l_s.length-2));
		
		l_s+="</div><table id='alltabs' cellpadding='0' cellspacing='0'><tr><td class='endtab' style='padding: 6px;'><a href='#' id='leftTabNav' onmouseover='p_tabs.nav.left();' onmouseout='p_tabs.nav.stop();'>"+img("ico_previous.gif",7,9)+"</a></td>";
		l_s+="<td valign='bottom' width='100%'><div id='navfixedbox'><div id='navfloatbox'><div id='navmovebox'><table cellpadding='0' cellspacing='0' width='100%'><tr><td style='font-size:1px;line-height:0px;'><img id='navctlimg' src='../images/s.gif' width='100%' style='height:1px' /></td></tr><tr><td><table cellpadding='0' cellspacing='0'><tr>";
		var i=0,firstMovingTab=true;
		while (i<tab.length){
			//if selected tab in not yet defined
			if (v_id==indef&&v_prof==tab[i].id) {v_id=i;p_tabs.sel=i;}
			else {p_tabs.sel=v_id;}
			//first tab initialise moving tab list (except fixed ones)
			//if (tab[i].seq==1) l_s+="<td><table cellpadding='0' cellspacing='0' border='0'><tr id='tabsframe'>";
		//if (firstMovingTab && tab[i].movable){l_s+="<td><table cellpadding='0' cellspacing='0' border='0'><tr id='tabsframe'>";firstMovingTab=false;}
			if (firstMovingTab){
				if (i==0)l_s+="<td><table cellpadding='0' cellspacing='0' border='0'><tr"+(tab[i].movable=="1"?" id='tabsframe'":"")+">";
				else {
					if (tab[i].movable==1)l_s+="</tr></table></td><td><table cellpadding='0' cellspacing='0' border='0'><tr id='tabsframe'>";
				}
				if (tab[i].movable==1) firstMovingTab=false;
			}
			l_s+="<td id='tab"+i+"' width='1' valign='bottom'>";
			if (i==v_id){
				p_tabs.currName=tab[i].label;
				l_s+="<table class='taba' cellpadding='0' cellspacing='0'><tr><td class='tabal' id='tab"+i+"_h'"+(l_movable&&tab[i].movable?" style='cursor:move'":"")+"><a href='#' onmousedown='"+(v_locked||!tab[i].editable?"":"p_tabs.edit("+i+")")+"' style='cursor:text'>";
				l_s+=(tab[i].isLoaded==false?img("ico_waiting.gif",16,16,"","imgmid"):((tab[i].icon==""||tab[i].icon==indef||!__showtabicon)?img("s.gif",16,16,"","imgmid"):"<img src='"+tab[i].icon+"' width='16' height='16' align='absmiddle'>"));
				l_s+=" "+tab[i].label;
				l_s+=" <span class='tabextra' id='tabextra"+i+"'>"+(tab[i].nbUnread==0?"":"("+tab[i].nbUnread+")")+"</span>";
				l_s+="</a></td><td class='tabar'>";
				if (jsid>0){
					l_s+="<table cellpadding='0' cellspacing='0' border='0'>";
					if (tab[i].lock!=""){l_s+="<tr><td style='font-size:2pt;'><a href='#' onclick='lockPage();return false;'>"+img("lock.gif",7,9,lg("lblSecuActive"),"imgmid")+"</a></td></tr>";}
					if (tab[i].editable){l_s+="<tr><td style='font-size:2pt;'><a href='#' onclick='"+(v_locked?"":"return p_banner.option.show()")+"'>"+img("ico_down_arrow.gif",11,8,lg("lblShowOpt"),"imgmid")+"</a></td></tr>";}
					else {l_s+="<tr><td style='font-size:2pt;'>"+img("s.gif",11,8,"imgmid")+"</td></tr>";}
					l_s+="</table>";
				} else {l_s+="&nbsp;";}
				l_s+="</td><td class='intertaba'>"+img("s.gif",1,1)+"</td></tr></table>";
				changePageTitle(p_tabs.currName);
			} else {
//				l_s+="<table class='tab' cellpadding='0' cellspacing='0'><tr><td class='tabl' id='tab"+i+"_h'"+(l_movable&&tab[i].movable?" style='cursor:move'":"")+"><A href="+((tab[i].type==4)?"'"+tab[i].fct+"'":"# onclick=\"p_tabs.sel="+i+";p_tabs.create(p_tabs.sel);"+tab[i].fct+";return false;\"")+" id='tab"+i+"_u'>"+tab[i].label+"</A></td><td class='tabr'>";
				l_s+="<table class='tab' cellpadding='0' cellspacing='0'><tr><td class='tabl'"+(tab[i].movable?" id='tab"+i+"_h' style='cursor:move'":"")+">";
				if (v_prof==0) {
					l_s+="<a href='#' onclick='openPage("+tab[i].id+");' id='tab"+i+"_u'>";
				} else {
					l_s+="<a href="+((tab[i].type==4)?"'"+tab[i].fct+"'":"'#' onclick=\"p_pages.hide();p_tabs.select("+i+");"+tab[i].fct+";p_tabs.select("+i+");return false;\"")+" id='tab"+i+"_u'>";
				}
				l_s+=(tab[i].isLoaded==false?img("ico_waiting.gif",16,16,"","imgmid"):((tab[i].icon==""||tab[i].icon==indef||!__showtabicon)?img("s.gif",16,16,"","imgmid"):"<img src='"+tab[i].icon+"' width='16' height='16' align='absmiddle'>"));
				l_s+=" "+tab[i].label;
				l_s+=" <span class='tabextra' id='tabextra"+i+"'>"+(tab[i].nbUnread==0?"":"("+tab[i].nbUnread+")")+"</span>";
				l_s+="</a>";

				l_s+="</td><td class='tabr'>";
				l_s+="<table cellpadding='0' cellspacing='0' border='0'>";
				if (tab[i].lock!=""){l_s+="<tr><td style='font-size:2pt;'>"+img("lock.gif",7,9,lg("lblSecuActive"),"imgmid")+"</td></tr>";}
				l_s+="<tr><td style='font-size:2pt;'>"+img("s.gif",11,8,"imgmid")+"</td></tr>";
				l_s+="</table>";
				//l_s+=(tab[i].lock=="")?"&nbsp;":img("lock.gif",7,9,lg("lblProtected"));
				l_s+="</td><td class='intertab'>"+img("s.gif",1,1)+"</td></tr></table>";
			}
			l_s+="</td>";
			i++;
		}
//		if (i>0) l_s+="<TD class='endtab'>&nbsp;</TD></TR></TABLE></TD>";
		//if (i>0) l_s+="</tr></table></td><td class='endtab' width='100%'>&nbsp;</td>";
		if (jsid>0) l_s+="<td nowrap='nowrap' class='"+(i==0?"notab":"endtab")+"' style='width:100%'><a href='#' onclick='p_pages.newPortal();return false;'>+ "+lg("lblNewpage")+"&nbsp;</a></td>";
		if (i>0) l_s+="</tr></table></td>";
		l_s+="<td class='endtab'>&nbsp;</td></tr></table></td></tr></table></div></div></div></td>";
		l_s+="<td class='endtab' style='padding: 6px'><a href='#' id='rightTabNav' onmouseover='p_tabs.nav.right();' onmouseout='p_tabs.nav.stop();'>"+img("ico_next.gif",7,9)+"</a></td>";
		//add a bloc if scrollbars with FF
		l_s+="<td class='endtab'>&nbsp;&nbsp;&nbsp;</td>";
	//	l_s+="<td class='endtab'>&nbsp;</td>";
		l_s+="</tr></table>";
		navPrint("tabs",l_s);
		p_tabs.isInit=false;
		if (l_movable) p_tabs.initMove();
		
		p_tabs.nav.init();
	},
	initMove:function(){
		// Initialize column & modules behaviors
		// do not initialize the tabs if already done
		if (p_tabs.isInit) return;
		//if no tab existing for user
		if (tab.length==0) return;
		p_tabs.isInit=true;
		var l_tabs=_gel("tabsframe");
		if (l_tabs!=null){
			for(var i=0;i<l_tabs.childNodes.length-1;i++){
				var l_mod=l_tabs.childNodes[i];
				initMove(l_mod,"tab",l_tabs,"horizontal",false);
			}
		}
	},
	save:function(v_movedId){
		// Save the tabs changes
		var l_tabs=_gel("tabsframe");
		var l_prevPlace=0;
		for(var i=0;i<l_tabs.childNodes.length-1;i++){
			if ((l_tabs.childNodes[i].id).indexOf("tab")!=-1){
				l_id=(l_tabs.childNodes[i].id).replace("tab","");
				if (l_id==v_movedId && (l_prevPlace+1)!=tab[l_id].seq){
					executescr("scr_movetab.php","id="+tab[l_id].id+"&old="+tab[l_id].seq+"&new="+(l_prevPlace+1),false);
				}
				l_prevPlace=tab[l_id].seq;
				tab[l_id].seq=i+1;
				//if (l_id==p_tabs.sel) l_newSeq=tab[l_id].seq;
			}
		}
		tab.sort(p_tabs.sort);
		// v1.4 : if on HTML predefined page, function was not working
		if (jsprof!=0){p_tabs.create(indef,false,false,jsprof);} else {p_tabs.create(p_tabs.sel);}
	},
	sort:function(a,b){
		if (a.seq<b.seq) return -1;
		if (a.seq>b.seq) return 1;
		return 0; 
	},
	edit:function(v_id){
		if (tab[p_tabs.sel].showType==1){
			p_newspaper.hide();
			return;
		}
		// Edit tab name
		p_tabs.create(p_tabs.sel,false,true);
		var l_tab=_gel("tab"+v_id+"_h");
		l_tab.innerHTML="<form onsubmit='p_tabs.rename(this.tabinput,"+v_id+");return false;'><input class='thinbox' name='tabinput' id='tabinput' type='text' size='30' maxlength='30' style='border:0px;font-size:7pt;margin:0px;height:13px;' value='"+tab[v_id].label+"' /> <input class='btnsmall' type='submit' value='"+lg("lblOk")+"' /> <a href='#' onclick='p_tabs.create(p_tabs.sel);'>"+img("ico_close.gif",9,9,lg("lblCancel"),"imgmid")+"</a></form>";
		var l_input=_gel("tabinput");
		l_input.select();
	},
	rename:function(v_input,v_id){
		// Change tab name
		var l_name=suppressCot(v_input.value);
		if (l_name!="" && l_name!=p_tabs.currName){
			p_tabs.currName=l_name;
			tab[v_id].label=l_name;
			executescr("scr_config_options.php","prof="+jsprof+"&portstyle="+tab[p_tabs.sel].style+"&portname="+_esc(p_tabs.currName)+"&col="+tab[p_tabs.sel].colnb+"&advise="+p_banner.info.requested,false);
		}
		p_tabs.create(p_tabs.sel);
		p_rss.pageUnread();
	},
	initHeadMenu:function(v_obj,v_id){
		if (v_obj==indef){
			if (_gel("headmenu")!=null) p_tabs.showHeadMenu(false);
		} else {
			p_tabs.currHeadLink=v_obj;
			var l_top=getPos(p_tabs.currHeadLink,"Top")+15;
			var l_left=getPos(p_tabs.currHeadLink,"Left")-3;
			var l_width=p_tabs.currHeadLink.offsetWidth+6;

			p_tabs.showHeadMenu(true);
			var l_obj=_gel("headmenu");
			l_obj.style.top=l_top+"px";
			l_obj.style.left=l_left+"px";
			//l_obj.style.width=l_width+"px";
			var l_s="";
			for (var i=0;i<__headmenu[v_id]["options"].length;i++){
				l_s+='<a href="#" onclick="p_tabs.showHeadMenu(false);'+__headmenu[v_id]["options"][i]["fct"]+'" onmouseover="p_tabs.showHeadMenu(true)" style="white-space:nowrap">'+(__headmenu[v_id]["options"][i]["images"]==""?"":img(__headmenu[v_id]["options"][i]["images"],false,false,"","imgmid")+" ")+lg(__headmenu[v_id]["options"][i]["label"])+'</a>';
			}
			l_obj.innerHTML=l_s;
	//		l_obj.onmouseover=function(){p_tabs.showHeadMenu(true);}
			l_obj.onmouseout=function(){p_tabs.showHeadMenu(false);}
		}
	},
	showHeadMenu:function(v_show){
		if (v_show){
			navShow("headmenu","block");
		} else {
			navShow("headmenu","none");
			//document.body.removeChild(_gel("headmenu"));
		}
	},
	moduleOver:function(v_id){
		var l_obj=_gel("tab"+v_id);
		l_obj.style.border="1px solid #ff0000";
		p_tabs.overtabid=v_id;
	},
	moduleOut:function(v_id){
		var l_obj=_gel("tab"+v_id);
		if (l_obj) l_obj.style.border="0px";
		p_tabs.overtabid=-1;
	},
	moduleOutAll:function(){
		for (var i=0;i<tab.length;i++){p_tabs.moduleOut(i);}
	},
	getId:function(v_id){
		for (var i=0;i<tab.length;i++){
			if (tab[i].id==v_id) return i;
		}
		return 0;
	},
	selectTab:function(name,tabs)
	{
		this.sel = 0;
		for (var i=0;i<tabs.length;i++)
		{
			if (tabs[i].id==name)
			{
				this.sel = i;
				return;
			}
		}
	}
}
p_tabs.nav={
	increment:2,
	timer:0,
	posx:0,
	movedObj:{},
	oversize:0,
	init:function(){
		this.timer=0;
		var l_obj=_gel('navfloatbox');
		this.movedObj=_gel('navmovebox');
		//reset position to previous one (in case of re-initialization)
		this.movedObj.style.left=this.posx+"px";
		
		//content size is get with image size
		var navWidth=(l_obj.offsetWidth?l_obj.offsetWidth:(l_obj.style.clip.width?l_obj.style.clip.width:0));
		var l_cntSize=(_gel("navctlimg")).width;
		this.oversize = l_cntSize - navWidth;
		
		//hide navigators button if useless
		if (this.posx>-1) (_gel("leftTabNav")).style.visibility="hidden";
		if (this.oversize+this.posx<=0) (_gel("rightTabNav")).style.visibility="hidden";;
	},
	left:function(){
		//move tabs left
		if (this.posx<0){
			this.posx+=this.increment;
			this.movedObj.style.left=this.posx+"px";
			this.timer = setTimeout("p_tabs.nav.left()",10);	
			(_gel("rightTabNav")).style.visibility="";
		} else {(_gel("leftTabNav")).style.visibility="hidden";}
	},
	right:function(){
		//move tabs right
		if (this.posx+this.oversize>0) {
			this.posx-=this.increment;
			this.movedObj.style.left=this.posx+"px";
			this.timer = setTimeout("p_tabs.nav.right()",10);	
			(_gel("leftTabNav")).style.visibility="";
		} else {(_gel("rightTabNav")).style.visibility="hidden";}
	},
	stop:function(){
		//stop moving tabs
		clearTimer(this.timer);
	}
}
var p_pages={
	def:"N",
	change:function(v_prof,v_keepCurrentPage){
		jsprof=v_prof;
		//p_area.clean(_gel("modules")); //suppressed with 1.4 because no tabs erased
		// if other items open => hide
		p_pages.closeAllDiv();
		navShow("modules","block");
		if (tab[p_tabs.sel].isLoaded!=indef){
			if (tab[p_tabs.sel].style!=p_app.style) setActiveStyleSheet(tab[p_tabs.sel].style);
			//if (p_edit.oldStyle!=tab[p_tabs.sel].style) setActiveStyleSheet(tab[p_tabs.sel].style);
			navShow("modules"+tab[p_tabs.sel].id,"block");
		} else {
			p_pages.open();
		}
		if (jsid>0) p_pages.setCurrent(v_prof);
		//activate menus
		p_edit.locked=false;
		p_addContent.locked=false;
// do not understand the meaning of this ?? suppressed with posh 1.4
//		if (!v_keepCurrentPage){
//			p_tabs.create(indef,false,false,jsprof);
//		}
	},
	/*
		openHome : open the default page
		inputs :
			v_prof : if the default page is personalized pages, open the page v_prof
	*/
	openNew:function(v_prof){
	//	if (jsprof==0){openPage(v_prof);}
	//	else {
			if (v_prof!=jsprof){
				p_pages.setCurrent(v_prof);
				p_pages.hide();
			}
			p_tabs.sel=999;
			//p_tabs.load(v_prof);
			p_app.loadTabs(v_prof);
			//p_pages.change(v_prof,true);
	//	}
	},
	open:function(){
		tab[p_tabs.sel].isLoaded=false;
		//	startLoading(); suppressed on 1.4.2, no need when switch from a page to another
		if (_gel("modules"+tab[p_tabs.sel].id)!=null){
			p_area.clean(_gel("modules"+tab[p_tabs.sel].id));
			navShow("modules"+tab[p_tabs.sel].id,"block");
		}
		if (jsid==0 || tab[p_tabs.sel].id==0 || tab[p_tabs.sel].id>=1000){
			p_area.load("selections/page"+jsprof+".xml");
		} else if (jsprof!=0){
			p_area.load("../portal/xmlmodules.php","id="+jsprof);
		}
	},
	setCurrent:function(v_prof){
		v_prof=parseInt(v_prof,10);
		jsprof=v_prof;
		writeCookie("currentpage="+v_prof);
	},
	/*
		loadOnStart : load the pages defined by user on startup
	*/
	loadOnStart:function(){
		for (var i=0;i<tab.length;i++){
			if (tab[i].loadstart==1 && tab[i].id!=jsprof && tab[i].isLoaded==indef) {p_area.load("xmlmodules.php","id="+tab[i].id,i);}
		}
	},
	/*
		summary : return portal summary
	*/
	summary:function(){
		var l_s="<div style='width:300px'><div class='subtitle'>"+lg("yourPages")+"</div><br /><br />";
		for (var i=0;i<tab.length;i++){
			l_s+=img("ico_next2.gif",12,11,"","imgmid")+" <b>"+tab[i].label+"</b><br />";
			l_s+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick='p_tabs.select("+i+");"+tab[i].fct+";p_tabs.select("+i+");return false;'>"+lg("open")+"</a> - <a href='#' onclick='p_pages.suppress("+i+",false);p_app.openHome(jsprof);'>"+lg("suppress")+"</a><br /><br />";
		}
		l_s+="<br /><a href='#' onclick='p_pages.newPortal();return false;'>+ "+lg("lblNewpage")+"</a></div>";
		return l_s;
	},
	others:function(v_id){
		// Open the "exemples" menu
		if (showBoxStatus){hideBox();}
		var l_s="<table cellpadding='0'><tr><td class='bottomhr'>"+lg("lblExamples")+" | ";
		for (var i=0;i<__dimension.length;i++){
			if (__dimension[i]["id"]!=0){
				if (__dimension[i]["lg"]=="" || __dimension[i]["lg"]==__lang){
					if (v_id==indef) v_id=__dimension[i]["id"];
					l_s+="<a id='dir"+__dimension[i]["seq"]+"' class='"+((v_id==__dimension[i]["id"])?"sellist":"optlist")+"' href='#' onclick='p_pages.others("+__dimension[i]["id"]+")'>"+__dimension[i]["name"]+"</a> | ";
				}
			}
		}
		l_s+="</td></tr>";
		l_s+="<tr><td id='listexample' style='height:116px;padding-top:8px;' valign='top'></td></tr>";
		l_s+="</table>";

		navPrint("box",box(0,img("ico_menu_examples.gif",12,12,"","imgmid")+" "+lg("lblOtherPortal")+" :","hideBox()",l_s));
		navShow("box","block");
		showBoxStatus=true;
		p_pages.initList(v_id,0);
		return false;
	},
	/*
		p_pages.newPortal : open new portal menu
	*/
	newPortal:function(v_id){
		if (__useSharing){
			var l_s=img("puce.gif",3,5)+" <a href='#' onclick='return p_pages.newEmpty();'>"+lg("lblNewEmpty")+"</a>";
//			l_s+=img("ico_right_arrow.gif",6,9)+" <u>"+lg("lblNewMagic")+" :</u> <form name='magic' onsubmit='p_pages.newFromKW(this);return false;'>";
//			l_s+="<INPUT type=text name='searchtxt' size=62 maxlength=150 value='ex: cinema, google, gastronomie, emploi,  ...' onFocus='focusKeys();' /> <INPUT class=btn type=submit value='creer ma page' /><BR /><font class='grey'>ex: cin&eacute;ma, google, gastronomie, emploi, bloc-note, lemonde.fr, ipod nano,internet, </font>";
//			l_s+="</FORM><br />";
			l_s+="<br /><br /><form name='f' onsubmit='return p_pages.search(this)'>"+img("puce.gif",3,5)+" "+lg("lblNewExample")+" :";
			l_s+="<br /><input type='text' name='keywords' value='"+lg("keywords")+"' onclick=\"this.value=''\" />"+tooltip("helpTags")+" <input type='submit' value='"+lg("search")+"' /></form>";
			l_s+="<br /><div id='listPagesForKeywords'></div>";
//			if (__portaldirtype=="module"){
//				l_s+=" | ";
//				for (var i=0;i<__dimension.length;i++){
//					if (__dimension[i]["id"]!=0){
//						if (__dimension[i]["lg"]=="" || __dimension[i]["lg"]==__lang){
//							if (v_id==indef) v_id=__dimension[i]["id"];
//							l_s+="<a id='dir"+__dimension[i]["seq"]+"' class='"+((v_id==__dimension[i]["id"])?"sellist":"optlist")+"' href='#' onclick='p_pages.newPortal("+__dimension[i]["id"]+")'>"+__dimension[i]["name"]+"</a> | ";
//						}
//					}
//				}
//			}
//			if (v_id==indef) v_id=0;
//			l_s+="<br /><div id='listexample'>"+lg("lblLoading")+"</div>";

			if (__menuposition=="h"){
				navPrint("box",box(0,img("ico_newportal.gif",16,16,"","imgmid")+" "+lg("lblNewTit"),"hideBox()",l_s));
				navShow("box","block");
				showBoxStatus=true;
			} else {
				p_menu.init();
				p_menu.display(0,lg("lblNewTit"),"ico_newportal.gif",indef,"<div style='padding:8px'>"+l_s+"</div>");
			}
			return false;
	
//			p_pages.initList(v_id,1);
		} else {p_pages.newEmpty();}
	},
	initList:function(v_cat,v_type){
		// Initialize modules directory menu
		var l_s="<table cellpadding='0' cellspacing='0' border='0'>";
		l_s+="<tr><td><table><tr>";
		l_s+="<td><div id='level1' class='dirdivi' style='width:230px;'></div></td>";
		l_s+="<td><div id='level2' class='dirdivi' style='width:200px;'></div></td>";
		l_s+="<td><div id='level3' class='dirdivi' style='width:200px;'></div></td>";
		l_s+="<td><div id='level4' class='dirdivi' style='width:170px;'></div></td>";
		l_s+="</tr></table></td></tr></table>"+img("",7,7)+"<br />";
		navShow("listexample","block");
		navPrint("listexample",l_s);
		navPrint("level1","Chargement ...");
		p_pages.getList(v_cat,1,v_type);
	},
	getList:function(v_cat,v_level,v_type){
		// Open the modules directory
		getXml("../cache/portaldir_"+v_cat+"_"+__lang+".xml?rand="+rand,p_pages.displayList,new Array(v_level,v_type));
	},
	displayList:function(response,vars){
		var l_s="";
		if (response.getElementsByTagName("dir")[0]||response.getElementsByTagName("portal")[0]){
			l_s+="<table cellpadding='0' cellspacing='1' border='0' style='width:90%'>";
			if (response.getElementsByTagName("dir")[0]){
				var l_i=0,l_dirid;
				while (response.getElementsByTagName("dir")[l_i]){
					var l_result=response.getElementsByTagName("dir")[l_i];
					l_dirid=getXMLval(l_result,"dirid","int",false,0);
					l_s+="<tr><td id='dir"+l_dirid+"' class='catopti' onmouseover='catOptOver(\""+l_dirid+"\")' onmouseout='catOptOut(\""+l_dirid+"\")'> <a href='#' class='menul' onclick='p_pages.getList(\""+l_dirid+"\","+(vars[0]+1)+","+vars[1]+");catOptSel(\""+l_dirid+"\","+vars[0]+");return false;'>"+getXMLval(l_result,"dirname","str",false,"...")+"</a></td></tr>";
					l_i++;
				}
			}
			if (response.getElementsByTagName("portal")[0]){
				var l_i=0,l_exampleid;
				while (response.getElementsByTagName("portal")[l_i]){
					var l_result=response.getElementsByTagName("portal")[l_i];
					l_exampleid=getXMLval(l_result,"id","int",false,0);
					l_s+="<tr><td>"+img("ico_example.gif",13,11,"","imgmid")+" <a href='#' class='menul' onclick='p_pages.loadOverview("+l_exampleid+","+vars[1]+");return false;'>"+getXMLval(l_result,"name","str",false,"...")+"</a></td></tr>";
					l_i++;
				}
			}
			l_s+="</table>";
		}
		else {l_s+=lg("lblNoPortal");}

		navClass("level"+vars[0],"dirdiva");
		navPrint("level"+vars[0],l_s);
		//clear unused div
		for (var i=vars[0]+1;i<5;i++){navPrint("level"+i,"");navClass("level"+i,"dirdivi");}
	},
	newEmpty:function(){
		// Create empty portal
		//var l_newid=tab.length;
		//tab[l_newid]=new tabObj(getXMLval(result,"number","int",false,0),getXMLval(result,"name","str",false,"..."),getXMLval(result,"type","str",false,"P"),getXMLval(result,"action","str",false,""),getXMLval(result,"locked","int",false,0),getXMLval(result,"seq","int",false,0),getXMLval(result,"edit","int",false,0),getXMLval(result,"move","int",false,0),getXMLval(result,"icon","str",false,""));
		var l_style=p_tabs.sel==-1?1:tab[p_tabs.sel].style;
		executescr("scr_createportal.php","w=3&s="+l_style+"&n=nouveau&t=0&nb=15&a=Y",false,true,p_pages.openNew);
	},
	suppress:function(v_tab,v_selectFirst){
		if (v_tab==indef) v_tab=p_tabs.sel;
		if (v_selectFirst==indef) v_selectFirst=true;
		if (__blockedModulePreventPageRemoval){
			//check if module is locked in the portal => no suppression
			for (var i=0;i<tab[v_tab].module.length;i++){
				if (tab[v_tab].module[i].blocked){
					p_alert.show(lg("msgNotRemovable"));
					return false;
				}
			}
		}
		// Suppress a portal
		response=confirm(lg("msgSuppressConfirm"));
		if (response==1){
			//find out the portal to redirect on
			//var l_nextPage=-1;
			//for (var i=0;i<tab.length;i++){
			//	if (tab[i].id!=jsprof){l_nextPage=i;break;}
			//}
			executescr("scr_suppersonal.php","id="+tab[v_tab].id+"&seq="+tab[v_tab].seq);
			
			//update tabs sequence
			//var l_firstUserPage=-1;
			for (var i=0;i<tab.length;i++){
				if (i>v_tab) tab[i].seq--;
				//if (l_firstUserPage==-1 && tab[i].movable==1) l_firstUserPage=i;
			}
			//delete the tab
			if (tab[v_tab].isLoaded) (_gel("modules")).removeChild(tab[v_tab].root);
			tab.splice(v_tab,1);
			//refresh tab and choose the first tab
			p_tabs.create(0);
			if (v_selectFirst==true){
				//activate the first tab
				if (tab.length>=1){eval(tab[0].fct);}
				else {p_tabs.sel=-1;p_pages.closeAllDiv();}
				//p_pages.change(tab[0].id);
			}
		}
		return false;
	},
	def:function(){
		// Set portal as default one
		response=confirm(lg("msgDefaultConfirm"));
		if (response==1){
			p_pages.def="Y";
			p_tabs.create(p_tabs.sel);
			if (p_banner.option.shown) {p_banner.option.shown=false;p_banner.option.show();}
			executescr("scr_setdefault.php","prof="+jsprof,true)
		}
	},
	show:function(v_id){
		//p_area.clean(_gel("modules")); //suppressed with 1.4 since no tab erased
		closeNewMod();
		hideBox();
		p_area.load("../cache/portal_"+v_id+".xml");
		startLoading();
	},
	hide:function(){
		//hide the pages element before swiching to another page
		if (p_tabs.sel!=-1){
			navShow("modules"+tab[p_tabs.sel].id,"none");
			closeNewMod();
			p_edit.hide();
			p_banner.option.hide();
		}
		hideBox();
	},
	isPageExisting:function(v_sess){
		if (v_sess!=indef){
			if (v_sess=="admin"){link("../admin/index.php");}
//			else if(v_sess=="redactor"){link("../redactor/index.php");}
			else {getXml("xmlpages.php",p_pages.createFromXml,v_sess);}
		}
	},
	createFromXml:function(response,vars){
		//if page tag, redirect to this page
		if (response.getElementsByTagName("page")[0]){
			link("../portal/"+getXMLval(response.getElementsByTagName("page")[0],"url","str",false,""));
			return;
		}
		var l_result=response.getElementsByTagName("portal");
		// Get modules from XML file for creation of a new portal
		for (var j=0;j<l_result.length;j++){
			var i=0,l_s="";
			var l_name=getXMLval(l_result[j],"name","str",false,"myPage");
			var l_style=getXMLval(l_result[j],"style","int",false,1);
			var l_nbcol=getXMLval(l_result[j],"nbcol","int",false,3);
			var l_mode=getXMLval(l_result[j],"showtype","int",false,0);
			var l_npnb=getXMLval(l_result[j],"npnb","int",false,25);
			while (l_result[j].getElementsByTagName("module")[i]){
				var l_result2=l_result[j].getElementsByTagName("module")[i];
				l_s+="&id"+i+"="+getXMLval(l_result2,"id","int",false,0);
				l_s+="&col"+i+"="+getXMLval(l_result2,"col","int",false,1);
				l_s+="&pos"+i+"="+getXMLval(l_result2,"pos","int",false,i);
				l_s+="&posj"+i+"="+getXMLval(l_result2,"posj","int",false,i);
				l_s+="&x"+i+"="+getXMLval(l_result2,"x","int",false,100);
				l_s+="&y"+i+"="+getXMLval(l_result2,"y","int",false,100);
				l_s+="&var"+i+"="+_esc(getXMLval(l_result2,"vars","str",false,""));
				l_s+="&blocked"+i+"="+getXMLval(l_result2,"blocked","int",false,0);
				l_s+="&minimized"+i+"="+getXMLval(l_result2,"minimized","int",false,0);
				i++;
			}
			executescr("scr_createportal.php","w="+l_nbcol+"&s="+l_style+"&n="+l_name+"&t="+l_mode+"&nb="+l_npnb+"&sess="+vars+l_s,false,true,(j==(l_result.length-1)?openPage:indef));
		}
	},
	closeAllDiv:function(){
		p_area.hideFrame();
		if (__useSharing){
			if (p_msg.shown) p_msg.hide();
			if (p_article.shown) p_article.hide();
			if (p_search.shown) p_search.hide();
		}
		if (p_network.shown) p_network.hide();
		if (p_factory.shown) p_factory.hide();
		if (p_banner.info.shown) p_banner.info.hide();
		if (p_banner.option.shown) p_banner.option.hide();
		if (p_plugin.shown) p_plugin.hide();
		navShow("modules","none");
		navShow("newspaper","none");
		navShow("magic","none");//do not suppress !
	}
}
var p_area={
	load:function(v_page,v_id,v_tab){
		if (v_tab==indef) v_tab=p_tabs.sel;
		if (v_tab==indef) v_tab=idToPos(jsprof);
		if (v_tab==indef || !v_tab) v_tab=0;
		tab[v_tab].module.length=0;
		tab[v_tab].isLoaded=false;
		p_rss.init(v_tab);
		if (!v_id) v_id="";
		var l_method=(v_id=="")?"GET":"POST";
		//create modules container div
		if (_gel("modules"+tab[v_tab].id)==null){
			tab[v_tab].root=document.createElement("div");
			if (v_tab!=p_tabs.sel) (tab[v_tab].root).style.display="none";
			(tab[v_tab].root).id="modules"+tab[v_tab].id;
			//(tab[p_tabs.sel].root).style.border="1px solid #ff0000";
			(_gel("modules")).appendChild(tab[v_tab].root);
		}
		getXml(v_page,p_area.treat,v_tab,"xml",v_id,l_method);
	},
	treat:function(response,vars){
		var i=0,result,l_tab=vars;
		//if page is not existing
		if (response.getElementsByTagName("nopage")[0]) openPage(tab[0].id);
		//if not yet install
		if (response.getElementsByTagName("install")[0]) link("../portal/installrequested.html");
		//if connected mode
		//if (response.getElementsByTagName("empty")[0]) link("../portal/login.php");
		var l_type=getXMLval(response,"type","int",false,1);
		if (l_type==1){
			//if page locked
			if (getXMLval(response,"pagelocked","int",false,0)==1){
				navShow('loading','none');
				tab[l_tab].locked=true;
				if (l_tab==p_tabs.sel)  askCode();
			} else {
				tab[l_tab].locked=false;
				tab[l_tab].colnb=getXMLval(response,"nbcol","int",false,tab[l_tab].colnb);
				tab[l_tab].showType=getXMLval(response,"showtype","int",false,tab[l_tab].showType);
				tab[l_tab].newspapernb=getXMLval(response,"npnb","int",false,tab[l_tab].newspapernb);
				tab[l_tab].controls=getXMLval(response,"ctrl","str",false,tab[l_tab].controls);
				tab[l_tab].moduleAlign=(getXMLval(response,"modulealign","str",false,(__moduleAlignDefault?"Y":"N"))=="Y"?true:false);
				//var oldstyle=tab[p_tabs.sel].style;
				tab[l_tab].style=getXMLval(response,"style","int",false,1);
				jspass=getXMLval(response,"usepass","str",false,"");
				p_banner.info.requested=getXMLval(response,"advise","str",false,p_banner.info.requested);
				tab[l_tab].usereader=__usereader?getXMLval(response,"usereader","int",false,tab[l_tab].usereader):0;
				p_pages.def=getXMLval(response,"default","str",false,p_pages.def);
				while (response.getElementsByTagName("module")[i]){
					result=response.getElementsByTagName("module")[i];
					tab[l_tab].module[i]=new moduleObj(getXMLval(result,"col","int",true,0),getXMLval(result,"pos","int",false,0),getXMLval(result,"posj","int",false,0),getXMLval(result,"height","int",false,100),getXMLval(result,"id","int",false,0),getXMLval(result,"site","str",false,"/"),getXMLval(result,"name","str",false,"--"),getXMLval(result,"vars","str",false,""),getXMLval(result,"minmodsize","int",false,180),getXMLval(result,"updmodsize","int",false,1),getXMLval(result,"minmodsize","int",false,180),getXMLval(result,"url","str",false,""),getXMLval(result,"x","int",false,0),getXMLval(result,"y","int",false,0),getXMLval(result,"uniq","int",false,0),getXMLval(result,"format","str",false,"I"),getXMLval(result,"nbvars","int",false,0),tab[l_tab].id,getXMLval(result,"blocked","int",false,0),getXMLval(result,"minimized","int",false,0),getXMLval(result,"usereader","int",false,1),getXMLval(result,"autorefresh","int",false,0));
					i++;
				}
				stats();
				//change style css if the one to show is not the one already selected
				if (l_tab==p_tabs.sel && (p_app.style==0 || p_app.style!=tab[l_tab].style)) setActiveStyleSheet(tab[l_tab].style);
		
				//p_edit.oldStyle=tab[p_tabs.sel].style;
				p_area.init(l_tab);
			}
		} else if (l_type==2 && l_tab==p_tabs.sel){
			p_area.frame(getXMLval(response,"param","str",false,"about:blank"));
			loading(false);
		} else if (l_type==3 && l_tab==p_tabs.sel){eval(getXMLval(response,"param","str",false,""));loading(false);}
	},
	init:function(v_tab){
		//init the page
		if (v_tab==indef) v_tab=p_tabs.sel;
//tab[v_tab].isLoaded=false;
		if (v_tab==p_tabs.sel){ //only if initializing active tab
			startLoading();
		//p_area.clean(tab[p_tabs.sel].root); //suppressed with 1.4 because page are no more erased
			if (tab[v_tab].showType==1) p_newspaper.hide();
			navShow("modules","block");
			if (p_banner.info.shown) navShow("advise","block");
		}
		//create cols if modules are aligned in columns
		if (tab[v_tab].moduleAlign) p_area.col.createAll(v_tab);
		p_area.module.createAll(v_tab);
		if (tab[v_tab].controls=='Y'){p_area.module.showHdr(v_tab);}
		p_area.displayItems(v_tab);
		tab[v_tab].moveIsInit=false;
		useMod=true;
		p_area.displayItems(v_tab);
		if (v_tab==p_tabs.sel){ //only if initializing active tab
			loading(false);
			checkcook();
		}
		//prevent cols to be wider than 400px
//		if (p_area.showType==0){for (var i=1;i<=p_area.col.nb;i++){cols[i].style.width="400px";};}else {cols[1].style.width="400px";}
	},
	clean:function(v_mainObj){
		var l_obj=null;
		//suppress all the descendant nodes of mainObj
		if (v_mainObj!=null){
			while (v_mainObj.hasChildNodes()){
				l_obj=v_mainObj;
				while (l_obj.hasChildNodes()) l_obj=l_obj.firstChild;
				l_obj=l_obj.parentNode;
				l_obj.removeChild(l_obj.firstChild);
			}
		}
	},
	frame:function(v_url,v_id){
		//if (v_id!=indef) {p_tabs.create(indef,indef,indef,v_id);}
		//if (showBoxStatus){hideBox();}
		navShow("modules","none");
		//navShow("advise","none");
		p_banner.option.hide();
		navShow("box","none");
		// frame height calculation
		var l_endPosition=getWindowHeight();
		var l_startPosition=getPos(_gel("other"),"Top");
		
	//	var l_s="<iframe src='"+v_url+"' frameborder='no' marginwidth='0' marginheight='0' scrolling='auto' style='height:"+(l_endPosition-l_startPosition)+"px;width:100%;z-index:auto;'></iframe>"
		var l_s="<iframe id='pagefrm"+v_id+"' src='"+v_url+"' frameborder='no' marginwidth='0' marginheight='0' scrolling='auto' style='height:"+(l_endPosition-l_startPosition)+"px;width:100%;z-index:auto;' onload='adjustFrameHeight(this);'></iframe>";
		navPrint("other",l_s);
		navShow("other","block");
		//lock menus
		p_edit.locked=true;
		p_addContent.locked=true;
		jsprof=tab[p_tabs.sel].id;
	},
	hideFrame:function(){
		navPrint("other","");
		navShow("other","none");
	},
	computeSizeAndResize:function(v_tab){
		if (tab[v_tab].moduleAlign){
			var l_colWidth=[];
			for (var i=0;i<tab[v_tab].module.length;i++){
				if (l_colWidth[tab[v_tab].module[i].newcol]==indef || tab[v_tab].module[i].minModSize>l_colWidth[tab[v_tab].module[i].newcol]) l_colWidth[tab[v_tab].module[i].newcol]=tab[v_tab].module[i].minModSize;
			}
			for (var i=0;i<tab[v_tab].module.length;i++)tab[v_tab].module[i].hide();
			var l_screenWidth=(_gel("header")).offsetWidth;
			var l_availWidth=((__menuposition=="v" && p_menu.leftShown)?l_screenWidth-leftMenuWidth:l_screenWidth)-(IE?0:10);
			(tab[v_tab].root).style.width=l_availWidth+"px";
			for (var i=0;i<tab[v_tab].module.length;i++)tab[v_tab].module[i].show();
		}
	},
	resize:function(){
//	p_area.computeSizeAndResize(p_tabs.sel);
	},
	// Display window items
	displayItems:function(v_tab){
		if (v_tab==indef) v_tab=p_tabs.sel;
		changeStyle("optmod","display","");
		//initialise modules move only if allowed and not in newspaper mode
		if(useMod&&tab[v_tab].showType==0){
			if(!tab[v_tab].moveIsInit){
				if (tab[v_tab].moduleAlign){
					p_area.col.init(v_tab);
				} else {
					p_area.module.initMove(v_tab);
				}
			}
		}
	}
}
function adjustFrameHeight(l_frm){
	l_obj=l_frm.contentDocument?l_frm.contentDocument:document.frames[l_frm.id].document;
	if (l_obj.body.offsetHeight){
		navHeight(l_frm.id,l_obj.body.offsetHeight+10);
	}
}
p_area.col={
	createAll:function(v_tab){
		//initialise Cols array
		tab[v_tab].cols.length=0;
		var l_table=document.createElement("table");
		//condition suppressed with 1.0.0 : better placement without and reused for version 1.1
		l_table.style.width="100%";
		l_table.cellSpacing=4;
		l_table.style.border=0;
		var l_tbody=document.createElement("tbody");
		var l_tr=document.createElement("tr");
		l_tr.id="maintr"+v_tab;
		if (tab[v_tab].showType==0){for (var i=1;i<=tab[v_tab].colnb;i++){l_tr.appendChild(p_area.col.create(i,v_tab));};} else {l_tr.appendChild(p_area.col.create(1,v_tab));}
		p_area.col.size(v_tab);
		l_tbody.appendChild(l_tr);
		l_table.appendChild(l_tbody);
		(tab[v_tab].root).appendChild(l_table);
	},
	init:function(v_tab){
		// Initialize column & modules behaviors
		// do not initialize the columns if already done
		if(tab[v_tab].moveIsInit)return;
		tab[v_tab].moveIsInit=true;
		for(var i=1;i<tab[v_tab].cols.length;i++){
			for(var l_item=0;l_item<tab[v_tab].cols[i].childNodes.length-1;l_item++){  
				var l_mod=tab[v_tab].cols[i].childNodes[l_item];
 				initMove(l_mod,"module",tab[v_tab].cols,"multidim",true,v_tab);
			}
		}
	},
	create:function(v_id,v_tab){
		tab[v_tab].cols[v_id]=document.createElement("td");
		tab[v_tab].cols[v_id].id="col"+v_id;
		tab[v_tab].cols[v_id].style.verticalAlign="top";
	// cols[v_id].style.width=parseInt((100/p_area.col.nb),10)+"%";
		return tab[v_tab].cols[v_id];
	},
	size:function(v_tab){
		//if newspaper mode, the cols are not sized (=> if no module on col1, col1 width=0)
		if (tab[v_tab].showType==0){
			for (var i=1;i<tab[v_tab].cols.length;i++){tab[v_tab].cols[i].style.width=(parseInt((100/tab[v_tab].colnb),10))+"%";}
		}
	},
	add:function(v_id){
		// Add columns (until selected one)
		var l_obj=_gel("maintr"+p_tabs.sel);
		// add the new cols
		if (tab[p_tabs.sel].showType==0){
			for (var i=tab[p_tabs.sel].colnb+1;i<=v_id;i++){
				l_obj.appendChild(p_area.col.create(i,p_tabs.sel));
				tab[p_tabs.sel].cols[i].appendChild(p_area.module.endList());
			}
			p_area.col.size(p_tabs.sel);
		}
		tab[p_tabs.sel].colnb=v_id;
	},
	sup:function(v_id){
		// Suppress columns
		var l_obj=_gel("maintr"+p_tabs.sel);
		if (tab[p_tabs.sel].showType==0){
			for (var i=tab[p_tabs.sel].colnb;i>v_id;i--){
				//suppress the node
				l_obj.removeChild(tab[p_tabs.sel].cols[i]);
				delete(tab[p_tabs.sel].cols[i]);
				tab[p_tabs.sel].cols.length-=1;
			}
			p_area.col.size(p_tabs.sel);
		}
		tab[p_tabs.sel].colnb=v_id;
	},
	check:function(v_id){
		//check that the suppressed columns are empty
		var l_ret=true;
		if (v_id<tab[p_tabs.sel].colnb){
			for (var i=0;i<tab[p_tabs.sel].module.length;i++){
				if (tab[p_tabs.sel].module[i].col>v_id){l_ret=false;p_alert.show(lg("msgColSup",tab[p_tabs.sel].module[i].col));break;}
			}
		}
		return l_ret;
	}
}
p_area.module={
	showAdminProperties:false,
	dragging:false,
	createAll:function(v_tab){
		// Create all the modules
		var l_col=1;
		var l_ontop=0;
		// compute the max Uniq ID
		for (var i=0;i<tab[v_tab].module.length;i++){if (tab[v_tab].module[i].uniq>tab[v_tab].maxUniq) tab[v_tab].maxUniq=tab[v_tab].module[i].uniq;}
		//sort the modules depending on the show type
		if (tab[v_tab].showType==0){tab[v_tab].module.sort(blocSort);} else {tab[v_tab].module.sort(newspaperSort);}
		for (var i=0;i<tab[v_tab].module.length;i++){
			while (tab[v_tab].module[i].col>l_col) l_col++;
			if (tab[v_tab].showType==0 || tab[v_tab].module[i].format!='R'){tab[v_tab].module[i].create();}
			//display modules if not in the active tab
			if (v_tab!=p_tabs.sel){tab[v_tab].module[i].show();}
			//if a module is added from outside of Portaneo
			if (tab[v_tab].module[i].pos==99){l_ontop=i;}
		}
		if (tab[v_tab].showType==1) {
			p_newspaper.init();
			p_newspaper.load();
			// if modules are aligned, a dummy div is added on the bottom of the column of widgets
			if (tab[v_tab].moduleAlign) tab[v_tab].cols[1].appendChild(p_area.module.endList());
		}
		else {
			// if modules are aligned, a dummy div is added on the bottom of each column
			if (tab[v_tab].moduleAlign){
				for (var i=1;i<=tab[v_tab].colnb;i++){
					tab[v_tab].cols[i].appendChild(p_area.module.endList());
				}
			}
		}
		//if a module is not placed, place it on top of first column (only if modules are aligned)
		if (l_ontop!=0 && tab[v_tab].moduleAlign){
			tab[v_tab].module[l_ontop].placeonTop();
			var l_var=[];
			l_var[0]=tab[v_tab].module[l_ontop].col;
			saveChanges(l_var,indef,v_tab);
		}
	},
	suppress:function(v_uniq,v_confirm){
		// Suppress a module
		var l_id=uniqToId(v_uniq),l_ret=false;
		// if module to suppress is not yet included in the page
		if (showNewMod && l_id==(tab[p_tabs.sel].maxUniq)){closeNewMod();}
		else {
			var l_response=v_confirm?confirm(lg("msgModSup")):1;
			if (l_response==1)
			{
				//suppress linked RSS feeds
				if (tab[p_tabs.sel].module[l_id].format=='R') p_area.module.supFeed(v_uniq);

				//virtually change the module position
				for(var i=0;i<tab[p_tabs.sel].module.length;i++){
					if (tab[p_tabs.sel].module[i].newcol==tab[p_tabs.sel].module[l_id].newcol && tab[p_tabs.sel].module[i].newpos>tab[p_tabs.sel].module[l_id].newpos){tab[p_tabs.sel].module[i].newpos-=1;}
					if (tab[p_tabs.sel].module[i].newposj>tab[p_tabs.sel].module[l_id].newposj){tab[p_tabs.sel].module[i].newposj-=1;}
				}
				if (tab[p_tabs.sel].showType==0 || tab[p_tabs.sel].module[l_id].format!='R') tab[p_tabs.sel].module[l_id].destruct();
				//register the suppression
				var l_vars=[];
				if (tab[p_tabs.sel].showType==0){l_vars[0]=tab[p_tabs.sel].module[l_id].col;}else{l_vars[0]=1;}
				saveChanges(l_vars,l_id);

				tab[p_tabs.sel].module.splice(l_id,1);
				l_ret=true;
			}
		}
		return l_ret;
	},
	minimize:function(v_uniq){
		var l_id=uniqToId(v_uniq);
		if (tab[p_tabs.sel].module[l_id].minimized){
			navShow("module"+tab[p_tabs.sel].id+"_"+v_uniq+"_c","block");
			navShow("module"+tab[p_tabs.sel].id+"_"+v_uniq+"_i","block");
			//var l_obj=_gel("module"+v_uniq+"_c");
			//l_obj.parentNode.parentNode.parentNode.style.display="block";
			tab[p_tabs.sel].module[l_id].minimized=false;
			(_gel("imgminimize"+v_uniq)).src="../images/ico_minimize.gif";
			executescr("scr_minimize.php","m=0&prof="+jsprof+"&u="+v_uniq);
		} else {
			navShow("module"+tab[p_tabs.sel].id+"_"+v_uniq+"_c","none");
			navShow("module"+tab[p_tabs.sel].id+"_"+v_uniq+"_i","none");
			//var l_obj=_gel("module"+v_uniq+"_c");
			//l_obj.parentNode.parentNode.parentNode.style.display="none";
			tab[p_tabs.sel].module[l_id].minimized=true;
			(_gel("imgminimize"+v_uniq)).src="../images/ico_maximize.gif";
			executescr("scr_minimize.php","m=1&prof="+jsprof+"&u="+v_uniq);
		}
	},
	supFeed:function(v_uniq,v_tab){
		//suppress feeds linked to a module
		if (v_tab==indef) v_tab=p_tabs.sel;
		var i=0;
		while (tab[v_tab].feeds[i]){
			if (tab[v_tab].feeds[i].modUniq==v_uniq){tab[v_tab].feeds.splice(i,1);} else {i++;}
		}
	},
	endList:function(){
		// Add an empty module at the bottom of a column
		var l_obj=null;
		l_obj=document.createElement("DIV");
		l_obj.className="necessary";
		//l_obj.innerHTML="&nbsp;";
		// necessary to add an empty column
		//l_obj.style.width="180px";
		l_obj.innerHTML=img("s.gif",180,1);
		l_obj.style.width="100%";
		return l_obj;
	},
	showHdr:function(v_tab){
		if (v_tab==indef) v_tab=p_tabs.sel;
		// Show the modules headers
		if (tab[v_tab].controls=='Y'){
			//changeStyle("hmod","display","block");
			for (var i=0;i<tab[v_tab].module.length;i++){
				navShow("hmod"+tab[v_tab].id+"_"+tab[v_tab].module[i].uniq,"block");
			}
		} else {
			//if (!IE){navShow("modules","none");} //FF bug fix
			//changeStyle("hmod","display","none");
			for (var i=0;i<tab[v_tab].module.length;i++){
				navShow("hmod"+tab[v_tab].id+"_"+tab[v_tab].module[i].uniq,"none");
			}
			//if (!IE) navShow("modules","block"); //FF bug fix
			p_area.resize();
		}
	},
	switchHdr:function(){
		tab[p_tabs.sel].controls=(tab[p_tabs.sel].controls=='Y')?'N':'Y';
		p_area.module.showHdr();
	},
	changeTab:function(v_desttab,v_module){
		executescr("scr_addmodule_othertab.php","src="+tab[p_tabs.sel].id+"&dest="+tab[v_desttab].id+"&tabdest="+v_desttab+"&uniq="+v_module,false,false,p_area.module.addInNewTab);
		//update rss unread number (only in source tab, the other is reload)
		var l_modId=uniqToId(v_module);
		if (tab[p_tabs.sel].module[l_modId].format=="R") {tab[p_tabs.sel].module[l_modId].nbunread=0;p_rss.pageUnread(p_tabs.sel);}
		//executescr("scr_addmodule_othertab.php","src="+tab[p_tabs.sel].id+"&dest="+v_desttab+"&tabdest="+p_tabs.getId(v_desttab)+"&uniq="+v_module,false,false,p_area.module.addInNewTab);
		//if (l_check){p_area.module.suppress(v_module);}
	},
	insertInTab:function(v_desttab,v_id){
		executescr("scr_addmodule_intab.php","dest="+tab[v_desttab].id+"&tabdest="+v_desttab+"&id="+v_id,false,false,p_area.module.addInNewTab);
		closeNewMod();
		//executescr("scr_addmodule_intab.php","dest="+v_desttab+"&tabdest="+p_tabs.getId(v_desttab)+"&id="+v_id,false,false,p_area.module.addInNewTab);
	},
	addInNewTab:function(v_ret){
		if (v_ret==indef) return;
		var v_param=v_ret.split(/_/);
		//add module in new tab
		if (tab[v_param[2]].isLoaded==true){
			tab[v_param[2]].isLoaded=indef;
			navPrint("tabextra"+v_param[2],"");
			//to be done : create twin module, place on bottom, change nbunread,...
		}
		//suppress module from old tab
		if (v_param[0]!="x") p_area.module.suppress(v_param[0]);
	},
	changeName:function(v_id,v_name,v_icon,v_tab){
		if (v_tab==indef) v_tab=p_tabs.sel;
		if (v_name!=indef) tab[v_tab].module[v_id].name=v_name;
		var l_s=tab[v_tab].module[v_id].name;
		if (tab[v_tab].module[v_id].nbunread!=0) l_s="<a class='rssstatus' href='#' onmousedown='return p_rss.readAll("+v_tab+","+v_id+")'>("+tab[v_tab].module[v_id].nbunread+")</a> "+l_s;
		if (v_icon!=indef){
			l_s=img(v_icon,16,16,"","imgmid")+" "+l_s;
		} else if (__showicon){l_s=img("../modules/pictures/"+tab[v_tab].module[v_id].icon,16,16,"","imgmid")+" "+l_s;}
		//navPrint("module"+module[v_id].uniq+"_h",v_name.substr(0,20));
		navPrint("module"+tab[v_tab].id+"_"+tab[v_tab].module[v_id].uniq+"_h",l_s);
	},
	initMove:function(v_tab){
		if(tab[v_tab].moveIsInit)return;
		tab[v_tab].moveIsInit=true;
		for(var l_item=0;l_item<tab[v_tab].root.childNodes.length;l_item++){  
			var l_mod=tab[v_tab].root.childNodes[l_item];
 			initMove(l_mod,"module",tab[v_tab].root,"multidim",true,v_tab);
		}
	},
	//switch modules aligned / not aligned
	align:function(v_align){
		var l_var=[];
		if (v_align){
			for (var i=0;i<tab[p_tabs.sel].module.length;i++){
				tab[p_tabs.sel].module[i].newx=(20+(i*30));
				tab[p_tabs.sel].module[i].newy=(120+(i*30));
			}
		}
		//save new position
		saveChanges(l_var);
		//regenerate the page
		tab[p_tabs.sel].moduleAlign=!v_align;
		//pages.open();
		p_area.clean(tab[p_tabs.sel].root);
		if (v_align){
			for (var i=0;i<tab[p_tabs.sel].module.length;i++){
				tab[p_tabs.sel].module[i].x=tab[p_tabs.sel].module[i].newx;
				tab[p_tabs.sel].module[i].y=tab[p_tabs.sel].module[i].newy;
			}
		}
		p_area.init(p_tabs.sel);
	}
}
var p_counter={
	timer:0,
	step:0,
	activityStep:0,
	reset:function(v_step){
		if (p_counter.timer) p_counter.stop();
		p_counter.step=v_step?v_step:0;
		p_counter.timer=setInterval("p_counter.action()",10000);
	},
	action:function(){
		if (p_counter.step==1) loading(false);
		// other action are launched when user is connected
		if (jsid>0){
//			if (p_counter.step==1&&__useSharing) p_msg.getNb();
			//if security applied on portal, lock after inactivity
			if (p_counter.activityStep==90&&jspass!="") lockPage();
			//refresh modules that need to be refreshed periodically (RSS, mails, ...)
			if (__rssrefreshdelay!=0 && p_counter.step%__rssrefreshdelay==(__rssrefreshdelay-1)) p_rss.refreshAll();
			//check connection to DB
			if (p_counter.step%60==59) p_connection.test();
		}
		if (p_counter.step%2==1 && __bartype==2) p_banner.info.roll();
		p_counter.step++;
		p_counter.activityStep++;
	},
	stop:function(){
		clearTimer(p_counter.timer);
	}
}
function startLoading(){
	//tab[p_tabs.sel].isLoaded=false;
	navShow("loading","block");
	p_counter.reset();
}
// show the modules when they are all loaded
function loading(v_t,v_tab){
	if (v_tab==indef) v_tab=p_tabs.sel;
	if (!v_t){
		if (v_tab!=-1 && v_tab!=indef){
			//only for portals
			if (tab[v_tab].type==1 || tab[v_tab].type==3){
				if (v_tab==p_tabs.sel) (tab[v_tab].root).style.display="block";
				for (var i=0;i<tab[v_tab].module.length;i++){tab[v_tab].module[i].show();}
				if (tab[v_tab].showType==1){
					//Normally, all sources are loaded (showtype=0 on startup) - v1.3.0
					var l_allLoaded=true;
					for (var i=0;i<tab[v_tab].module.length;i++){
						if (tab[v_tab].module[i].format=='R' && !tab[v_tab].module[i].isLoaded){
							l_allLoaded=false;
							//p_rss.refresh(i); Suppressed with 1.4.2
						}
					}
					if (!l_allLoaded) p_newspaper.show(true,p_newspaper.currSrc);
					//navShow("newspaper","block");
				}
				additionalMod();
				//check for tab status ( loading or loaded)
				var l_allLoaded=true;
				for (var i=0;i<tab[v_tab].module.length;i++){
					if (tab[v_tab].module[i].format=='R' && !tab[v_tab].module[i].isLoaded){
						l_allLoaded=false;
					}
				}
				if (l_allLoaded){
					tab[v_tab].isLoaded=true;
					p_tabs.refresh(p_tabs.sel);
				}
			}
		}
		navShow("loading","none");
	}
}
// Change uniq id of a module
function changeUniq(v_id,v_uniq){
	if (v_uniq==indef) v_uniq=tab[p_tabs.sel].maxUniq;
	executescr("scr_changeuniq.php","uniq="+v_uniq+"&prof="+jsprof+"&x="+tab[p_tabs.sel].module[v_id].newcol+"&y="+tab[p_tabs.sel].module[v_id].newpos);
}
//get the tab position from its unique id
function idToPos(v_id){
	if (v_id==-1) return -1;
	if (tab.length==1000) return 999;
	for (var i=0;i<tab.length;i++){
		if (tab[i].id==v_id) return i;
	}
	return false;
}
// Get Module id from its uniq value
function uniqToId(v_uniq,v_tab){
	if (v_tab==indef) v_tab=p_tabs.sel;
	for (var k=0;k<tab[v_tab].module.length;k++){if (tab[v_tab].module[k].uniq==v_uniq) return k;}
	return 0;
}
//get module id of a module object
function getModuleId(v_obj){
	var ret=-1;
	var l_objid=v_obj.id;
	if (l_objid.indexOf("module")>=0){
		var l_idstr=l_objid.replace("module","");//substr(l_objid.indexOf("_")+1);
		var l_tab=idToPos(l_idstr.substr(0,l_idstr.indexOf("_")));
		var l_uniq=l_idstr.substr(l_idstr.indexOf("_")+1);
		ret=uniqToId(l_uniq,l_tab);
	}
	return ret;
}
// Create shadow
function mDiv(){
	if(!mDivObj){
		mDivObj=document.createElement("DIV");
		mDivObj.style.display="none";
		mDivObj.style.position="absolute";
		mDivObj.style.cursor="move";
		mDivObj.style.backgroundColor="#c6c3c6";
		mDivObj.style.paddingBottom="0px";
		document.body.appendChild(mDivObj)
	}
	return mDivObj
}
//** hide the shadow module after move
function hideDivMove(){
	mDiv().style.display="none";
	//IE bug : after module move, p_param.valid was not working any more
	p_area.clean(mDivObj);
} 
// Format the shadow module
function updModMove(v_content){
	v_content=_lc(v_content);
	//** suppress the iframes
	while(v_content.indexOf("<iframe")!=-1){
		var l_p1=v_content.indexOf("<iframe");
		var l_p2=v_content.indexOf("</iframe>")+9;
		v_content=v_content.substr(0,l_p1)+v_content.substr(l_p2,v_content.length);
	}
	//other events during drag could interfert
	v_content=v_content.replace(/onmouseover=/g,"");
	v_content=v_content.replace(/onmouseout=/g,"");
	return v_content;
}
// Module deplacement prototype
var p_move={
	obj:null,
	status:"",
	init:function(mObj){
		mObj.onmousedown=p_move.start;
		if(isNaN(parseInt(mDiv().style.left)))mDiv().style.left="0px";
		if(isNaN(parseInt(mDiv().style.top)))mDiv().style.top="0px";
		mObj.onDragStart=new Function();
		mObj.onDragEnd=new Function();
		mObj.onDrag=new Function();
	},
	start:function(e){
		var mObj=p_move.obj=this;
		e=p_move.fixE(e);
		mObj.onDragStart(parseInt(mDiv().style.left),parseInt(mDiv().style.top),e.clientX,e.clientY);
		mObj.lastMouseX=e.clientX;
		mObj.lastMouseY=e.clientY;
		document.onmousemove=p_move.drag;
		document.onmouseup=p_move.end;
		p_move.status="dragging";
		return false;
	}, 
	drag:function(e){
		e=p_move.fixE(e);
		var mObj=p_move.obj;
		var mX=e.clientX;
		var mY=e.clientY;
		var posX,posY;
		posX=parseInt(mDiv().style.left)+mX-mObj.lastMouseX;
		posY=parseInt(mDiv().style.top)+mY-mObj.lastMouseY;
		mDiv().style.left=posX+"px";
		mDiv().style.top=posY+"px";
		mObj.lastMouseX=mX;
		mObj.lastMouseY=mY;
		if (IE) {mObj.onDrag((mX+document.documentElement.scrollLeft),(mY+document.documentElement.scrollTop));}
		else {mObj.onDrag(e.pageX,e.pageY);}
  		return false;
	}, 
	end:function(){
		document.onmousemove=null;
		document.onmouseup=null;
		p_move.obj.onDragEnd(parseInt(mDiv().style.left),parseInt(mDiv().style.top));
		p_move.obj=null;
		p_move.status="";
	},
	fixE:function(e){
		if(typeof e=="undefined")e=window.event;
		if(typeof e.layerX=="undefined")e.layerX=e.offsetX;
		if(typeof e.layerY=="undefined")e.layerY=e.offsetY;
		return e;
	}
};
// Initialize modules behaviors
function initMove(v_obj,v_type,v_parent,v_direction,v_usecache,v_extra){
	var l_obj=_gel(v_obj.id+"_h");
	// if the node is not recognize as a moving object, go to next node
	if(!l_obj)return;
	if (v_type=="module"){
		if (v_extra==indef) v_extra=p_tabs.sel;
		//Check that module is movable
		var l_id=getModuleId(v_obj);
		if (tab[v_extra].module[l_id].blocked) return;
	}
	// move cursor on bar mouseover
	l_obj.style.cursor="move";
	l_obj.objMoved=v_obj;
	p_move.init(l_obj);
	// manage an url in the object header
	var l_uObj=_gel(v_obj.id+"_u");  
	if(l_uObj){
		if (l_uObj.href==window.location.href || l_uObj.href==window.location.href+"#"){
			l_uObj.onmousedown=l_uObj.onclick;
		} else {
			l_uObj.onmousedown=function(){window.location.href=this.href;}
		}
	}
	l_obj.onDragStart=function(){
		var l_selObj=this.objMoved;
		setPos(l_selObj,v_parent);
		l_selObj.origNextSibling=l_selObj.nextSibling;
		// dragged object building
		var mDivObj=mDiv();
		mDivObj.style.zIndex=1000;
		mDivObj.style.left=getPos(l_selObj,"Left")+"px";
		mDivObj.style.top=getPos(l_selObj,"Top")+"px";
		mDivObj.style.height=l_selObj.offsetHeight+"px";
		mDivObj.style.width=l_selObj.offsetWidth+"px";
		mDivObj.style.display="block";
		mDivObj.style.opacity=0.6;
		mDivObj.style.filter="alpha(opacity=60)";
		mDivObj.innerHTML=(v_type=="module")?updModMove(l_selObj.innerHTML):l_selObj.innerHTML;
		mDivObj.className=l_selObj.className;

		this.isDrag=false;
		if (v_usecache) p_cache.show("block");
	} ;
	l_obj.onDrag=function(v_x,v_y){
		if (tab[p_tabs.sel].moduleAlign){
			this.canBeReleased=objMove(this.objMoved,v_x,v_y,v_parent,v_direction,v_type);
		} else {
			this.canBeReleased=objFreeMove(this.objMoved,v_x,v_y,v_parent,v_direction,v_type);
		}
		this.isDrag=true;
		p_area.module.dragging=true;
	} ;
	l_obj.onDragEnd=function(v_x,v_y){
		hideDivMove();
		if (!IE) p_area.resize();
		if(this.isDrag && this.canBeReleased){
			var l_uniq=this.objMoved.id.replace(v_type,"");
			if (v_type=="module"){
				l_uniq=l_uniq.substr(l_uniq.indexOf("_")+1);
				l_id=uniqToId(l_uniq);
				//set module position if modules are not aligned
				if (!tab[p_tabs.sel].moduleAlign){
					this.objMoved.style.left=v_x+"px";
					this.objMoved.style.top=v_y+"px";
				}
				tab[p_tabs.sel].module[l_id].newx=v_x;
				tab[p_tabs.sel].module[l_id].newy=v_y;
				var l_vars=[];
				if (tab[p_tabs.sel].showType==0){
					var l_old=tab[p_tabs.sel].module[l_id].col;
					var l_new=this.objMoved.parentNode.id.replace(/col/,"");
					if (l_old==l_new){l_vars[0]=l_old;} else {l_vars[0]=l_old;l_vars[1]=l_new;}
				} else {l_vars[0]=1;}
				//if not in a user page -> create else ->change tab
				//if (p_tabs.sel==indef){
				saveChanges(l_vars);
				if (jsprof==0){
					if (p_tabs.overtabid!=-1){p_area.module.insertInTab(p_tabs.overtabid,tab[p_tabs.sel].module[l_id].id);}
				} else {
					if (p_tabs.overtabid!=-1){p_area.module.changeTab(p_tabs.overtabid,l_uniq);}
				}
				p_tabs.moduleOutAll();
			}
			if (v_type=="tab"){p_tabs.save(l_uniq);}
			if (v_type=="admpage"){admPages.save(l_uniq);}
		}
		if (v_usecache) p_cache.show("none");
		this.style.zIndex=1;
		p_area.module.dragging=false;
	}
}
// Set position of modules during deplacement
function setPos(v_obj,v_parent){
	var l_lstNb=v_parent.length?v_parent.length:2;
	for(var j=1;j<l_lstNb;j++){
		var l_decalY=0;
		var l_lst=v_parent.length?v_parent[j]:v_parent;
		for(var i=0;i<l_lst.childNodes.length;i++){
			var l_node=l_lst.childNodes[i];
			//** if the node is the treated div one, the next nodes must be moved up by div height
			if (l_node==v_obj) decalY=l_node.offsetHeight;
			//** set the position of each nodes (use of decalY for modules under the one moved)
			l_node.pagePosLeft=getPos(l_node,"Left");
			l_node.pagePosTop=getPos(l_node,"Top")-l_decalY;
		}
	}
} 
// Module position during deplacement
function objMove(v_obj,v_x,v_y,v_parent,v_direction,v_type){
	var l_nextMod=null;
	var l_x,l_y,l_w,l_h,l_treated=false;
	var l_pond=(v_direction=="multidim")?40:v_obj.offsetHeight;
	var l_lstNb=v_parent.length?v_parent.length:2;
	//is object moving over an existing one
	for(var j=1;j<l_lstNb;j++){
		var l_lst=v_parent.length?v_parent[j]:v_parent;
		for(var i=0;i<l_lst.childNodes.length;i++){
			var l_node=l_lst.childNodes[i];
			l_x=l_node.pagePosLeft;
			l_y=l_node.pagePosTop;
			l_w=l_node.offsetWidth;
			l_h=l_node.offsetHeight;
			if (v_x>l_x && v_x<(l_x+l_w) && v_y>l_y && v_y<(l_y+l_h)){
				l_treated=true;
				if (v_y<(l_y+l_pond)){
					if (l_node==v_obj.nextSibling&&l_node.nextSibling) {l_nextMod=l_node.nextSibling;break;}
					else {l_nextMod=l_node;break;}
				}
			}
		}
	}
	//if module over a tab
	if (!l_treated && v_type=="module" && jsid>0){
		var l_tabs=_gel("tabsframe");
		if (l_tabs!=null)
		for(var i=0;i<l_tabs.childNodes.length;i++){
			var l_node=l_tabs.childNodes[i];
			if (l_node.id=="") continue;
			var l_id=l_node.id.replace(/tab/,"");
			if (l_id==p_tabs.sel) continue;
			//l_x=l_node.pagePosLeft;
			l_x=getPos(l_node,"Left");
			l_y=getPos(l_node,"Top");
			l_w=l_node.offsetWidth;
			l_h=l_node.offsetHeight;
			if (v_x>l_x && v_x<(l_x+l_w) && v_y>l_y && v_y<(l_y+l_h)){
				l_treated=true;
				p_tabs.moduleOver(l_id);
				//v_obj.style.display="none";
				return true;
			} else {
				p_tabs.moduleOut(l_id);
			}
		}
	}
//	//is object out of selection (under first row)
//	if (!l_treated&&v_direction=="multidim"){
//		for(var j=1;j<l_lstNb;j++){
//			var l_lst=v_parent.length?v_parent[j]:v_parent;
//			var l_node=l_lst.childNodes[0];
//			l_x=l_node.pagePosLeft;
//			l_y=l_node.pagePosTop;
//			l_w=l_node.offsetWidth;
//			l_h=l_node.offsetHeight;
//			if (v_x>l_x&&v_y<=l_y) {l_nextMod=l_node;break;}
//		}
//	}
	//is object out of selection (aside the first col)
	if (!l_treated&&v_direction=="multidim"){
		var l_lst=v_parent.length?v_parent[1]:v_parent;
		for(var i=0;i<l_lst.childNodes.length;i++){
			var l_node=l_lst.childNodes[i];
			l_x=l_node.pagePosLeft;
			l_y=l_node.pagePosTop;
			l_w=l_node.offsetWidth;
			l_h=l_node.offsetHeight;
			if (v_x<=l_x&&v_y<=l_y) {l_nextMod=l_node;break;}
		}
	}
	//is the module below the "necessary" boxes
	if (!l_treated&&v_direction=="multidim"){
		for(var j=1;j<l_lstNb;j++){
			var l_lst=v_parent.length?v_parent[j]:v_parent;
			for(var i=0;i<l_lst.childNodes.length;i++){
				var l_node=l_lst.childNodes[i];
				if (l_node.className=="necessary"){
					l_x=l_node.pagePosLeft;
					l_y=l_node.pagePosTop;
					l_w=l_node.offsetWidth;
					if (v_x>l_x && v_x<(l_x+l_w) && v_y>l_y){
						l_treated=true;
						l_nextMod=l_node;break;
					}
				}
			}
		}
	}

	if (l_nextMod!=null&&v_obj!=l_nextMod){
		if (v_type=="module"){
			var l_id=getModuleId(l_nextMod);
			if (l_id!=-1 && tab[p_tabs.sel].module[l_id].blocked) return true;
		}
		l_nextMod.parentNode.insertBefore(v_obj,l_nextMod);
		setPos(v_obj,v_parent);
		//only for IE (Is causing a displaying issue with FF on newspaper mode : the col1 is moving under the newspaper div)
		if (IE) hideParent(v_obj);
	}
	return true;
}
// Module free move
function objFreeMove(v_obj,v_x,v_y,v_parent,v_direction,v_type){
	var l_x,l_y,l_treated=false;

	//if module over a tab
	if (v_type=="module" && jsid>0){
		var l_tabs=_gel("tabsframe");
		if (l_tabs!=null)
		for(var i=0;i<l_tabs.childNodes.length;i++){
			var l_node=l_tabs.childNodes[i];
			if (l_node.id=="") continue;
			var l_id=l_node.id.replace(/tab/,"");
			if (l_id==p_tabs.sel) continue;
			//l_x=l_node.pagePosLeft;
			l_x=getPos(l_node,"Left");
			l_y=getPos(l_node,"Top");
			l_w=l_node.offsetWidth;
			l_h=l_node.offsetHeight;
			if (v_x>l_x && v_x<(l_x+l_w) && v_y>l_y && v_y<(l_y+l_h)){
				l_treated=true;
				p_tabs.moduleOver(l_id);
				//v_obj.style.display="none";
				return true;
			} else {
				p_tabs.moduleOut(l_id);
			}
		}
	}
	//is object out of selection (under first row)
	if (!l_treated&&v_direction=="multidim"){
//		var l_tabs=_gel("tabsframe");
//		if (l_tabs!=null){
//			l_y=l_tabs.pagePosTop
		l_y=getPos(v_parent,"Top");
		if (v_y<=l_y) {return false;}
	}

	return true;
}
// Hide parent of concerned node
function hideParent(v_obj){
	v_obj.parentNode.style.display="none";
	v_obj.parentNode.style.display="";
}
// Modules number restriction 
function maxModReached(){
	var l_ret=false;
	if (tab[p_tabs.sel].module.length>__maxModNb){
		p_alert.show(lg("msgMaxMod",__maxModNb));
		l_ret=true;
	}
	return l_ret;
}
// Get the module identifier
function getModId(v_obj){
	var l_id=v_obj.parentNode.id;
	//l_id=id.replace("module","")
	l_id=id.substr(id.indexOf("_")+1);
	return parseInt(l_id.replace("_o",""),10);
}
// Save Module changes
function saveChanges(v_vars,v_supid,v_tab){
	var l_inc=0,l_save=false;
	var l_s="prof="+jsprof;
	if (v_tab==indef) v_tab=p_tabs.sel;
	if (tab[v_tab].moduleAlign){
		//build the saving string (for each column IMPACTED)
		for (var l_var=0;l_var<v_vars.length;l_var++){
			for (var l_nod=0;l_nod<tab[v_tab].cols[v_vars[l_var]].childNodes.length-1;l_nod++){
				//get the information of the concerned node (only if module one)
				var l_mod=tab[v_tab].cols[v_vars[l_var]].childNodes[l_nod];
				if (getModuleId(l_mod)!=-1){
					l_id=getModuleId(l_mod);
				} else {continue;}
				if (tab[v_tab].showType==0){
					//redefine the position of the modules in the modified columns
					tab[v_tab].module[l_id].newpos=l_nod+1;
					tab[v_tab].module[l_id].newcol=v_vars[l_var];
				} else {
					tab[v_tab].module[l_id].newposj=l_nod+1;
				}
				//if position modified, the saving string is updated
				if (tab[v_tab].module[l_id].col!=tab[v_tab].module[l_id].newcol || tab[v_tab].module[l_id].pos!=tab[v_tab].module[l_id].newpos || tab[v_tab].module[l_id].posj!=tab[v_tab].module[l_id].newposj){
					//check if new module (added) or not
					l_save=true;
					if (tab[v_tab].module[l_id].col<1){
						l_s+="&idn="+tab[v_tab].module[l_id].id+"&un="+tab[v_tab].module[l_id].uniq+"&pxn="+tab[v_tab].module[l_id].newcol+"&pyn="+tab[v_tab].module[l_id].newpos+"&xn="+tab[v_tab].module[l_id].newx+"&yn="+tab[v_tab].module[l_id].newy+"&jn="+tab[v_tab].module[l_id].newposj+"&vn="+_esc(tab[v_tab].module[l_id].vars);
					} else {
						l_inc++;
						l_s+="&id"+l_inc+"="+tab[v_tab].module[l_id].id+"&px"+l_inc+"="+tab[v_tab].module[l_id].newcol+"&py"+l_inc+"="+tab[v_tab].module[l_id].newpos+"&j"+l_inc+"="+tab[v_tab].module[l_id].newposj+"&x"+l_inc+"="+tab[v_tab].module[l_id].newx+"&y"+l_inc+"="+tab[v_tab].module[l_id].newy+"&u"+l_inc+"="+tab[v_tab].module[l_id].uniq;
					}
					tab[v_tab].module[l_id].col=tab[v_tab].module[l_id].newcol;
					tab[v_tab].module[l_id].pos=tab[v_tab].module[l_id].newpos;
					tab[v_tab].module[l_id].posj=tab[v_tab].module[l_id].newposj;
				}
			}
		}
	} else {
		//build the saving string (for each column IMPACTED)
		for (var l_nod=0;l_nod<tab[v_tab].root.childNodes.length;l_nod++){
			//get the information of the concerned node (only if module one)
			var l_mod=tab[v_tab].root.childNodes[l_nod];
			if (getModuleId(l_mod)!=-1){
				l_id=getModuleId(l_mod);
			} else {continue;}
			//if position modified, the saving string is updated
			if (tab[v_tab].module[l_id].x!=tab[v_tab].module[l_id].newx || tab[v_tab].module[l_id].y!=tab[v_tab].module[l_id].newy){
				//check if new module (added) or not
				l_save=true;
				if (tab[v_tab].module[l_id].col<1){
					l_s+="&idn="+tab[v_tab].module[l_id].id+"&un="+tab[v_tab].module[l_id].uniq+"&pxn="+tab[v_tab].module[l_id].newcol+"&pyn="+tab[v_tab].module[l_id].newpos+"&xn="+tab[v_tab].module[l_id].newx+"&yn="+tab[v_tab].module[l_id].newy+"&jn="+tab[v_tab].module[l_id].newposj+"&vn="+_esc(tab[v_tab].module[l_id].vars);
				} else {
					l_inc++;
					l_s+="&id"+l_inc+"="+tab[v_tab].module[l_id].id+"&px"+l_inc+"="+tab[v_tab].module[l_id].newcol+"&py"+l_inc+"="+tab[v_tab].module[l_id].newpos+"&j"+l_inc+"="+tab[v_tab].module[l_id].newposj+"&x"+l_inc+"="+tab[v_tab].module[l_id].newx+"&y"+l_inc+"="+tab[v_tab].module[l_id].newy+"&u"+l_inc+"="+tab[v_tab].module[l_id].uniq;
				}
				tab[v_tab].module[l_id].x=tab[v_tab].module[l_id].newx;
				tab[v_tab].module[l_id].y=tab[v_tab].module[l_id].newy;
			}
		}
	}
	if (v_supid!=indef){
		l_save=true;
		l_s+="&ids="+tab[v_tab].module[v_supid].id+"&us="+tab[v_tab].module[v_supid].uniq;
	}
	//call the XML saving function
	if (l_save){
		executescr("scr_config_place.php",l_s,false);
	}
	// this action restart the protection counter
	if (jspass!=""){p_counter.reset(4);}
}
// fill & Refresh module with format="M"
function refreshModCont(v_id,v_tab){
	if (v_tab==indef) v_tab=p_tabs.sel;
//	getXml(module[v_id].url+"pid="+jsid+"&prof="+jsprof+"&p="+module[v_id].uniq+"&"+module[v_id].vars,displayModCont,new Array(v_id,0,module[v_id].uniq),"xml");
	getXml(tab[v_tab].module[v_id].url,displayModCont,new Array(v_id,0,tab[v_tab].module[v_id].uniq,v_tab),"xml","pid="+jsid+"&prof="+tab[v_tab].id+"&p="+tab[v_tab].module[v_id].uniq+"&"+tab[v_tab].module[v_id].vars,"POST");
	return false;
}
function displayModCont(response,vars){
	var l_tab=vars[3];
	if (response.getElementsByTagName("Module")[0]){
		var l_mod=response.getElementsByTagName("Module")[0];
		var l_script="";
		//refresh edit box only if current tab
		p_param.fillEditBox(l_mod,vars[2],l_tab);
		if (l_mod.getElementsByTagName("Content")[0]){
			var l_contenttag=response.getElementsByTagName("Content")[0];
			var l_content=l_contenttag.firstChild.nodeValue;
			l_content=l_content.replace(/__MODULE_ID__/g,vars[2]);
//			var l_script=getXMLval(l_contenttag,"script","str",false,"")
			if (l_content.indexOf("<script>")!=-1 || l_content.indexOf('<script language="text/javascript">')!=-1 || l_content.indexOf("<script language='text/javascript'>")!=-1){
				var l_pos1=l_content.indexOf("<script>");
				if (l_pos1==-1) l_pos1=l_content.indexOf("<script language='text/javascript'>");
				if (l_pos1==-1) l_pos1=l_content.indexOf('<script language="text/javascript">');
				l_pos1=l_content.indexOf(">",l_pos1);
				var l_pos2=l_content.indexOf("</script>",l_pos1);
				var l_script=l_content.substring((l_pos1+1),l_pos2);
			}
			navPrint("module"+tab[l_tab].id+"_"+vars[2]+"_c",l_content);
			//launch script
			if (l_script!="") eval(l_script);
		}
	}
}
// fill & Refresh module with format="H"
//function refreshHtmlCont(v_id,v_pass){
//	var l_frm2=(IE)?frames["modfram"+module[v_id].uniq].window:document.getElementById("modfram"+module[v_id].uniq).contentWindow;
//	if (IE) {l_frm2.attachEvent('onload', function() {alert('tata');});}
//	else {l_frm2.addEventListener('load',function() {alert('tata');},false);}
//	if (v_pass==indef) l_frm2.location.href=pfolder+"empty_module.html";
//	//wait for the frame to be loaded
//	var l_frm=(IE)?frames["modfram"+module[v_id].uniq].document:document.getElementById("modfram"+module[v_id].uniq).contentDocument;
//	if (!l_frm||!l_frm.body||l_frm.body.innerHTML=="") {var l_script="refreshHtmlCont("+v_id+",true)";setTimeout(l_script, 1000);}
//	else { 
//		getXml(module[v_id].url,displayHtmlCont,new Array(v_id,0,module[v_id].uniq),"xml","pid="+jsid+"&prof="+jsprof+"&p="+module[v_id].uniq+"&"+module[v_id].vars,"GET");
//	}
//	return false;
//}
function displayHtmlCont(response,vars){
	if (response.getElementsByTagName("Module")[0]){
		var l_mod=response.getElementsByTagName("Module")[0];
		p_param.fillEditBox(l_mod,vars[2],l_tab);
		if (l_mod.getElementsByTagName("Content")[0]){
			var l_node=response.getElementsByTagName("Content")[0];
			if (l_node.firstChild.nodeType == 3){l_node.removeChild(l_node.firstChild);}
			l_content=l_node.firstChild.nodeValue;
			l_content=l_content.replace(/__MODULE_ID__/g,vars[2]);

			var l_frm=(IE)?frames["modfram"+tab[p_tabs.sel].id+"_"+vars[2]].document:document.getElementById("modfram"+tab[p_tabs.sel].id+"_"+vars[2]).contentDocument;
			var l_body=l_frm.body;
			l_body.innerHTML=l_content;
		}
	}
}
var p_param={
	show:function(v_uniq){
		//show edit box for selected module
		if (navIsShown("editbar"+tab[p_tabs.sel].id+"_"+v_uniq)) {p_param.hide(v_uniq);}
		else {navShow("editbar"+tab[p_tabs.sel].id+"_"+v_uniq,"block");}
		return false;
	},
	hide:function(v_uniq){
		//hide edit box for selected module
		navShow("editbar"+tab[p_tabs.sel].id+"_"+v_uniq,"none");
		return false;
	},
	fillEditBox:function(response,v_uniq,v_tab){
		//generate edit box for a module
		if (v_tab==indef) v_tab=p_tabs.sel;
		l_s="<form name='editform"+tab[v_tab].id+"_"+v_uniq+"' onsubmit='return p_param.valid("+v_uniq+");'>";
		var l_id=uniqToId(v_uniq,v_tab);
		//var ptitl=module[l_id].name;
		var ptitl=(getVar(tab[v_tab].module[l_id].vars,"ptitl")==""?tab[v_tab].module[l_id].name:getVar(tab[v_tab].module[l_id].vars,"ptitl"));
		if (tab[v_tab].module[l_id].format!='R' || tab[v_tab].showType==0){	
			l_s+="<table cellpadding='2' cellspacing='0' width='90%'>";
			l_s+="<tr><td>"+lg("lblModuleTitle")+"</td><td><input type='text' name='ptitl' size='18' value=\""+ptitl+"\" /></td></tr>";
			if (__barcolnb>1){
				l_s+="<tr><td>"+lg("lblBarColor")+"</td><td>";
				l_s+="<table cellspacing='1' cellpadding='0'><tr><td class='barstyle0'><a href='#' onclick='return p_param.setBColor("+v_uniq+")'>"+img("s.gif",18,18,"","barcoli","barcol"+tab[v_tab].id+"_"+v_uniq+"-")+"</a></td>";
				for (var i=1;i<=__barcolnb;i++){
					l_s+="<td class='barstyle"+i+"'><a href='#' onclick='return p_param.setBColor("+v_uniq+","+i+")'>"+img("s.gif",18,18,"","barcoli","barcol"+tab[v_tab].id+"_"+v_uniq+"-"+i)+"</a></td>";
				}
				l_s+="<td><input type='hidden' name='bcolor' value='' /></td></tr></table></td></tr>";
			}
			var i=0;
			while (response && response.getElementsByTagName("UserPref")[i]){
				var l_pref=response.getElementsByTagName("UserPref")[i];
				var l_type=getXMLprop(l_pref,"datatype","str",true,"string");
				if (l_type!="hidden") l_s+="<tr><td>"+lg(getXMLprop(l_pref,"display_name","str",false,""))+"</td><td>";
				var l_name=getXMLprop(l_pref,"name","str",true,"");
				var l_selValue=getVar(tab[v_tab].module[l_id].vars,l_name);
				var l_def=(l_selValue=="")?getXMLprop(l_pref,"default_value","str",false,""):l_selValue;
				switch(l_type){
					case "enum":
					l_s+="<select name='"+l_name+"'>";
					var j=0;
					while(l_pref.getElementsByTagName("EnumValue")[j]){
						var l_opt=l_pref.getElementsByTagName("EnumValue")[j];
						var l_optValue=getXMLprop(l_opt,"value","str",false,"")
						l_s+="<option value='"+l_optValue+"'"+((l_optValue==l_def)?" selected='selected'":"")+">"+getXMLprop(l_opt,"display_value","str",false,l_optValue)+"</option>";
						j++;
					}
					l_s+="</select>";
					break;
					case "string":
					l_s+="<input type='text' name='"+l_name+"' value='"+l_def+"' size='24' />";
					break;
					case "readonly":
					l_s+="<input type='text' name='"+l_name+"' value='"+l_def+"' size='24' disabled='disabled' />";
					break;
					case "password":
					l_s+="<input type='password' name='"+l_name+"' value='"+l_def+"' size='24' />";
					break;
					case "hidden":
					l_s+="<input type='hidden' name='"+l_name+"' value='"+l_def+"' />";
					break;
					case "bool":
					l_s+="<input type='checkbox' name='"+l_name+"'"+((l_def==1)?" checked='checked'":"")+" />";
					break;
				}
				
				if (l_type!="hidden") l_s+="</td></tr>";
				i++;
			}
			if (p_area.module.showAdminProperties){
				//l_s+="<div id='adminbar"+this.uniq+"' class='editbox'>essai</div>";
				l_s+="<tr><td class='tophr'>"+lg("lblFixedModule")+"</td><td class='tophr'><input type='checkbox' name='admblocked'"+(tab[v_tab].module[l_id].blocked?" checked='checked'":"")+" /></td></tr>";
			}
			l_s+="<tr><td colspan='2' align='center'><input class='btn' type='submit' value='"+lg("lblBtnValid")+"' /> <a href='#' onclick='return p_param.hide("+v_uniq+");'>"+lg("lblClose")+"</a></td></tr>";
			l_s+="</table></form>";
			navPrint("editbar"+tab[v_tab].id+"_"+v_uniq,l_s);
			p_param.setBColor(v_uniq,getVar(tab[v_tab].module[l_id].vars,"bcolor"),v_tab);
			p_area.module.changeName(l_id,ptitl,indef,v_tab);
		}
	},
	valid:function(v_uniq){
		//save new module customization
		var l_form=document.forms["editform"+tab[p_tabs.sel].id+"_"+v_uniq];
		var i=0,l_var,l_vars=[],l_refreshAll=false;
		var l_id=uniqToId(v_uniq);
		while(l_form.elements[i]){
			l_var="";
			switch(_lc(l_form.elements[i].type)){
				case "text":
				case "password":
				case "select-one":
				case "hidden":
					l_var=l_form.elements[i].name+"="+_esc(l_form.elements[i].value);break;
				case "checkbox":
				case "radio":
					l_var=(l_form.elements[i].checked?l_form.elements[i].name+"=1":l_form.elements[i].name+"=0");break;
			}
			if ((l_form.elements[i].name).substr(0,3)=="adm"){
				if (l_form.elements[i].name=="admblocked") {
					//the entire module needs to be refresh -> only solution: refresh all the modules
					if (tab[p_tabs.sel].module[l_id].blocked!=l_form.elements[i].checked) l_refreshAll=true;
					tab[p_tabs.sel].module[l_id].blocked=l_form.elements[i].checked;
				}
			} else {
				if (l_var!="")l_vars.push(l_var);
			}
			i++;
		}
		var l_qs=l_vars.join("&");
		//if title has changed or not
		if (tab[p_tabs.sel].module[l_id].name==getVar(l_qs,"ptitl")){
			//l_qs=supVar(l_qs,"ptitl");
		} else {
			p_area.module.changeName(l_id,getVar(l_qs,"ptitl"));
		}
		//if icon is set, keep it
		if (getVar(tab[p_tabs.sel].module[l_id].vars,"icon")!="") l_qs+="&icon="+getVar(tab[p_tabs.sel].module[l_id].vars,"icon");
		tab[p_tabs.sel].module[l_id].changeVar("",l_qs);
		if (l_refreshAll) {p_area.init(p_tabs.sel);}
		else {
			tab[p_tabs.sel].module[l_id].refresh();
			tab[p_tabs.sel].module[l_id].hdrColor();
			p_param.hide(v_uniq);
		}
		//if (p_area.module.showAdminProperties) executescr("../admin/scr_pages_adminproperties.php",v_uniq+l_admprop,true);
		return false;
	},
	getModuleParam:function(v_id,v_tab){
		if (v_tab==indef) v_tab=p_tabs.sel;
		var l_url=(tab[v_tab].module[v_id].url).replace(".php","_param.xml");
		l_url=l_url.replace(/\?/g,"");
		getXml(l_url,p_param.treatModuleParam,new Array(tab[v_tab].module[v_id].uniq,0,v_tab),"xml");
	},
	treatModuleParam:function(response,vars){
		if (response.getElementsByTagName("Module")[0]){
			var l_mod=response.getElementsByTagName("Module")[0];
			p_param.fillEditBox(l_mod,vars[0],vars[2]);
		}
	},
	setBColor:function(v_uniq,v_color,v_tab){
		//get the new color number in the form
		if (v_tab==indef) v_tab=p_tabs.sel;
		if (!v_color) v_color="";
		if (!document.forms["editform"+tab[v_tab].id+"_"+v_uniq]) return false;
		document.forms["editform"+tab[v_tab].id+"_"+v_uniq].bcolor.value=v_color;
		//change selected image border
		(_gel("barcol"+tab[v_tab].id+"_"+v_uniq+"-")).className="barcoli";
		for (var i=1;i<=__barcolnb;i++){
			(_gel("barcol"+tab[v_tab].id+"_"+v_uniq+"-"+i)).className="barcoli";
		}
		(_gel("barcol"+tab[v_tab].id+"_"+v_uniq+"-"+v_color)).className="barcola";
		return false;
	}
}

//==================================================================================================================
//						MENUS MANAGEMENT
//==================================================================================================================

var p_addContent={
	leftmenuinit:false,
	locked:false,
	menu:function(v_type){
		//no access to menu if page locked
		if (p_tabs.sel<0 || tab[p_tabs.sel].locked || p_addContent.locked){
			p_alert.show(lg("featureNotAvailableInScreen"),1);
			return false;
		}
		//if (jsprof==0&&jsid!=0) return false;
		// Open the "add content" menu
		if (showBoxStatus){hideBox();}
		if (__menuposition=="h"){
			var l_s="<table cellpadding='0'><tr><td><table class='addmenuhdr'><tr><td nowrap='nowrap'>";
			var l_initdim;
			if (__showModuleExpl){
				for (var i=0;i<__dimension.length;i++){
					if (__dimension[i]["lg"]=='' || __dimension[i]["lg"]==__lang){
						if (!l_initdim) l_initdim=__dimension[i]["id"];
						l_s+="<a id='dir"+__dimension[i]["seq"]+"' class='optlist' href='#' onclick='return p_addContent.lists("+__dimension[i]["seq"]+","+__dimension[i]["id"]+",1)'>"+__dimension[i]["name"]+"</a> | ";
					}
				}
				if (__useList) l_s+="<a id='dir"+i+"' class='optlist' href='#' onclick='return p_addContent.lists("+i+",0,1)'>"+lg("lblList")+"</a> | ";
			}
			l_s+="</td><td nowrap='nowrap' valign='middle'>";
			if (__showModuleSearch) l_s+="<form name='mod__search' onsubmit='p_addContent.getSearch(document.mod__search.searchtxt.value,0);return false;'>&nbsp;"+img("ico_search.gif",12,12)+" <input class='thinbox' name='searchtxt' type='text' size='20' value='"+lg("lblSearch")+"' onclick=\"this.value='';\" /><input type='submit' name='buts' class='btn' value='Go' /></form>";
			l_s+="</td><td nowrap='nowrap' valign='middle'>";
			if (__showrsscell) l_s+="<form name='rss' onsubmit='return p_rss.checkFeed()'>&nbsp;|&nbsp;"+lg("lblAddRSS")+" "+tooltip("msgRSShlp")+" <input class='thinbox' name='vars' type='text' size='20' value='"+lg("lblRSSFlow")+"' onclick=\"javascript:vars.value='';navPrint('authrss','');\" /><input type='submit' name='butr' class='btn' value='Go' /><div id='authrss' style='width:180px;text-align:left;display:none;'></div></form></td>";
			if (__userModuleJs=='I') l_s+="<td nowrap='nowrap'>&nbsp;|&nbsp;<a href='#' onclick='return createMyModule()'>"+img("ico_ownmodule.gif",14,14)+" "+lg("lblCreateYourMod")+"</a></td>";
			l_s+="</tr></table></td></tr>";
			if (__showModuleExpl) l_s+="<tr><td id='listmod' style='height:116px;padding-top:8px;' valign='top'></td></tr>";
			l_s+="</table>";

			navPrint("box",box(0,img("ico_menu_add.gif",12,12,"","imgmid")+" "+lg("lblAddMenu")+" (sign in to save the added widgets on your page):","hideBox()",l_s));
			navShow("box","block");
			showBoxStatus=true;
			if (__showModuleExpl){if (v_type!=indef && __useList){p_addContent.lists(0,0,v_type);}else{p_addContent.lists(0,l_initdim,0);};}
		} else {
			p_menu.init();
			if (!p_addContent.leftmenuinit){
				var l_s="";
				//l_s+="<div class='leftmenuheader'><table cellpadding='0' cellspacing='0' width='100%'><tr><td width='36'>"+img("ico_menu_add.gif",28,28)+"</td><td>"++"</td><td style='text-align:right;padding-right:6px;'><a href='#' onclick='p_addContent.hide()'>"+img("ico_close.gif",9,9)+"</a></td></tr></table></div>";
				//l_s+="<div class='leftmenucontent'>";
				if (__showrsscell){
					l_s+="<div class='leftmenuitem' onclick='return p_addContent.displayItem(1)'>"+img("ico_rss2.gif",16,16,"","imgmid")+" "+lg("lblAddRSS")+"</div>";
					l_s+="<div class='leftmenuitemcontent' id='itemaddrss'>";
					l_s+="<form name='rss' onsubmit='return p_rss.checkFeed()'><br />"+lg("enterRssUrl")+" :<br /><br /><input class='thinbox' name='vars' type='text' size='25' value='"+lg("lblRSSFlow")+"' onclick=\"javascript:vars.value='';navPrint('authrss','');\" /><input type='submit' name='butr' class='btn' value='Go' /> "+tooltip("msgRSShlp")+"<div id='authrss' style='width:180px;text-align:left;display:none;'></div></form>";
					if (jsid>0) l_s+="<br /><a href='#' onclick='return p_rss.importMenu()'>"+lg("lblImport")+"/"+lg("lblExport")+" (OPML)</a> "+tooltip("msgOpmlhlp");
					l_s+="<br /></div>";
//					l_s+="<tr><td class='bottomhr' nowrap='nowrap' align='middle' style='height:56px'><form name='rss' onsubmit='return p_rss.checkFeed()'>"+lg("lblAddRSS")+" <a href='#' onclick=\"return p_alert.show(lg('msgRSShlp'),2)\">"+img("ico_help_s.gif",12,12,lg("lblHelp"),"imgmid")+"</a><br /><input class='thinbox' name='vars' type='text' size='20' value='"+lg("lblRSSFlow")+"' onclick=\"javascript:vars.value='';navPrint('authrss','');\" /><input type='submit' name='butr' class='btn' value='Go' /><div id='authrss' style='width:180px;text-align:left;display:none;'></div></form>";
//					if (jsid>0) l_s+="<a href='#' onclick='return p_rss.importMenu()'>"+lg("lblImport")+"/"+lg("lblExport")+" (OPML)</a> <a href='#' onclick=\"return p_alert.show(lg('msgOpmlhlp'),2)\">"+img("ico_help_s.gif",12,12,lg("lblHelp"),"imgmid")+"</a>";
//					l_s+="</td></tr>";
				}
				if (__showModuleSearch) l_s+="<div class='leftmenuitem' onclick='return p_addContent.displayItem(2)'>"+img("ico_search.gif",16,16,"","imgmid")+" "+lg("lblSearch")+"</div><div class='leftmenuitemcontent' id='itemaddsearch'><form name='mod__search' onsubmit='p_addContent.getSearch(document.mod__search.searchtxt.value,0);return false;'><br />"+lg("searchModuleByKeywords")+" : <br /><br /><input class='thinbox' name='searchtxt' type='text' size='25' value='"+lg("lblSearch")+"' onclick=\"this.value='';\" /> <input type='submit' name='buts' class='btn' value='Go' />&nbsp;"+tooltip("helpTags")+"<div id='listmod' style='width:210px;text-align:left;'></div></form><br /></div>";
				if (__showModuleExpl) l_s+="<div class='leftmenuitem' onclick='return p_addContent.displayItem(3)'>"+img("ico_directory.gif",16,14,"","imgmid")+" "+lg("lblExplore")+"</div><div class='leftmenuitemcontent' id='itemaddexplore'><div id='exp0' class='explorer'>loading ...</div></div>";
				if (__userModuleJs=='I') l_s+="<div class='leftmenuitem' onclick='return p_addContent.displayItem(4)'>"+img("mymodules.gif",16,15,"","imgmid")+" "+lg("lblArchive2")+"</div><div class='leftmenuitemcontent' id='itemaddmymodule'>loading ...</div>";
				p_menu.display(0,lg("lblAddContent"),"ico_menu_add.gif",indef,l_s,"");
				if (__showModuleExpl) {p_addContent.displayItem(3);p_addContent.getExplorer(0);}
				p_addContent.leftmenuinit=true;
				p_edit.leftmenuinit=false;
			}
			//if (!IE) p_area.resize();
			p_area.resize();
		}
		return false;
	},
	displayItem:function(v_item){
		if (v_item==1) navShow("itemaddrss","block");
		else navShow("itemaddrss","none");
		if (v_item==2) navShow("itemaddsearch","block");
		else navShow("itemaddsearch","none");
		if (v_item==3) navShow("itemaddexplore","block");
		else navShow("itemaddexplore","none");
		if (v_item==4) {navShow("itemaddmymodule","block");p_addContent.getMyModules();}
		else navShow("itemaddmymodule","none");
		return false;
	},
	lists:function(v_id,v_catid,v_order){
		for (var i=0;i<__dimension.length;i++){
			navClass("dir"+__dimension[i]["seq"],((__dimension[i]["seq"]==v_id)?"sellist":"optlist"));
		}
		if (v_catid==0){p_addContent.getList(1,v_order);}
		else {p_addContent.initDir(v_catid);}
		return false;
	},
	getList:function(v_page,v_order){
		if (v_order==indef) v_order=1;
		// Open the services lists
		getXml("selections/allservices"+v_order+"_"+v_page+".xml",p_addContent.displayList,new Array(v_page,v_order));
	},
	displayList:function(response,vars){
		var l_s="";
		l_s+="<table cellpadding='0' cellspacing='0'>";
		if (response.getElementsByTagName("page")[0]){
			var l_id;
			l_s+="<tr><td width='20'></td><td><table width='600'><tr>";
			l_s+="<td><input type=radio"+((vars[1]==1)?" checked='checked'":"")+" onclick='p_addContent.getList(1,1);' />"+lg("lblNewMods")+"</td>";
			if (__useNotation) l_s+="<td><input type='radio'"+((vars[1]==2)?" checked='checked'":"")+" onclick='p_addContent.getList(1,2);' />"+lg("lblBestRank")+"</td>";
			if (__useNotation) l_s+="<td><input type='radio'"+((vars[1]==3)?" checked='checked'":"")+" onclick='p_addContent.getList(1,3);' />"+lg("lblPopMods")+"</td>";
			l_s+="<td><input type='radio'"+((vars[1]==4)?" checked='checked'":"")+" onclick='p_addContent.getList(1,4);' />"+lg("lblNewsMods")+"</td>";
			l_s+="</tr></table></td><td width='20'></td></tr>";
			l_s+="<tr><td style='height:126px' valign='top' align='center'>";
			if (vars[0]>1){l_s+="<a href='#' onclick='p_addContent.getList("+(vars[0]-1)+","+vars[1]+");return false;'>"+img("prev.gif",14,27,lg("lblPrevMods"))+"</a>";}
			l_s+="</td><td valign='top' class='dirdiva'><table cellpadding='0' cellspacing='1' width='700'>";
			var i=0;
			while (response.getElementsByTagName("item")[i]){
				result=response.getElementsByTagName("item")[i];
				l_id=getXMLval(result,"id","int",false,0);
				l_s+="<tr><td>"+img("../modules/pictures/box0_"+l_id+".ico",16,16,"","imgmid")+" <a class='menul' href='#' onclick='openmod("+l_id+")'>"+getXMLval(result,"name","str",false,"--")+"</a> : "+getXMLval(result,"desc","str",false,"...")+"</td></tr>";
				i++;
			}
			if (i==7){l_s+="</table></td><td valign='top' align='center'><a href='#' onclick='p_addContent.getList("+(vars[0]+1)+","+vars[1]+");return false;'>"+img("next.gif",14,27,lg("lblNextMods"))+"</a>";}
		} else {l_s+=lg("lblDisplayErr");}
		l_s+="</td></tr></table>";
		navShow("listmod","block");
		navPrint("listmod",l_s);
	},
	getSearch:function(v_s,v_page){
		// Open the search results
		v_s=formatSearch(v_s);
		navClass("dirlink","optlist");
		navClass("listlink","optlist");
		navClass("sellink","optlist");
		navPrint("listmod",lg("searching"));
		getXml("xmlsearch.php?searchtxt="+_esc(v_s)+"&p="+v_page,p_addContent.displaySearch,new Array(v_s,v_page));
	},
	displaySearch:function(response,vars){
		var l_s="",l_result;
		if (response.getElementsByTagName("nbres")[0]){
			var l_nbres=getXMLval(response,"nbres","int",false,0);
			l_s+="<br />"+lg("lblResultsFor")+" '"+vars[0]+"' :";
		//	if (__useContact) l_s+="<td align='right'><a href='#' onclick='return p_contact.menu(2);'>"+lg("lblModMissing")+"</a></td>";
			l_s+="<div class='dirdiva' style='height:180px;'><table cellpadding='0' cellspacing='1'>";
			if (response.getElementsByTagName("item")[0]){
				for (var i=0;i<10;i++){
					if (response.getElementsByTagName("item")[i]){
						l_result=response.getElementsByTagName("item")[i];
						l_s+="<tr><td>"+img("../modules/pictures/box0_"+getXMLval(l_result,"id","int",false,0)+".ico",16,16,"","imgmid")+" <a class='menul' href='#' onclick='return openmod("+getXMLval(l_result,"id","int",false,0)+")'>"+getXMLval(l_result,"name","str",false,"...")+"</a></td></tr>";
					}
				}
			} else {l_s+="<tr><td>"+lg("lblSrchNoMod")+"</td></tr>";}
			l_s+="</table></div>";
			l_s+="<table style='width:95%'><tr>";
			if (vars[1]!=0){l_s+="<td><a href='#' onclick=\"p_addContent.getSearch('"+vars[0]+"',"+(parseInt(vars[1])-1)+");return false;\">"+img("ico_previous2.gif",12,11,lg("lblPrevMods"))+" "+lg("previous")+"</a></td>";}
			if (l_nbres==11){l_s+="<td style='text-align:right'><a href='#' onclick=\"p_addContent.getSearch('"+vars[0]+"',"+(parseInt(vars[1])+1)+");return false;\">"+lg("next")+" "+img("ico_next2.gif",12,11,lg("lblNextMods"))+"</a></td>";}
			l_s+="</tr></table>";
		}
		else {l_s+="<font style='color:#ff0000'>"+lg("lblSrch3car")+"</font>";}
		navShow("listmod","block");
		navPrint("listmod",l_s);
	},
	clearSearch:function(){
		navPrint("listmod","");
		return false;
	},
	initDir:function(v_cat){
		// Initialize modules directory menu
		var l_s="<table cellpadding='0' cellspacing='0' border='0'><TR>";
		l_s+="<td><table cellspacing='0' width='100%'><tr><td>"+lg("lblNavDir")+" :</td><td align='right'></td></tr></table></td></tr>";
		l_s+="<tr><td><table><tr>";
		l_s+="<td><div id='level1' class='dirdivi' style='width:230px'></div></td>";
		l_s+="<td><div id='level2' class='dirdivi' style='width:200px'></div></td>";
		l_s+="<td><div id='level3' class='dirdivi' style='width:200px'></div></td>";
		l_s+="<td><div id='level4' class='dirdivi' style='width:170px'></div></td>";
		l_s+="</tr></table></td></tr></table>"+img("",7,7)+"<br />";
		navShow("listmod","block");
		navPrint("listmod",l_s);
		navPrint("level1","Chargement ...");
		p_addContent.getDir(v_cat,1);
	},
	getDir:function(v_cat,v_level){
		// Open the modules directory
		getXml("../cache/cat_"+v_cat+"_"+__lang+".xml?rand="+rand,p_addContent.displayDir,v_level);
	},
	displayDir:function(response,vars){
		var l_s="";
		if (response.getElementsByTagName("parent")[0]){
			l_s+="<table cellpadding='0' cellspacing='1' border='0' style='width:90%'>";
			if (response.getElementsByTagName("dir")[0]){
				var l_i=0,l_dirid;
				while (response.getElementsByTagName("dir")[l_i]){
					var l_result=response.getElementsByTagName("dir")[l_i];
					l_dirid=getXMLval(l_result,"dirid","int",false,0);
					l_dirquantity=getXMLval(l_result,"quantity","int",false,0);
					if (l_dirquantity!=0) l_s+="<tr><td id='dir"+l_dirid+"' class='catopti' onmouseover='catOptOver(\""+l_dirid+"\")' onmouseout='catOptOut(\""+l_dirid+"\")'>&nbsp;<a href='#' class='menul' onclick='p_addContent.getDir("+l_dirid+","+(vars+1)+");catOptSel("+l_dirid+","+vars+");return false;'>"+getXMLval(l_result,"dirname","str",false,"...")+" ("+l_dirquantity+")</a></td></tr>";
					l_i++;
				}
			}
			if (response.getElementsByTagName("item")[0]){
				var l_i=0,l_itemid;
				while (response.getElementsByTagName("item")[l_i]){
					var l_result=response.getElementsByTagName("item")[l_i];
					l_itemid=getXMLval(l_result,"id","int",false,0);
					l_s+="<tr><td>"+img("../modules/pictures/box0_"+l_itemid+".ico",16,16,"","imgmid")+"&nbsp;<a href='#' class='menul' onclick='openmod("+l_itemid+");return false;'>"+getXMLval(l_result,"name","str",false,"...")+"</a></td></tr>";
					l_i++;
				}
			}
			l_s+="</table>";
		}
		else {l_s+=lg("lblDisplayErr");}

		navClass("level"+vars,"dirdiva");
		navPrint("level"+vars,l_s);
		//clear unused div
		for (var i=vars+1;i<5;i++){navPrint("level"+i,"");navClass("level"+i,"dirdivi");}
	},
	getExplorer:function(v_cat,v_open){
		if (v_open==indef) v_open=1;
		getXml("../cache/cat_"+v_cat+(v_cat==0?"":"_"+__lang)+".xml?rand="+rand,p_addContent.displayExplorer,new Array(v_cat,v_open));
		return false;
	},
	displayExplorer:function(response,vars){
		var l_s="";
		if (vars[0]!=0) l_s+="<a href='#' class='dirlink' onclick='return p_addContent.getExplorer("+vars[0]+","+(vars[1]==0?"1":"0")+");'>"+img((vars[1]==1?"ico_minus.gif":"ico_plus.gif"),9,9)+" "+getXMLval(response,"dirname","str",true,"--")+"</a><br />";
		if (response.getElementsByTagName("parent")[0] && vars[1]==1){
			if (response.getElementsByTagName("dir")[0]){
				var l_i=0,l_dirid;
				while (response.getElementsByTagName("dir")[l_i]){
					var l_result=response.getElementsByTagName("dir")[l_i];
					l_dirid=getXMLval(l_result,"dirid","int",false,0);
					l_dirquantity=getXMLval(l_result,"quantity","int",false,0);
					l_lang=getXMLval(l_result,"lang","str",false,"");
					if (l_lang=="" || l_lang==__lang){
						if (l_dirquantity!=0 || vars[0]==0) l_s+="<div class='expdir' id='exp"+l_dirid+"'><a href='#' class='dirlink' onclick='return p_addContent.getExplorer("+l_dirid+");'>"+img("ico_plus.gif",9,9)+" "+getXMLval(l_result,"dirname","str",false,"...")+" ("+l_dirquantity+")</a></div>";
					}
					l_i++;
				}
			}
			if (response.getElementsByTagName("item")[0]){
				var l_i=0,l_itemid;
				while (response.getElementsByTagName("item")[l_i]){
					var l_result=response.getElementsByTagName("item")[l_i];
					l_itemid=getXMLval(l_result,"id","int",false,0);
					l_s+="<div>"+img("../modules/pictures/box0_"+l_itemid+".ico",16,16,"","imgmid")+"&nbsp;<a href='#' class='modlink' onclick='openmod("+l_itemid+");return false;'>"+getXMLval(l_result,"name","str",false,"...")+"</a></div>";
					l_i++;
				}
			}
		}

		//if (vars[0]!=0) navClass("exp"+vars[0],(vars[1]==0?"expdiri":"expdira"));
		navPrint("exp"+vars[0],l_s);
	},
	getMyModules:function(){
		getXml("../portal/xmlmymodules.php",p_addContent.displayMyModules);
	},
	displayMyModules:function(response,vars){
		var l_s="",l_result=response.getElementsByTagName("module");
		for (var i=0;i<l_result.length;i++){
			if (getXMLval(l_result[i],"status","str",false,"N")=="O") l_s+="<a href='#' onclick='openmod("+getXMLval(l_result[i],"id","int",false,0)+")'>"+img("puce.gif",3,5,"","imgmid")+" "+getXMLval(l_result[i],"name","str",false,"???")+"</a><br/>";
		}
		l_s+="<br /><a href='#' onclick='p_factory.init()'>"+img("mymodules_create.gif",16,16,"","imgmid")+" "+lg("createExpertModule")+"</a>";
		navPrint("itemaddmymodule",l_s);
	}
}
function createMyModule(){
	if (jsid==0){p_alert.show(lg("msgTutorialConn"));}
	else {link("../tutorial/");}
	return false;
}
// Directory management
function dirOptOver(v_id){if (_gel("dir"+v_id)&&(_gel("dir"+v_id)).className=="diropti") navClass("dir"+v_id,"diropta");}
function dirOptOut(v_id){if (_gel("dir"+v_id)&&(_gel("dir"+v_id)).className=="diropta") navClass("dir"+v_id,"diropti");}
function dirOptSel(v_id,v_level){
	navClass("dir"+v_id,"diropts");
	if (dirOptSelId[v_level]!=indef && dirOptSelId[v_level]!=v_id){navClass("dir"+dirOptSelId[v_level],"diropti");}
	dirOptSelId[v_level]=v_id;
}
function catOptOver(v_id){if (_gel("dir"+v_id)&&(_gel("dir"+v_id)).className=="catopti") navClass("dir"+v_id,"catopta");}
function catOptOut(v_id){if (_gel("dir"+v_id)&&(_gel("dir"+v_id)).className=="catopta") navClass("dir"+v_id,"catopti");}
function catOptSel(v_id,v_level){
	navClass("dir"+v_id,"catopts");
	if (dirOptSelId[v_level]!=indef && dirOptSelId[v_level]!=v_id){navClass("dir"+dirOptSelId[v_level],"catopti");}
	dirOptSelId[v_level]=v_id;
}
var p_edit={
	oldStyle:1,
	leftmenuinit:false,
	tempIcon:"",
	locked:false,
	menu:function(){
		//no access to menu if page locked
		if (p_tabs.sel<0 || tab[p_tabs.sel].locked || p_edit.locked){
			p_alert.show(lg("featureNotAvailableInScreen"),1);
			return false;
		}
		//if (jsprof==0&&jsid!=0) return false;
		// Open the "edit" menu
		if (showBoxStatus){hideBox();}
		p_edit.oldStyle=tab[p_tabs.sel].style;
		if (__menuposition=="h"){
			var l_s="<form name='option'>";
			l_s+="<table width='100%'><tr><td class='bottomhr'><table width='100%' cellpadding='3'>";
			if (__themeNb>1) l_s+="<tr><td class='menuopt'>"+lg("lblColors")+" <input type='button' value='<' style='width:20px' onclick='prevstyle();' /> <input type='text' name='selstyle' value='style "+tab[p_tabs.sel].style+"' style='text-align:center;width:40px;' size='7' disabled /> <input type='button' value='>' style='width:20px' onclick='nextstyle();' /></td></tr>";
			//l_s+="<tr><td class='menuopt'>"+lg("lblColNb")+" <input type='radio' name='nbcol' value='2' />2 <input type=radio name='nbcol' value=3 />3 <input type=radio name='nbcol' value=4 />4</td></tr>";
			if (__columnchange) l_s+="<tr><td class='menuopt'>"+lg("lblColNb")+" <input type='button' value='-' style='width:20px' onclick='p_edit.supCols()' /> <input type='text' name='nbcol' value='"+tab[p_tabs.sel].colnb+"' style='text-align:right;width:20px;' size='1' disabled /> <input type='button' value='+' style='width:20px' onclick='p_edit.addCols()' /></td></tr>";
			if (__usereader) l_s+="<tr><td class='menuopt'><label>"+lg("lblUseInternalReader")+" <input type='checkbox' name='usereader' "+(tab[p_tabs.sel].usereader==1?"checked='checked' ":"")+"/></label> "+tooltip("msgReaderhlp")+"</td></tr>";
			if (__ctrlhiding) l_s+="<tr><td class='menuopt'><label>"+lg("lblMoveMods")+" <input type='checkbox' name='controls' "+((tab[p_tabs.sel].controls=='Y')?"checked='checked' ":"")+"/></label> "+tooltip("msgCtrlhlp")+"</td></tr>";
			if (__modulealign) l_s+="<tr><td class='menuopt'><label>"+lg("lblModuleAlign")+" <input type='checkbox' name='modulealign' "+((tab[p_tabs.sel].moduleAlign)?"checked='checked' ":"")+"/></label> "+tooltip("msgModuleAlign")+"</td></tr>";
			l_s+="<tr><td class='menuopt'><label>"+lg("loadOnStart")+" <input type='checkbox' name='loadonstart' "+((tab[p_tabs.sel].loadstart==1)?"checked='checked' ":"")+"/></label> "+tooltip("msgLoadStarthlp")+"</td></tr>";
			if (jsid!=0 && __doubleprotection){
				//if info feed exists
				//if (__rssinfo!=""){
				//	l_s+="<tr><td class='menuopt'>"+lg("lblDailyAdvise")+" <input type='checkbox' name='useadvise'";
				//	if (p_banner.info.requested=="Y") l_s+=" checked='checked'";
				//	l_s+=" /></td></tr>";
				//}
				l_s+="<tr><td class='menuopt'><label>"+lg("lblSecurity")+" <input type='checkbox' name='usepass'";
				if (jspass!="") l_s+=" checked='checked'";
				l_s+=" /></label> "+tooltip("msgSecurityhlp")+"</td></tr>";
			}
			if (__showtabicon) {
				l_s+="<tr><td>"+lg("addIconToPage")+"<br /><br /><div id='pageicons'>";
				l_s+="</div></td></tr>";
			}
			l_s+="</table><br /><input class='btnbig' type='button' value='"+lg("lblBtnValid")+"' onclick='p_edit.save();' /><br /><br />";
			l_s+="</div></td></tr>";
			if (jsid!=0&&IE) l_s+="<tr><td class='bottomhr'>"+img("ico_home.gif",14,14)+" <a class='menul' href='#' onclick='addHome();return false;'>"+lg("lblHome",__apname)+"</a> &nbsp; &nbsp; "+img("ico_favorite.gif",14,14)+" <a class='menul' href='#' onclick='addFav();return false;'>"+lg("lblFav",__apname)+"</a></td></tr>";
			//l_s+="<tr><td>"+helpMove()+"</td></tr>";
			l_s+="</td></tr></table></form>";

			//p_area.module.showHdr();
			navPrint("box",box(0,img("ico_menu_tools.gif",12,12,"","imgmid")+" "+lg("lblEditMenu"),"p_edit.hide()",l_s));
			navShow("box","block");
			showBoxStatus=true;
		} else {
			p_menu.init()
			var l_s="";
			l_s+="<div class='leftmenuitem' onclick='return p_edit.displayItem(1)'>"+lg("optionsOfThisPage")+"</div><div class='leftmenuitemcontent' id='itemeditpage'>";
			l_s+="<form name='option'><table cellpadding='0' cellspacing='0' border='0' width='100%'>";
			if (__themeNb>1) l_s+="<tr><td class='bottomhr'>"+lg("lblColors")+" &nbsp; <input type='button' value='<' style='width:20px' onclick='prevstyle();' /> <input type='text' name='selstyle' value='style "+tab[p_tabs.sel].style+"' style='text-align:center;width:40px;' size='7' disabled /> <input type='button' value='>' style='width:20px' onclick='nextstyle();' /></td></tr>";
			if (__columnchange) l_s+="<tr><td class='bottomhr'>"+lg("lblColNb")+" &nbsp; <input type='button' value='-' style='width:20px' onclick='p_edit.supCols()' /> <input type='text' name='nbcol' value='"+tab[p_tabs.sel].colnb+"' style='text-align:right;width:20px;' size='1' disabled /> <input type='button' value='+' style='width:20px' onclick='p_edit.addCols()' /></td></tr>";
			if (__usereader) l_s+="<tr><td class='bottomhr'><input type='checkbox' name='usereader' "+(tab[p_tabs.sel].usereader==1?"checked='checked' ":"")+"/> "+lg("lblUseInternalReader")+" "+tooltip("msgReaderhlp")+"</td></tr>";
			if (__ctrlhiding) l_s+="<tr><td class='bottomhr'><input type='checkbox' name='controls' "+((tab[p_tabs.sel].controls=='Y')?"checked='checked' ":"")+"/> "+lg("lblMoveMods")+" "+tooltip("msgCtrlhlp")+"</td></tr>";
			if (__moduleAlign) l_s+="<tr><td class='menuopt'><input type='checkbox' name='modulealign' "+((tab[p_tabs.sel].moduleAlign)?"checked='checked' ":"")+"/> "+lg("lblModuleAlign")+" "+tooltip("msgModuleAlign")+"</td></tr>";
			l_s+="<tr><td class='bottomhr'><input type='checkbox' name='loadonstart' "+((tab[p_tabs.sel].loadstart==1)?"checked='checked' ":"")+"/> "+lg("loadOnStart")+" "+tooltip("msgLoadStarthlp")+"</td></tr>";
			if (jsid!=0 && __doubleprotection){
				//if info feed exists
				//if (__rssinfo!=""){
				//	l_s+="<tr><td class='bottomhr' align='center'>"+lg("lblDailyAdvise")+" <input type='checkbox' name='useadvise'";
				//	if (p_banner.info.requested=="Y") l_s+=" checked='checked'";
				//	l_s+=" /></td></tr>";
				//}
				l_s+="<tr><td class='bottomhr'><input type='checkbox' name='usepass'";
				if (jspass!="") l_s+=" checked='checked'";
				l_s+=" /> "+lg("lblSecurity")+" "+tooltip("msgSecurityhlp")+"</td></tr>";
			}
			if (__showtabicon) {
				l_s+="<tr><td class='bottomhr'>"+lg("addIconToPage")+"<br /><br /><div id='pageicons'>";
				l_s+="</div></td></tr>";
			}
			l_s+="<tr><td class='bottomhr' align='center'><br /><input class='btnbig' type='button' value='"+lg("lblBtnValid")+"' onclick='p_edit.save();' /><br /></td></tr>";
			//l_s+="<tr><td><br />"+helpMove()+"</td></tr>";
			l_s+="</table></form>";
			l_s+="</div>";
			l_s+="<div class='leftmenuitem' onclick='return p_edit.displayItem(2)'>"+lg("optionsOfThePortal")+"</div><div class='leftmenuitemcontent' id='itemeditportal'>";
			if (jsid!=0&&IE) l_s+="<br />"+img("ico_home.gif",14,14)+" <a class='menul' href='#' onclick='addHome();return false;'>"+lg("lblHome",__apname)+"</a><br />"+img("ico_favorite.gif",14,14)+" <a class='menul' href='#' onclick='addFav();return false;'>"+lg("lblFav",__apname)+"</a>";
			l_s+="</div>";
			p_menu.display(0,lg("options"),"","p_edit.hide()",l_s,"");
			p_edit.leftmenuinit=true;
			p_addContent.leftmenuinit=false;
			//}
			//if (!IE) p_area.resize();
			p_area.resize();
			p_edit.displayItem(1);
		}
		//document.forms['option'].nbcol[(p_area.col.nb-2)].checked=true;
		if (__showtabicon){
			p_edit.showIcons();
			if (tab[p_tabs.sel].icon!="") p_edit.setIcon(indef,tab[p_tabs.sel].icon); else p_edit.setIcon(-1);
		}
		return false;
	},
	displayItem:function(v_item){
		if (v_item==1) navShow("itemeditpage","block");
		else navShow("itemeditpage","none");
		if (v_item==2) navShow("itemeditportal","block");
		else navShow("itemeditportal","none");
		return false;
	},
	showIcons:function(){
		var l_s="<a href='#' onclick='p_edit.setIcon(-1)'>"+lg("noIcon")+"</a> ";
		for (i=0;i<__nbicons;i++){
			l_s+="<a href='#' onclick='p_edit.setIcon("+i+")'><img id='icon"+i+"' src='../modules/pictures/_deficon"+i+".gif' style='width:16px;height:16px;border:1px solid #ffffff;' align='absmiddle' /></a> ";
		}
		navPrint("pageicons",l_s);
	},
	hide:function(){
		p_menu.hide();
		//re-initialize the colors (if not saved)
		if (tab[p_tabs.sel].style!=p_edit.oldStyle){
			tab[p_tabs.sel].style=p_edit.oldStyle;
			setActiveStyleSheet(tab[p_tabs.sel].style);
		}
	},
	addCols:function(){
		l_colnb=parseInt(document.forms["option"].nbcol.value,10);
		if (l_colnb<9){
			l_colnb++;
			document.forms["option"].nbcol.value=l_colnb;
		}
	},
	supCols:function(){
		l_colnb=parseInt(document.forms["option"].nbcol.value,10);
		if (l_colnb>1){
			l_colnb--;
			document.forms["option"].nbcol.value=l_colnb;
		}
	},
	setIcon:function(v_id,v_url){
		for (var i=0;i<__nbicons;i++){
			if (v_id==indef) {(_gel("icon"+i)).style.borderColor=("../modules/pictures/_deficon"+i+".gif"==v_url?"#ff0000":"#ffffff");}
			else {(_gel("icon"+i)).style.borderColor=(i==v_id?"#ff0000":"#ffffff");}
		}
		if (v_id==indef) {p_edit.tempIcon=v_url;}
		else {p_edit.tempIcon=(v_id==-1?"":"../modules/pictures/_deficon"+v_id+".gif");}
	},
	save:function(){
		// Save the settings
		var l_form=document.forms['option'];
		var l_alarm=true;
		//sécurity
		var l_secu=(l_form.usepass)?l_form.usepass.checked:false;
		jspass=l_secu?"ok":"";
		//info banner
		if (l_form.useadvise){
			p_banner.info.requested=(l_form.useadvise.checked)?"Y":"N";
			if (p_banner.info.requested=="Y" && p_banner.info.loaded && p_banner.info.shown) p_banner.info.load(0);
		}
		//style
		p_edit.oldStyle=tab[p_tabs.sel].style;
		// showtype
		//var l_showType=getRadioValue(l_form.showtype);
		//use reader
		var l_usereader=__usereader?(l_form.usereader.checked?1:0):0;
		//controls
		var l_controls=(l_form.controls.checked?"Y":"N");
		var l_moduleAlign=l_form.modulealign.checked;
		
		tab[p_tabs.sel].label=p_tabs.currName;
		tab[p_tabs.sel].lock=jspass;
		
		//Columns
		l_nbCol=parseInt(l_form.nbcol.value,10);
		var l_allowSuppress=p_area.col.check(l_nbCol);
		if (l_allowSuppress){
			if (l_nbCol>tab[p_tabs.sel].colnb){p_area.col.add(l_nbCol);}
			else if (l_nbCol<tab[p_tabs.sel].colnb){p_area.col.sup(l_nbCol);}
		} else {l_nbCol=tab[p_tabs.sel].colnb;l_alarm=false;}
		//if (p_area.showType!=l_showType) changeShowType(l_showType);
		if (tab[p_tabs.sel].controls!=l_controls){
			p_area.module.switchHdr();
		}
		if (tab[p_tabs.sel].moduleAlign!=l_moduleAlign){
			p_area.module.align(tab[p_tabs.sel].moduleAlign);
		}
		if (tab[p_tabs.sel].showType==1&&l_nbCol!=tab[p_tabs.sel].colnb) p_alert.show(lg("lblColNbErr"));
		
		tab[p_tabs.sel].usereader=l_usereader;
		tab[p_tabs.sel].icon=p_edit.tempIcon;
		tab[p_tabs.sel].loadstart=(l_form.loadonstart.checked?1:0);
		p_tabs.create(p_tabs.sel);

		executescr("scr_config_options.php","prof="+jsprof+"&portstyle="+tab[p_tabs.sel].style+"&portname="+_esc(p_tabs.currName)+"&col="+l_nbCol+"&advise="+p_banner.info.requested+"&usepass="+l_secu+"&usereader="+l_usereader+"&ctrl="+l_controls+"&align="+(l_moduleAlign?"Y":"N")+"&icon="+p_edit.tempIcon+"&load="+tab[p_tabs.sel].loadstart,l_alarm);
		if (l_allowSuppress) p_edit.hide();
	}
}
// Open the new module window
function openmod(v_id,v_vars,v_type){
	if (v_vars==indef) v_vars='';
	if (v_type==indef) v_type='portal';
	getXml("../cache/item_"+v_id+".xml?rand="+rand,displayMod,new Array(v_id,v_vars,v_type));
	return false;
}
function displayMod(response,vars){
	var l_s="",l_result,l_newId;
	if (response.getElementsByTagName("item")[0]){
		l_s+="<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td valign='top'><table cellpadding=0 cellspacing=0>";
		l_result=response.getElementsByTagName("item")[0];
		var l_size=getXMLval(l_result,"size","int",false,100);
		var l_minwidth=getXMLval(l_result,"minwidth","int",false,180);
		var l_sizable=getXMLval(l_result,"sizable","int",false,1);
		var l_name=getXMLval(l_result,"name","str",false,"--");
		var l_format=getXMLval(l_result,"format","str",false,"I");
		var l_website=getXMLval(l_result,"website","str",false,"");
		var l_nbvars=getXMLval(l_result,"nbvars","int",false,0);
		var l_usereader=getXMLval(l_result,"usereader","int",false,tab[p_tabs.sel].usereader);
		var l_editor=getXMLval(l_result,"editor","str",false,"?");
		var l_editorid=getXMLval(l_result,"editor_id","int",false,0);
		if (__useSharing) l_editor="<a href='../notebook/index.php?id="+l_editorid+"' target='_blank'>"+l_editor+"</a>";
		if (vars[1]=='') vars[1]=getXMLval(l_result,"var","str",false,"");
		if (showNewMod) closeNewMod();
		l_newId=tab[p_tabs.sel].module.length;
		// var url=l_result.getElementsByTagName("url")[0].firstChild.nodeValue+"pid="+jsid+"&prof="+jsprof+"&p="+l_newId;
		var l_url=getXMLval(l_result,"url","str",false,"");
		//show overview if configured in admin panel
		if ((__useoverview || vars[2]=="uniq" || p_tabs.sel==-1) && tab[p_tabs.sel].moduleAlign){
			l_s+="<tr><td style='padding-top:8px;width:390px;' valign='top'>";
			l_s+=getXMLval(l_result,"description","str",false,"...");
			if (l_editorid!=0 && vars[0]!=86) l_s+="<br /><br />"+lg("proposedBy")+" : "+l_editor;
			//if (vars[2]=="portal") l_s+="<br /><br /><center><input class='btnbig' type='button' value='"+lg("lblBtnModAdd")+"' onclick='tab[p_tabs.sel].module[tab[p_tabs.sel].module.length-1].placeinCol(1);closeNewMod();' /></center><br />";
			//l_s+="<td id=col"+(vars[2]=="portal"?"0":"1")+" style='width:400px;' class='menumodule'></td></tr></table></td></tr>";
			l_s+="<td rowspan='2' id=col"+(vars[2]=="portal"?"0":"1")+" style='width:400px;' class='menumodule'></td></tr><tr><td style='vertical-align: bottom;padding-bottom: 15px;'>";
			if (vars[2]=="portal") l_s+="<br /><center><input class='btnbig' type='button' value='"+lg("lblBtnModAdd")+"' onclick='tab[p_tabs.sel].module[tab[p_tabs.sel].module.length-1].placeinCol(1);closeNewMod();' /></center>";
			l_s+="</td></tr></table></td></tr>";
			l_s+="</table>";
			navPrint("newmod",box(0,l_name+img("star_yellow2_"+getXMLval(l_result,"nota","int",false,0)+".gif",53,12),"closeNewMod()",l_s));
			navShow("newmod","block");
			tab[p_tabs.sel].maxUniq++;

			if (vars[2]=="portal"){
				tab[p_tabs.sel].cols[0]=_gel("col0");
				tab[p_tabs.sel].module[l_newId]=new moduleObj(0,0,0,l_size,vars[0],l_website,l_name,vars[1],l_minwidth,l_sizable,400,l_url,150,150,tab[p_tabs.sel].maxUniq,l_format,l_nbvars,tab[p_tabs.sel].id,0,0,l_usereader);
				tab[p_tabs.sel].module[l_newId].create();
				tab[p_tabs.sel].module[l_newId].show();
				p_area.module.showHdr();
			} else if (vars[2]=="uniq"){
				tab[p_tabs.sel].cols[1]=_gel("col1");
				tab[p_tabs.sel].module[l_newId]=new moduleObj(1,1,1,l_size,vars[0],l_website,l_name,vars[1],l_minwidth,l_sizable,400,l_url,150,150,1,l_format,l_nbvars,tab[p_tabs.sel].id,0);
				tab[p_tabs.sel].module[l_newId].create();
				tab[p_tabs.sel].module[l_newId].show();
				tab[p_tabs.sel].cols[1].appendChild(p_area.module.endList());
				p_area.module.showHdr();
				tab[p_tabs.sel].moveIsInit=false;
				p_area.displayItems();
				//initMove(cols[0],"module",cols,"multidim",true);
			}
			showNewMod=true;
		} else {
			tab[p_tabs.sel].maxUniq++;
			tab[p_tabs.sel].module[l_newId]=new moduleObj(-1,0,0,l_size,vars[0],l_website,l_name,vars[1],l_minwidth,l_sizable,400,l_url,150,150,tab[p_tabs.sel].maxUniq,l_format,l_nbvars,tab[p_tabs.sel].id,0);
			tab[p_tabs.sel].module[l_newId].create();
			tab[p_tabs.sel].module[l_newId].show();
			tab[p_tabs.sel].module[l_newId].placeinCol(1);
		}
	} else {debug("Cache is not generated for this module","error");}
}
// Close the new module window
function closeNewMod(){
	// if last module created is not placed in the portal
	if (tab[p_tabs.sel].module.length==0) return;
	var l_id=tab[p_tabs.sel].module.length-1;
	if (tab[p_tabs.sel].module[l_id].newcol==0 || !isPortal) {
	//if (module[l_id].newcol==0 || jsprof==0) {
		p_area.module.supFeed(tab[p_tabs.sel].maxUniq);
		tab[p_tabs.sel].module[l_id].destruct();
		delete(tab[p_tabs.sel].module[l_id]);
		tab[p_tabs.sel].module.length-=1;
		tab[p_tabs.sel].maxUniq--;
	}
	navPrint("newmod","");
	navShow("newmod","none");
	showNewMod=false;
}

function hideBox(){
	navPrint("box","");
	navShow("box","none");
	showBoxStatus=false;
}
function hideAllBox(){
	hideBox();
	if (__menuposition=="v"){p_menu.hide();}
}

//===============================================================================================================
//					OTHER OBJECTS MANAGEMENT
//===============================================================================================================

// initialize the hidding window (for drag action)
var p_cache={
	isInit:false,
	obj:indef,
	init:function(){
		if (p_cache.obj==indef) p_cache.obj=_gel("cache");
		p_cache.obj.style.width=document.body.scrollWidth+"px";
		p_cache.obj.style.height=getWindowHeight()+"px"; //document.body.scrollHeight;
		//if (!NS&&!OP){p_cache.obj.style.backgroundColor="#efefef";p_cache.obj.style.opacity=0.1;p_cache.obj.style.filter="alpha(opacity=10)";}
	},
	show:function(v_status){
		p_cache.init();
		p_cache.obj.style.display=v_status;
	},
	shadow:function(){
		p_cache.init();
		p_cache.obj.style.display="block";
		p_cache.obj.style.backgroundColor="#000000";
		p_cache.obj.style.opacity="0.5";
		p_cache.obj.style.filter="alpha(opacity=50)";
	},
	hideShadow:function(){
		p_cache.obj.style.display="none";
		p_cache.obj.style.backgroundColor="#ffffff";
		p_cache.obj.style.opacity="0";
		p_cache.obj.style.filter="alpha(opacity=0)";
	}
}
// Switch the display of the news
//function changeShowType(v_id){
//	if (p_area.showType==v_id){alert(lg("msgTypeNoChg"));}
//	else {
//		//navClass("show"+p_area.showType,"iconei");
//		p_area.showType=v_id;
//		//navClass("show"+p_area.showType,"iconea");
//		//executescr("scr_setshowtype.php","prof="+jsprof+"&st="+v_id);
//		p_area.init();
//	}
//	return false;
//}
// Check if additionnal module is requested
function additionalMod(){
	if (getVar(window.location.search.substring(1),"open")){
		var l_vars=(getVar(window.location.search.substring(1),"vars"))?getVar(window.location.search.substring(1),"vars"):"";
		openmod(getVar(window.location.search.substring(1),"open"),l_vars);
	}
}

// statistic management
function stats(){
	executescr("scr_addstats.php","prof="+jsprof+"&id="+jsid,false);
}
function _IG_Analytics(){}
function _IG_RegisterOnloadHandler(v_fct){
	window.onload=v_fct;
}
function _IG_FetchContent(v_url,v_fct){
	getXml(v_url,v_fct,"","html","","GET");
}
function _IG_FetchXmlContent(v_url,v_fct){
	getXml(v_url,v_fct,"","xml","","GET");
}
function _IG_FetchFeedAsJSON(v_url,v_fct,v_entries,v_summaries){
	if (v_entries==indef) v_entries=5;
	if (v_summaries==indef) v_summaries=false;
	getXml(v_url,getRssFromXml,new Array(v_fct,v_entries,v_summaries),"xml","","GET");
}
function getRssFromXml(response,vars){
	var feed={};
	feed.Title=getXMLval(response,"title","str",false,"no title");
	feed.Link=getXMLval(response,"link","str",false,"");
	feed.Author=getXMLval(response,"author","str",false,"");
	feed.Description=getXMLval(response,"description","str",false,"");
	feed.Entry=[];
	var i=0;
	while (response.getElementsByTagName("item")[i] && i<vars[1]){
		var result=response.getElementsByTagName("item")[i];
		feed.Entry[i]={};
		feed.Entry[i].Title=getXMLval(result,"title","str",false,"no title");
		feed.Entry[i].Link=getXMLval(result,"link","str",false,"");
		feed.Entry[i].Summary=(getXMLval(result,"description","str",false,"")).substr(0,200);
		feed.Entry[i].Date=getXMLval(result,"pubdate","str",false,"");
		i++;
	}
	vars[0](feed);
}
// Display saving box
function showSave(){
	if (showBoxStatus){p_menu.hide();}
	if (__menuposition=="h"){
		var l_s="<table><tr>";
		l_s+="<td valign=top width='400'><div class='bottomhr'><b>"+lg("lblAccountCreation")+" :</b></div><b>::</b> Please use all lower case letters for your e-mail address to create an account.<br /><br />";
		l_s+="<form name='form1' method='post' onsubmit='return p_connection.subscribe(this,savePage);'>";
		l_s+="<table cellspacing='2' cellpadding='0' border='0'>";
		l_s+="<tr><td>"+(__accountType=="mail"?lg("lblEmail"):lg("lblLogin"))+" :&nbsp;</td><td><input class='thinbox' name='username' type='text' size='17' maxlength='64' /> </td></tr>";
		if (__accountType=="mail") l_s+="<tr><td>"+lg("lblEmailConfirmation")+" :&nbsp;</td><td><input class='thinbox' name='username2' type='text' size='17' maxlength='64' /></td></tr>";
		l_s+="<tr><td>"+lg("lblPassword")+" :&nbsp;</td><td><input class='thinbox' type='password' name='pass' size='17' maxlength='16' /></td></tr>";
		l_s+="<tr><td>"+lg("lblPasswordConfirmation")+" :&nbsp;</td><td><input class='thinbox' type='password' name='confpass' size='17' maxlength='16' /></td></tr>";
		l_s+="</table><br />";
		l_s+="<label><input type='checkbox' name='autoconn' />"+lg("lblAutoConnection")+"</label><br />";
		if (__useNewsletter) l_s+="<label><input type='checkbox' name='newsletter' />"+lg("lblNewsletterRequired")+"</label> "+__apname+".<br />";
		if (__useConditions) l_s+="<input type='checkbox' name='conditions' />"+lg("lblConditionsStr","<a href='#' onclick=\"return link('conditions.html',true,true);\">"+lg("lblConditions")+"</a>")+".<br />";
		l_s+=img("",8,8)+"<br /><br />";
		l_s+="<center><input class='btn' type='submit' name='"+lg("lblOk")+"' style='width:250px' value='"+lg("lblSavePage")+"' /></center>";
		l_s+="</form><br />";
		l_s+="</td><td width='50'></td><td valign='top' width='400'><div class='bottomhr'><b>"+lg("lblAlreadyMember")+" ?</b></div><br />";
		l_s+="<form name='form2' method='post' onsubmit='return p_connection.set(this,savePage);'>";
		l_s+="<table cellspacing='0' cellpadding='0' border='0'>";
		l_s+="<tr><td>&nbsp;&nbsp;"+(__accountType=="mail"?lg("lblEmail"):lg("lblLogin"))+" :&nbsp;&nbsp;</td><td><input class='thinbox' name='username' id='username' type='text' size='17' maxlength='64' value='' />&nbsp;&nbsp;</td></tr>";
		l_s+="<tr><td style='height:20px'>&nbsp;&nbsp;"+lg("lblPassword")+" :&nbsp;&nbsp;</td><td><input class='thinbox' name='password' type='password' size='17' maxlength='16' />&nbsp;&nbsp;<a href='"+pfolder+"password_missing.php' target=_blank style='font-size:7pt;'>"+lg("lblMissingPassword")+" ?</a></td></tr>";
		l_s+="<tr><td></td><td><label><input type='checkbox' name='autoconn' />"+lg("lblAutoConnection")+"</label></td></tr>";
		l_s+="<tr><td style='height:8px'></td></tr><tr><td colspan='2' align='center'><br /><input class='btn' type='submit' value='"+lg("lblSavePage")+"' style='width:250px' /></td></tr>";
		l_s+="</table></form>";
		l_s+="<br /><br /><table width='400'><tr><td style='border:1px solid #ffffff;padding:8px;'>"+__conditionComment+"</td></tr></table>";
		l_s+="</td></tr></table>";
		navPrint("box",box(0,img("ico_menu_disk.gif",16,16,"","imgmid")+" "+lg("lblSavePage"),"hideBox()",l_s));
		navShow("box","block");
	} else {
		p_menu.init();
		var l_s="";
		l_s+="<div class='leftmenuitem' onclick=\"p_menu.showItem('itemsave1');p_menu.hideItem('itemsave2');return false;\">"+lg("lblAccountCreation")+"</div>";
		l_s+="<div class='leftmenuitemcontent' id='itemsave1'>";
		l_s+="<form name='form1' method='post' onsubmit='return p_connection.subscribe(this,savePage);'>";
		l_s+=(__accountType=="mail"?lg("lblEmail"):lg("lblLogin"))+" :<br /><input class='thinbox' name='username' type='text' size='17' maxlength='64' /><br />";
		if (__accountType=="mail") l_s+=lg("lblEmailConfirmation")+" :<br /><input class='thinbox' name='username2' type='text' size='17' maxlength='64' /><br />";
		l_s+=lg("lblPassword")+" :<br /><input class='thinbox' type='password' name='pass' size='17' maxlength='16' /><br />";
		l_s+=lg("lblPasswordConfirmation")+" :<br /><input class='thinbox' type='password' name='confpass' size='17' maxlength='16' /><br />";
		l_s+="<br /><label><input type='checkbox' name='autoconn' />"+lg("lblAutoConnection")+"</label><br />";
		if (__useNewsletter) l_s+="<label><input type='checkbox' name='newsletter' />"+lg("lblNewsletterRequired")+"</label> "+__apname+".<br />";
		if (__useConditions) l_s+="<input type='checkbox' name='conditions' />"+lg("lblConditionsStr","<a href='#' onclick=\"return link('conditions.html',true,true);\">"+lg("lblConditions")+"</a>")+".<br />";
		l_s+="<br /><center><input type='submit' name='"+lg("lblOk")+"' value='"+lg("lblSavePage")+"' /></center>";
		l_s+="</form>";
		l_s+="<br /></div>";
		
		l_s+="<div class='leftmenuitem' onclick=\"p_menu.showItem('itemsave2');p_menu.hideItem('itemsave1');return false;\">"+lg("lblAlreadyMember")+"</div>";
		l_s+="<div class='leftmenuitemcontent' id='itemsave2'>";
		l_s+="<form name='form2' method='post' onsubmit='return p_connection.set(this,savePage);'>";
		l_s+=(__accountType=="mail"?lg("lblEmail"):lg("lblLogin"))+" :<br /><input class='thinbox' name='username' id='username' type='text' size='17' maxlength='64' value='' /><br />";
		l_s+=lg("lblPassword")+" :<br /><input class='thinbox' name='password' type='password' size='17' maxlength='16' />&nbsp;&nbsp;<a href='"+pfolder+"password_missing.php' target=_blank style='font-size:7pt;'>"+lg("lblMissingPassword")+" ?</a><br/>";
		l_s+="<br /><label><input type='checkbox' name='autoconn' />"+lg("lblAutoConnection")+"</label><br />";
		l_s+="<br /><center><input type='submit' value='"+lg("lblSavePage")+"' /><br />";
		l_s+="</form>";
		l_s+=__conditionComment;
		l_s+="<br /></div>";

		p_menu.display(0,lg("lblSavePage"),"ico_menu_disk.gif",indef,l_s);
		p_menu.showItem('itemsave1');
	}
	showBoxStatus=true;
	return false;
}
var p_connection={
	active:true,
	changePass:function(){
		// Change user password
		var l_pass1=_esc(document.forms["newpass"].pass1.value);
		var l_pass2=_esc(document.forms["newpass"].pass2.value);
		if (l_pass1==l_pass2){
			executescr("scr_changepwd.php","oldpass="+_esc(document.forms["newpass"].oldpass.value)+"&pass1="+l_pass1,true);
		} else {p_alert.show(lg("msgSubPassDiff"));}
	},
	set:function(v_form,v_function,v_type){
		// connect to profile
		var l_connStr="u="+v_form.username.value+"&p="+v_form.password.value;
		if (v_form.autoconn && v_form.autoconn.checked) l_connStr+="&auto=1";
		if (v_type) l_connStr+="&rtype=1";
		if (v_form.username.value==""){p_alert.show(lg("lblEmailChk")+".\r\n");}
		else {executescr("scr_connect.php",l_connStr,true,true,v_function);}
		return false;
	},
	subscribe:function(v_form,v_function){
		// subscribe to application
		var l_e="";
		if (v_form.username.value==""){l_e+=lg("msgSubEmailMiss")+"\r\n";}
		if (v_form.pass.value==""){l_e+=lg("msgSubPassMiss")+"\r\n";}
		else {if (__accountType=="mail" && !checkEmail(v_form.username.value)){l_e+=lg("msgSubEmailValid")+"\r\n";};}
		if (__accountType=="mail" && v_form.username.value!=v_form.username2.value){l_e+=lg("msgSubEmaildiff")+"\r\n";}
		if (v_form.pass.value!=v_form.confpass.value){l_e+=lg("msgSubPassDiff")+"\r\n";}
		if(__useConditions&&!v_form.conditions.checked){l_e+=lg("msgSubCond");}
		var l_connStr="u="+v_form.username.value+"&p="+v_form.pass.value+((__useNewsletter&&v_form.newsletter.checked)?"&n=1":"");
		if (v_form.autoconn.checked) l_connStr+="&auto=1";
		if (l_e==""){
			executescr("scr_subscribe.php",l_connStr,true,true,v_function);
		}
		else {p_alert.show(l_e);}
		return false;
	},
	test:function(){
		if (p_connection.active) getXml("xmlcheckuserconnection.php",p_connection.testTreatment,"","xml","","get",p_connection.errorTest);
	},
	testTreatment:function(response,vars){
		var l_check=getXMLval(response,"userid","str",false,0);
		if (l_check==0) p_connection.errorTest();
	},
	errorTest:function(){
		if (!p_connection.active) return;
		p_connection.active=false;
		var l_response=confirm(lg("youHaveBeenDisconnected"));
		if (l_response==1) link();
	}
}

// User profile changes box
//function changeProfile(){
//	if (showBoxStatus){hideBox();}
//
//	var l_s="<table><tr>";
//	l_s+="<td valign='top' width='400'><div class='bottomhr'><b>"+lg("lblModifyPassword")+" :</b></div><br />";
//	l_s+="<form name='newpass'><table>";
//	l_s+="<tr><td>"+lg("lblOldPassword")+" :</td><td> <input class='thinbox' type='password' name='oldpass' maxlength='16' /></td></tr>";
//	l_s+="<tr><td>"+lg("lblNewPassword")+" :</td><td> <input class='thinbox' type='password' name='pass1' maxlength='16' /></td></tr>";
//	l_s+="<tr><td>"+lg("lblRetypeNewPassword")+" :</td><td> <input class='thinbox' type='password' name='pass2' maxlength='16' /></td></tr>";
//	l_s+="<tr><td></td><td><input class='btn' type='button' value='"+lg("lblModify")+"' onclick='changePass();' /></td></tr>";
//	l_s+="</table></form></td><td width='20'></td><td valign='top' width='400'>";
//	l_s+="<div class='bottomhr'><b>"+lg("lblChangeUser")+" :</b></div><br /><form name='conBox' method='post' onsubmit='return connect(this,link,true)'><table><tr><td>"+(__accountType=="mail"?lg("lblEmail"):lg("lblLogin"))+"</td><td><input class='thinbox' type='text' name='username' size='30' maxlength='64' /></td></tr><tr><td>"+lg("lblPassword")+"</td><td><input class='thinbox' type='password' name='password' size='16' maxlength='16' /></td></tr><tr><td></td><td><input type='checkbox' name='autoconn' />"+lg("lblAutoConnection")+"<br /><br /><input type='submit' value='"+lg("lblOk")+"' class='btn' /> <a href='../portal/password_missing.php' target='_blank' style='font-size:7pt;'>"+lg("lblMissingPassword")+" ?</a></td></tr></table></form>";
//	l_s+="</td></tr></table></form>";

//	navPrint("box",box(0,"VOTRE PROFIL","hideBox()",l_s));
//	navShow("box","block");
//	showBoxStatus=true
//	return false;
//}
// Security box
function askCode(){
	hideAllBox();
	p_newspaper.hide();
	
	var l_s="<center><form name='identif' method='post' onsubmit='return checkCode(this)'><br /><br /><br /><table cellpadding='10' width='400'><tr><td class='protectbox'>";
	l_s+="<center><b>"+lg("lblPortalProtected")+"</b><br /><br />"+lg("lblRequestPassword")+" :<br /><br />"+lg("lblPassword")+" : <input class='thinbox' type='password' name='pass' /><input class='btn' type='submit' value='"+lg("lblBtnValid")+"' /><br /><br /><div align='right'><a href='../portal/password_missing.php' target=_blank>"+lg("lblMissingPassword")+" ?</a></div>";
	l_s+="</td></tr></table><br /><br /><br /></form></center>";
	navPrint("modules"+tab[p_tabs.sel].id,l_s);
	navShow("modules","block");
	document.forms["identif"].pass.focus();
	setActiveStyleSheet(1);
}
function checkCode(v_form){
	executescr("scr_unlock.php","id="+jsprof+"&pass="+v_form.pass.value,true,false,p_pages.open);
	return false;
}
function lockPage(){
	p_counter.activityStep=0;
	executescr("scr_protect.php","",false,false,p_pages.open);
	//link("scr_protect.php?page="+tab[p_tabs.sel].fct);
}
function connectBox(){
//	var l_s="<FORM name='conBox' action='scr_authentif.php' method=post><div class='bottomhr'>"+lg("lblConnectToYourPortal")+" :</div><br /><table><tr><td>"+lg("lblEmail")+" </td><td><INPUT class='thinbox' type='text' name='username' size=25 maxlength=64 /></td></tr><tr><td>"+lg("lblPassword")+" </td><td><INPUT class='thinbox' type='password' name='password' size=16 maxlength=16 /></td></tr><tr><td></td><td><INPUT type='submit' value='"+lg("lblConnect")+"' class=btn /> <A class=w href='password_missing.php' target='_blank'>"+lg("lblMissingPassword")+" ?</A></td></tr></table><br /></FORM>"
	if (__menuposition=="h"){
		var l_s="<form name='conBox' method='post' onsubmit='return p_connection.set(this,link,true)'><div class='bottomhr'>"+lg("lblConnectToYourPortal")+" :</div><br /><table width='70%' border='0' cellspacing='0' cellpadding='0'><tr><td width='50%'><table><tr><td>"+(__accountType=="mail"?lg("lblEmail"):lg("lblLogin"))+" </td><td><input class='thinbox' type='text' name='username' size='25' maxlength='64' /></td></tr><tr><td>"+lg("lblPassword")+" </td><td><input class='thinbox' type='password' name='password' size='16' maxlength='16' /></td></tr><tr><td></td><td><label><input type='checkbox' name='autoconn' />"+lg("lblAutoConnection")+"</label><br /><br /><input type='submit' value='"+lg("lblConnect")+"' class='btn' /> <a class='w' href='password_missing.php' target='_blank'>"+lg("lblMissingPassword")+" ?</a></td></tr></table></td><td width='50%'><table width='100%' border='0' align='left' cellpadding='10' cellspacing='0'><tr><td><b class='tiphd1'>New to Mysurfpad.com?</b><br /><b class='tiphd2'><a href='#' onclick='showSave()' class='tiphd2A'>CLICK HERE</a></b><b class='tiphd'> to Create Your Free Account and Homepage</b></td></tr></table></td></tr></table><br /></form>";
		navPrint("box",box(0,lg("lblConnect"),"hideBox()",l_s));
		navShow("box","block");
	} else {
		var l_s="<form name='conBox' method='post' onsubmit='return p_connection.set(this,link,true)'><div class='bottomhr'>"+lg("lblConnectToYourPortal")+" :</div><br /><table><tr><td>"+(__accountType=="mail"?lg("lblEmail"):lg("lblLogin"))+" </td><td><input class='thinbox' type='text' name='username' size='25' maxlength='64' /></td></tr><tr><td>"+lg("lblPassword")+" </td><td><input class='thinbox' type='password' name='password' size='16' maxlength='16' /></td></tr><tr><td></td><td><label><input type='checkbox' name='autoconn' />"+lg("lblAutoConnection")+"</label><br /><br /><input type='submit' value='"+lg("lblConnect")+"' class='btn' /> <a class='w' href='password_missing.php' target='_blank'>"+lg("lblMissingPassword")+" ?</a></td></tr><tr><td>New to Mysurfpad.com - Create Free Account Now</td></tr></table><br /></form>"
		p_menu.init();
		p_menu.display(0,lg("lblConnect"),"",indef,l_s);
	}
	document.conBox.username.focus();
	return false;
}
// Save current page
function savePage(v_type){
	if (v_type=="user"){
		// save the page (modules + personalization)
		executescr("scr_createportal.php",getConfig(),false,true,openPage);
	}
}
// Save portal configuration in cookie
function getConfig(){
	var l_ret="w="+tab[p_tabs.sel].colnb+"&s="+tab[p_tabs.sel].style+"&n="+_esc(p_tabs.currName)+"&t="+tab[p_tabs.sel].showType+"&nb="+tab[p_tabs.sel].newspapernb+"&i="+tab[p_tabs.sel].icon+"&a="+(tab[p_tabs.sel].moduleAlign?"Y":"N");
	for (var i=0;i!=tab[p_tabs.sel].module.length;i++){
		l_ret+="&id"+i+"="+tab[p_tabs.sel].module[i].id+"&pos"+i+"="+tab[p_tabs.sel].module[i].newpos+"&col"+i+"="+tab[p_tabs.sel].module[i].newcol+"&posj"+i+"="+tab[p_tabs.sel].module[i].newposj+"&x"+i+"="+tab[p_tabs.sel].module[i].newx+"&y"+i+"="+tab[p_tabs.sel].module[i].newy+"&var"+i+"="+_esc(tab[p_tabs.sel].module[i].vars)+"&blocked"+i+"="+(tab[p_tabs.sel].module[i].blocked?"1":"0")+"&minimized"+i+"="+(tab[p_tabs.sel].module[i].minimized?"1":"0");
	}
	return l_ret;
}
function getAvailPortals(v_sess){
	if (v_sess){
		//link("addtoapplication2.php?mid="+tab[p_tabs.sel].module[0].id+"&v="+_esc(tab[p_tabs.sel].module[0].vars));
		getXml("xmltabs.php",showAvailPortals);
	}
}
function showAvailPortals(response,vars){
	var l_s="<b>"+lg("selectThePortalDestination")+"</b> :<br />",l_result=response.getElementsByTagName("tab");
	for (var i=0;i<l_result.length;i++){
		if (getXMLval(l_result[i],"type","int",false,0)==3){
			l_s+="<br />"+img("ico_right_arrow.gif",6,9)+" <a href='#' onclick='addModToAvailPortal("+getXMLval(l_result[i],"number","int",false,1)+");'>"+getXMLval(l_result[i],"name","str",false,"- ? -")+"<a>";
		}
	}
	navPrint("connectiondiv",l_s+"<br /><br />");
}
function addModToAvailPortal(v_prof){
	//set current page as the one selected
	writeCookie("currentpage="+v_prof);	
	link("scr_config_updateportal.php?prof="+v_prof+"&modid="+tab[p_tabs.sel].module[0].id+"&v="+_esc(tab[p_tabs.sel].module[0].vars));
}
// Init page
function initPage(v_id){
	if (getVar(window.location.search.substring(1),"searchtxt")){
		loadMagic(getVar(window.location.search.substring(1),"searchtxt"));
	} else if (getVar(window.location.search.substring(1),"portal")) {
		p_area.load("../cache/portal_"+getVar(window.location.search.substring(1),"portal")+".xml");
	} else if (getVar(window.location.search.substring(1),"n")){
		p_area.load("xmlmodules_invitation.php?i="+getVar(window.location.search.substring(1),"i")+"&e="+getVar(window.location.search.substring(1),"e")+"&p="+getVar(window.location.search.substring(1),"p"));
		p_tabs.currName=getVar(window.location.search.substring(1),"n");
	} else {
		if (v_id==indef) v_id=0;
		p_area.load("selections/page"+v_id+".xml");
	}
}

//===============================================================================================================
//					RSS MANAGEMENT
//===============================================================================================================

var p_rss={
	opmlfile:"",
	checkFeed:function(v_rss){
		//get content of the rss link input by user
		//var l_rss=document.forms['rss'].vars.value;//replaced in posh 1.4 by :
		var l_rss=_esc((v_rss==indef?document.forms['rss'].vars.value:v_rss));
		l_auth=(document.forms['rss'] && document.forms['rss'].pass)?Base64.encode(document.forms['rss'].login.value+":"+document.forms['rss'].pass.value):indef;
		if (__useproxy){
			if (__proxypacfile=="")	getXml("../portal/xmlvalidrssproxy.php",p_rss.checkFeedXml,new Array(l_rss,l_auth),"html","url="+l_rss,"POST");
			else {
				if (getProxy(l_rss)==""){
					if (l_auth==indef){
						getXml("../portal/xmlvalidrss.php",p_rss.checkFeedXml,new Array(l_rss,l_auth),"html","url="+l_rss,"POST");
					} else {
						getXml("../portal/xmlvalidrssauth.php",p_rss.checkFeedXml,new Array(l_rss,l_auth),"html","url="+l_rss+"&auth="+l_auth,"POST");
					}
				} else getXml("../portal/xmlvalidrssproxy.php",p_rss.checkFeedXml,new Array(l_rss,l_auth),"html","proxy="+getProxy(l_rss)+"&url="+l_rss,"POST");
			}
		} else {
			if (l_auth==indef){
				getXml("../portal/xmlvalidrss.php",p_rss.checkFeedXml,new Array(l_rss,l_auth),"html","url="+l_rss,"POST");
			} else {
				getXml("../portal/xmlvalidrssauth.php",p_rss.checkFeedXml,new Array(l_rss,l_auth),"html","auth="+l_auth+"&url="+l_rss,"POST");
			}
		}
		//rss checks notification
		navPrint("authrss",lg("checkingFeed"));
		navShow("authrss","block");
		return false;
	},
	checkFeedXml:function(response,vars){
		//analyse content of the rss link input by user
		if (response.indexOf("<?xml")==-1 && response.indexOf("<rss")==-1){
			//check if page propose rss links
			//var l_document=parseTextToHtml(response);
			//var l_tags=l_document.getElementsByTagName("link");
			var l_tags=p_getElementsByTagName(response,"link");
			var l_links="";
			if (l_tags.length>0){
				for (var i=0;i<l_tags.length;i++){
					if (l_tags[i]["type"]=="application/rss+xml"){
						l_links+="<div style='margin:2px;padding:2px;background-color:#efefef;border:1px solid #c6c3c6;'><a href='#' onclick=\"p_rss.checkFeed('"+(ishttp(l_tags[i]["href"])?l_tags[i]["href"]:document.forms['rss'].vars.value+"/"+l_tags[i]["href"])+"')\">"+(l_tags[i]["title"]).substr(0,35)+"</a></div>";
					}
				}
				if (l_links!="") l_links="<br />"+lg("availableFeedsForThisSite")+" :"+l_links;
			}
			if (l_links==""){
				if (response.indexOf("404")!=-1) {p_alert.show(lg("invalidRss"));navShow("authrss","none");}
				else if (response=="") {p_alert.show(lg("invalidRss"));navShow("authrss","none");}
				else if (response.indexOf("401")!=-1) {p_rss.authentification();}
				else {p_alert.show(lg("msgIncorrectFeed"));navShow("authrss","none");}
			} else {
				navPrint("authrss",l_links);
				navShow("authrss","block");
			}
		} else {
			p_rss.getFeed(vars);
		}
		return false;
	},
	authentification:function(){
		//get information for authentified rss feed
		navPrint("authrss","<font style='color:#ff0000'>"+lg("lblProtectedFeed")+"</font><br /><table><tr><td>"+lg("lblLogin")+"</td><td><input name='login' type='text' size='10' /></td></tr><tr><td>"+lg("lblPassword")+"</td><td><input name='pass' type='password' size='10' /></td></tr><tr><td></td><td><input type='submit' class='btn' value='Go' /></td></tr></table>");
		navShow("authrss","block");
	},
	getFeed:function(vars,v_fct){
		//temporaly shortcut for authentified feed
//		if (vars[1]!=indef){
//			p_rss.showMod(vars[0],indef,vars[1]);
//			return false;
//		}
		if (v_fct==indef) v_fct=p_rss.getFeedXml;
		if (__useproxy){
			if (__proxypacfile=="")	getXml("../portal/xmlcheckfeedproxy.php",v_fct,vars,"xml","url="+vars[0],"POST");
			else {
				if (getProxy(vars[0])==""){
					getXml("../portal/xmlcheckfeed.php",v_fct,vars,"xml","url="+vars[0],"POST");
				} else getXml("../portal/xmlcheckfeedproxy.php",v_fct,vars,"xml","proxy="+getProxy(vars[0])+"&url="+vars[0],"POST")
			}
		} else {
			getXml("../portal/xmlcheckfeed.php",v_fct,vars,"xml","url="+vars[0],"POST");
		}
		return false;
	},
	getFeedXml:function(response,vars){
		if (response.getElementsByTagName("error")[0]){
			p_alert.show(lg("msgIncorrectFeed"));
			navShow("authrss","none");
		} else {
			//l_icon=getXMLval(response,"icon","str",false,"0");
			l_id=getXMLval(response,"id","int",false,0);
			//p_rss.showMod(vars[0],(l_icon==0?indef:l_icon),vars[1]);
			p_rss.showMod(vars[0],l_id,vars[1]);
		}
	},
	showMod:function(v_rss,v_id,v_auth){
		//suppress checking feed notification
		navShow("authrss","none");
		// show RSS module
		//openmod(86,"rssurl="+_esc(v_rss)+(v_icon==indef?"":"&icon="+v_icon)+(v_auth==indef?"":"&auth="+v_auth)); //replaced with posh 1.4 by :
		//p_tabs.sel=999 for rss feed adding in directory,
		if (p_tabs.sel=="999"){
			link("../tutorial/rssaddtodirectory_step2.php?id="+v_id+(v_auth==indef?"":"&auth="+v_auth));
		} else {
			openmod(86,"pfid="+v_id+"&rssurl="+v_rss+"&icon=rss"+v_id+".ico"+(v_auth==indef?"":"&auth="+v_auth));
		}
		return false;
	},
	refreshAll:function(){
		//refresh all opened pages
		for (var i=0;i<tab.length;i++){
			if (tab[i].isLoaded==true){
				if (tab[i].feeds.length>0){
					p_rss.init(i);
					tab[i].isLoaded=false;
					p_tabs.refresh(p_tabs.sel);
				}
				if (i==p_tabs.sel && tab[p_tabs.sel].showType==1){
					p_newspaper.refresh();
				} else {
					for (var j=0;j<tab[i].module.length;j++){
						if (tab[i].module[j].format=='R'){tab[i].module[j].refresh();}
						else {
							//refresh also modules where autorefresh=1
							if (tab[i].module[j].autorefresh) tab[i].module[j].refresh();
						}
					}
				}
			}
		}
	},
	refresh:function(v_id,v_tab){
		// Fill & Refresh RSS module
		if (v_tab==indef) v_tab=p_tabs.sel;
		//navPrint("module"+module[v_id].uniq+"_c",lg("lblLoading"))
		p_area.module.changeName(v_id,indef,"ico_waiting.gif",v_tab);
		var l_oldNb=parseInt(getVar(tab[v_tab].module[v_id].vars,"nb"),10);
		var l_nb=(l_oldNb==0||isNaN(l_oldNb))?5:l_oldNb;
		//if no cache, add random number
		if (rssNoCache){tab[v_tab].module[v_id].url+="pnocache="+Math.round(Math.random()*100)+"&";}
		//get RSS feed
		if (v_tab!=p_tabs.sel || tab[v_tab].showType==0){
			if (__registerfeeds){
				getXml("../portal/xmlfeeds.php",p_rss.display,new Array(v_id,l_nb,tab[v_tab].module[v_id].uniq,v_tab),"xml","s=0&"+tab[v_tab].module[v_id].vars,"POST");
			} else {
				getXml(tab[v_tab].module[v_id].url,p_rss.display,new Array(v_id,l_nb,tab[v_tab].module[v_id].uniq,v_tab),"xml","pid="+jsid+"&prof="+tab[v_tab].id+"&p="+tab[v_tab].module[v_id].uniq+"&bar="+tab[v_tab].controls+"&"+tab[v_tab].module[v_id].vars,"POST");
			}
		} else {
			if (__registerfeeds){
				getXml("../portal/xmlfeeds.php",p_newspaper.chk,new Array(v_id,l_nb,tab[v_tab].module[v_id].uniq),"xml","s=0&"+tab[v_tab].module[v_id].vars,"POST");
			} else {
				getXml(tab[v_tab].module[v_id].url,p_newspaper.chk,new Array(v_id,l_nb,tab[v_tab].module[v_id].uniq),"xml","pid="+jsid+"&prof="+tab[v_tab].id+"&p="+tab[v_tab].module[v_id].uniq+"&bar="+tab[v_tab].controls+"&"+tab[v_tab].module[v_id].vars,"POST");
			}
		}
		return false;
	},
	init:function(v_tab){
		// initialize feeds
		if (v_tab==indef) v_tab=tabs.sel;
		for (i=0;i<tab[v_tab].module.length;i++){tab[v_tab].module[i].isLoaded=false;}
		tab[v_tab].feeds.length=0;
	},
	get:function(response,v_modId,v_nb,v_tab){
		// get module feeds
		if (v_tab==indef) v_tab=p_tabs.sel;
		
		if (response.getElementsByTagName("header")[0]){
			//if RSS, name is the URL of the RSS feed (only on current tab)
			if (tab[v_tab].module[v_modId].id==86 && v_tab==p_tabs.sel) {
				var l_vars=_unesc(tab[v_tab].module[v_modId].vars);
				var l_p1=(l_vars.indexOf("rssurl=http://")==-1)?(l_vars.indexOf("rssurl=https://")+15):(l_vars.indexOf("rssurl=http://")+14);
				if (l_p1!=-1){
					var l_p2=l_vars.indexOf("/",l_p1);
					if (l_p2==-1) l_p2=l_vars.indexOf("&",l_p1);
					if (l_p2==-1) l_p2=l_vars.length;
					tab[v_tab].module[v_modId].link=l_vars.substring(l_p1,l_p2);
					// if new feed in page, update the module title with feed title
					if (getVar(tab[v_tab].module[v_modId].vars,"ptitl")=="") tab[v_tab].module[v_modId].changeVar("ptitl",getXMLval(response,"ftitle","str",false,"RSS reader"));
					p_area.module.changeName(v_modId,getVar(tab[v_tab].module[v_modId].vars,"ptitl"),v_tab);
				}
			}

			tab[v_tab].module[v_modId].header=getXMLval(response,"header","str",false,"");
			tab[v_tab].module[v_modId].footer=getXMLval(response,"footer","str",false,"");
			tab[v_tab].module[v_modId].isLoaded=true;
			// fill edit box (only for current tab)
			p_param.fillEditBox(response,tab[v_tab].module[v_modId].uniq,v_tab);
			var i=0,l_item,l_title,l_link,l_image,l_date,l_desc,l_read,l_id;
			while (i<v_nb && response.getElementsByTagName("item")[i]){
				l_item=response.getElementsByTagName("item")[i];
				l_id=getXMLval(l_item,"id","str",false,tab[v_tab].feeds.length);
				l_title=p_rss.secure(getXMLval(l_item,"title","str",false,"..."));
				l_desc=p_rss.secure(getXMLval(l_item,"content","str",false,"")==""?getXMLval(l_item,"desc","str",false,""):getXMLval(l_item,"content","str",false,""));
				l_link=getXMLval(l_item,"link","str",false,"");
				l_read=getXMLval(l_item,"read","int",false,0);
				if (l_item.getElementsByTagName("pubdate")[0] && l_item.getElementsByTagName("pubdate")[0].firstChild) l_date=rssDate(l_item.getElementsByTagName("pubdate")[0].firstChild.nodeValue);
				if (l_title=="") l_title=lg("lblNoTitle");
				if (l_item.getElementsByTagName("audio")[0] && l_item.getElementsByTagName("audio")[0].firstChild) l_title+=" <a href='#' onclick=\"p_reader.open('"+getXMLval(l_item,"audio","str",false,"")+"','a')\">"+img("ico_readmedia.gif",12,12,lg("lblListen"),"imgmid")+"</a>";
				if (l_item.getElementsByTagName("video")[0] && l_item.getElementsByTagName("video")[0].firstChild) l_title+=" <a href='#' onclick=\"p_reader.open('"+getXMLval(l_item,"video","str",false,"")+"','v')\">"+img("ico_readmedia.gif",12,12,lg("lblWatch"),"imgmid")+"</a>";
				//if (l_item.getElementsByTagName("quicktime")[0] && l_item.getElementsByTagName("quicktime")[0].firstChild) l_title+=" <a href='#' onclick=\"p_reader.open('"+getXMLval(l_item,"quicktime","str",false,"")+"','q')\">"+img("video.gif",16,16,lg("lblWatch"),"imgmid")+"</a>";
				//if (l_item.getElementsByTagName("mpeg")[0] && l_item.getElementsByTagName("mpeg")[0].firstChild) l_title+=" <a href='#' onclick=\"p_reader.open('"+getXMLval(l_item,"mpeg","str",false,"")+"','m')\">"+img("video.gif",16,16,lg("lblWatch"),"imgmid")+"</a>";
				if (l_item.getElementsByTagName("image")[0] && l_item.getElementsByTagName("image")[0].firstChild) {
					l_image=" src='"+getXMLval(l_item,"image","str",false,"")+"' "+((getXMLprop(l_item.getElementsByTagName("image")[0],"width","str",false,"")=="")?"":" width="+getXMLprop(l_item.getElementsByTagName("image")[0],"width","str",false,""));
				} else {l_image="x";}
				tab[v_tab].feeds.push(new feedObj(l_id,tab[v_tab].module[v_modId].id,tab[v_tab].module[v_modId].uniq,tab[v_tab].module[v_modId].name,l_title,l_link,l_image,l_date,l_desc,l_read));

				i++;
			}
			tab[v_tab].module[v_modId].isLoaded=true;
			loading(false,v_tab);
			return true;
		}
		return false;
	},
	display:function(response,vars){
		//display rss module content
		var l_tab=(vars[3]==indef?p_tabs.sel:vars[3]);
		if (tab[l_tab].locked) return;
		var l_s="",l_item,l_title;
		var l_modId=vars[0];

		//bug correction : if a module is removed during its refresh or other module refresh
		if (!tab[l_tab].module[l_modId]) return;//if (!module[l_modId]) l_modId=uniqToId(vars[2]);
		var l_auth=tab[l_tab].module[l_modId].auth;
		l_s+="<table cellpadding='0' cellspacing='0' width='100%'><tr><td>";

		if (!tab[l_tab].module[l_modId].isLoaded && response!=indef) p_rss.get(response,l_modId,(vars[1]==indef?10:vars[1]),l_tab);
		if (tab[l_tab].module[l_modId] && tab[l_tab].module[l_modId].isLoaded){
			l_s+=tab[l_tab].module[l_modId].header;
			l_s+="</td></tr><tr><td style='padding:6px'><table cellpadding='1' cellspacing='3' width='100%'>";
			var i=0,j=0;
			while (tab[l_tab].feeds[i] && (vars[1]==indef || j<vars[1])){
				if (tab[l_tab].feeds[i].modUniq==tab[l_tab].module[l_modId].uniq){
					var l_addedFct="";
					if (jsid>0&&__useSharing) l_addedFct+="<td width='10'><a href='#' onclick='p_friends.menu(2,"+tab[l_tab].feeds[i].id+")'>"+img("ico_share_s.gif",16,10,lg("lblShareInfo"))+"</a></td>";
					if (jsid>0&&__useArchive) l_addedFct+="<td width='10'><a href='#' onclick='return p_article.save("+tab[l_tab].feeds[i].id+")'>"+img("ico_disk_s.gif",8,9,lg("lblSave"))+"</a></td>";
					if (tab[l_tab].feeds[i].image!="x" && j==0){l_s+="<tr id='feed"+tab[l_tab].id+"_"+vars[2]+"_"+tab[l_tab].feeds[i].id+"' class='link"+((__registerfeeds && !l_auth)?(tab[l_tab].feeds[i].read==0?"unread":"read"):"")+"'><td valign='top'><a href='"+tab[l_tab].feeds[i].link+"' target='npdetailf' onclick=\"return p_rss.linkClicked(this,"+vars[2]+","+i+","+vars[0]+","+vars[1]+");\" onmouseover='p_rss.showOverview("+i+",event)' onmouseout='p_rss.hideOverview("+i+")'><img"+tab[l_tab].feeds[i].image+" align='left' style='margin-right:6px;width:100px;' />"+tab[l_tab].feeds[i].title+"</a></td>"+l_addedFct+"</tr></table><br /><table cellpadding='1' cellspacing='0' width='100%'>";}
					else {
						//l_s+="<tr><td class='contentpic'>"+img("puce.gif",3,5)+"</td><td><a id='feed"+tab[l_tab].id+"_"+vars[2]+"_"+tab[l_tab].feeds[i].id+"' "+(__registerfeeds?"class='link"+(tab[l_tab].feeds[i].read==0?"unread":"read")+"' ":"")+" href='"+tab[l_tab].feeds[i].link+"' target='npdetailf' onclick=\"return p_rss.linkClicked(this,"+vars[2]+","+i+","+vars[0]+","+vars[1]+");\" onmouseover='p_rss.showOverview("+i+",event)' onmouseout='p_rss.hideOverview("+i+")'>"+tab[l_tab].feeds[i].title+"</a></td>";
						l_s+="<tr id='feed"+tab[l_tab].id+"_"+vars[2]+"_"+tab[l_tab].feeds[i].id+"' class='link"+((__registerfeeds && !l_auth)?(tab[l_tab].feeds[i].read==0?"unread":"read"):"")+"'><td class='contentpic'></td><td><a href='"+tab[l_tab].feeds[i].link+"' target='npdetailf' onclick=\"return p_rss.linkClicked(this,"+vars[2]+","+i+","+vars[0]+","+vars[1]+");\" onmouseover='p_rss.showOverview("+i+",event)' onmouseout='p_rss.hideOverview("+i+")'>"+tab[l_tab].feeds[i].title+"</a></td>"+l_addedFct+"</tr>";
					}
					j++;
				}
				i++;
			}
			if (j==0){
				if (tab[l_tab].module[l_modId].footer=="auth"){l_s+="<tr><td><a href='#' onclick='p_param.show("+tab[l_tab].module[l_modId].uniq+")'>"+img("lock.gif",7,9,"","imgmid")+" "+lg("authFeed")+"</a></td></tr>";tab[l_tab].module[l_modId].footer="";}
				else {l_s+="<tr><td>"+lg("lblNoArticle")+"</td></tr>";}
			}
			l_s+="</table></td></tr><tr><td>"+tab[l_tab].module[l_modId].footer;
		} else {l_s+=lg("lblModIssue");}
		l_s+="</td></tr></table>";
		//navPrint("module"+module[l_modId].tab+"_"+vars[2]+"_c",l_s);
		navPrint("module"+tab[l_tab].id+"_"+vars[2]+"_c",l_s);
		p_rss.moduleUnread(vars[2],l_tab);
	},
	displayAll:function(){
		for (var i=0;i<tab[p_tabs.sel].module.length;i++){
			if (tab[p_tabs.sel].module[i].format=='R'){
				p_rss.display(indef,new Array(i,(getVar(tab[p_tabs.sel].module[i].vars,"nb")?getVar(tab[p_tabs.sel].module[i].vars,"nb"):5),tab[p_tabs.sel].module[i].uniq));
			}
		}
	},
	moduleUnread:function(v_id,v_tab){
		if (v_tab==indef) v_tab=p_tabs.sel;
		var l_id=uniqToId(v_id,v_tab);
		var l_content=_gel("module"+tab[v_tab].id+"_"+v_id+"_c"),nbur=0;
		if (__registerfeeds && !tab[v_tab].module[l_id].auth){
			for (var i=0;i<tab[v_tab].feeds.length;i++){
				if (tab[v_tab].feeds[i].modUniq==v_id && tab[v_tab].feeds[i].read==0) nbur++;
			}
		} else {
			var l_link=l_content.getElementsByTagName("a");
			for (var i=0;i<l_link.length;i++){
				var l_node=l_link[i];
				if (l_node.target=='npdetailf'){
					if (document.all){
						if (l_node.currentStyle.color!="#999999") nbur++;
					} else {
						if (window.getComputedStyle(l_node, null).color!="rgb(153, 153, 153)") nbur++;
					}
				}
			}
		}
		tab[v_tab].module[l_id].nbunread=nbur;
		//if (nbur>0) p_area.module.changeName(l_id);
		p_area.module.changeName(l_id,indef,indef,v_tab);
		p_rss.pageUnread(v_tab);
	},
	linkClicked:function(v_linkobj,v_id,v_i,v_modId,v_nbart){
		var l_id=uniqToId(v_id);
		p_counter.activityStep=0; // reset non activity check
		if (__registerfeeds && !tab[p_tabs.sel].module[l_id].auth){
			if (tab[p_tabs.sel].feeds[v_i].read==0){
				executescr("scr_feed_changestatus.php","artid0="+tab[p_tabs.sel].feeds[v_i].id+"&s0=1");
				tab[p_tabs.sel].feeds[v_i].read=1;
				navClass("feed"+tab[p_tabs.sel].id+"_"+v_id+"_"+tab[p_tabs.sel].feeds[v_i].id,"linkread");
				tab[p_tabs.sel].module[l_id].nbunread--;
				p_area.module.changeName(l_id);
				p_rss.pageUnread();
			}
		} else {
			if (tab[p_tabs.sel].showType==0){
				var l_newUnread=false;
				if (document.all){
					if (v_linkobj.currentStyle.color!="#999999") l_newUnread=true;
				} else {
					if (window.getComputedStyle(v_linkobj, null).color!="rgb(153, 153, 153)") l_newUnread=true;
				}
				if (l_newUnread){
					tab[p_tabs.sel].module[l_id].nbunread--;
					p_area.module.changeName(l_id);
					p_rss.pageUnread();
				}
			}
		}
		//if already in newspaper mode > no action
		if (tab[p_tabs.sel].showType==0){
			if (tab[p_tabs.sel].usereader==1 && tab[p_tabs.sel].module[l_id].usereader){
				p_newspaper.init();
				p_newspaper.showDetail(tab[p_tabs.sel].feeds[v_i].id);
				p_newspaper.load(v_modId);
				// no page preloading if feeds are managed in the DB (no use for read status update)
				if (__registerfeeds && !tab[p_tabs.sel].module[l_id].auth) return false;
				//if no link, do not open destination file
				if ((tab[p_tabs.sel].feeds[v_i].link).indexOf("noplink")!=-1) return false;
				return (tab[p_tabs.sel].feeds[v_i].link==""?false:true);
			} else {
				if (IE) return true;
				link(tab[p_tabs.sel].feeds[v_i].link,true);
				//link visited status is not instantaneous with FF
				if (!__registerfeeds ||  tab[p_tabs.sel].module[l_id].auth) setTimeout("p_rss.display(indef,new Array("+v_modId+","+v_nbart+","+v_id+"))",1000);
				return false;
			}
		}
	},
	readAll:function(v_tab,v_modId){
		var l_s="",inc=0;
		for (var i=0;i<tab[v_tab].feeds.length;i++){
			if (tab[v_tab].feeds[i].modUniq==tab[v_tab].module[v_modId].uniq){
				navClass("feed"+tab[v_tab].id+"_"+tab[v_tab].module[v_modId].uniq+"_"+tab[v_tab].feeds[i].id,"linkread");
				l_s+="artid"+inc+"="+tab[v_tab].feeds[i].id+"&s"+inc+"=1&";
				tab[v_tab].feeds[i].read=1;
				inc++;
			}
		}
		executescr("scr_feed_changestatus.php",l_s);
		tab[v_tab].module[v_modId].nbunread=0;
		p_area.module.changeName(v_modId);
		p_rss.pageUnread();
		return false;
	},
	pageUnread:function(v_tab){
		if (v_tab==indef) v_tab=p_tabs.sel;
		if (jsid==-1) return;
		tab[v_tab].nbUnread=0;
		for (var i=0;i<tab[v_tab].module.length;i++){
			if (tab[v_tab].module[i].nbunread>0) tab[v_tab].nbUnread+=tab[v_tab].module[i].nbunread;
		}
		//p_banner.option.shown=false;
		//p_banner.option.show();
		if (tab[v_tab].nbUnread>0) navPrint("tabextra"+v_tab,"("+tab[v_tab].nbUnread+")");
		if (v_tab==p_tabs.sel) changePageTitle();
	},
	showOverview:function(v_id,event){
		var l_desc=removeTags((tab[p_tabs.sel].feeds[v_id]?tab[p_tabs.sel].feeds[v_id].desc:""));
		var maxLength=100,result=(tab[p_tabs.sel].feeds[v_id]?"<b>"+tab[p_tabs.sel].feeds[v_id].title+"</b><br />":""); //max length of description
		var endPos = (l_desc.indexOf('.',maxLength)) + 1; //get position of (.) starting from maxLength
		if (endPos=="") { //if description is shorter than maxLength
			result+=l_desc; //use original description
		} else {
			result+=l_desc.substr(0,endPos); //use shorter description
		}
		if (tab[p_tabs.sel].feeds[v_id]) mouseBox(result,event);
	},
	hideOverview:function(){
		mouseBox("");
	},
	secure:function(v_s){
		var l_s=v_s.replace(/&lt;/g,"<");
		l_s=l_s.replace(/&gt;/g,">");
		l_s=l_s.replace(/<script/g,"<!--");
		l_s=l_s.replace(/<\/script>/g,"-->");
		l_s=l_s.replace(/&amp;/g,"&");
		l_s=l_s.replace(/&#38;/g,"&");
		return l_s;
	},
	importMenu:function(){
		var l_s="<table cellpadding='5' cellspacing='0' width='100%'>";
		l_s+="<tr><td class='bottomhr'><b>"+lg("lblImportOpml")+"</b><br /><br />";
		l_s+="<form enctype='multipart/form-data' method='post' action='../portal/scr_opml_import.php' target='iopml'>";
		l_s+="<input type='file' name='opml' /> <input type='submit' value='"+lg("lblUpload")+"' />";
		l_s+="</form><iframe style='display:none' src='about:blank' id='iopml' name='iopml' onload='p_rss.importTreat()'></iframe><div id='opmlres'></div></td></tr>";
		l_s+="<tr><td><b>"+lg("lblExportOpml")+"</b><br /><br />";
		l_s+="<input type='button' value='"+lg("lblExportBtn")+"' onclick='p_rss.exportOpml()' />";
		l_s+="</td></tr></table>";
		navPrint("box",box(0,lg("lblImport"),"hideBox()",l_s));
		navShow("box","block");
		return false;
	},
	importTreat:function(){
		var i = _gel("iopml");
		if (i.contentDocument) {
			var d = i.contentDocument;
		} else if (i.contentWindow) {
			var d = i.contentWindow.document;
		} else {
			var d = window.frames["iopml"].document;
		}
		if (d.location.href == "about:blank") {
			return;
		}
		if (d.body.innerHTML==""){p_alert.show(lg("msgXMLerror"));}
		else {
			p_rss.opmlfile=d.body.innerHTML;
			getXml(p_rss.opmlfile,p_rss.importSelectTab,"");
		}
	},
	importSelectTab:function(response,vars){
		var l_s="";
		if (response.getElementsByTagName("opml")[0] || response.getElementsByTagName("body")[0]){
			var opmlcont=response.getElementsByTagName("body")[0]?response.getElementsByTagName("body")[0]:response.getElementsByTagName("opml")[0];
			l_s+="<br />"+lg("lblChooseOpmlTab")+" :<br /><br />";
			for (var i=0;i<opmlcont.childNodes.length;i++){
				var result=opmlcont.childNodes[i];
				if (_lc(result.nodeName)=="outline") l_s+="- <a href='#' onclick='p_rss.getImportTab("+i+")'>"+getXMLprop(result,"title","str",false,"empty")+"</a><br />";
			}
			l_s+="<div id='opmlfeeds'></div>";
		}
		if (l_s=="" || l_s==indef) l_s=lg("msgXMLerror");
		navPrint("opmlres",l_s);
	},
	getImportTab:function(v_id){
		getXml(p_rss.opmlfile,p_rss.addImportTab,v_id);
	},
	addImportTab:function(response,vars){
		var l_s="<br />"+lg("selectFeedsToImport")+" :<br />";
		if (response.getElementsByTagName("opml")[0]){
			var opmlcont=response.getElementsByTagName("body")[0]?response.getElementsByTagName("body")[0]:response.getElementsByTagName("opml")[0];
			var selOutline=opmlcont.childNodes[vars];
			for (var i=0;i<selOutline.childNodes.length;i++){
				var result=selOutline.childNodes[i];
				if (_lc(result.nodeName)=="outline"){
					l_s+="<a href='#' onclick=\"p_rss.checkFeed('"+getXMLprop(result,"xmlUrl","str",false,"")+"')\">"+getXMLprop(result,"title","str",false,"")+"</a> ";
				}
			}
		}
		navPrint("opmlfeeds",l_s);
			
//			var l_title=getXMLprop(selOutline,"title","str",false,"empty");
//			var l_s="",l_col=1,l_pos=1,l_inc=0;
//			for (var i=0;i<selOutline.childNodes.length;i++){
//				var result=selOutline.childNodes[i];
//				if (_lc(result.nodeName)=="outline"){
//					l_s+="&id"+l_inc+"=86";
//					l_s+="&col"+l_inc+"="+l_col;
//					l_s+="&pos"+l_inc+"="+l_pos;
//					l_s+="&posj"+l_inc+"="+l_inc;
//					l_s+="&var"+l_inc+"="+_esc("nb=5&rssurl="+getXMLprop(result,"xmlUrl","str",false,""));
//					l_s+="&blocked"+l_inc+"=0";
//					l_s+="&minimized"+l_inc+"=0";
//					l_col++;
//					if (l_col==4) {l_col=1;l_pos++;}
//					l_inc++;
//				}
//			}
//			executescr("scr_createportal.php","w=3&s="+tab[p_tabs.sel].style+"&n="+l_title+"&t=0&nb=25&sess="+getSession()+l_s,false,true,openPage);
//		}
	},
	exportOpml:function(){
		link("xmlopmlexport.php",true);
	},
	getId:function(v_id){
		for (var i=0;i<tab[p_tabs.sel].feeds.length;i++){
			if (tab[p_tabs.sel].feeds[i].id==v_id) return i;
		}
		return v_id;
	}
}
var p_newspaper={
	selArticle:0,
	readerWidth:0,
	readerHeight:0,
	currSrc:indef,
	init:function(){
		//hide modules
		navShow("modules","none");
		navShow("newspaper","block");
		//hide menus
		hideAllBox();
		mouseBox("");
		
		var l_obj=_gel("newspaper");
		if (!l_obj){
			var l_div=_gel("modules");
			l_obj=null;l_obj=document.createElement("div");
			l_obj.id="newspaper";
			l_obj.style.display="none";
			l_obj.style.verticalAlign="top";
			l_div.appendChild(l_obj)
			//l_div.insertBefore(l_obj,tab[p_tabs.sel].cols[1]);
		}
		//compute frames dimensions
		l_left=getPos(l_obj,"Left");
		l_top=getPos(l_obj,"Top");
		p_rss.readerWidth=getWindowWidth()-l_left-350;
		p_rss.readerHeight=getWindowHeight()-l_top-70;
		//l_obj.innerHTML="<div class='module'><table class='bmod' cellpadding='0' cellspacing='0' width='100%' border='0'><tr><td class='newspaperbar'><table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td class='menutitle' width='100%'>"+img("ico_newspaper.gif",17,15,"","imgmid")+" &nbsp; <b>"+lg("lblNewsTitle")+"</b></td>";<td nowrap='nowrap'><a href='#' onclick='return p_newspaper.size(2)'>"+lg("lblLessArticle")+"</a> | <a href='#' onclick='return p_newspaper.size(1)'>"+lg("lblMoreArticle")+"</a> | <a href='#' onclick='p_rss.init();p_newspaper.load();return false;'>"+img("ico_refresh.gif",13,9,lg("lblRefresh"))+" "+lg("lblRefresh")+"</a> | <a href='#' onclick='p_newspaper.hide()'>"+img("ico_close.gif",9,9,lg("lblClose"),"imgmid")+" "+lg("lblClose")+"</a></td></tr></table></td></tr><tr><td id='npcontent' class='newspaper'>"+lg("lblLoading")+"</td></tr></table>"+img("s.gif",600,1);

		var l_s="<div id='myreader'>";
		l_s+="<div class='addonbar' style='text-align:right'><a href='#' onclick='return p_newspaper.refresh();'>"+img("ico_refresh.gif",13,9,lg("lblRefresh"))+" "+lg("lblRefresh")+"</a> | <a href='#' onclick='p_newspaper.hide();p_rss.displayAll();'>"+img("ico_close.gif",9,9,lg("lblClose"),"imgmid")+" "+lg("lblClose")+"</a></div>";
		l_s+="<div class='newspaper'>";
		l_s+="<div id='sourcelist'>"+lg("lblLoading")+"</div>";
		l_s+="<table cellpadding='0' cellspacing='0'>";
		l_s+="<tr><td width='300px' valign='top'><div id='nparticles' style='width:300px;height:"+p_rss.readerHeight+"px;overflow:auto;vertical-align:top;'></div></td>";
		l_s+="<td id='npdetail' class='frame' style='width:"+p_rss.readerWidth+"px;height:"+p_rss.readerHeight+"px;'>&nbsp;</td></tr>";
		l_s+="</table>";
		l_s+="</div>";
		l_s+="</div>";
//		l_s+="<table class='bmod' cellpadding='0' cellspacing='0' width='100%' border='0'><tr><td class='newspaperbar'><table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td class='menutitle' width='100%'>"+img("ico_newspaper.gif",17,15,"","imgmid")+" &nbsp; </td><td nowrap='nowrap'><a href='#' onclick='return p_newspaper.refresh();'>"+img("ico_refresh.gif",13,9,lg("lblRefresh"))+" "+lg("lblRefresh")+"</a> | <a href='#' onclick='p_newspaper.hide();p_rss.displayAll();'>"+img("ico_close.gif",9,9,lg("lblClose"),"imgmid")+" "+lg("lblClose")+"</a></td></tr></table></td></tr>";
//		l_s+="<tr><td id='npcontent' class='newspaper'>";
//		l_s+="<div id='sourcelist'>"+lg("lblLoading")+"</div>";
//		l_s+="<table><tr><td width='300px' valign='top'><div id='nparticles' style='width:285px;height:"+p_rss.readerHeight+"px;overflow:auto;vertical-align:top;'></div></td>";
//		l_s+="<td id='npdetail' class='frame' style='width:"+p_rss.readerWidth+"px;height:"+p_rss.readerHeight+"px;'>&nbsp;</td></tr></table>";
//		l_s+="</td></tr></table>";
//		l_s+="</div>";
		l_obj.innerHTML=l_s;
		tab[p_tabs.sel].showType=1;
	},
	load:function(v_src){
		// Switch to newspaper display
	//	p_newspaper.init();
		var l_inc=0,l_allLoaded=true;
		for (var i=0;i<tab[p_tabs.sel].module.length;i++){
			if (tab[p_tabs.sel].module[i].format=='R' && !tab[p_tabs.sel].module[i].isLoaded){
				l_allLoaded=false;
				p_rss.refresh(i);
				//getXml(module[i].url+"pid="+jsid+"&prof="+jsprof+"&p="+module[i].uniq+"&"+module[i].vars,p_newspaper.chk,new Array(module[i].name,i));
			}
		}
		// normally all sources are loaded
		//if (l_allLoaded) p_newspaper.show(true,v_src);
		p_newspaper.show(true,v_src);
	},
	refresh:function(){
		p_rss.init(p_tabs.sel);
		p_newspaper.load();
		return false;
	},
	chk:function(response,vars){if (p_rss.get(response,vars[0],vars[1])) {p_newspaper.show(true,p_newspaper.currSrc);};},
	getSrcList:function(){
		var l_s="<b>"+lg("lblSrc")+" :</b>";
		var srclink=[];
		for (var i=0;i<tab[p_tabs.sel].module.length;i++){
			if (tab[p_tabs.sel].module[i].format=='R'){
				if (tab[p_tabs.sel].module[i].isLoaded){
					if (p_newspaper.currSrc==i){srclink.push(" <font class='sourcesel'>"+tab[p_tabs.sel].module[i].name+(tab[p_tabs.sel].module[i].nbunread==0?"":" <a href='#' title='"+lg("readAll")+"' onclick='p_rss.readAll("+p_tabs.sel+","+i+");p_newspaper.show(false,"+p_newspaper.currSrc+");'>("+tab[p_tabs.sel].module[i].nbunread+")</a>")+"</font>");}
					else {srclink.push(" <a href='#' style='font-weight:normal' onclick='return p_newspaper.show(false,"+i+")'>"+tab[p_tabs.sel].module[i].name+"</a>"+(tab[p_tabs.sel].module[i].nbunread==0?"":" <a href='#' title='"+lg("readAll")+"' onclick='p_rss.readAll("+p_tabs.sel+","+i+");p_newspaper.show(false,"+p_newspaper.currSrc+");'>("+tab[p_tabs.sel].module[i].nbunread+")</a>"));}
				} else {srclink.push(" "+tab[p_tabs.sel].module[i].name+" "+img("ico_wait.gif",9,9,lg("lblSrcLoading"),"imgmid"));}
				//l_s+="&nbsp;<a href='#' onclick='p_newspaper.supSrc("+i+");'>+img("ico_close.gif",9,9,lg("lblSrcSup"),"imgmid")+"</a>";
				//l_s+=" |";
			}
		}
		l_s+=srclink.join(" | ");
		//l_s+=" + <a href='#' onclick='p_addContent.menu(4);return false;'>"+lg("lblSrcAdd")+"</a>";
		if (p_newspaper.currSrc!=indef) l_s+=" | <a href='#' style='color:#008200' onclick='return p_newspaper.show(false)'>"+lg("lblSrcAll")+"</a>";
		if(__useGSearch) l_s+="<center><b>"+lg("lblSrcSrch")+"</b> <div id='searchform' width='350'></div></center><br /><table width='100%'><tr><td valign='top' width='100%'><div id='searchResults' width='600'>"+lg("lblLoading")+"</div></td></tr></table>";
		navPrint("sourcelist",l_s);
	},
	show:function(v_sort,v_src){
		// Display news as newspaper
		var j=0;
		p_newspaper.currSrc=v_src;
		//if multisources, display only once on the last source loading
		p_newspaper.getSrcList();
		l_s="";
		if (v_sort) tab[p_tabs.sel].feeds.sort(sortDate);
		i=0;
		l_s+="<table cellpadding='2' cellspacing='0' border='0' width='100%'>";
		//while (i<p_newspaper.nb && j<p_rss.feeds.length){
		while (j<tab[p_tabs.sel].feeds.length){
			if (v_src==indef || tab[p_tabs.sel].feeds[j].modUniq==tab[p_tabs.sel].module[v_src].uniq){
				var l_style=(i%2==1)?"dark":"clear";
				l_s+="<tr class='"+l_style+"'>";
				//if (p_rss.feeds[j].image!="x"){l_s+="<td class='"+l_style+"' width='42'><img"+p_rss.feeds[j].image+" width='40' /></td>";}else{l_s+="<td class='"+l_style+"'>&nbsp;</td>";}
				//l_s+="<td class='normal'>"+img("../modules/pictures/box0_"+p_rss.feeds[j].modId+".gif",16,16,p_rss.feeds[j].modName,"imgmid")+"</td>";
				var l_id=uniqToId(tab[p_tabs.sel].feeds[j].modUniq);
				l_s+="<td class='normal'>"+img("../modules/pictures/"+tab[p_tabs.sel].module[l_id].icon,16,16,"","imgmid")+"</td>";
				
				l_s+="<td id='npart"+tab[p_tabs.sel].feeds[j].id+"' class='"+(tab[p_tabs.sel].feeds[j].id==p_newspaper.selArticle?"highlight":"normal"+((__registerfeeds && !tab[p_tabs.sel].module[l_id].auth)?(tab[p_tabs.sel].feeds[j].read==0?"unread":"read"):""))+"'><a class='title' href='"+tab[p_tabs.sel].feeds[j].link+"' target='npdetailf' onclick='return p_newspaper.showDetail("+tab[p_tabs.sel].feeds[j].id+")'>"+tab[p_tabs.sel].feeds[j].title+"</a><br />";
				l_s+="<span class='source'>"+tab[p_tabs.sel].feeds[j].modName+"</span> - "+formatDelai(dateDelai(tab[p_tabs.sel].feeds[j].date));


//				if (jsid!=0&&__useArchive) l_s+=" - <a style='font-weight:normal' href='#' onclick='return p_article.save("+j+")'>"+lg("lblSave")+"</a>";
				if (jsid>0&&__useSharing) l_s+=" <a href='#' onclick='p_friends.menu(2,"+tab[p_tabs.sel].feeds[j].id+")'>"+img("ico_share_s.gif",16,10,lg("lblShareInfo"))+"</a>";
				if (jsid>0&&__useArchive) l_s+=" <a href='#' onclick='return p_article.save("+tab[p_tabs.sel].feeds[j].id+")'>"+img("ico_disk_s.gif",8,9,lg("lblSave"))+"</a>";

				l_s+="<br /><br /></td>";
				l_s+="</tr>"; 
				i++;
			}
			j++;
		}
		if (i==0) l_s+="<tr><td><div style='width:100%;height:200px'>"+lg("lblSrcMissing")+"</div></td></tr>";
		l_s+="</table>";
		navPrint("nparticles",l_s);
		if(__useGSearch) initGSearch(true);
		return false;
	},
	showDetail:function(v_id){
		//after newspaper sorting, array id change => getId
		//l_id=(tab[p_tabs.sel].feeds[v_id].id==v_id)?v_id:p_rss.getId(v_id);
		var l_id=p_rss.getId(v_id);
		var l_modId=uniqToId(tab[p_tabs.sel].feeds[l_id].modUniq);
		var l_s="<div id='npdetailititle'><h2>"+tab[p_tabs.sel].feeds[l_id].title+"</h2>";
		l_s+="<span class='source'>"+tab[p_tabs.sel].feeds[l_id].modName+"</span> - "+formatDelai(dateDelai(tab[p_tabs.sel].feeds[l_id].date));
		if (tab[p_tabs.sel].feeds[l_id].link!="" && (tab[p_tabs.sel].feeds[l_id].link).indexOf("noplink")==-1) l_s+="<br /><br /><input type='button' id='npshowsumbtn' value=\""+lg("lblOpenSummary")+"\" onclick=\"return p_newspaper.showSummary("+tab[p_tabs.sel].feeds[l_id].id+");\" \> <input type='button' id='npshowsitebtn' value=\""+lg("lblOpenInReader")+"\" onclick=\"return p_newspaper.showSite('"+tab[p_tabs.sel].feeds[l_id].link+"');\" \> <input type='button' value=\""+lg("lblOpenInNewPage")+"\" onclick=\"link('"+tab[p_tabs.sel].feeds[l_id].link+"',true);\" \>";
		l_s+="<br /></div>";
		l_s+="<div id='npdetaili'><div id='npdetailidesc'><br />"+setExternalLink(tab[p_tabs.sel].feeds[l_id].desc)+"</div></div>";
		l_s+="<iframe id='npdetailf' name='npdetailf' src='' style='width:100%;height:"+p_rss.readerHeight+"px;display:none;'></iframe>";
		navPrint("npdetail",l_s);
		(_gel("npshowsumbtn")).disabled=true;
		//un highlight the previous article
		navClass("npart"+p_newspaper.selArticle,((__registerfeeds && !tab[p_tabs.sel].module[l_modId].auth)?"normalread":"read"));
		//highlight the selected article
		navClass("npart"+tab[p_tabs.sel].feeds[l_id].id,"highlight");
		p_newspaper.selArticle=tab[p_tabs.sel].feeds[l_id].id;
		//if (__registerfeeds && !tab[p_tabs.sel].module[l_modId].auth){
		if (__registerfeeds){
	// ca boucle :		p_rss.linkClicked(indef,tab[p_tabs.sel].feeds[l_id].modUniq,l_id,uniqToId(tab[p_tabs.sel].feeds[l_id].modUniq));
			p_rss.linkClicked(indef,tab[p_tabs.sel].feeds[l_id].modUniq,l_id,uniqToId(tab[p_tabs.sel].feeds[l_id].modUniq));
			p_newspaper.getSrcList();
			if (!tab[p_tabs.sel].module[l_modId].auth) return false;
		}
		p_newspaper.getSrcList();
		return (tab[p_tabs.sel].feeds[l_id].link==""?false:true);
	},
	showSite:function(v_src){
		if ((_gel("npdetailf")).src=="" || (_gel("npdetailf")).src==window.location) (_gel("npdetailf")).src=v_src;
		navShow("npdetaili","none");
		navShow("npdetailf","block");
		(_gel("npshowsumbtn")).disabled=false;
		(_gel("npshowsitebtn")).disabled=true;
		return false;
	},
	showSummary:function(v_id){
		navShow("npdetaili","block");
		navShow("npdetailf","none");
		navPrint("npdetailidesc","<br />"+setExternalLink(tab[p_tabs.sel].feeds[p_rss.getId(v_id)].desc));
		(_gel("npshowsumbtn")).disabled=true;
		(_gel("npshowsitebtn")).disabled=false;
		return false;
	},
	hide:function(){
		//tab[p_tabs.sel].feeds.sort(sortId); //sort items by id, by date sometimes it is not relevant in the modules
		navShow("newspaper","none");
		//p_area.clean(_gel("newspaper"));
		navShow("modules","block");
		tab[p_tabs.sel].showType=0;
	},
	supSrc:function(v_id){
		//suppress Newspaper Source
		if (p_area.module.suppress(tab[p_tabs.sel].module[v_id].uniq,true)) p_newspaper.show(false);
	},
	size:function(v_act){
		// Select number of article to show
		var l_oldNb=tab[p_tabs.sel].newspapernb;
		if (v_act==1 && tab[p_tabs.sel].newspapernb<30 && tab[p_tabs.sel].newspapernb<tab[p_tabs.sel].feeds.length) tab[p_tabs.sel].newspapernb+=5;
		if (v_act==2&&tab[p_tabs.sel].newspapernb>5) tab[p_tabs.sel].newspapernb-=5;
		if (tab[p_tabs.sel].newspapernb!=l_oldNb){
			executescr("scr_newspaper.php","prof="+jsprof+"&nb="+tab[p_tabs.sel].newspapernb);
			p_newspaper.show(false);
		}
		return false;
	}
}
var p_reader={
	open:function(v_src,v_type){
		// Open media inside Portaneo
		var l_s="<table width='100%' cellpadding='0' cellspacing='0'><tr><td class='advise' align='center'><table cellpadding='3' cellspacing='0'><tr><td>";
		if (v_type=="a") l_s+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='400' height='18' id='mp3player' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'><param name='movie' value='"+pfolder+"../tools/mp3player.swf'><param name='flashvars' value='file="+_esc(v_src)+"&autostart=true'><param name='wmode' value='transparent' /><embed src='"+pfolder+"../tools/mp3player.swf' wmode='transparent' width='400' height='18' flashvars='file="+_esc(v_src)+"&autostart=true' name='mp3player' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
		if (v_type=="v") l_s+="<object classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='320' height='250' codebase='http://www.apple.com/qtactivex/qtplugin.cab'><param name='controller' value='TRUE'><param name='type' value='video/quicktime'><param name='autoplay' value='true'><param name='target' value='myself'><param name='src' value='"+v_src+"'><param name='pluginspage' value='http://www.apple.com/quicktime/download/'><embed controller='TRUE' target='myself'  width='320' height='250' src='"+v_src+"' qtsrc='"+v_src+"' type='video/quicktime' bgcolor='black' border='0' loop='false' autoplay='true' pluginspage='http://www.apple.com/quicktime/download/'></embed></object><br /><br />"+lg("lblVideoWarning");
		l_s+="</td><td valign='top'><a href='#' onclick='p_reader.hide();return false;'>"+img("ico_close.gif",9,9)+"</a></td></tr></table></td></tr></table>";
		navShow("audio","block");
		navPrint("audio",l_s);
	},
	hide:function(){p_area.clean(_gel("audio"));navShow("audio","none");}
}

//===============================================================================================================
//					PORTAL INFO MANAGEMENT
//===============================================================================================================

//Manage the information in the portal banner
var p_banner={};
p_banner.option={
	shown:false,
	show:function(){
		//no access to options if page locked
		if (tab[p_tabs.sel].locked) return false;
		if (p_banner.option.shown){p_banner.option.hide();}
		else {
			//display the options in the banner
			var l_s="<table cellpadding='3' cellspacing='0' border='0' width='100%'><tr><td class='advise' align='center'>";
			for (var i=0;i<__option.length;i++){
				if ((__option[i]["anonymous"]&&jsid<=0)||(__option[i]["connected"]&&jsid>0)) l_s+="<a href='#' id='"+__option[i]["id"]+"' onclick='return "+__option[i]["fct"]+"'>"+img(__option[i]["img"],16,16,__option[i]["comment"],"imgmid")+" "+__option[i]["label"]+"</a> | ";
			}
			if (jsid>0){
			//	if (def=="N"){l_s+=" | <a href='#' onclick='p_pages.def()'>"+lg("lblDefault")+"</a>";}
				l_s+="<a href='#' onclick='return p_pages.suppress();'>"+img("ico_suppress.gif",13,10,"","imgmid")+" "+lg("lblSuppresspage")+"</a>";
			}
			l_s+="</td></tr></table>";
			navPrint("advise",l_s);
			navShow("advise","block");
			p_banner.option.shown=true;
			p_banner.info.shown=false;
		}
		return false;
	},
	hide:function(){
		navShow("advise","none");
		p_banner.info.load(0);
		p_banner.option.shown=false;
	}
}
p_banner.info={
	shown:true,
	requested:'Y',
	loaded:false,
	item:[],
	itemid:0,
	load:function(v_id){
		if (__bartype==1 && __bartexthtml!="" && p_banner.info.shown!=false){
			var l_s=__bartexthtml;
			if (__barclosing) l_s="<table cellpadding='0' cellspacing='0' border='0' width='100%'><tr><td>"+l_s+"</td><td width='16' valign='top'><a href='#' onclick='return p_banner.info.hide()'>"+img("ico_close.gif",9,9)+"</a></td></tr></table>";
			navPrint("advise",l_s);
			p_banner.info.show();
		}
		//if (p_banner.info.requested=="Y"&&__rssinfo!=""){
		if (__bartype==2 && __rssinfo!=""){
			getXml(__rssinfo,p_banner.info.displayRss,v_id);
			p_banner.info.show();
			p_banner.info.loaded=true;
		}
	},
	displayRss:function(response,vars){
		var i=0;
		while (response.getElementsByTagName("item")[i]){
			var result=response.getElementsByTagName("item")[i];
			if (getXMLval(result,"link","str",false,"")==""){
				p_banner.info.item.push(getXMLval(result,"title","str",false,"..."));
			} else {
				p_banner.info.item.push("<a href='"+getXMLval(result,"link","str",false,"#")+"'>"+getXMLval(result,"title","str",false,"...")+"</a>");
			}
			i++;
		}
		p_banner.info.roll();
	},
	roll:function(){
		if (p_banner.info.item.length>0 && p_banner.info.shown){
			var l_s="";
			//l_s+=lg("lblDisplay")+" <a href='#' onclick='changeShowType(0)'>"+img("ico_bloc.gif",16,16,lg("lblSBloc"),(p_area.showType==0?"iconea":"iconei"),"show0")+"</a> : <a href='#' onclick='changeShowType(1)'>"+img("ico_newspaper.gif",16,16,lg("lblSNews"),(p_area.showType==0?"iconei":"iconea"),"show1")+"</a> | ";
			if (p_banner.info.itemid==p_banner.info.item.length) p_banner.info.itemid=0;
			l_s+=p_banner.info.item[p_banner.info.itemid];
			p_banner.info.itemid++;
			navPrint("advise",l_s);
		}
	},
	show:function(){
		//if (p_banner.info.requested=="Y" && !p_banner.info.shown) {
			navShow("advise","block");
			p_banner.info.shown=true;
		//	p_banner.option.shown=false;
		//}
	},
	hide:function(){
		//if (p_banner.info.requested=="Y" && p_banner.info.shown){
			navShow("advise","none");
			p_banner.info.shown=false;
		//}
	}
}
var p_alert={
	shown:false,
	timer:0,
	/*
	** Display message
	** Input :
	** - v_msg : message to display
	** - v_type : message type 1:information 2:help 3:alert/error
	*/
	show:function(v_msg,v_type){
		var l_img;
		switch (v_type){
			case indef:
			case 1:
				l_img="ico_info.gif";break;
			case 2:
				l_img="ico_help2.gif";break;
			case 3:
				l_img="ico_alert.gif";break;
		}
		if (_gel("errordiv")==null){
			var l_obj=null;
			l_obj=document.createElement("div");
			l_obj.id="errordiv";
			l_obj.className="errordiv";
			document.body.appendChild(l_obj);
		} else {l_obj=_gel("errordiv");}
		l_obj.style.top=(document.all)?document.documentElement.scrollTop+"px":window.pageYOffset+"px";
		var l_msg="<img src='../images/"+l_img+"' align='absmiddle' /> "+v_msg;
		if (p_alert.shown){
			navPrint("errormsg","<br />"+l_msg,true);
		} else {
			var l_s="<table width='100%'><tr><td align='center' id='errormsg' onclick='return p_alert.hide()'>"+l_msg+"</td><td width='13' align='center'><a href='#' onclick='return p_alert.hide()'>"+img("ico_close.gif",9,9)+"</a></td></tr></table>";
			navPrint("errordiv",l_s);
		}
		//avoid that the message remain in the middle of the page
		window.onscroll=p_alert.hide;
		p_effect.fadein(l_obj);
		p_alert.shown=true;
		//hide after x seconds
		if(p_alert.timer==0){
			p_alert.timer=setTimeout("p_alert.hide()",7000);
		} else {
			clearTimer(p_alert.timer);
			p_alert.timer=setTimeout("p_alert.hide()",7000);
		}
		return false;
	},
	hide:function(){
		if (p_alert.shown==true){
			p_alert.shown=false;
			p_effect.fadeout(_gel("errordiv"));
			window.onscroll=null;
			p_alert.timer=0;
		}
		return false;
	}
}
var p_effect={
	obj:{},
	opacity:0,
	timer:0,
	fadein:function(v_obj){
		if(p_effect.timer!=0) clearTimer(p_effect.timer);
		//if (p_effect.timer) clearTimeout(p_effect.timer);
		p_effect.obj=v_obj;
		p_effect.opacity=0;
		p_effect.fadeinaction();
		p_effect.obj.style.display="block";
	},
	fadeinaction:function(){
		p_effect.opacity+=0.1;
		p_effect.obj.style.opacity=""+p_effect.opacity;
		p_effect.obj.style.filter="alpha(opacity="+(p_effect.opacity*100)+")";
		if (p_effect.opacity<1){p_effect.timer=setTimeout("p_effect.fadeinaction()",70);}
		else {clearTimer(p_effect.timer);}
	},
	fadeout:function(v_obj){
		if(p_effect.timer!=0) clearTimer(p_effect.timer);
		p_effect.obj=v_obj;
		p_effect.opacity=1;
		p_effect.fadeoutaction();
	},
	fadeoutaction:function(){
		p_effect.opacity-=0.1;
		p_effect.obj.style.opacity=""+p_effect.opacity;
		p_effect.obj.style.filter="alpha(opacity="+(p_effect.opacity*100)+")";
		if (p_effect.opacity>0){p_effect.timer=setTimeout("p_effect.fadeoutaction()",70);}
		else {p_effect.obj.style.display="none";clearTimer(p_effect.timer);}
	}
}
//  Base64 encode
//  http://www.webtoolkit.info/
var Base64 = {
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
	// public method for encoding
	encode:function(input){
		if (input=="" || input==":") return "";
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
		input = Base64._utf8_encode(input);
		while (i < input.length) {
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
			output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
		}
		return output;
	},
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
		for (var n = 0; n < string.length; n++) {
			var c = string.charCodeAt(n);
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
		}
		return utftext;
	}
}
function mymodulesObj(id,name,typ){
	this.id=id;
	this.name=name;
	this.typ=typ;
}
var p_factory={
	shown:false,
	items:[],
	waitItems:[],
	menu:new Array({"id":1,"title":"lblArchive2","icon":"mymodules.gif","fct":"p_factory.display(0,0)","isLink":true},{"id":2,"title":"lblCreateYourMod","icon":"mymodules_create.gif","fct":"p_factory.createModuleMenu()","isLink":true}),

	init:function(){
		p_plugin.open();
		p_plugin.init();
//		p_pages.closeAllDiv();
//		p_pages.hide();
//		p_tabs.create(-1);
		p_factory.load();
		tab[p_tabs.sel]=new tabObj(-1,"","P","",0,0,0,0,"",0);
		jsprof=0;
		return false;
	},
	load:function(){
		//if (!p_factory.shown) getXml("xmlmymodules.php?start="+v_start+"&nb=10",p_factory.get,"");
		getXml("xmlmymodules.php",p_factory.get,"");
	},
	get:function(response,vars){
		var i=0;
		p_factory.items.length=0;
		p_factory.waitItems.length=0;
		while (response.getElementsByTagName("module")[i]){
			var l_result=response.getElementsByTagName("module")[i];
			if (getXMLval(l_result,"status","str",false,"")=="O"){
				p_factory.items.push(new mymodulesObj(getXMLval(l_result,"id","int",false,0),getXMLval(l_result,"name","str",false,"=="),getXMLval(l_result,"typ","str",false,"")));
			} else {
				p_factory.waitItems.push(new mymodulesObj(getXMLval(l_result,"id","int",false,0),getXMLval(l_result,"name","str",false,"=="),getXMLval(l_result,"typ","str",false,"")));
			}
			i++;
		}
		p_factory.display(0,0);
	},
	display:function(v_page,v_pageVal){
		p_plugin.menu(p_factory.menu,1);
		//var l_s=p_factory.menu(1)+"<br /><br />";
		var l_s="<a href='#' onclick='return p_factory.load()'>"+img("ico_refresh.gif",13,9,"","imgmid")+" "+lg("lblRefresh")+"</a><br /><br />";
		l_s+="<div class='subtitle'>"+lg("mymodulesVal")+"</div><br /><table>";
		var l_start=v_page*10;
		var l_end=l_start+10;
		for (var i=l_start;i<l_end;i++){
			if (i<p_factory.items.length){
				l_s+="<tr><td><img src='../modules/pictures/box0_"+p_factory.items[i].id+".ico' align='absmiddle' width='16' height='16' /></td><td><a href='#' onclick=\"openmod("+p_factory.items[i].id+",'','uniq')\"><b>"+p_factory.items[i].name+"</b></a></td></tr>";
				if (p_factory.items[i].typ=="R") l_s+="<tr><td></td><td>[<a href='../tutorial/redactor_article_modify_add.php?mid="+p_factory.items[i].id+"'>"+lg("addArticle")+"</a>] [<a href='../tutorial/redactor_feed.php?mid="+p_factory.items[i].id+"'>"+lg("feedDetail")+"</a>]</td></tr>";
			}
		}
		l_s+="</table>";
		if (p_factory.items.length==0) l_s+="<i>"+lg("mymodulesValNone")+"</i>";
		if (v_page!=0) l_s+="<a href='#' onclick='p_factory.display("+(v_page-1)+","+v_pageVal+")'>"+img("ico_previous2.gif",12,11,"","imgmid")+" "+lg("previous")+"</a> ";
		if (p_factory.items.length>i) l_s+="&nbsp; <a href='#' onclick='p_factory.display("+(v_page+1)+","+v_pageVal+")'>"+lg("next")+" "+img("ico_next2.gif",12,11,"","imgmid")+"</a>";
		l_s+="<br /><br />";

		l_s+="<div class='subtitle'>"+lg("mymodulesWait")+"</div><br /><table>";
		var l_startVal=v_pageVal*10;
		var l_endVal=l_start+10;
		for (var i=l_startVal;i<l_endVal;i++){
			if (i<p_factory.waitItems.length){
				l_s+="<tr><td><img src='../modules/quarantine/icon"+p_factory.waitItems[i].id+".ico' align='absmiddle' width='16' height='16' /></td><td><b>"+p_factory.waitItems[i].name+"</b></td></tr>";
			}
		}
		l_s+="</table>";
		if (p_factory.waitItems.length==0) l_s+="<i>"+lg("mymodulesWaitNone")+"</i>";
		if (v_pageVal!=0) l_s+="<a href='#' onclick='p_factory.display("+v_page+","+(v_pageVal-1)+")'>"+img("ico_previous2.gif",12,11,"","imgmid")+" "+lg("previous")+"</a> ";
		if (p_factory.waitItems.length>i) l_s+="&nbsp; <a href='#' onclick='p_factory.display("+v_page+","+(v_pageVal+1)+")'>"+lg("next")+" "+img("ico_next2.gif",12,11,"","imgmid")+"</a>";


		p_plugin.content(l_s);
		//navShow("mymodules","block");
		p_factory.shown=true;
	},
	createModuleMenu:function(){
		p_plugin.menu(p_factory.menu,2);
		var l_s="<br /><br />";

		l_s+='<div class="subtitle">'+lg("addRssFeed")+'</div><br />';
		l_s+='<a href="../tutorial/rssaddtodirectory.php" target="_createmodule"><img src="../images/ico_rsstomodule.gif" align="absmiddle" /> <b>'+lg("addRssFeedToDirectory")+'</b></a><br /><br />';
		l_s+='<div class="subtitle">'+lg("createYourModules")+'</div><br />';
		if (__allowredactor) l_s+="<a href='../tutorial/createrss.php' target='_createmodule'><img src='../images/ico_moduleandrss.gif' align='absmiddle' /> <b>"+lg("createRssFeed")+"</b></a><br /><br />";
		l_s+='<a href="../tutorial/expert.php" target="_createmodule"><img src="../images/ico_expertmodule.gif" align="absmiddle" /> <b>'+lg("createExpertModule")+'</b></a><br />';

		p_plugin.content(l_s);
		//navShow("mymodules","block");
		p_factory.shown=true;	
	},
	hide:function(){
		p_plugin.hide();
		p_factory.shown=false;
	}
}
var p_network={
	shown:false,
	menu:new Array({"id":1,"title":"myAccount","icon":"ico_myaccount.gif","fct":"p_network.myprofile()","isLink":true}),
	init:function(){
		p_plugin.open();
		p_plugin.init();
//		p_pages.closeAllDiv();
//		p_pages.hide();
//		p_tabs.create(-1);
	},
	myprofile:function(){
		p_network.init();
		p_plugin.menu(p_network.menu,1);
//		var l_s=p_network.menu(1)+"<br />";
		var l_s="<div id='myprofile' class='bottomhr'></div>";
		l_s+="<br /><b><u>"+lg("lblModifyPassword")+"</u> :</b><br /><br />";
		l_s+="<form name='newpass'><table>";
		l_s+="<tr><td>"+lg("lblOldPassword")+" :</td><td> <input class='thinbox' type='password' name='oldpass' maxlength='16' /></td></tr>";
		l_s+="<tr><td>"+lg("lblNewPassword")+" :</td><td> <input class='thinbox' type='password' name='pass1' maxlength='16' /></td></tr>";
		l_s+="<tr><td>"+lg("lblRetypeNewPassword")+" :</td><td> <input class='thinbox' type='password' name='pass2' maxlength='16' /></td></tr>";
		l_s+="<tr><td></td><td><input class='btn' type='button' value='"+lg("lblModify")+"' onclick='p_connection.changePass();' /></td></tr>";
		l_s+="</table></form>";
		l_s+="<br /><div class='bottomhr'><b>"+lg("lblChangeUser")+" :</b></div><br /><form name='conBox' method='post' onsubmit='return p_connection.set(this,link,true)'><table><tr><td>"+(__accountType=="mail"?lg("lblEmail"):lg("lblLogin"))+"</td><td><input class='thinbox' type='text' name='username' size='30' maxlength='64' /></td></tr><tr><td>"+lg("lblPassword")+"</td><td><input class='thinbox' type='password' name='password' size='16' maxlength='16' /></td></tr><tr><td></td><td><input type='checkbox' name='autoconn' />"+lg("lblAutoConnection")+"<br /><br /><input type='submit' value='"+lg("lblOk")+"' class='btn' /> <a href='../portal/password_missing.php' target='_blank' style='font-size:7pt;'>"+lg("lblMissingPassword")+" ?</a></td></tr></table></form>";
		p_plugin.content(l_s);
		//navPrint("network",l_s);
		//navShow("network","block");
		if (__useSharing) p_network.profile.load();
		p_network.shown=true;
	},
//	menu:function(v_menuid){
//		var l_s="<div class='addonbar'>"+(v_menuid==1?"":"<a href='#' onclick='p_network.myprofile()'>")+img("ico_myaccount.gif",14,14,"","imgmid")+" "+lg("myAccount")+(v_menuid==1?"":"</a>")+" | ";
//		if (__useSharing) l_s+=(v_menuid==2?"":"<a href='#' onclick='p_network.dashboard.load();'>")+img("mynetwork.gif",16,16,"","imgmid")+" "+lg("myNetwork")+(v_menuid==2?"":"</a>")+" | ";
//		l_s+=(v_menuid==3?"":"<a href='#' onclick='p_network.changeProfile()'>")+img("ico_changeaccount.gif",24,13,"","imgmid")+" "+lg("changeAccount")+(v_menuid==3?"":"</a>")+"</div>";
//		return l_s;
//	},
	hide:function(){
//		navPrint("network","");
//		navShow("network","none");
		p_plugin.hide();
		p_network.shown=false;
	}
}
var p_table={
	name:"default",
	title:"",
	headers:[],
	rows:[],
	footer:"",
	container:"",
	order:0,
	asc:false,
	filter:[],
	saveincookie:false,
	headerObj:function(name,label,filtered){
		this.name=name;
		this.label=label;
		this.filtered=filtered;
	},
	row:function(){
		this.columns=[];
	},
	cell:function(val,label){
		this.val=val;
		this.label=(label==indef?val:label);
	},
	refresh:indef,
	reset:function(){
		p_table.headers.length=0;
		p_table.rows.length=0;
		p_table.filter.length=0;
	},
	init:function(){
		if (p_table.saveincookie){
			if (getCookie(p_table.name+"order")!="") p_table.order=getCookie(p_table.name+"order");
			if (getCookie(p_table.name+"asc")!="") p_table.asc=(getCookie(p_table.name+"asc")==1?true:false);
		}
		if (p_table.saveincookie){
			if (getCookie(p_table.name+"filter")!="") p_table.filter=(getCookie(p_table.name+"filter")).split(" AND ");
		}
	},
	show:function(){		
		var l_s='<table cellpadding="3" cellspacing="0" border="1" bordercolor="#c6c3c6" width="100%">';
		if (p_table.title!="") l_s+="<tr><td colspan='"+p_table.headers.length+"' bgcolor='#c6c3c6'>"+p_table.title+"</td></tr>";
		l_s+="<tr>";
		for (i=0;i<p_table.headers.length;i++){
			l_s+="<td bgcolor='#c6c3c6'><a href='#' onclick='p_table.sortAndRefresh("+i+","+((p_table.order==i && !p_table.asc)?"true":"false")+")'>"+p_table.headers[i].label+" "+(p_table.order==i?(p_table.asc?img("ico_up_arrow.gif"):img("ico_down_arrow.gif")):"")+"</a></td>";
		}
		l_s+="</tr>";
		for (i=0;i<p_table.rows.length;i++){
			l_s+="<tr>";
			for (j=0;j<p_table.rows[i].columns.length;j++){
				l_s+="<td>"+p_table.rows[i].columns[j].label+"</td>";
			}
			l_s+="</tr>";
		}
		if (p_table.footer!="") l_s+="<tr><td colspan='"+p_table.headers.length+"' bgcolor='#c6c3c6'>"+p_table.footer+"</td></tr>";
		navPrint(p_table.container,l_s);
	},
	sortAndRefresh:function(v_order,v_asc){
		if (v_order!=indef) p_table.order=v_order;
		if (v_asc!=indef) p_table.asc=v_asc?true:false;
		p_table.rows.sort(p_table.sortrule);
		p_table.show();
		writeCookie(p_table.name+"order="+p_table.order);
		writeCookie(p_table.name+"asc="+(p_table.asc?1:0));
	},
	sortrule:function(v_a,v_b){
		var v_reverse=p_table.asc?-1:1;
		if (removeTags(v_a.columns[p_table.order].label)<removeTags(v_b.columns[p_table.order].label)) return -1*v_reverse;
		if (removeTags(v_a.columns[p_table.order].label)>removeTags(v_b.columns[p_table.order].label)) return 1*v_reverse;
		return 0; 
	},
	displayFilter:function(v_div){
		var l_s="";
		for (var i=0;i<p_table.filter.length;i++){
			l_s+=p_table.filter[i]+" <a href='#' onclick='p_table.remFilter("+i+");return false;'>"+img("ico_close.gif",9,9,lg("suppress"),"imgmid")+"</a> &nbsp;";
		}
		l_s+="<br /><form name='filter' onsubmit='p_table.addFilter(this);return false;'><select name='field' onchange='p_table.fillFilter(this.value)'>";
		var l_firstFiltered;
		for (var i=0;i<p_table.headers.length;i++){
			if (p_table.headers[i].filtered){
				l_s+="<option value=\""+i+"\">"+p_table.headers[i].label+"</option>";
				if (l_firstFiltered==indef) l_firstFiltered=i;
			}
		}
		l_s+="</select>";
		l_s+=" <select name='comparator'><option value='='>egal à</option><option value='!='>différent de</option><option value='<'><</option><option value='>'>></option><option value='<='><=</option><option value='>='>>=</option></select>";
		l_s+=" <select name='val'></select> <input type='submit' value='Ajouter ce filtre' /></form>";
		navPrint(v_div,l_s);
		p_table.fillFilter(l_firstFiltered);
	},
	fillFilter:function(v_id){
		document.forms.filter.val.options.length=0;
		var l_options=[],l_optionsLabel=[];
		for (var i=0;i<p_table.rows.length;i++){
			if (!inArray(l_options,p_table.rows[i].columns[v_id].val)){
				l_options.push(p_table.rows[i].columns[v_id].val);
				l_optionsLabel.push(removeTags(p_table.rows[i].columns[v_id].label));
			}
		}
		for (var i=0;i<l_options.length;i++){
			document.forms.filter.val.options[document.forms.filter.val.options.length] = new Option(l_optionsLabel[i],l_options[i]);
		}
	},
	addFilter:function(v_form){
		p_table.filter.push(p_table.headers[v_form.field.value].name+" "+v_form.comparator.value+" '"+v_form.val.value+"'");
		writeCookie(p_table.name+"filter="+p_table.filter.join(" AND "));
		p_table.refresh();
	},
	remFilter:function(v_i){
		p_table.filter.splice(v_i,1);
		writeCookie(p_table.name+"filter="+p_table.filter.join(" AND "));
		p_table.refresh();
	}
}
var p_plugin={
	shown:false,
	open:function(){
		p_pages.closeAllDiv();
		p_pages.hide();
		//p_tabs.sel=-1;
		jspass=="";
		p_tabs.create(-1);
	},
	init:function(){
		navPrint("plugin","<div id='pluginmenu' class='addonbar'></div><div id='plugincontent'></div>");
		navShow("plugin","block");
		p_plugin.shown=true;
	},
	menu:function(v_elemts,v_selected){
		var l_elemt=[];
		for (var i=0;i<v_elemts.length;i++){
			l_elemt.push((v_elemts[i]["icon"]==""?"":img(v_elemts[i]["icon"],indef,indef,"","imgmid")+" ")+((v_elemts[i]["isLink"] && v_elemts[i]["id"]!=v_selected)?"<a href='#' onclick=\""+v_elemts[i]["fct"]+"\">"+lg(v_elemts[i]["title"])+"</a>":lg(v_elemts[i]["title"])));
		}
		navPrint("pluginmenu",l_elemt.join(" | "));
	},
	wait:function(){
		navWait("plugincontent");
	},
	content:function(v_content){
		navPrint("plugincontent",v_content);
	},
	hide:function(){
		navPrint("plugin","");
		navShow("plugin","none");
		p_plugin.shown=false;
	},
	clear:function(){
		navPrint("plugin","");
		p_plugin.init();
	}
}