
/* USER VARIABLES */
var gSTabPrefix = 'tab';
var numberOfColumns = 4;	// Number of columns for dragable boxes
var numberOfTabs = 0;
var purcentOccupation = 90;

var src_linkOpenAllImage = './img/link_openAll.png';
var src_linkAddImage = './img/link_add.png';
var src_boxDeleteImage = './img/box_delete.png';
var src_rightImage = './img/arrow_right.gif';
var src_rightImageName = 'arrow_right.gif';
var src_downImage = './img/arrow_down.gif';
var src_ImageBoxCloseAll = './img/box_closeall.png';
var src_ImageBoxOpenAll = './img/box_openall.png';
var src_ImageTopClose = './img/top_close.png';
var src_ImageTopOpen = './img/top_open.png';
var src_refreshSource = './img/refresh.gif';
var src_smallRightArrow = './img/small_arrow.gif';
var drag_box_authorized = true;
var options_box_authorized = true;

var transparencyWhenDragging = true;
var txt_editLink = 'Edit';
var txt_editLink_stop = 'End edit';

var txt_addLinkImage = './img/easyfav_plus.gif';
var autoScrollSpeed = 4;	// Autoscroll speed	- Higher = faster
var dragObjectBorderWidth = 1;	// Border size of your RSS boxes - used to determine width of dotted rectangle

var useCookiesToRememberRSSSources = true;
var DB_saveBoxPosition				= true;

var nameOfCookie = 'dragable_rss_boxes';	// Name of cookie
var active_box_image = false;

/* END USER VARIABLES */



var columnParentBox;
var dragableBoxesObj;

var boxIndex = 0;
var boxSpecialIndex = 0;

var autoScrollActive = false;
var dragableBoxesArray = new Array();
var dragableBoxesID = new Array();
var specialBoxesArray = new Array();

var dragDropCounter = -1;
var dragObject = false;
var dragObjectNextSibling = false;
var dragObjectParent = false;
var destinationObj = false;

var mouse_x;
var mouse_y;

var el_x;
var el_y;

var rectangleDiv;
var okToMove = true;

var documentHeight = false;
var documentScrollHeight = false;
var dragableAreaWidth = false;

var opera = navigator.userAgent.toLowerCase().indexOf('opera')>=0?true:false;
var cookieCounter=0;
var cookieRSSSources = new Array();

var staticObjectArray = new Array();

var FLAG_DB_ADDNEWBOX = false;

var iRefreshTimeEasyFavs = 30000;
var iRefreshTimeLastFavs = 300000;

// Drag And Drop sur des onglets
var	tabDragOnBoxTimeout = null;
var	tabDragOnBox = null;

function refreshSpawnTime(iMilli)
{
	var date = new Date();
	var diff = parseFloat((date.getTime() - iMilli) / 1000);
	document.getElementById("spawntime").innerHTML = "charged in " + diff.toFixed(2) + " s";
	document.getElementById("spawntime").style.opacity = 0;
}

function refreshEasyFavsCounter(iCount)
{
	document.getElementById("easyfavCounter").innerHTML = iCount + " easyfavs";
}

var timeOutEasyFavs = null;
var timeOutLastFavs = null;

function initRefreshFavs()
{
	//
	timeOutEasyFavs = setTimeout(refreshEasyFavs, iRefreshTimeEasyFavs);
	timeOutLastFavs = setTimeout(refreshLastFavs, iRefreshTimeLastFavs);
}

function refreshEasyFavs()
{
	// If Drag, don't do it
	if (!isDraggingNode())
	{
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = './common/links.php?refresheasyfavs&idbox=0';	// Specifying which file to get
		ajaxObjects[ajaxIndex].onCompletion = function(){ DB_responseRefreshEasyFavs(ajaxObjects[ajaxIndex].response);};	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
	}
	if (timeOutEasyFavs)
		clearTimeout(timeOutEasyFavs);
	timeOutEasyFavs = setTimeout(refreshEasyFavs,  iRefreshTimeEasyFavs);
}

function refreshLastFavs()
{
	// If Drag, don't do it
	if (!isDraggingNode())
	{
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = './common/links.php?refreshlastfavs&idbox=0&page=0';	// Specifying which file to get
		ajaxObjects[ajaxIndex].onCompletion = function(){ DB_responseRefreshLastFavs(ajaxObjects[ajaxIndex].response);};	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
	}
	if (timeOutLastFavs)
		clearTimeout(timeOutLastFavs);	
	timeOutLastFavs = setTimeout(refreshLastFavs,  iRefreshTimeLastFavs);
}

function DB_responseRefreshLastFavs(_sResponse)
{
	// If Drag, don't do it
	if (isDraggingNode())
	return;
	var lastFavsDiv = document.getElementById("tree_ul_MyEasyFav-1");
	lastFavsDiv.innerHTML = _sResponse;
	JSTreeList["MyEasyFav-1"].initTree();
	computeEasyLinkPosition();
	registerAllLightbox(lastFavsDiv.getElementsByTagName("a"));
	registerAllLightBoxForVideo(lastFavsDiv.getElementsByTagName("a"));
}

function refreshLastFavsNext(e)
{
	var iPage = document.getElementById('lastfavs_img_right').inextpage;
	if (iPage == 1)
	document.getElementById('lastfavs_img_left').style.visibility = "visible";

	document.getElementById('lastfavs_img_right').inextpage = iPage + 1;
	document.getElementById('lastfavs_img_left').ipreviouspage = iPage - 1;
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = './common/links.php?refreshlastfavs&idbox=0&page=' + iPage;	// Specifying which file to get
	ajaxObjects[ajaxIndex].onCompletion = function(){ DB_responseRefreshLastFavs(ajaxObjects[ajaxIndex].response);};	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
}

function refreshLastFavsPrevious(e)
{
	var iPage = document.getElementById('lastfavs_img_left').ipreviouspage;
	if (iPage == 0)
	document.getElementById('lastfavs_img_left').style.visibility = "hidden";
	else
	document.getElementById('lastfavs_img_left').ipreviouspage = iPage - 1;
	document.getElementById('lastfavs_img_right').inextpage = iPage + 1;
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = './common/links.php?refreshlastfavs&idbox=0&page=' + iPage;	// Specifying which file to get
	ajaxObjects[ajaxIndex].onCompletion = function(){ DB_responseRefreshLastFavs(ajaxObjects[ajaxIndex].response);};	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
}

function DB_responseRefreshEasyFavs(_sResponse)
{
	// If Drag, don't do it
	if (isDraggingNode())
	return;
	var easyFavsDiv = document.getElementById("tree_ul_MyEasyFav0");

	easyFavsDiv.innerHTML = _sResponse;
	JSTreeList["MyEasyFav0"].initTree();
	computeEasyLinkPosition();
	registerAllLightbox(easyFavsDiv.getElementsByTagName("a"));
	registerAllLightBoxForVideo(easyFavsDiv.getElementsByTagName("a"));
}

function isDraggingNode()
{
	if(JSTreeObj.dragDropTimer<10)return false;
	return true;
}

function isDraggingBox()
{
	if (dragDropCounter >= 10)
	return true;
	return false;
}

function Get_Cookie(name) {
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}
// This function has been slightly modified
function Set_Cookie(name,value,expires,path,domain,secure) {
	expires = expires * 60*60*24*1000;
	var today = new Date();
	var expires_date = new Date( today.getTime() + (expires) );
	var cookieString = name + "=" +escape(value) +
	( (expires) ? ";expires=" + expires_date.toGMTString() : "") +
	( (path) ? ";path=" + path : "") +
	( (domain) ? ";domain=" + domain : "") +
	( (secure) ? ";secure" : "");
	document.cookie = cookieString;
}

function autoScroll(direction,yPos)
{
	if(document.documentElement.scrollHeight>documentScrollHeight && direction>0)return;
	if(opera)return;
	//var oldTop = document.documentElement.scrollTop;
	window.scrollBy(0,direction);
	//var newTop = document.documentElement.scrollTop;
	//el_y = el_y + newTop - oldTop;
	if(!dragObject)return;

	//alert(oldTop + " " + newTop);
	if(direction<0){
		if(document.documentElement.scrollTop>0){
			dragObject.style.top = (el_y - mouse_y + yPos + document.body.scrollTop) + 'px';
		}else{
			autoScrollActive = false;
		}
	}else{
		if(yPos>(documentHeight-50)){
			dragObject.style.top = (el_y - mouse_y + yPos + document.body.scrollTop) + 'px';
		}else{
			autoScrollActive = false;
		}
	}
	if(autoScrollActive)setTimeout('autoScroll('+direction+',' + yPos + ')',5);
}

function initNumberOfTabs(_iNumber)
{
	numberOfTabs = _iNumber;
}

function initDragDropBox(e)
{
	dragDropCounter = 1;
	if(document.all)e = event;

	if (e.target) source = e.target;
	else if (e.srcElement) source = e.srcElement;
	if (source.nodeType == 3) // defeat Safari bug
	source = source.parentNode;

	if(source.tagName.toLowerCase()=='img' || source.tagName.toLowerCase()=='a' || source.tagName.toLowerCase()=='input' || source.tagName.toLowerCase()=='td' || source.tagName.toLowerCase()=='tr' || source.tagName.toLowerCase()=='table')
	return true;


	mouse_x = e.clientX;
	mouse_y = e.clientY;
	//var numericId = this.id.replace(/[^0-9-]/g,'');
	var numericId = this.boxId;
	
	el_x = getLeftPos(this.parentNode.parentNode)/1;
	el_y = getTopPos(this.parentNode.parentNode)/1 - document.body.scrollTop;

	dragObject = this.parentNode.parentNode;

	documentScrollHeight = document.documentElement.scrollHeight + 100 + dragObject.offsetHeight;


	if(dragObject.nextSibling){
		dragObjectNextSibling = dragObject.nextSibling;
		if(dragObjectNextSibling.tagName!='DIV')dragObjectNextSibling = dragObjectNextSibling.nextSibling;
	}
	dragObjectParent = dragableBoxesArray[numericId]['parentObj'];

	dragDropCounter = 0;
	initDragDropBoxTimer();
	closeAndSaveBoxTitle(false);
	document.body.style.MozUserSelect='none';
	LINK_HideMenu();
	BOX_HideMenu();
	return true;
}


function initDragDropBoxTimer()
{
	if(dragDropCounter>=0 && dragDropCounter<10){
		dragDropCounter++;
		setTimeout('initDragDropBoxTimer()',10);
		return;
	}
	if(dragDropCounter==10){
		mouseoutBoxHeader(false,dragObject);
	}

}

function moveDragableElement(e){
	if(document.all)e = event;
	if(dragDropCounter<10)return;

	if(document.all && e.button!=1 && !opera){
		stop_dragDropElement();
		return;
	}
	COMMON_clearSelection();

	if(document.body!=dragObject.parentNode){
		dragObject.style.width = (dragObject.offsetWidth - (dragObjectBorderWidth*2)) + 'px';
		dragObject.style.position = 'absolute';
		dragObject.style.textAlign = 'left';
		if(transparencyWhenDragging){
			dragObject.style.filter = 'alpha(opacity=70)';
			dragObject.style.opacity = '0.7';
		}
		//dragObject.setAttribute("style", "z-index:10;");
		dragObject.parentNode.insertBefore(rectangleDiv,dragObject);
		rectangleDiv.style.display='block';
		document.body.appendChild(dragObject);

		rectangleDiv.style.width = dragObject.style.width;
		rectangleDiv.style.height = (dragObject.offsetHeight - (dragObjectBorderWidth*2)) + 'px';

	}

	if(e.clientY<100 || e.clientY>(documentHeight-100)){
		if(e.clientY<100 && !autoScrollActive){
			autoScrollActive = true;
			autoScroll((autoScrollSpeed*-1),e.clientY);
		}

		if(e.clientY>(documentHeight-100) && document.documentElement.scrollHeight<=documentScrollHeight && !autoScrollActive){
			autoScrollActive = true;
			autoScroll(autoScrollSpeed,e.clientY);
		}
	}else{
		autoScrollActive = false;
	}


	var leftPos = e.clientX;
	var topPos = e.clientY + document.body.scrollTop;
	//var topPos = e.clientY + document.documentElement.scrollTop;

	dragObject.style.left = (e.clientX - mouse_x + el_x) + 'px';
	dragObject.style.top = (el_y - mouse_y + e.clientY + document.body.scrollTop) + 'px';


	if(!okToMove)return;
	okToMove = false;

	destinationObj = false;
	rectangleDiv.style.display = 'none';

	var objFound = false;
	var tmpParentArray = new Array();

	if(!objFound){
		for(var no=1;no<dragableBoxesArray.length;no++){
			var box = dragableBoxesArray[no];
			if(box['obj']==dragObject)continue;
			tmpParentArray[box['obj'].parentNode.id] = true;
			if(!objFound){
				var tmpX = getLeftPos(box['obj']);
				var tmpY = getTopPos(box['obj']);

				if(leftPos>tmpX && leftPos<(tmpX + box['obj'].offsetWidth) && topPos>(tmpY-20) && topPos<(tmpY + (box['obj'].offsetHeight/2))){
					destinationObj = box['obj'];
					destinationObj.parentNode.insertBefore(rectangleDiv,box['obj']);
					rectangleDiv.style.display = 'block';
					objFound = true;
					break;

				}

				if(leftPos>tmpX && leftPos<(tmpX + box['obj'].offsetWidth) && topPos>=(tmpY + (box['obj'].offsetHeight/2)) && topPos<(tmpY + box['obj'].offsetHeight)){
					objFound = true;
					if(box['obj'].nextSibling){

						destinationObj = box['obj'].nextSibling;
						if(!destinationObj.tagName)destinationObj = destinationObj.nextSibling;
						if(destinationObj!=rectangleDiv)destinationObj.parentNode.insertBefore(rectangleDiv,destinationObj);
					}else{
						destinationObj = box['obj'].parentNode;
						box['obj'].parentNode.appendChild(rectangleDiv);
					}
					rectangleDiv.style.display = 'block';
					break;
				}


				if(!box['obj'].nextSibling && leftPos>tmpX && leftPos<(tmpX + box['obj'].offsetWidth)
				&& topPos>topPos>(tmpY + (box['obj'].offsetHeight))){
					destinationObj = box['obj'].parentNode;
					box['obj'].parentNode.appendChild(rectangleDiv);
					rectangleDiv.style.display = 'block';
					objFound = true;

				}
			}

		}

	}

	if(!objFound){
		for (var iTab = 0; iTab < numberOfTabs; iTab++)
		{
			for(var no=1;no<=numberOfColumns;no++){
				if(!objFound){
					var obj = document.getElementById('dragableBoxesColumn' + gSTabPrefix + iTab + no);

					var left = getLeftPos(obj)/1;

					var width = obj.offsetWidth;
					if(leftPos>left && leftPos<(left+width)){
						destinationObj = obj;
						obj.appendChild(rectangleDiv);
						rectangleDiv.style.display='block';
						objFound=true;

					}

				}
			}
		}
		// Check pour le drag dans une autre tab
		//alert(topPos)
		//leftPos
		var bFound = false;
		for (var i = 0; i < tabArray.length; i++)
		{
			var topPosTab = COMMON_GetTopPos(tabArray[i].parentNode);
			var leftPosTab = COMMON_GetLeftPos(tabArray[i].parentNode);
			if (topPos >= topPosTab && topPos <= topPosTab + tabArray[i].parentNode.offsetHeight
				&& leftPos >= leftPosTab && leftPos <= leftPosTab + tabArray[i].parentNode.offsetWidth)
			{
				bFound = true;
				if (tabDragOnBox != tabArray[i])
				{
					if (tabDragOnBoxTimeout)
						clearTimeout(tabDragOnBoxTimeout);
					tabDragOnBoxTimeout = setTimeout('boxDragOnTab()',500);
					tabDragOnBox = tabArray[i];
					tabArray[i].getElementsByTagName("A")[0].id = "dragOn";
				}
			}
			else
			{
				tabArray[i].getElementsByTagName("A")[0].id = "";
			}
		}
		if (!bFound)
		{
			if (tabDragOnBoxTimeout)
			{
				clearTimeout(tabDragOnBoxTimeout);
			}
			tabDragOnBox = null;
		}
	}
	setTimeout('okToMove=true',5);

}
function	boxDragOnTab()
{
	if (tabDragOnBox)
	{
		for (var i = 0; i < tabArray.length; i++)
		{
			var topPosTab = COMMON_GetTopPos(tabArray[i].parentNode);
			var leftPosTab = COMMON_GetLeftPos(tabArray[i].parentNode);
			if (tabDragOnBox == tabArray[i])
			{
				tabinterfaceElement.expandit(i);
				DB_selectTab(tabDragOnBox.dbid);
				//alert(document.getElementById("tab" + i).innerHTML);
				for (var iTab = 0; iTab < numberOfTabs; iTab++)
				{
					var obj = document.getElementById('dragableBoxesColumn' + gSTabPrefix + i + "1");
					destinationObj = obj;
				}
			}
		}
	}
	tabDragOnBoxTimeout = null;
	tabDragOnBox = null;
}

function stop_dragDropElement()
{
	document.body.style.MozUserSelect=MozUserSelect;
	if (!dragObject)
	return;
	if(dragDropCounter<10){
		dragDropCounter = -1
		return;
	}
	tabDragOnBoxTimeout = null;
	tabDragOnBox = null;

	dragDropCounter = -1;
	if(transparencyWhenDragging){
		dragObject.style.filter = '';
		dragObject.style.opacity = '1.0';
	}
	dragObject.style.position = 'static';
	dragObject.style.width = '';
	var dbId = dragObject.id.replace(/[^0-9-]/g,'');
	var numericId = dragObject.boxId;
	var tabId = -1;
	iRowPos = -1;
	if(destinationObj && destinationObj.id!=dragObject.id){
		if(destinationObj.id.indexOf('dragableBoxesColumn')>=0){
			tabId = parseInt(destinationObj.id.replace(/[^0-9-]/g,''));
			destinationObj.appendChild(dragObject);
			dragableBoxesArray[numericId]['parentObj'] = destinationObj;
		}else{
			tabId = parseInt(destinationObj.parentNode.id.replace(/[^0-9-]/g,''));
			destinationObj.parentNode.insertBefore(dragObject,destinationObj);
			dragableBoxesArray[numericId]['parentObj'] = destinationObj.parentNode;
		}
		childNode = dragableBoxesArray[numericId]['parentObj'].childNodes;
		iRowPos = 0;
		for (var i = 0; i < childNode.length; i++)
		{
			if (childNode[i].nodeType == 1
			&& childNode[i].nodeName == "DIV"
			&& childNode[i].id)
			{
				if (childNode[i].id.indexOf("dragableBox") == 0
				&& childNode[i].style.display != "none")
				{
					if (childNode[i].id == "dragableBox" + dbId)
					break;
					else
					{
						iRowPos++;
					}
				}
			}
		}
	}else{
		if(dragObjectNextSibling){
			dragObjectParent.insertBefore(dragObject,dragObjectNextSibling);
		}else{
			dragObjectParent.appendChild(dragObject);
		}
	}

	/*for (var i = 1; i < dragableBoxesArray.length; i++)
	{
	if (dragableBoxesArray[i]['obj'] == dragObject)
	alert(i);
	}*/


	autoScrollActive = false;
	rectangleDiv.style.display = 'none';
	dragObject = false;
	dragObjectNextSibling = false;
	destinationObj = false;

	if(useCookiesToRememberRSSSources)
	setTimeout('saveCookies()',100);
	if(DB_saveBoxPosition && iRowPos != -1 && tabId != -1)
		setTimeout('DB_moveBox("' + dragableBoxesID[numericId] + '", ' + (tabId % 10) + ', ' + (iRowPos + 1) + ')',100);

	if (window.event || window.navigator.appName == "Microsoft Internet Explorer") // IE
	{
		documentHeight = document.body.offsetHeight;
	}
	else
	{
		documentHeight = document.documentElement.clientHeight;
	}
}

function onScrollFunction(e)
{
	computeAddFormPosition();
}

function onResizeFunction(e)
{
	LINK_HideMenu();
	TAB_HideMenu();

	computeAddFormPosition();
	//centerLightBoxImageAndVideo();
}

function computeEasyLinkPosition()
{
	var div = document.getElementById("floatingEasyLinkContainer");
	var divIn = document.getElementById("tabcontainer");
	var heightAdd = 22;
	div = document.getElementById("floatingFriendsContainer");
	if (div)
	{
		div.style.top = heightAdd;
		heightAdd = div.offsetHeight + 20;
	}
	div = document.getElementById("floatingEasyLinkContainer");
	if (div)
	{
		div.style.top = heightAdd;
		heightAdd = heightAdd + div.offsetHeight;
	}
	div = document.getElementById("floatingLastLinkContainer");
	if (div)
	{
		div.style.top = heightAdd;
		heightAdd = heightAdd + div.offsetHeight;
	}
	div = document.getElementById("floatingHistoContainer");
	if (div)
	{
		div.style.top = heightAdd;
		heightAdd = heightAdd + div.offsetHeight;
	}
	
}

function computeSearchResultPosition()
{
	var div = document.getElementById("floatingSearchContainer");
	var searchInput = document.getElementById("searchInput");
	if (div && searchInput)
	{
		div.style.top = COMMON_GetTopPos(searchInput) + searchInput.offsetHeight - 5;
		div.style.left = COMMON_GetLeftPos(searchInput);
		div.style.width = searchInput.offsetWidth - 2;
	}
}

function computeAddFormPosition()
{
	var div = document.getElementById("floatingFormContainer");
	if (div)
	{
		div.style.top = document.body.scrollTop;
		if (window.event)
		{
			div.style.left = document.body.scrollWidth / 2 - div.offsetWidth / 2;
		}
		else
		{
			div.style.left = document.documentElement.clientWidth / 2 - div.offsetWidth / 2;
		}
	}
}

function saveCookies()
{
	return;
	cookieCounter = 0;
	var tmpUrlArray = new Array();
	for (var tabNumber = 0; tabNumber < numberOfTabs; tabNumber++)
	{
		for(var no=1;no<=numberOfColumns;no++)
		{
			var parentObj = document.getElementById('dragableBoxesColumn' + gSTabPrefix + tabNumber + no);

			var items = parentObj.getElementsByTagName('DIV');
			if(items.length==0)continue;

			var item = items[0];

			var tmpItemArray = new Array();
			while(item){
				var boxIndex = item.id.replace(/[^0-9-]/g,'');
				if(item.id!='rectangleDiv'){
					tmpItemArray[tmpItemArray.length] = boxIndex;
				}
				item = item.nextSibling;
			}

			var columnIndex = no;

			for(var no2=tmpItemArray.length-1;no2>=0;no2--){
				var boxIndex = tmpItemArray[no2];
				var url = dragableBoxesArray[boxIndex]['rssUrl'];
				var heightOfBox = dragableBoxesArray[boxIndex]['heightOfBox'];
				var maxRssItems = dragableBoxesArray[boxIndex]['maxRssItems'];
				var minutesBeforeReload = dragableBoxesArray[boxIndex]['minutesBeforeReload'];
				var uniqueIdentifier = dragableBoxesArray[boxIndex]['uniqueIdentifier'];
				var state = dragableBoxesArray[boxIndex]['boxState'];
				if(!tmpUrlArray[url]){
					tmpUrlArray[url] = true;

					//Set_Cookie(nameOfCookie + cookieCounter,url + '#;#' + columnIndex + '#;#' + maxRssItems + '#;#' + heightOfBox + '#;#' + minutesBeforeReload + '#;#' + uniqueIdentifier + '#;#' + state ,60000);
					cookieRSSSources[url] = cookieCounter;
					cookieCounter++;

				}else{

					//Set_Cookie(nameOfCookie + cookieCounter,'' + '#;#' + columnIndex + '#;#' + '' + '#;#' + heightOfBox + '#;#' + '' + '#;#' + uniqueIdentifier ,60000);
					cookieCounter++;
				}

			}
		}
	}
}


function getTopPos(inputObj)
{
	if (!inputObj)
		return 0;
	var returnValue = inputObj.offsetTop;
	while((inputObj = inputObj.offsetParent) != null){
		if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
	}
	return returnValue;
}

function getLeftPos(inputObj)
{
	if (!inputObj)
		return 0;
	var returnValue = inputObj.offsetLeft;
	while((inputObj = inputObj.offsetParent) != null){
		if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
	}
	return returnValue;
}


function createColumns(BoxParentContainerId)
{
	columnParentBox = document.getElementById(BoxParentContainerId);
	var columnWidth = Math.floor(80/numberOfColumns);
	var sumWidth = 0;
	for(var no=0;no<numberOfColumns;no++){
		var div = document.createElement('DIV');
		if(no==(numberOfColumns-1))columnWidth = (80) - sumWidth;
		sumWidth = sumWidth + columnWidth;
		div.style.cssText = 'float:left;width:'+columnWidth+'%;padding:0px;margin:0px;';
		div.style.styleFloat='left';
		div.style.width = columnWidth + '%';
		div.style.padding = '10px 0 0 0';
		div.style.margin = '0px';

		div.id = 'dragableBoxesColumn' + BoxParentContainerId + (no+1);
		columnParentBox.appendChild(div);

		var clearObj = document.createElement('HR');
		clearObj.style.clear = 'both';
		clearObj.style.visibility = 'hidden';
		div.appendChild(clearObj);
	}

	var clearingDiv = document.createElement('DIV');
	columnParentBox.appendChild(clearingDiv);
	clearingDiv.style.clear='both';
}

function renameColumns(BoxId, BoxNewId)
{
	var columnParentBox = document.getElementById(BoxId);

	for(var no=0;no<numberOfColumns;no++){
		var div = columnParentBox.childNodes[no];
		div.id = 'dragableBoxesColumn' + BoxNewId + (no+1);
	}
}
function deleteColumns(BoxId)
{
	columnParentBox = document.getElementById(BoxId);
	var childNodes = columnParentBox.childNodes;
	for(var no=0;no<childNodes.length;no++){
		columnParentBox.removeChild(childNodes[no]);
	}
}

function mouseoverBoxHeader()
{
	if(dragDropCounter==10)return;
	JSTreeObj.alertBoxOver(this);
	var id = this.id.replace(/[^0-9-]/g,'');
	//var id = this.boxId;
	document.getElementById('dragableBoxExpand' + id).style.visibility = 'visible';
	document.getElementById('dragableBoxRefreshSource' + id).style.visibility = 'visible';
	document.getElementById('dragableBoxOptionLink' + id).style.visibility = 'visible';
}

function mouseoutBoxHeader(e,obj)
{
	if(!obj)obj=this;
	JSTreeObj.alertBoxOver(null);
	var id =  obj.id.replace(/[^0-9-]/g,'');
	//var id =  obj.boxId;
	document.getElementById('dragableBoxExpand' + id).style.visibility = 'hidden';
	document.getElementById('dragableBoxRefreshSource' + id).style.visibility = 'hidden';
	document.getElementById('dragableBoxOptionLink' + id).style.visibility = 'hidden';
}

function  mousedblclickBoxHeader(e, inputObj)
{
	if(document.all)e = event;
	if(!inputObj)inputObj=this;

	var dbId = inputObj.id.replace(/[^0-9-]/g,'');
	var numericId = inputObj.boxId;
	dragableBoxesArray[numericId]['boxState'] = !dragableBoxesArray[numericId]['boxState'];

	var obj = document.getElementById('dragableBoxContent' + dbId);
	obj.style.display = dragableBoxesArray[numericId]['boxState'] == false?'none':'block';

	document.getElementById('dragableBoxHeader_txtNbLink' + dbId).style.display = dragableBoxesArray[numericId]['boxState'] == true?'none':'block';
	if (dragableBoxesArray[numericId]['boxState'] == false)
	updateBoxNbLink(numericId);

	var objImg = document.getElementById('dragableBoxExpand' + dbId);
	objImg.src = dragableBoxesArray[numericId]['boxState']  == false ?src_downImage:src_rightImage

	if (options_box_authorized)
	DB_modifyBoxMinimze(document.getElementById('dragableBoxOptionLink' + dbId).dbid, dragableBoxesArray[numericId]['boxState'] == false);
	saveCookies();
}

function	closeAndSaveBoxTitle(bDBSave)
{
	var element;
	for (var i = 0; i < dragableBoxesID.length; i++)
	{
		element = document.getElementById('dragableBoxHeader_txt' + (dragableBoxesID[i + 1]));
		if (element && element.open == true)
		{
			element.open = false;
			if(bDBSave)
			{
				var oldValue = element.childNodes[0].value;
				var sShownValue = String_htmlentities(oldValue, 'HTML_ENTITIES');
				element.innerHTML = sShownValue;
				DB_modifyBoxTitle(dragableBoxesID[i + 1], oldValue);
			}
			else
			{
				element.innerHTML = element.oldValue;
			}
		}
	}
}

var g_treating_search = false;
function search_responseSearch(jsonLinkList)
{
	if (g_treating_search)
		return;

	g_treating_search = true;
	var searchResultContainer = document.getElementById("floatingSearchContainer");
	searchResultContainer.style.display = 'block';
	searchResultContainer.style.innerHTML = "";
	var linkList = jsonLinkList;
	var i = 0;
	while (linkList[i + 1])
	{
		var link = linkList[i + 1];
		var li = document.createElement("li");
		if (i%2 == 0)
			COMMON_SetClass(li, "li_1");
		else
			COMMON_SetClass(li, "li_2");
			
		li.setAttribute("nodrag","true");
		li.setAttribute("nodrop","true");
		li.setAttribute("nodelete", "true");
		li.setAttribute("norename", "true");
		li.setAttribute("nodesc", "true");
		li.setAttribute("dbid","0");
		li.setAttribute("id","searchResult" + (i + 1));
		
		var imgThumbnail = document.createElement('img');
		imgThumbnail.src = link['thumbnail'];
		if (link['video_src'])
			COMMON_SetClass(imgThumbnail, "thumbnail");
		else if (link['image_src'])
			COMMON_SetClass(imgThumbnail, "thumbnail");
		else
			COMMON_SetClass(imgThumbnail, "thumbnail_ico");
		li.appendChild(imgThumbnail);
		
		var aObj = document.createElement("a");
		aObj.href = link['url'];
		aObj.innerHTML = link['name'];
		li.appendChild(aObj);
		
		var input = document.createElement('input');
		input.type = "hidden";
		input.setAttribute("id","desc");
		input.setAttribute("value", link['desc']);
		li.appendChild(input);

		if (link['video_src'])
		{
			var input = document.createElement('input');
			input.type = "hidden";
			input.setAttribute("id","video_src");
			input.setAttribute("value", link['video_src']);
			li.appendChild(input);
		}
		else if (link['image_src'])
		{
			var input = document.createElement('input');
			input.type = "hidden";
			input.setAttribute("id","image_src");
			li.appendChild(input);
		}
		
		searchResultContainer.appendChild(li);
		JSTreeObj.__registerElement(li);
	
		i++;
	}
	registerAllLightbox(searchResultContainer.getElementsByTagName("a"));
	registerAllLightBoxForVideo(searchResultContainer.getElementsByTagName("a"));
	g_treating_search = false;
}

function searchThroughNotifClick(e)
{
	document.getElementById('filterName').checked = true;
	document.getElementById('filterNameValue').focus();
	document.getElementById('filterNameValue').select();
	searchThroughNotif(null);
}

function searchThroughNotif(e)
{
	list = document.getElementById('filterNameValueList');
	var optionList = list.getElementsByTagName("option");
	value = "";
	for (var i = 0; i < optionList.length; i++)
	{
		if (optionList[i].selected)
		{
			value = optionList[i].innerHTML;
			break;
		}
	}
	

	if (value.length > 2)
	{
		Notifications_OnChangeFilter(null);
	}
}

var g_searchingEasy = false;
function	searchThrowUniverse(e)
{
	BOX_HideMenu();
	LINK_HideMenu();
	TAB_HideMenu();
	UNIVERSE_HideOptionsMenu();
	computeSearchResultPosition();
	var searchInput = document.getElementById("searchInput");
	var searchTextList = searchInput.value.toLowerCase().split(" ");
	var iFoundNb = 0;
	var iMaxFoundNb = 5;
	var searchResultContainer = document.getElementById("floatingSearchContainer");
	searchResultContainer.innerHTML = "";
	var searchSize = 0;
	for (var i = 0; i < searchTextList.length; i++)
	{
		searchSize = searchSize + searchTextList[i].length;
	}
	if (searchSize >= 3)
	{
		// 
		if (document.getElementById("searchThrewEasyfav").checked)
		{
			if (!g_searchingEasy)
			{
				g_searchingEasy = true;
				AJAX_SendRequest('./ajax/universe.php?searchEasyfav&value=' + escape(searchInput.value));
			}
		}
		else
		{
			// get all the boxes
			for (var i = 1; i < dragableBoxesArray.length; i++)
			{
				var dbId = dragableBoxesID[i];
				var childLi = dragableBoxesArray[i]['obj'].getElementsByTagName("LI");
				var elementAdded = new Array();
				for (var j = 0; j < childLi.length; j++)
				{
					var firstLink = childLi[j].getElementsByTagName("A")[0];
	
					var content = firstLink.innerHTML.toLowerCase();
					var bFound = true;
					for (var k = 0; k < searchTextList.length; k++)
					{
						if (content.indexOf(searchTextList[k]) == -1 || iFoundNb >= iMaxFoundNb)
						{
							bFound = false;
							break;
						}
					}
					if (bFound)
					{
						elementAdded[iFoundNb] = j;
						iFoundNb++;
						var li = document.createElement("li");
						li.innerHTML = childLi[j].innerHTML;
						var tdList = li.getElementsByTagName("td");
						var tabId = dragableBoxesArray[i]['parentObj'].parentNode.id.replace(/[^0-9-]/g,'');
						var tbaTxt = tabArray[tabId].getElementsByTagName('a')[0].innerHTML;
						
						tdList[tdList.length - 1].innerHTML = tdList[tdList.length - 1].innerHTML + "<br/>"+ tbaTxt + " > " + document.getElementById('dragableBoxHeader_txt' + dragableBoxesArray[i]['obj'].dbId).innerHTML;
						
						//searchResultContainer.innerHTML = searchResultContainer.innerHTML + (childLi[j].outerHTML);
						searchResultContainer.appendChild(li);
						if (COMMON_GetClass(childLi[j]) == "li_private")
						{
							COMMON_SetClass(li, "li_private");
						}
						else
						{
							if (iFoundNb % 2 == 0)
							{
								COMMON_SetClass(li, "li_2");
							}
							else
							{
								COMMON_SetClass(li, "li_1");
							}
						}
					}
				}
				var content = document.getElementById('dragableBoxHeader_txt' + dbId).innerHTML.toLowerCase();
				var bFound = true;
				for (var k = 0; k < searchTextList.length; k++)
				{
					if (content.indexOf(searchTextList[k]) == -1 || iFoundNb >= iMaxFoundNb)
					{
						bFound = false;
						break;
					}
				}
				if (bFound)
				{
					for (var j = 0; j < childLi.length; j++)
					{
						var bAdd = true;
						for (var k = 0; k < elementAdded.length; k++)
						{
							if (elementAdded[k] == j)
							{
								bAdd = false;
								break;
							}
						}
						if (bAdd && iFoundNb < iMaxFoundNb)
						{
							var firstLink = childLi[j].getElementsByTagName("A")[0];
	
							iFoundNb++;
							var li = document.createElement("li");
							li.innerHTML = childLi[j].innerHTML;
							var tdList = li.getElementsByTagName("td");
							tdList[tdList.length - 1].innerHTML = tdList[tdList.length - 1].innerHTML + "<br/>Onglet > " + document.getElementById('dragableBoxHeader_txt' + dragableBoxesArray[i]['obj'].dbId).innerHTML;
							//searchResultContainer.innerHTML = searchResultContainer.innerHTML + (childLi[j].outerHTML);
							searchResultContainer.appendChild(li);
							if (COMMON_GetClass(childLi[j]) == "li_private")
							{
								COMMON_SetClass(li, "li_private");
							}
							else
							{
								if (iFoundNb % 2 == 0)
								{
									COMMON_SetClass(li, "li_2");
								}
								else
								{
									COMMON_SetClass(li, "li_1");
								}
							}
						}
					}
				}
			}
		}
		registerAllLightbox(searchResultContainer.getElementsByTagName("a"));
		registerAllLightBoxForVideo(searchResultContainer.getElementsByTagName("a"));
		searchResultContainer.style.display = 'block';
	}
	else
	{
		searchResultContainer.style.display = 'none';
		// hide the panel
	}
}

function 	keyboard_isEnter(e)
{
	var keynum = 0;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	return (keynum == 13);
}
function keyboard_isEscape(e)
{
	var keynum = 0;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	return (keynum == 27);
}

/////////////////////////
// RENAME
////////////////////
function  mousedblClickText(e, inputObj)
{
	if(document.all)e = event;
	if(!inputObj)inputObj=this;

	var numericId = inputObj.id.replace(/[^0-9-]/g,'');

	var element = document.getElementById('dragableBoxHeader_txt' + numericId);
	if (element.open == true)
	{
		COMMON_StopPropagation(e);
	}
	else
	{
		closeAndSaveBoxTitle(false);
		element.open = true;
		element.oldValue = element.innerHTML;
		element.innerHTML = "<input type=\"text\" value=\"" + element.innerHTML + "\" onkeydown='if (keyboard_isEnter(event)) closeAndSaveBoxTitle(true); else { if (keyboard_isEscape(event)) closeAndSaveBoxTitle(false);}' maxlength='25'>";
		element.getElementsByTagName('input')[0].focus();
		COMMON_StopPropagation(e);
	}
}

function BOX_renameFromMenu(e, inputObj)
{
	var numericId = g_boxImgClicked.parentNode.id.replace(/[^0-9-]/g,'');
	var element = document.getElementById('dragableBoxHeader_txt' + numericId);
	if (element.open == false)
	{
		closeAndSaveBoxTitle(false);
		element.open = true;
		element.oldValue = element.innerHTML;
		element.innerHTML = "<input type=\"text\" value=\"" + element.innerHTML + "\" onkeydown='if (keyboard_isEnter(event)) closeAndSaveBoxTitle(true); else { if (keyboard_isEscape(event)) closeAndSaveBoxTitle(false);}' maxlength='25'>";
		element.getElementsByTagName('input')[0].focus();
	}	
	else
	{
		element.getElementsByTagName('input')[0].focus();
	}
	BOX_HideMenu();
}

var g_move_or_follow_value = "followToUniverse";

function BOX_MoveToUniverseFromMenu(e, inputObj)
{
	if (g_follow_box_clicked)
	{
		var numericId = g_box_selectedId.replace(/[^0-9-]/g,'');
		
		var iDBUniv = COMMON_GetTarget(e).getAttribute("iddb");
		AJAX_SendRequest('./common/box.php?' + g_move_or_follow_value+ '&id=' + escape(numericId) + '&iduniv=' + iDBUniv);
		UNIVERSE_HideMenu();
	}
	else
	{
		var numericId = g_boxImgClicked.parentNode.id.replace(/[^0-9-]/g,'');
		
		var iDBUniv = COMMON_GetTarget(e).getAttribute("iddb");
		AJAX_SendRequest('./common/box.php?' + g_move_or_follow_value + '&id=' + escape(numericId) + '&iduniv=' + iDBUniv);

		BOX_HideMenu();		
	}
}

function BOX_MoveToUniverseFromMenuResponse(numericId)
{
	document.getElementById('dragableBox' + numericId).style.display='none';
}

function BOX_MoveToCreatedUniverseFromMenu(e, inputObj)
{
	var numericId = g_boxImgClicked.parentNode.id.replace(/[^0-9-]/g,'');
	COMMON_show_AddFormRequest('./home/layout_addUniverse.php?moveBox&id='+numericId, callbackAddUniverse, callbackOnCloseAddUniverse);
}

function BOX_MoveBoxAndCreateUniverse()
{
	
}

function refreshRSS()
{
	//reloadRSSData(this.id.replace(/[^0-9-]/g,''));
	reloadRSSData(this.boxId);
	setTimeout('dragDropCounter=-5',5);
}

function showHideBoxContent(e,inputObj)
{
	if(document.all)e = event;
	if(!inputObj)inputObj=this;

	var dbId = inputObj.id.replace(/[^0-9-]/g,'');
	var numericId = inputObj.boxId;
	var obj = document.getElementById('dragableBoxContent' + dbId);
	if (inputObj.src.indexOf(src_rightImageName)>=0)
		$(obj).fadeOut();
	else
		$(obj).fadeIn();
	//obj.style.display = inputObj.src.indexOf(src_rightImageName)>=0?'none':'block';
	inputObj.src = inputObj.src.indexOf(src_rightImageName)>=0?src_downImage:src_rightImage

	dragableBoxesArray[numericId]['boxState'] = obj.style.display=='block'?true:false;
	if (dragableBoxesArray[numericId]['boxState'] == false)
	updateBoxNbLink(numericId);

	if (options_box_authorized)
	DB_modifyBoxMinimze(document.getElementById('dragableBoxOptionLink' + dbId).dbid, dragableBoxesArray[numericId]['boxState'] == false);

	document.getElementById('dragableBoxHeader_txtNbLink' + dbId).style.display = dragableBoxesArray[numericId]['boxState'] == true?'none':'block';

	saveCookies();
	setTimeout('dragDropCounter=-5',5);
	LINK_HideMenu();
}

function showHideSpecialBoxContent(e, inputObj)
{
	if(document.all)e = event;
	if(!inputObj)inputObj=this;

	var numericId = inputObj.id.replace(/[^0-9-]/g,'');
	var obj = document.getElementById('dragableBoxSpecialContent' + numericId);
	obj.style.display = inputObj.src.indexOf(src_rightImageName)>=0?'none':'block';
	inputObj.src = inputObj.src.indexOf(src_rightImageName)>=0?src_downImage:src_rightImage

	computeEasyLinkPosition();
	LINK_HideMenu();

	//specialBoxesArray[numericId]['boxState'] = obj.style.display=='block'?1:0;
}

function mouseover_CloseButton()
{
	this.className = 'closeButton_over';
	setTimeout('dragDropCounter=-5',5);
}

function highlightCloseButton()
{
	this.className = 'closeButton_over';
}

function mouseout_CloseButton()
{
	this.className = 'closeButton';
}

function askCloseBox(e,inputObj)
{
	if(!inputObj)inputObj = this;
	if (window.confirm(g_lang_box_kill))
	{
		closeDragableBox(e,inputObj);
	}
}

function closeDragableBox(e,inputObj)
{
	if(!inputObj)inputObj = this;

	var numericId = inputObj.id.replace(/[^0-9-]/g,'');
	document.getElementById('dragableBox' + numericId).style.display='none';
	BOX_HideMenu();
	AW_Show(g_lang_box_deleted, false);
	DB_removeBox(document.getElementById('dragableBoxOptionLink' + numericId).dbid);
	setTimeout('dragDropCounter=-5',5);
}

function askCloseBoxFromMenu(e, inputObj)
{
	if (window.confirm(g_lang_box_kill))
	{
		closeDragableBoxFromMenu();
	}	
}

function closeDragableBoxFromMenu()
{
	var numericId = g_boxImgClicked.parentNode.id.replace(/[^0-9-]/g,'');
	document.getElementById('dragableBox' + numericId).style.display='none';
	BOX_HideMenu();
	AW_Show(g_lang_box_deleted, false);
	DB_removeBox(document.getElementById('dragableBoxOptionLink' + numericId).dbid);
	setTimeout('dragDropCounter=-5',5);	
}

function editRSSContent()
{
	//var numericId = this.id.replace(/[^0-9-]/g,'');
	var numericId = this.boxId;
	var obj = document.getElementById('dragableBoxEdit' + numericId);
	if(obj.style.display=='none'){
		obj.style.display='block';
		this.innerHTML = txt_editLink_stop;
		document.getElementById('dragableBoxHeader' + numericId).style.height = '135px';
	}else{
		obj.style.display='none';
		this.innerHTML = txt_editLink;
		document.getElementById('dragableBoxHeader' + numericId).style.height = '20px';
	}
	setTimeout('dragDropCounter=-5',5);
}

var g_iAddLinkBoxJSId = 0;
var g_iAddLinkBoxDBID = 0;

function addLinkFormFromMenuMethod(e, inputObj)
{
	var oIndex = g_boxImgClicked.parentNode.id.replace('dragableBoxOptionLink','');
	g_iAddLinkBoxJSId = oIndex;
	g_iAddLinkBoxDBID = g_boxImgClicked.parentNode.dbid;
	
	COMMON_show_AddFormRequest('./home/layout_addLink.php', addLinkFormResponse);				
}

function openAllLinkFormFromMenuMethod()
{
	if (confirm(g_lang_box_open_all))
	{
		var oIndex = g_boxImgClicked.parentNode.id.replace('dragableBoxOptionLink','');
		var box = document.getElementById('dragableBox' + oIndex);
		var liList = box.getElementsByTagName('li');
		for (i = 0; i < liList.length; i++)
		{
			window.open(liList[i].getElementsByTagName('a')[0].href);			
		}
		BOX_HideMenu();
	}	
}

function boxHighlight(e, inputObj)
{
	var numericId = g_boxImgClicked.parentNode.id.replace(/[^0-9-]/g,'');
	//var element = document.getElementById('dragableBoxHeader_txt' + numericId);
	AJAX_SendRequest('./ajax/box.php?highlight=' + numericId);
	BOX_HideMenu();	
}

function boxFollow(e, inputObj)
{
	if ($("#universe_menu").hasClass('hidden')) {
		//$("#box_menu").fadeIn('fast').removeClass('hidden');
		if(document.all)e = event;
		if(!inputObj)inputObj=this;
		document.getElementById("universe_menu").style.top = COMMON_GetTopPos(inputObj);
		document.getElementById("universe_menu").style.left = COMMON_GetLeftPos(inputObj) + inputObj.offsetWidth;
		$("#universe_menu").animate({height: 'toggle', opacity: 1}, 300).removeClass('hidden');
	} else {
		$("#universe_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
	}		
}

function boxFollowFromLightbox(e, inputObj)
{
	g_follow_box_clicked = true;
	if	(document.getElementById('newuniverse'))
		document.getElementById('newuniverse').style.display = 'none';
	if ($("#universe_menu").hasClass('hidden')) {
		//$("#box_menu").fadeIn('fast').removeClass('hidden');
		if(document.all)e = event;
		if(!inputObj)inputObj=this;
		document.getElementById("universe_menu").style.top = COMMON_GetTopPos(inputObj);
		document.getElementById("universe_menu").style.left = COMMON_GetLeftPos(inputObj) + inputObj.offsetWidth;
		$("#universe_menu").animate({height: 'toggle', opacity: 1}, 300).removeClass('hidden');
	} else {
		$("#universe_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
	}	
}
function addLinkFormResponse()
{
	document.getElementById("addInput").value = "http://";
	document.getElementById("addInput").focus();
	document.getElementById("addInput").select();
	if (g_currentPrivacy == 1)
		document.getElementById("addInputPrivate").checked = true;
	else if (g_currentPrivacy == 2)
		document.getElementById("addInputFriend").checked = true;	
}


function showStatusBarMessage(numericId,message)
{
	document.getElementById('dragableBoxStatusBar' + numericId).innerHTML = message;

}

function addSpecialBoxHeader(parentObj,externalUrl,notDrabable)
{
	var div = document.createElement('DIV');
	div.className = 'dragableBoxSpecialHeader';

	div.id = 'dragableBoxSpecialHeader' + boxSpecialIndex;
	//div.onmouseover = mouseoverBoxHeader;
	//div.onmouseout = mouseoutBoxHeader;
	//div.ondblclick = mousedblclickBoxHeader;

	var image = document.createElement('IMG');
	image.id = 'dragableBoxSpecialExpand' + boxSpecialIndex;
	image.src = src_rightImage;
	image.style.cursor = 'pointer';
	image.onmousedown = showHideSpecialBoxContent;
	div.appendChild(image);

	var textSpan = document.createElement('SPAN');
	textSpan.id = 'dragableBoxSpecialHeader_txt' + boxSpecialIndex;
	textSpan.open = false;
	//textSpan.ondblclick = mousedblClickText;
	div.appendChild(textSpan);

	parentObj.appendChild(div);
}

function addBoxHeader(parentObj,externalUrl,notDrabable, _iDBId, _bFollowingBox)
{
	var div = document.createElement('DIV');
	div.className = 'dragableBoxHeader';

	div.id = 'dragableBoxHeader' + _iDBId;
	div.boxId = boxIndex;
	//div.id = 'dragableBoxHeader' + boxIndex;
	div.onmouseover = mouseoverBoxHeader;
	div.onmouseout = mouseoutBoxHeader;
	if(!notDrabable){
		div.onmousedown = initDragDropBox;
		div.style.cursor = 'move';
	}
	if (!_bFollowingBox)
		div.ondblclick = mousedblclickBoxHeader;

	var image = document.createElement('IMG');
	
	image.id = 'dragableBoxExpand' + _iDBId;
	image.boxId = boxIndex;
	//image.id = 'dragableBoxExpand' + boxIndex;
	image.src = src_rightImage;
	image.style.visibility = 'hidden';
	image.style.cursor = 'pointer';
	image.onmousedown = showHideBoxContent;
	div.appendChild(image);

	if (active_box_image)
	{
		image = document.createElement('IMG');
		image.id = 'dragableBoxIcon' + _iDBId;
		//image.id = 'dragableBoxIcon' + boxIndex;
		image.src = './img/icons/1.png';
		div.appendChild(image);
	}

	var textSpan = document.createElement('SPAN');
	textSpan.id = 'dragableBoxHeader_txt' + _iDBId;
	//textSpan.id = 'dragableBoxHeader_txt' + boxIndex;
	textSpan.open = false;
	if (options_box_authorized && !_bFollowingBox)
		textSpan.ondblclick = mousedblClickText;
	div.appendChild(textSpan);

	var textNbSpan = document.createElement('SPAN');
	textNbSpan.id = 'dragableBoxHeader_txtNbLink' + _iDBId;
	//textNbSpan.id = 'dragableBoxHeader_txtNbLink' + boxIndex;
	textNbSpan.innerHTML="()";
	//textNbSpan.style.display='none';

	div.appendChild(textNbSpan);

	parentObj.appendChild(div);

	var optionLinkDiv = document.createElement('DIV');
	optionLinkDiv.style.cssText = 'float:right';
	optionLinkDiv.style.styleFloat = 'right';
	optionLinkDiv.id = 'dragableBoxOptionLink' + _iDBId;
	COMMON_SetClass(optionLinkDiv, 'dragableBoxOptions');
	optionLinkDiv.style.cursor = 'pointer';
	optionLinkDiv.dbid = _iDBId;
	optionLinkDiv.style.visibility = 'hidden';
	div.appendChild(optionLinkDiv);
	var img = document.createElement('IMG');
	img.src = "./img/box_open_viewer.png";
	img.title = g_lang_box_read_viewer;
	optionLinkDiv.appendChild(img);
	img.onclick=function()
	{
		var oIndex = this.parentNode.id.replace('dragableBoxOptionLink','');
		window.open("./viewer?box=" + oIndex);
	}
	var img = document.createElement('IMG');
	img.src = "./img/box_options.png";
	optionLinkDiv.appendChild(img);
	img.onclick=function()
	{
		ShowBoxOptionsMenu(this);
	}

	var image = document.createElement('IMG');
	image.src = src_refreshSource;
	image.id = 'dragableBoxRefreshSource' + _iDBId;
	//image.id = 'dragableBoxRefreshSource' + boxIndex;
	image.style.cssText = 'float:right';
	image.style.styleFloat = 'right';
	image.style.visibility = 'hidden';
	image.onclick = refreshRSS;
	image.style.cursor = 'pointer';
	if(!externalUrl)image.style.display='none';
	div.appendChild(image);
}
var g_tabImgClicked = null;
function ShowTabOptionsMenu(obj)
{
	tabTarget = obj.parentNode.getElementsByTagName('A')[0];
	
	if ($("#tab_menu").hasClass('hidden')) {
		//$("#box_menu").fadeIn('fast').removeClass('hidden');
		document.getElementById("tab_menu").style.top = COMMON_GetTopPos(obj) + obj.offsetHeight;
		document.getElementById("tab_menu").style.left = COMMON_GetLeftPos(obj) + obj.offsetWidth;
		$("#tab_menu").animate({height: 'toggle', opacity: 1}, 300).removeClass('hidden');
		
		if (!$("#link_menu").hasClass('hidden')) {
			$("#link_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
		}
		if (!$("#box_menu").hasClass('hidden')) {
			$("#box_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
		}
		if (!$("#universe_menu").hasClass('hidden'))
			$("#universe_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
		UNIVERSE_HideOptionsMenu();
		g_tabImgClicked = obj;
	} else {
		$("#tab_menu").animate({height: 'toggle', opacity: 0}, 100).addClass('hidden');
		if (g_tabImgClicked != obj)
		{
			g_tabImgClicked = obj;
			setTimeout('ShowTabOptionsMenu_Delayed()', 100);
		}
		else
			g_tabImgClicked = null;			
	}
}

function ShowTabOptionsMenu_Delayed()
{
	document.getElementById("tab_menu").style.top = COMMON_GetTopPos(g_tabImgClicked) + g_tabImgClicked.offsetHeight;
	document.getElementById("tab_menu").style.left = COMMON_GetLeftPos(g_tabImgClicked)  + g_tabImgClicked.offsetWidth;
	$("#tab_menu").animate({height: 'toggle', opacity: 1}, 200).removeClass('hidden');	
}

var g_linkImgClicked = null;
function ShowLinkOptionsMenu(obj)
{
	if ($("#link_menu").hasClass('hidden')) {
		//$("#box_menu").fadeIn('fast').removeClass('hidden');
		document.getElementById("link_menu").style.top = COMMON_GetTopPos(obj) + obj.offsetHeight;
		document.getElementById("link_menu").style.left = COMMON_GetLeftPos(obj) + obj.offsetWidth;
		$("#link_menu").animate({height: 'toggle', opacity: 1}, 300).removeClass('hidden');
		
		if (!$("#box_menu").hasClass('hidden')) {
			$("#box_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
		}
		if (!$("#universe_menu").hasClass('hidden'))
			$("#universe_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
		if (!$("#tab_menu").hasClass('hidden'))
			$("#tab_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
		UNIVERSE_HideOptionsMenu();
		
		sBoxID = obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
		numericId = sBoxID.replace(/[^0-9-]/g,'');
		if (!document.getElementById('dragableBoxInner'  + numericId))
		{
			if (document.getElementById("link_rename"))
				document.getElementById("link_rename").style.display='block';		
			if (document.getElementById("link_delete"))
				document.getElementById("link_delete").style.display='block';	
			if (document.getElementById("link_make_public"))
				document.getElementById("link_make_public").style.display='block';	
			if (document.getElementById("link_make_private"))
				document.getElementById("link_make_private").style.display='block';	
			if (document.getElementById("link_make_friend"))
				document.getElementById("link_make_friend").style.display='block';
			if (document.getElementById("link_add_public"))
				document.getElementById("link_add_public").style.display='none';	
			if (document.getElementById("link_add_private"))
				document.getElementById("link_add_private").style.display='none';	
			if (document.getElementById("link_add_friend"))
				document.getElementById("link_add_friend").style.display='none';
			if (document.getElementById("link_title_privacy"))
				document.getElementById("link_title_privacy").style.display='block';
			if (document.getElementById("link_easyfaver"))
				document.getElementById("link_easyfaver").style.display='none';
		}
		else if (document.getElementById('dragableBoxInner'  + numericId).className == 'dragableBoxInner')
		{
			if (g_bIsOwnerUniverse)
			{
				if (document.getElementById("link_rename"))
					document.getElementById("link_rename").style.display='block';		
				if (document.getElementById("link_delete"))
					document.getElementById("link_delete").style.display='block';					if (document.getElementById("link_make_public"))
					document.getElementById("link_make_public").style.display='block';	
				if (document.getElementById("link_make_private"))
					document.getElementById("link_make_private").style.display='block';	
				if (document.getElementById("link_make_friend"))
					document.getElementById("link_make_friend").style.display='block';
				if (document.getElementById("link_add_public"))
					document.getElementById("link_add_public").style.display='none';	
				if (document.getElementById("link_add_private"))
					document.getElementById("link_add_private").style.display='none';	
				if (document.getElementById("link_add_friend"))
					document.getElementById("link_add_friend").style.display='none';
				if (document.getElementById("link_title_privacy"))
					document.getElementById("link_title_privacy").style.display='block';
				if (document.getElementById("link_easyfaver"))
					document.getElementById("link_easyfaver").style.display='block';				
			}
			else
			{
				if (document.getElementById("link_rename"))
					document.getElementById("link_rename").style.display='none';		
				if (document.getElementById("link_delete"))
					document.getElementById("link_delete").style.display='none';					if (document.getElementById("link_add_public"))
					document.getElementById("link_add_public").style.display='block';	
				if (document.getElementById("link_add_private"))
					document.getElementById("link_add_private").style.display='block';	
				if (document.getElementById("link_add_friend"))
					document.getElementById("link_add_friend").style.display='block';
				if (document.getElementById("link_title_privacy"))
					document.getElementById("link_title_privacy").style.display='none';
				if (document.getElementById("link_make_public"))
					document.getElementById("link_make_public").style.display='none';	
				if (document.getElementById("link_make_private"))
					document.getElementById("link_make_private").style.display='none';	
				if (document.getElementById("link_make_friend"))
					document.getElementById("link_make_friend").style.display='none';
				if (document.getElementById("link_easyfaver"))
					document.getElementById("link_easyfaver").style.display='none';					}
		}
		else
		{
			if (document.getElementById("link_rename"))
				document.getElementById("link_rename").style.display='none';		
			if (document.getElementById("link_delete"))
				document.getElementById("link_delete").style.display='none';	
			if (document.getElementById("link_make_public"))
				document.getElementById("link_make_public").style.display='none';	
			if (document.getElementById("link_make_private"))
				document.getElementById("link_make_private").style.display='none';	
			if (document.getElementById("link_make_friend"))
				document.getElementById("link_make_friend").style.display='none';
			if (document.getElementById("link_add_public"))
				document.getElementById("link_add_public").style.display='block';	
			if (document.getElementById("link_add_private"))
				document.getElementById("link_add_private").style.display='block';	
			if (document.getElementById("link_add_friend"))
				document.getElementById("link_add_friend").style.display='block';
			if (document.getElementById("link_title_privacy"))
				document.getElementById("link_title_privacy").style.display='none';
			if (document.getElementById("link_easyfaver"))
				document.getElementById("link_easyfaver").style.display='none';
		}
		g_linkImgClicked = obj;
	} else {
		$("#link_menu").animate({height: 'toggle', opacity: 0}, 100).addClass('hidden');
		if (g_linkImgClicked != obj)
		{
			g_linkImgClicked = obj;
			setTimeout('ShowLinkOptionsMenu_Delayed()', 100);
		}
		else
			g_linkImgClicked = null;			
	}	
}
function ShowLinkOptionsMenu_Delayed(obj)
{
	sBoxID = g_linkImgClicked.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
	numericId = sBoxID.replace(/[^0-9-]/g,'');
	if (document.getElementById('dragableBoxInner'  + numericId).className == 'dragableBoxInner')
	{
		document.getElementById("link_rename").style.display='block';		
		document.getElementById("link_delete").style.display='block';	
		document.getElementById("link_make_public").style.display='block';	
		document.getElementById("link_make_private").style.display='block';	
		document.getElementById("link_make_friend").style.display='block';
		document.getElementById("link_add_public").style.display='none';	
		document.getElementById("link_add_private").style.display='none';	
		document.getElementById("link_add_friend").style.display='none';
		document.getElementById("link_title_privacy").style.display='block';
	}
	else
	{
		document.getElementById("link_rename").style.display='none';		
		document.getElementById("link_delete").style.display='none';	
		document.getElementById("link_make_public").style.display='none';	
		document.getElementById("link_make_private").style.display='none';	
		document.getElementById("link_make_friend").style.display='none';
		document.getElementById("link_add_public").style.display='block';	
		document.getElementById("link_add_private").style.display='block';	
		document.getElementById("link_add_friend").style.display='block';
		document.getElementById("link_title_privacy").style.display='none';
	}
	document.getElementById("link_menu").style.top = COMMON_GetTopPos(g_linkImgClicked) + g_linkImgClicked.offsetHeight;
	document.getElementById("link_menu").style.left = COMMON_GetLeftPos(g_linkImgClicked)  + g_linkImgClicked.offsetWidth;
	$("#link_menu").animate({height: 'toggle', opacity: 1}, 200).removeClass('hidden');
}

var g_boxImgClicked = null;
function ShowBoxOptionsMenu(obj)
{
	if ($("#box_menu").hasClass('hidden')) {
		//$("#box_menu").fadeIn('fast').removeClass('hidden');
		document.getElementById("box_menu").style.top = COMMON_GetTopPos(obj) + obj.offsetHeight;
		document.getElementById("box_menu").style.left = COMMON_GetLeftPos(obj) + obj.offsetWidth;
		
		numericId = obj.parentNode.id.replace(/[^0-9-]/g,'');
		// Follow ou pas ?	
		/*if (document.getElementById("box_add_link"))
		{
			if (document.getElementById('dragableBoxInner'  + numericId).className == 'dragableBoxInner')
			{
				document.getElementById("box_add_link").style.display='block';		
				document.getElementById("box_rename").style.display='block';	
			}
			else
			{
				document.getElementById("box_add_link").style.display='none';
				document.getElementById("box_rename").style.display='none';	
			}
		}*/
		if (g_bIsOwnerUniverse)
		{
			document.getElementById("box_add_link").style.display='block';		
			document.getElementById("box_rename").style.display='block';	
			document.getElementById("box_rename").style.display='block';	
			document.getElementById("box_follow").style.display='none';		
			document.getElementById("box_move_to_universe").style.display='block';		
			document.getElementById("box_kill").style.display='block';	
		}
		else
		{
			document.getElementById("box_add_link").style.display='none';
			document.getElementById("box_rename").style.display='none';		
			if (g_bIsLogged)
				document.getElementById("box_follow").style.display='block';
			else
				document.getElementById("box_follow").style.display='none';				
			document.getElementById("box_move_to_universe").style.display='none';		
			document.getElementById("box_kill").style.display='none';	
		}
		if (g_bIsLogged)
		{			
			document.getElementById("box_highlight").style.display='block';				
			document.getElementById("box_main_title").style.display='block';				
		}
		else
		{
			document.getElementById("box_highlight").style.display='none';				
			document.getElementById("box_main_title").style.display='none';				
		}

		$("#box_menu").animate({height: 'toggle', opacity: 1}, 300).removeClass('hidden');
		if (!$("#universe_menu").hasClass('hidden'))
			$("#universe_menu").animate({height: 'toggle', opacity: 0}, 50).addClass('hidden');
		if (!$("#link_menu").hasClass('hidden')) {
			$("#link_menu").animate({height: 'toggle', opacity: 0}, 50).addClass('hidden');
		}
		if (!$("#tab_menu").hasClass('hidden'))
			$("#tab_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
		UNIVERSE_HideOptionsMenu();
		g_boxImgClicked = obj;
	} else {
		$("#box_menu").animate({height: 'toggle', opacity: 0}, 100).addClass('hidden');
		if (!$("#universe_menu").hasClass('hidden'))
			$("#universe_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
		if (g_boxImgClicked != obj)
		{
			g_boxImgClicked = obj;
			setTimeout('ShowBoxOptionsMenu_Delayed()', 100);
		}
		else
			g_boxImgClicked = null;			
	}
	//$("#box_menu").animate({height: 'toggle', opacity: 1}, 300).removeClass('hidden');
}

function ShowBoxOptionsMenu_Delayed(obj)
{
	document.getElementById("box_menu").style.top = COMMON_GetTopPos(g_boxImgClicked) + g_boxImgClicked.offsetHeight;
	document.getElementById("box_menu").style.left = COMMON_GetLeftPos(g_boxImgClicked) + g_boxImgClicked.offsetWidth;
	
	numericId = g_boxImgClicked.parentNode.id.replace(/[^0-9-]/g,'');
	// Follow ou pas ?	
	if (document.getElementById("box_add_link"))
	{
		if (document.getElementById('dragableBoxInner'  + numericId).className == 'dragableBoxInner')
		{
			document.getElementById("box_add_link").style.display='block';		
			document.getElementById("box_rename").style.display='block';	
		}
		else
		{
			document.getElementById("box_add_link").style.display='none';
			document.getElementById("box_rename").style.display='none';	
		}
	}

	$("#box_menu").animate({height: 'toggle', opacity: 1}, 200).removeClass('hidden');
}

function ShowBoxUniverseOptions(e, inputObj)
{
	if	(document.getElementById('newuniverse'))
		document.getElementById('newuniverse').style.display = 'block';
	if ($("#universe_menu").hasClass('hidden')) {
		//$("#box_menu").fadeIn('fast').removeClass('hidden');
		if(document.all)e = event;
		if(!inputObj)inputObj=this;
		document.getElementById("universe_menu").style.top = COMMON_GetTopPos(inputObj);
		document.getElementById("universe_menu").style.left = COMMON_GetLeftPos(inputObj) + inputObj.offsetWidth;
		$("#universe_menu").animate({height: 'toggle', opacity: 1}, 300).removeClass('hidden');
	} else {
		$("#universe_menu").animate({height: 'toggle', opacity: 0}, 300).addClass('hidden');
	}	
}

function saveFeed(boxIndex)
{
	var heightOfBox = dragableBoxesArray[boxIndex]['heightOfBox'] = document.getElementById('heightOfBox[' + boxIndex + ']').value;
	var intervalObj = dragableBoxesArray[boxIndex]['intervalObj'];
	if(intervalObj)clearInterval(intervalObj);

	if(heightOfBox && heightOfBox>40){
		var contentObj = document.getElementById('dragableBoxContent' + boxIndex);
		contentObj.style.height = heightOfBox + 'px';
		contentObj.setAttribute('heightOfBox',heightOfBox);
		contentObj.heightOfBox = heightOfBox;
		//if(document.all)contentObj.style.overflowY = 'auto';else contentObj.style.overflow='-moz-scrollbars-vertical;';
		if(opera)contentObj.style.overflow='auto';

	}

	dragableBoxesArray[boxIndex]['rssUrl'] = document.getElementById('rssUrl[' + boxIndex + ']').value;
	dragableBoxesArray[boxIndex]['heightOfBox'] = heightOfBox;
	dragableBoxesArray[boxIndex]['maxRssItems'] = document.getElementById('maxRssItems[' + boxIndex + ']').value;
	dragableBoxesArray[boxIndex]['heightOfBox'] = document.getElementById('heightOfBox[' + boxIndex + ']').value;
	dragableBoxesArray[boxIndex]['minutesBeforeReload'] = document.getElementById('minutesBeforeReload[' + boxIndex + ']').value;

	if(dragableBoxesArray[boxIndex]['minutesBeforeReload'] && dragableBoxesArray[boxIndex]['minutesBeforeReload']>5){
		var tmpInterval = setInterval("reloadRSSData(" + boxIndex + ")",(dragableBoxesArray[boxIndex]['minutesBeforeReload']*1000*60));
		dragableBoxesArray[boxIndex]['intervalObj'] = tmpInterval;
	}
	reloadRSSData(boxIndex);

	if(useCookiesToRememberRSSSources)setTimeout('saveCookies()',100);

}

function addRSSEditContent(parentObj)
{
	var editLink = document.createElement('A');
	editLink.href = '#';
	editLink.onclick = cancelEvent;
	editLink.style.cssText = 'float:right';
	editLink.style.styleFloat = 'right';
	editLink.id = 'dragableBoxEditLink' + boxIndex;
	editLink.innerHTML = txt_editLink;
	editLink.className = 'dragableBoxEditLink';
	editLink.style.cursor = 'pointer';
	editLink.style.visibility = 'hidden';
	editLink.onmousedown = editRSSContent;
	parentObj.appendChild(editLink);

	var editBox = document.createElement('DIV');
	editBox.style.clear='both';
	editBox.id = 'dragableBoxEdit' + boxIndex;
	editBox.style.display='none';

	var content = '<form><table cellpadding="1" cellspacing="1"><tr><td>Source:<\/td><td><input type="text" id="rssUrl[' + boxIndex + ']" value="' + dragableBoxesArray[boxIndex]['rssUrl'] + '" size="25" maxlength="255"><\/td><\/tr>'
	+ '<tr><td>Items:<\/td><td width="30"><input type="text" id="maxRssItems[' + boxIndex + ']" onblur="this.value = this.value.replace(/[^0-9-]/g,\'\');if(!this.value)this.value=' + dragableBoxesArray[boxIndex]['maxRssItems'] + '" value="' + dragableBoxesArray[boxIndex]['maxRssItems'] + '" size="2" maxlength="2"><\/td><\/tr><tr><td>Fixed height:<\/td><td><input type="text" id="heightOfBox[' + boxIndex + ']" onblur="this.value = this.value.replace(/[^0-9-]/g,\'\');if(!this.value)this.value=' + dragableBoxesArray[boxIndex]['heightOfBox'] + '" value="' + dragableBoxesArray[boxIndex]['heightOfBox'] + '" size="2" maxlength="3"><\/td><\/tr><tr>'
	+'<tr><td>Reload every:<\/td><td width="30"><input type="text" id="minutesBeforeReload[' + boxIndex + ']" onblur="this.value = this.value.replace(/[^0-9-]/g,\'\');if(!this.value || this.value/1<5)this.value=' + dragableBoxesArray[boxIndex]['minutesBeforeReload'] + '" value="' + dragableBoxesArray[boxIndex]['minutesBeforeReload'] + '" size="2" maxlength="3">&nbsp;minute<\/td><\/tr>'
	+'<tr><td><input type="button" onclick="saveFeed(' + boxIndex + ')" value="Save"><\/td><\/tr><\/table><\/form>';
	editBox.innerHTML = content;

	parentObj.appendChild(editBox);

}

function addBoxContentContainer(parentObj,heightOfBox, _sTabId, _iBoxId)
{
	var div = document.createElement('DIV');
	div.className = 'dragableBoxContent';
	if(opera)div.style.clear='none';
	//div.id = 'dragableBoxContent' + boxIndex;
	div.id = 'dragableBoxContent' + _iBoxId;
	parentObj.appendChild(div);
	if(heightOfBox && heightOfBox/1>40){
		div.style.height = 'auto'; //heightOfBox + 'px';
		div.setAttribute('heightOfBox',heightOfBox);
		div.heightOfBox = heightOfBox;
		//if(document.all)div.style.overflowY = 'auto';else div.style.overflow='-moz-scrollbars-vertical;';
		if(opera)div.style.overflow='auto';
	}
}

function addBoxSpecialContentContainer(parentObj)
{
	var div = document.createElement('DIV');
	div.className = 'dragableBoxSpecialContent';
	div.id = 'dragableBoxSpecialContent' + boxSpecialIndex;
	parentObj.appendChild(div);
}

function addBoxStatusBar(parentObj, _sTabId)
{
	var div = document.createElement('DIV');
	div.className = 'dragableBoxStatusBar';
	div.id = 'dragableBoxStatusBar' + _sTabId;
	parentObj.appendChild(div);

	var img = document.createElement('IMG');
	img.src = "./img/arrow_left.png";
	img.style.styleFloat = 'left';
	img.style.cssText = 'float:left';
	img.style.cursor = 'pointer';
	img.style.visibility = 'hidden';
	img.ipreviouspage = -1;
	img.id = "lastfavs_img_left";
	img.onmousedown = refreshLastFavsPrevious;
	div.appendChild(img);

	img = document.createElement('IMG');
	img.style.styleFloat = 'right';
	img.style.cssText = 'float:right';
	img.style.cursor = 'pointer';
	img.src = "./img/arrow_right.png";
	img.inextpage = 1;
	img.id = "lastfavs_img_right";
	img.onmousedown = refreshLastFavsNext;
	div.appendChild(img);
}

function createABox(columnIndex,heightOfBox,externalUrl,uniqueIdentifier,notDragable, _sTabId, _iBoxId, _bMinimized, _bFollowingBox)
{
	boxIndex++;
	var maindiv = document.createElement('DIV');
	//maindiv.className = 'dragableBox';
	//maindiv.id = 'dragableBox' + boxIndex;
	
	maindiv.id = 'dragableBox' + _iBoxId;
	maindiv.boxId = boxIndex;
	maindiv.dbId = _iBoxId;
	COMMON_SetClass(maindiv, "dragableBox");

	var div = document.createElement('DIV');
	div.className='dragableBoxInner';
	div.id = 'dragableBoxInner' + _iBoxId;
	maindiv.appendChild(div);

	addBoxHeader(div,externalUrl,notDragable, _iBoxId, _bFollowingBox);

	addBoxContentContainer(div,heightOfBox, _sTabId, _iBoxId);

	var obj = document.getElementById('dragableBoxesColumn' + _sTabId + columnIndex);
	var subs = obj.getElementsByTagName('DIV');
	if(subs.length>0){
		obj.insertBefore(maindiv,subs[0]);
	}else{
		obj.appendChild(maindiv);
	}

	dragableBoxesArray[boxIndex] = new Array();
	dragableBoxesArray[boxIndex]['obj'] = maindiv;
	dragableBoxesArray[boxIndex]['parentObj'] = maindiv.parentNode;
	dragableBoxesArray[boxIndex]['uniqueIdentifier'] = uniqueIdentifier;
	dragableBoxesArray[boxIndex]['heightOfBox'] = heightOfBox;
	dragableBoxesArray[boxIndex]['boxState'] =  _bMinimized == 0;	// Expanded

	dragableBoxesID[boxIndex] 	= _iBoxId;

	staticObjectArray[uniqueIdentifier] = boxIndex;

	var obj = document.getElementById('dragableBoxContent' + _iBoxId);
	//var obj = document.getElementById('dragableBoxContent' + boxIndex);
	obj.style.display = dragableBoxesArray[boxIndex]['boxState'] == false?'none':'block';
	var objImg = document.getElementById('dragableBoxExpand' + _iBoxId);
	//var objImg = document.getElementById('dragableBoxExpand' + boxIndex);
	objImg.src = dragableBoxesArray[boxIndex]['boxState'] == false?src_downImage:src_rightImage

	document.getElementById('dragableBoxHeader_txtNbLink' + _iBoxId).style.display = dragableBoxesArray[boxIndex]['boxState'] == true?'none':'block';
	//document.getElementById('dragableBoxHeader_txtNbLink' + boxIndex).style.display = dragableBoxesArray[boxIndex]['boxState'] == true?'none':'block';
	return boxIndex;
}

function createEmptyBox(parent, title, html, statusBar, _bFlagMainLink)
{
	boxSpecialIndex++;
	var maindiv = document.createElement('DIV');
	maindiv.className = 'dragableBox';
	maindiv.id = 'dragableBox' + boxSpecialIndex;
	maindiv.setAttribute("mainLink", _bFlagMainLink);

	var div = document.createElement('DIV');
	div.className='dragableBoxInner';
	maindiv.appendChild(div);

	addSpecialBoxHeader(div,false,true);
	addBoxSpecialContentContainer(div);
	var htmlContentOfNewBox = html;	// HTML content of new box
	var titleOfNewBox = title;

	specialBoxesArray[boxSpecialIndex] = new Array();
	specialBoxesArray[boxSpecialIndex]['obj'] = maindiv;
	specialBoxesArray[boxSpecialIndex]['parentObj'] = maindiv.parentNode;

	document.getElementById(parent).appendChild(maindiv);
	document.getElementById('dragableBoxSpecialContent' + boxSpecialIndex).innerHTML = htmlContentOfNewBox;
	document.getElementById('dragableBoxSpecialHeader_txt'  + boxSpecialIndex).innerHTML = titleOfNewBox;
	if (statusBar)
	addBoxStatusBar(div, parent);
}

function showRSSData(ajaxIndex,boxIndex)
{
	var rssContent = ajaxObjects[ajaxIndex].response;
	tokens = rssContent.split(/\n\n/g);

	var headerTokens = tokens[0].split(/\n/g);
	if(headerTokens[0]=='0'){
		headerTokens[1] = '';
		headerTokens[0] = 'Invalid source';
		closeDragableBox(false,document.getElementById('dragableBoxHeader_txt' + boxIndex));
		return;
	}
	document.getElementById('dragableBoxHeader_txt' + boxIndex).innerHTML = '<span>' + headerTokens[0] + '&nbsp;<\/span><span class="rssNumberOfItems">(' + headerTokens[1] + ')<\/span>';	// title

	var string = '<table cellpadding="1" border="1" cellspacing="0">';
	for(var no=1;no<tokens.length;no++){	// Looping through RSS items
		var itemTokens = tokens[no].split(/##/g);
		string = string + '<tr><td><img src="' + src_smallRightArrow + '"><td><p class=\"boxItemHeader\"><a class=\"boxItemHeader\" href="' + itemTokens[3] + '" onclick="var w = window.open(this.href, target="_blank");return false">' + itemTokens[0] + '<\/a><\/p><\/td><\/tr>';
	}
	string = string + '<\/table>';
	document.getElementById('dragableBoxContent' + boxIndex).innerHTML = string;
	//showStatusBarMessage(boxIndex,'');
	ajaxObjects[ajaxIndex] = false;
}

function reloadRSSData(numericId)
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	showStatusBarMessage(numericId,'Loading data...');
	ajaxObjects[ajaxIndex].requestFile = './common/readRSS.php?rssURL=' + escape(dragableBoxesArray[numericId]['rssUrl']) + '&maxRssItems=' + dragableBoxesArray[numericId]['maxRssItems'];	// Specifying which file to get
	ajaxObjects[ajaxIndex].onCompletion = function(){ showRSSData(ajaxIndex,numericId); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function

}

function createARSSBox(url,columnIndex,heightOfBox,maxRssItems,minutesBeforeReload,uniqueIdentifier,state, _sTabId, _iBoxId, _bMinimized, _bFollowingBox)
{

	if(!heightOfBox)heightOfBox = '0';
	if(!minutesBeforeReload)minutesBeforeReload = '0';

	var tmpIndex = createABox(columnIndex,heightOfBox,true, false, !drag_box_authorized, _sTabId, _iBoxId, _bMinimized, _bFollowingBox);

	if(useCookiesToRememberRSSSources)
	{
		if(!cookieRSSSources[url]){
			cookieRSSSources[url] = cookieCounter;
			//Set_Cookie(nameOfCookie + cookieCounter,url + '#;#' + columnIndex + '#;#' + maxRssItems + '#;#' + heightOfBox + '#;#' + minutesBeforeReload + '#;#' + uniqueIdentifier + '#;#' + state  ,60000);
			cookieCounter++;
		}
	}

	dragableBoxesArray[tmpIndex]['rssUrl'] = url;
	dragableBoxesArray[tmpIndex]['maxRssItems'] = maxRssItems?maxRssItems:100;
	dragableBoxesArray[tmpIndex]['minutesBeforeReload'] = minutesBeforeReload;
	dragableBoxesArray[tmpIndex]['heightOfBox'] = heightOfBox;
	dragableBoxesArray[tmpIndex]['uniqueIdentifier'] = uniqueIdentifier;
	dragableBoxesArray[tmpIndex]['state'] = state;

	if(state==0){
		showHideBoxContent(false,document.getElementById('dragableBoxExpand' + tmpIndex));
	}

	staticObjectArray[uniqueIdentifier] = tmpIndex;

	var tmpInterval = false;
	if(minutesBeforeReload && minutesBeforeReload>0){
		var tmpInterval = setInterval("reloadRSSData(" + tmpIndex + ")",(minutesBeforeReload*1000*60));
	}

	dragableBoxesArray[tmpIndex]['intervalObj'] = tmpInterval;

	if(!document.getElementById('dragableBoxContent' + tmpIndex).innerHTML)document.getElementById('dragableBoxContent' + tmpIndex).innerHTML = 'loading RSS data';

	if(url.length>0 && url!='undefined'){

		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		if(!maxRssItems)maxRssItems = 100;
		ajaxObjects[ajaxIndex].requestFile = './common/readRSS.php?rssURL=' + escape(url) + '&maxRssItems=' + maxRssItems;	// Specifying which file to get
		ajaxObjects[ajaxIndex].onCompletion = function(){ showRSSData(ajaxIndex,tmpIndex); };	// Specify function that will be executed after file has been found
		//ajaxObjects[ajaxIndex].onreadystatechange  = function(){ showRSSData(ajaxIndex,tmpIndex); };	// Specify function that will be executed after file has been found
		//ajaxObjects[ajaxIndex].ontimeout = function(){ showRSSData(ajaxIndex,tmpIndex); };	// Specify function that will be executed after file has been found
		//ajaxObjects[ajaxIndex].responseText = function(){ showRSSData(ajaxIndex,tmpIndex); };	// Specify function that will be executed after file has been found
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
	}else{
		hideHeaderOptionsForStaticBoxes(tmpIndex);
	}
}

function createHelpObjects()
{
	/* Creating rectangle div */
	rectangleDiv = document.createElement('DIV');
	rectangleDiv.id='rectangleDiv';
	rectangleDiv.style.display='none';
	document.body.appendChild(rectangleDiv);
}

function DB_moveBox(_iBoxId, _iColumn, _iRow)
{
	// Get The selected tab
	var tabId = 0;
	for (var i = 0; i < tabArray.length; i++)
	{
		if (i == tabinterfaceElement.selectedtab)
		{
			tabId = tabArray[i].dbid;
			break;
		}
	}
	if (tabId != 0)
	{
		var ajaxIndex = ajaxObjects.length;
		ajaxObjects[ajaxIndex] = new sack();
		ajaxObjects[ajaxIndex].requestFile = './common/box.php?columnchange&id=' + _iBoxId + '&column=' + _iColumn + '&row=' + _iRow + '&tab=' + tabId;	// Specifying which file to get
		ajaxObjects[ajaxIndex].onCompletion = function(){};	// Specify function that will be executed after file has been found
		
		//ajaxObjects[ajaxIndex].onreadystatechange  = function(){ showRSSData(ajaxIndex,tmpIndex); };	// Specify function that will be executed after file has been found
		//ajaxObjects[ajaxIndex].ontimeout = function(){ showRSSData(ajaxIndex,tmpIndex); };	// Specify function that will be executed after file has been found
		//ajaxObjects[ajaxIndex].responseText = function(){ showRSSData(ajaxIndex,tmpIndex); };	// Specify function that will be executed after file has been found
		
		ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
	}
}

function DB_addEasyFav(_sUrl, _bPrivate)
{
	AJAX_SendRequest('./common/links.php?easyLink&url=' + escape(_sUrl) + '&private=' + _bPrivate);
}

function DB_responseEasyFav(_sResponse)
{
	AW_Show(g_lang_easyfaved, false);
}

function DB_addRSS(_sUrl)
{
	var iTab = tabinterfaceElement.selectedtab;
	if (iTab == -1)
		iTab = 0;
	createARSSBox(_sUrl, 1, 100, 10, 10, 'staticObject' + cookieCounter, 1, gSTabPrefix + iTab, 0, 0, _bFollowingBox);
}

function DB_SaveTopPanelState(_bValue)
{
	AJAX_SendRequest('./common/settings.php?toppanel&value=' + _bValue);
}

function DB_DeleteBG()
{
	var optionList = document.getElementById("universeListChangeBg").getElementsByTagName('option');
	var id = '';
	for (var i = 0; i < optionList.length; i++)
	{
		if (optionList[i].selected)
		{
			id = optionList[i].value;
			break;
		}
	}
	AJAX_SendRequest('./ajax/universe.php?backgrounddelete&id=' + id);
	document.body.style.backgroundRepeat = "no-repeat";
	document.body.style.backgroundImage = "";
	document.body.style.backgroundImage = "./img/universe_bg.png";
	document.getElementById('backgroundUnivDiv').style.display = "none";
}
function DB_SaveBGRepeat()
{
	var optionList = document.getElementById("universeListChangeBg").getElementsByTagName('option');
	var id = '';
	for (var i = 0; i < optionList.length; i++)
	{
		if (optionList[i].selected)
		{
			id = optionList[i].value;
			break;
		}
	}
	value = document.getElementById('backgroundRepeatCheck').checked;
	AJAX_SendRequest('./ajax/universe.php?backgroundrepeat&value=' + value + '&id=' + id);
	document.body.style.backgroundRepeat = value ? "repeat":"no-repeat";
}
function DB_SaveShowLinkDesc()
{
	AJAX_SendRequest('./common/settings.php?showlinkdesc&value=' + document.getElementById('showLinkDescCheck').checked);
}

function DB_SaveShowLinkDate()
{
	AJAX_SendRequest('./common/settings.php?showlinkdate&value=' + document.getElementById('showLinkDateCheck').checked);
}

function DB_shareLink(_sUrl, _iPrivacyValue)
{
	AJAX_SendRequest('./common/links.php?shareLink&url=' + escape(_sUrl) + '&private=' + _iPrivacyValue);
}

function DB_addLink(_iBoxId, _iBoxIndex, _sUrl, _iPrivacyValue)
{
	AJAX_SendRequest('./common/links.php?addLink&box=' + _iBoxId + '&url=' + escape(_sUrl) + '&private=' + _iPrivacyValue + '&boxjs=' + _iBoxIndex);
}

function DB_responseAddLink(urlId, title, description, boxjs, sSpecialEmbed, privacy, thumbnail, isthumbico, generatedThumbnail, isimage, videosrc, timestamp)
{
	COMMON_hideAddForm();
	var url = document.getElementById("addInput").value;
	if (url.indexOf("://") == -1)
	url = "http://" + url;
	var sName = "MyEasyFav" + boxjs;
	var oDiv = document.getElementById("tree_ul_" + sName);

	var elementAdd = document.createElement('LI');
	elementAdd.setAttribute("dbid", urlId);
	elementAdd.id = 'node' + urlId + sName;
	if (privacy == 1)
		COMMON_SetClass(elementAdd, "li_private");
	else if (privacy == 2)
		COMMON_SetClass(elementAdd, "li_friends");
	else
		COMMON_SetClass(elementAdd, "li_1");
	//elementAdd.setAttribute("class", "li_1");


	var img = document.createElement('IMG');
	img.id = 'nodeIMG' + urlId + sName;
	bEmbedContent = false;
	if (thumbnail == "")
	{
		if (generatedThumbnail != "")
		{
			thumbnail = generatedThumbnail;
			bEmbedContent = true;
		}
		else
		{
			thumbnail = "./img/no_thumb.png";
		}
	}
	if (isthumbico)
	{
		if (generatedThumbnail != "")
		{
			thumbnail = generatedThumbnail;
			isthumbico = false;
		}		
	}
	if (videosrc.length == 0 || (sSpecialEmbed && sSpecialEmbed.length != 0))
		img.src = thumbnail;
	else
	{
		img.src = "./img/embed_content_play.png";
		img.style.backgroundImage = 'url(' + thumbnail+ ')';
	}
	COMMON_SetClass(img, 'thumbnail');
	if (img.src.indexOf('.ico') != -1 || isthumbico == "1")
		COMMON_SetClass(img, 'thumbnail_ico');
	else
		COMMON_SetClass(img, 'thumbnail');

	elementAdd.appendChild(img);

	var link = document.createElement('A');
	link.id = 'nodeATag' + urlId + sName;
	link.href = url;
	link.target = '_blank';
	link.innerHTML = title;

	elementAdd.appendChild(link);

	var input = document.createElement('INPUT');
	input.setAttribute('name', 'desc');
	input.setAttribute('value', description);
	input.setAttribute('type', 'hidden');
	elementAdd.appendChild(input);


	if (videosrc != "")
	{
		var input = document.createElement('INPUT');
		input.setAttribute('type', 'hidden');
		input.setAttribute('value', videosrc);
		input.setAttribute('id', "VideoSrc" + urlId + sName);
		elementAdd.appendChild(input);
	}

	if (isimage != 0)
	{
		var input = document.createElement('INPUT');
		input.setAttribute('type', 'hidden');
		input.setAttribute('id', "Image" + urlId + sName);
		elementAdd.appendChild(input);
	}
	if (sSpecialEmbed && sSpecialEmbed.length != 0)
	{
		var input = document.createElement('INPUT');
		input.setAttribute('type', 'hidden');
		input.setAttribute('id', "SpecialEmbed" + urlId + sName);
		elementAdd.appendChild(input);	
	}
	var inputDate = document.createElement('INPUT');
	inputDate.setAttribute('type', 'hidden');
	inputDate.setAttribute('id', "Date" + urlId + sName);
	inputDate.setAttribute('value', timestamp);
	elementAdd.appendChild(inputDate);

	if (oDiv.childNodes.length == 0)
	oDiv.appendChild(elementAdd);
	else
	oDiv.insertBefore(elementAdd, oDiv.childNodes[0]);
	JSTreeObj.__registerElement(document.getElementById('node' + urlId + sName));

	var childList = oDiv.childNodes;
	for (var i = 1; i < childList.length; i++)
	{
		if (COMMON_HasAttributes(childList[i]))
		{
			for (var j = 0; j < childList[i].attributes.length; j++)
			{
				if (childList[i].attributes[j].nodeName == "class")
				{
					if (childList[i].attributes[j].nodeValue != "li_private" && childList[i].attributes[j].nodeValue != "li_friends")
					childList[i].attributes[j].nodeValue = 'li_' + (i % 2 + 1);
					break;
				}
			}
		}
	}
	registerAllLightBox(oDiv.getElementsByTagName('A'));
	registerAllLightBoxForVideo(oDiv.getElementsByTagName("a"));
	
	updateBoxNbLink(boxjs);
}

function DB_moveLink(_oLinkObj, _iNewBoxId, _iNewRow)
{
	var sFunction = "moveLink";
	if (_oLinkObj.getAttribute('lastfav'))
		sFunction = "moveLinkLastFav";
	var _iLinkId = _oLinkObj.getAttribute('dbid');
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = './common/links.php?' + sFunction + '&box=' + _iNewBoxId + '&id=' + _iLinkId + '&row=' + _iNewRow;	// Specifying which file to get
	ajaxObjects[ajaxIndex].onCompletion = function(){DB_responseMoveLink(_oLinkObj, ajaxObjects[ajaxIndex].response);};	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function
}

function DB_responseMoveLink(_oLinkObj, _sResponse)
{
	if (_sResponse != "")
	{
		_oLinkObj.setAttribute('dbid', _sResponse);
	}
}

function DB_renameLink(_iLinkId, _sName)
{
	AJAX_SendRequest('./common/links.php?renameLink&id=' + _iLinkId + '&name=' + escape(_sName));
}

function DB_deleteLink(obj, _iLinkId)
{
	DB_responseDeleteLink(obj);
	AJAX_SendRequest('./common/links.php?deleteLink&id=' + _iLinkId);
}

function DB_responseDeleteLink(obj)
{
	var parentRef = obj.parentNode;
	obj.parentNode.removeChild(obj);
	var childList = parentRef.childNodes;
	for (var i = 0; i < childList.length; i++)
	{
		if (COMMON_HasAttributes(childList[i]))
		{
			for (var j = 0; j < childList[i].attributes.length; j++)
			{
				if (childList[i].attributes[j].nodeName == "class" && childList[i].attributes[j].nodeValue == "li_1" || childList[i].attributes[j].nodeValue == "li_2")
				{
					childList[i].attributes[j].nodeValue = 'li_' + (i % 2 + 1);
					break;
				}
			}
		}
	}
}

function DB_privatePublicLink(obj, _iLinkId, _iPrivacy)
{
	AJAX_SendRequest('./common/links.php?privateLink&id=' + _iLinkId + '&privacy=' + _iPrivacy);
}

function DB_easyfavFromMenu(obj, _iLinkId, _sJsId)
{
	AJAX_SendRequest('./common/links.php?easyfavit&id=' + _iLinkId + '&jsid=' + _sJsId);
	LINK_HideMenu();
}

function BOX_removeLinkFromBox(_sJsId)
{
	// Supprimer des nodes l'element easyfave.
	element = document.getElementById(_sJsId);
	element.parentNode.removeChild(element);
}
function BOX_playRandom()
{
	AJAX_SendRequest('./common/box.php?playRandom');
}
/************************************
******** BOX FUNCTIONS **************
***********************************/

function DB_addNewBox(_iDbId)
{
	//TAB_HideMenu();
	if (!_iDbId)
	{
		var tabContainer = document.getElementById('tabcontainer');
		var childDiv = tabContainer.getElementsByTagName('DIV');
		var dbid = 0;
		for (var i = 0; i < childDiv.length; i++)
		{
			if (childDiv[i].parentNode == tabContainer)
			{
				if (window.event || window.navigator.appName == "Microsoft Internet Explorer") // IE
				{
					if(childDiv[i].style.display == "block")
					{
						dbid = childDiv[i].getAttribute('dbid');
						break;
					}
				}
				else
				{
					style = childDiv[i].getAttribute('style');
					if(style == 'display: block;')
					{
						dbid = childDiv[i].getAttribute('dbid');
						break;
					}
				}
			}
		}		
	}
	else
	{
		dbid = _iDbId;
	}
	if (dbid && FLAG_DB_ADDNEWBOX == false)
	{
		FLAG_DB_ADDNEWBOX = true;
		AJAX_SendRequest('./common/box.php?addNewBox&tabId=' + dbid);
	}
}

function DB_removeBox(_iBoxId)
{
	AJAX_SendRequest('./common/box.php?removeBox&id=' + _iBoxId);
}

function DB_modifyBoxTitle(_iBoxId, _sTitle)
{
	AJAX_SendRequest('./common/box.php?modifyTitleBox&id=' + _iBoxId + '&title=' + _sTitle);
}

function DB_modifyBoxMinimze(_iBoxId, _bMinimzed)
{
	var bMinimized = _bMinimzed == true ? 1 : 0;
	AJAX_SendRequest('./common/box.php?minimized=' + bMinimized + '&id=' + _iBoxId);
}

function LogOut()
{
	AJAX_SendRequest("./logout/");
}

function cancelSelectionEvent(e)
{
	source = COMMON_GetTarget(e);
	/*if(document.all)e = event;

	if (e.target) source = e.target;
	else if (e.srcElement) source = e.srcElement;
	if (source.nodeType == 3) // defeat Safari bug
	source = source.parentNode;
	*/
	if(source.tagName.toLowerCase()=='input')return true;

	if(dragDropCounter>=0)
	return false;
	else
	{
		return true;
	}

}

function cancelEvent()
{
	return false;
}
var MozUserSelect;

function createFeed(formObj, _sTabId)
{
	var url = formObj.rssUrl.value;
	var items = formObj.items.value;
	var height = formObj.height.value;
	var reloadInterval = formObj.reloadInterval.value;
	if(isNaN(height) || height/1<40)height = false;
	if(isNaN(reloadInterval) || reloadInterval/1<5)reloadInterval = false;
	createARSSBox(url,1,height,items,reloadInterval, _sTabId);
}

function createRSSBoxesFromCookie()
{
	var tmpArray = new Array();
	var cookieValue = Get_Cookie(nameOfCookie + '0');
	cookieCounter=0;
	while(cookieValue && cookieValue!='')
	{
		var items = cookieValue.split('#;#');
		var index = items[0];
		if(!items[0])index = items[5];
		if(items.length>1 && !tmpArray[index])
		{
			tmpArray[index] = true;
			createARSSBox(items[0],items[1],items[3],items[2],items[4],items[5],items[6], '');
			cookieRSSSources[items[0]]=cookieCounter-1;
		}
		else
		{
			cookieCounter++;
		}
		var cookieValue = Get_Cookie(nameOfCookie + cookieCounter);
	}
}


/* Clear cookies */

function clearCookiesForDragableBoxes()
{
	var cookieValue = Get_Cookie(nameOfCookie);
	while(cookieValue && cookieValue!=''){
		Set_Cookie(nameOfCookie + cookieCounter,'',-500);
		cookieCounter++;
		var cookieValue = Get_Cookie(nameOfCookie + cookieCounter);
	}

}

/* Delete all boxes */

function deleteAllDragableBoxes()
{
	var divs = document.getElementsByTagName('DIV');
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='dragableBox')closeDragableBox(false,divs[no]);
	}

}

/* Reset back to default settings */

function resetDragableBoxes(_sTabId)
{
	cookieCounter = 0;
	clearCookiesForDragableBoxes();

	deleteAllDragableBoxes();
	cookieCounter = 0;
	cookieRSSSources = new Array();
	createDefaultBoxes(_sTabId);
}

function hideHeaderOptionsForStaticBoxes(boxIndex)
{
	if(document.getElementById('dragableBoxRefreshSource' + boxIndex))document.getElementById('dragableBoxRefreshSource' + boxIndex).style.display='none';
	if(document.getElementById('dragableBoxOptionLink' + boxIndex))document.getElementById('dragableBoxOptionLink' + boxIndex).style.display='none';
}


function createHTMLBoxes(title, html, _iColumnPos, _sTabId, _iBoxId, _bMinimized, _bFollow, _sFollowingNickname)
{
	var htmlContentOfNewBox = html;	// HTML content of new box
	var titleOfNewBox = title;
	if(!staticObjectArray['staticObject' + cookieCounter]){	// The box is not stored in cookie - we need to create it.
		var newIndex = createABox(_iColumnPos,100,false,'staticObject' + cookieCounter, !drag_box_authorized, _sTabId, _iBoxId, _bMinimized, _bFollow);
		document.getElementById('dragableBoxContent' + _iBoxId).innerHTML = htmlContentOfNewBox;
		document.getElementById('dragableBoxHeader_txt'  + _iBoxId).innerHTML = titleOfNewBox;
		if (_bFollow)
		{
			document.getElementById('dragableBoxInner'  + _iBoxId).className = 'dragableBoxInner dragableBoxInnerFollowing';
			document.getElementById('dragableBoxHeader'  + _iBoxId).className = 'dragableBoxHeader dragableBoxHeaderFollowing';
			
		}
			//_sFollowingNickname
		//document.getElementById('dragableBoxContent' + newIndex).innerHTML = htmlContentOfNewBox;
		//document.getElementById('dragableBoxHeader_txt'  + newIndex).innerHTML = titleOfNewBox;
	}else{	// Box is stored in cookie - all we have to do is to move content into it.
		document.getElementById('dragableBoxContent'  + staticObjectArray['staticObject' + cookieCounter]).innerHTML = htmlContentOfNewBox;
		document.getElementById('dragableBoxHeader_txt'  + staticObjectArray['staticObject' + cookieCounter]).innerHTML = titleOfNewBox;
	}
	//updateBoxNbLink(newIndex);
	updateBoxNbLink(_iBoxId);
	//hideHeaderOptionsForStaticBoxes(staticObjectArray['staticObject' + cookieCounter]);
	cookieCounter++;
}

function	updateBoxNbLink(newIndex)
{
	var treeObj = document.getElementById("tree_ul_MyEasyFav" + newIndex);
	if (treeObj)
	{
		var element = treeObj.getElementsByTagName("LI");
		document.getElementById('dragableBoxHeader_txtNbLink'  + newIndex).innerHTML = "&nbsp;(" + (element.length) + ")";
	}
}

/* You customize this function */
function createDefaultBoxes(_sTabId)
{
	if(cookieCounter==0){
		createARSSBox('http://rss.cnn.com/rss/cnn_topstories.rss',2,false,5,1, _sTabId);
		createARSSBox('http://feeds.feedburner.com/reuters/topNews/',3,false,5, _sTabId);
		createARSSBox('http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml',2,false,5,10, _sTabId);
		createARSSBox('http://rss.pcworld.com/rss/latestnews.rss',1,false,5, _sTabId);
	}

	/* Create static boxes */
	var htmlContentOfNewBox = '<DIV>This is a static box created from the function createDefaultBoxes().</div>';	// HTML content of new box
	var titleOfNewBox = 'This is a static box';
	if(!staticObjectArray['staticObject1']){	// The box is not stored in cookie - we need to create it.
		var newIndex = createABox(1,100,false,'staticObject1', !drag_box_authorized, _sTabId);
		document.getElementById('dragableBoxContent' + newIndex).innerHTML = htmlContentOfNewBox;
		document.getElementById('dragableBoxHeader_txt' + newIndex).innerHTML = titleOfNewBox;
	}else{	// Box is stored in cookie - all we have to do is to move content into it.
		document.getElementById('dragableBoxContent' + staticObjectArray['staticObject1']).innerHTML = htmlContentOfNewBox;
		document.getElementById('dragableBoxHeader_txt' + staticObjectArray['staticObject1']).innerHTML = titleOfNewBox;

	}
	hideHeaderOptionsForStaticBoxes(staticObjectArray['staticObject1']);

	setTimeout('saveCookies()',100);

}

/* Disable drag for a box */
function disableBoxDrag(boxIndex)
{
	document.getElementById('dragableBoxHeader' + boxIndex).onmousedown = '';
	document.getElementById('dragableBoxHeader' + boxIndex).style.cursor = 'default';

}


function initDragableBoxesScript(BoxId)
{
	createColumns(BoxId);
}

function reduceAllBoxes()
{
	var img = document.getElementById('box_open_close');
	var openState = true;
	openState =img.getAttribute("openstate"); 
	if (openState == true || openState == 'true')
	{
		closeAndSaveBoxTitle(false);
		openState = false;
	}
	else
	{
		openState = true;
	}
	img.setAttribute("openstate", openState);
	img.src = openState  == true ?src_ImageBoxOpenAll:src_ImageBoxCloseAll;
	if (openState)
		Image_AddHoverChangeSrc(document.getElementById("box_open_close"), "./img/box_openall.png", "./img/box_openall_hover.png");
	else
		Image_AddHoverChangeSrc(document.getElementById("box_open_close"), "./img/box_closeall.png", "./img/box_closeall_hover.png");
		
	for (var i = 1; i < dragableBoxesArray.length; i++)
	{
		dragableBoxesArray[i]['boxState'] = openState;
		if (openState == false)
		{
			$(document.getElementById('dragableBoxContent' + dragableBoxesID[i])).fadeOut();
			$(document.getElementById('dragableBoxHeader_txtNbLink' + dragableBoxesID[i])).fadeIn();			
		}
		else
		{
			$(document.getElementById('dragableBoxContent' + dragableBoxesID[i])).fadeIn();
			$(document.getElementById('dragableBoxHeader_txtNbLink' + dragableBoxesID[i])).fadeOut();	
		}
		
		//document.getElementById('dragableBoxContent' + dragableBoxesID[i]).style.display = openState == false?'none':'block';
		//document.getElementById('dragableBoxHeader_txtNbLink' + dragableBoxesID[i]).style.display = openState == true ?'none':'block';
		document.getElementById('dragableBoxExpand' + dragableBoxesID[i]).src = dragableBoxesArray[i]['boxState']  == false ?src_downImage:src_rightImage;		
	}
	LINK_HideMenu();
	BOX_HideMenu();
}

function reduceTopPanels()
{
	var img = document.getElementById('top_open_close');
	openTopPanels(img.getAttribute('closeState')=="false"?false:true);
	COMMON_hideAddForm();
}

function openTopPanels(bOpen)
{
	var img = document.getElementById('top_open_close');
	var closeState = !bOpen;
	if (bOpen)
	{
		img.setAttribute('closeState', closeState);
		img.src = src_ImageTopClose;
		//document.getElementById("topPanel").style.display = closeState == false ? "block":"none";
		if ($("#topPanel").hasClass('hidden'))
			$("#topPanel").animate({height: 'toggle', opacity: 1}, 300).removeClass('hidden');
	}
	else
	{
		img.setAttribute('closeState', closeState);
		img.src = src_ImageTopOpen;
		if (!$("#topPanel").hasClass('hidden'))
			$("#topPanel").animate({height: 'toggle', opacity: 1}, 300).addClass('hidden');
		//document.getElementById("topPanel").style.display = closeState == false ? "block":"none";		
	}
	DB_SaveTopPanelState(closeState == false);
	LINK_HideMenu();
	TAB_HideMenu();
	BOX_HideMenu();
}

function BOX_HideMenu()
{
	if (!$("#box_menu").hasClass('hidden')) {
		$("#box_menu").animate({height: 'toggle', opacity: 0}, 100).addClass('hidden');
	}	
	if (!$("#universe_menu").hasClass('hidden')) {
		$("#universe_menu").animate({height: 'toggle', opacity: 0}, 100).addClass('hidden');
	}	
}

function launchPlayer()
{
	for(var no=1;no<dragableBoxesArray.length;no++){
		if (BOX_showLightbox(dragableBoxesArray[no], false, true))
			return;
	}
	alert(g_lang_player_no_embed);
}

function BOX_previous()
{
	UNIVERSE_HideMenu();
	for(var no=1;no<dragableBoxesArray.length;no++){
		if (g_box_selectedId == dragableBoxesArray[no]['obj'].id)
		{
			if (no == 1)
			{
				alert('this is the first embedable box');
				return;
			}
			else
			{
				if (BOX_showLightbox(dragableBoxesArray[no - 1], false))
					return;
				else
				for(var no2=1;no2<dragableBoxesArray.length - no2;no2++){					
					if (BOX_showLightbox(dragableBoxesArray[no - no2], false))
						return;
				}
				alert('this is the first embedable box');
				return;
			}
		}
	}	
}

function BOX_next()
{
	UNIVERSE_HideMenu();
	var bShowNext = false;
	for(var no=1;no<dragableBoxesArray.length;no++){
		if (bShowNext)
		{
			if (no == dragableBoxesArray.length - 1)
			{
				alert('this is the last embedable box');
				return;
			}
			else
			{
				if (BOX_showLightbox(dragableBoxesArray[no + 1], false))
					return;
			}
		}			
		if (g_box_selectedId == dragableBoxesArray[no]['obj'].id)
		{
			if (no == dragableBoxesArray.length - 1)
			{
				alert('this is the last embedable box');
				return;
			}
			else
			{
				if (BOX_showLightbox(dragableBoxesArray[no + 1], false))
					return;
				else
					bShowNext = true;
			}
		}
	}
}

function BOX_showLightbox(_boxObj, _bJustTest, _bCenter)
{
	box = document.getElementById(_boxObj['obj'].id);
	if (box)
	{
		liList = box.getElementsByTagName('li');
		for (i = 0; i < liList.length; i++)
		{
			aObj = liList[i].getElementsByTagName('table')[0].getElementsByTagName('td')[1].getElementsByTagName('a')[0];
			if (aObj && (aObj.getAttribute('rel') == 'lightbox' || aObj.getAttribute('rel') == 'lightboxvideo' || aObj.getAttribute('rel') == 'lightboxspecialembed'))
			{
				if (!_bJustTest)
				{
					var title = document.getElementById('dragableBoxHeader_txt' + _boxObj['obj'].dbId).innerHTML;
					showLightboxVideo(aObj, true, _bCenter, title);					
				}
				return true;
			}
		}
	}
	return false;
}

function BOX_IsLastPrevious()
{
	for(var no=1;no<dragableBoxesArray.length;no++){
		if (g_box_selectedId == dragableBoxesArray[no]['obj'].id)
		{
			if (no == 1)
			{
				return true;
			}
			else
			{
				if (BOX_showLightbox(dragableBoxesArray[no - 1], true))
					return false;
				else
				{
					for(var no2=1;no2<no;no2++){					
						if (BOX_showLightbox(dragableBoxesArray[no - no2], true))
							return false;						
					}
				}
				return true;
			}
		}
	}	
	return true
}
function BOX_IsLastNext()
{
	var bShowNext = false;
	for(var no=1;no<dragableBoxesArray.length;no++){
		if (bShowNext)
		{
			if (no == dragableBoxesArray.length - 1)
			{
				return true;
			}
			else
			{
				if (BOX_showLightbox(dragableBoxesArray[no + 1], true))
					return false;
			}
		}			
		if (g_box_selectedId == dragableBoxesArray[no]['obj'].id)
		{
			if (no == dragableBoxesArray.length - 1)
			{
				return true;
			}
			else
			{
				if (BOX_showLightbox(dragableBoxesArray[no + 1], true))
					return false;
				else
					bShowNext = true;
			}
		}
	}
	return true;
}
/*	if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "lightbox" || anchor.getAttribute("rel") == "lightboxspecialembed")){
		anchor.onclick = function (e)
		{
			if (COMMON_MouseLeftClickValue() == COMMON_GetButtonClicked(e))
			{
				showLightboxVideo(this, true);
			}
}*/
