function pop_up(url, largeur, hauteur, haut, gauche) {
	resize=arguments[5];
	if (resize == 'resize') {
		width_screen = screen.width;
		height_screen = screen.height;

		if (largeur > width_screen) largeur = width_screen-(2*gauche);
		if (hauteur > height_screen) hauteur = height_screen-(2*haut);

		window.open(url, 'seemore', 'top=' + haut + ', left=' + gauche + ', height=' + hauteur + ', width=' + largeur + ', toolbar=no, resizable=yes, location=no, menubar=no, status=no, scrollbars=no');
	}
	else {
		window.open(url, 'seemore', 'top=' + haut + ', left=' + gauche + ', height=' + hauteur + ', width=' + largeur + ', toolbar=no, resizable=yes, location=no, menubar=no, status=no, scrollbars=no');
	}
}

function checkEnterKey(ns) {
	if (document.all) { // IE
		keycode = event.keyCode;
	}
	else { // FF
		keycode = ns.which;
	}

	if (keycode == 13) return true;
	else return false;
}

function lib_bwcheck(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera=this.agent.indexOf("Opera")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.safari=this.agent.indexOf("Safari")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera)
	return this
}

function isJre15() {
	Exp_java = new RegExp("java", "gi");
	Exp_15 = new RegExp("1\.5", "gi");

	is_java = false;
	is_15 = false;

	for (var i=0; i<navigator.plugins.length; i++) {
		tab_is_java = Exp_java.exec(navigator.plugins[i].name);
		if (tab_is_java) is_java = true;

		if (is_java) {
			tab_is_15 = Exp_15.exec(navigator.plugins[i].description);
			if (tab_is_15) is_15 = true;
		}
	}

	if (is_15 && is_java) return true;
	else return false;
}

function trim(str) {
   return str.replace(/(^\s*)|(\s*$)/g,"")
}

function print_r(tableau)
{
	vide=0;
	tmp_ch='Array\n{\n';
	for(j=0; j < tableau.length; j++)
	{
		tmp_ch+=' ['+j+'] => '+tableau[j]+'\n';
		if(tableau[j] == '')
			vide++;
	}
	tmp_ch+='}\n------------ Informations supl�entaires ------------\nTaille du tableau :'+tableau.length+'\nNombre de champs vides :'+vide;
	alert(tmp_ch);
}

function is_inside(val,tab)
{
	compt=tab.length;
	for(i=0;i < compt;i++)
	{
		if(tab[i] == val)
		{
			v=i+1
			return v;
		}
	}
	return false;
}

function getAbsoluteTop(objectId)
{
   o = document.getElementById(objectId);
   oTop = o.offsetTop;
   while(o.offsetParent!=null)
   {
       oParent = o.offsetParent;
       oTop += oParent.offsetTop;
       o = oParent;
   }
   return oTop;
}

function getAbsoluteLeft(objectId)
{
   o = document.getElementById(objectId)
   oLeft = o.offsetLeft;
   while(o.offsetParent!=null)
   {
       oParent = o.offsetParent;
       oLeft += oParent.offsetLeft;
       o = oParent;
   }
   return oLeft;
}

function getAbsoluteRight(objectId)
{
   o = document.getElementById(objectId)
   oRight = o.offsetRight;
     while(o.offsetParent!=null)
   {
       oParent = o.offsetParent;
       oRight += oParent.offsetRight;
       o = oParent;
   }
   return oRight;
}

function getAbsoluteBottom(objectId)
{
   o = document.getElementById(objectId);
   oBottom = o.offsetBottom;
      while(o.offsetParent!=null)
   {
       oParent = o.offsetParent;
       oBottom +=oParent.offsetBottom;
       o = oParent;
   }
   return oBottom;
}

//////////////////////////////////////////////////////
//Gestion des Opacités de calques
//////////////////////////////////////////////////////
//Change l'opacitée d'un calque grace à son id l'opacitée est à entrer en pourcents
function changeOpacity(opacity, id)
{
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

//Fadin ou fadeout de l'opacitée
function fadeOpacity(id, opacStart, opacEnd, millisec)
{
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//Détermine le sens du fade de l'opacitée
	if(opacStart > opacEnd)
	{
		for(i = opacStart; i >= opacEnd; i--)
		{
			opacityTimeout=setTimeout("changeOpacity(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd)
	{
		for(i = opacStart; i <= opacEnd; i++)
		{
			opacityTimeout=setTimeout("changeOpacity(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//////////////////////////////////////////////////////
// Gestion de la position de la sourie
//////////////////////////////////////////////////////
function getMousePos(ns){
	if (document.all){
		var XM=event.clientX+document.documentElement.scrollLeft;
		var YM=event.clientY+document.documentElement.scrollTop;
	}else{
		var XM=ns.pageX;
		var YM=ns.pageY;
	}
	var positions=new Array(XM,YM);
	return positions
}
//////////////////////////////////////////////////////

//Fadein ou fadeout en fonction de l'opacitée courante
function fadeCurrentOpacity(id, opacEnd, millisec) {
	var currentOpac = 100;
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}
	fadeOpacity(id, currentOpac, opacEnd, millisec);
}

function MoveTo(MyObject, x, y) {
   if (document.getElementById||document.all) {
      MyObject.style.left = x + "px";
      MyObject.style.top = y + "px";
      return;
   }
   if(document.layers) MyObject.moveTo(x, y);
}


// annuaire

function directory_click(nb) {

	var tmp=document.getElementById('dir'+nb);

	if (tmp) {
		// repliation
		var bro=document.getElementsByClassName('cdirectorydiv');
		for (a=0; a<bro.length; a++) {
			var tmpid=bro[a].getAttribute('id');
			if (tmpid!='dir'+nb)
				bro[a].style.display = 'none';
		}
		// depliation
		if (tmp.style.display=='none')
			tmp.style.display = 'block';
	}
}

function directory_unclick() {
	var bro=document.getElementsByClassName('cdirectorydiv');
	for (a=0; a<bro.length; a++) {
		var tmpid=bro[a].getAttribute('id');
		bro[a].style.display = 'none';
	}
}

// Renvoie la position + 1 [Pour les test id(is_inside(...) car 0 n'est pas valide pour le test] de valeur dans tableau ou false
function is_inside(val,tab){
	compt=tab.length;
	for(i=0;i < compt;i++){
		if(tab[i] == val){
			v=i+1;
			return v;
		}
	}
	return false;
}



/* DOCK */ 

function load_app(app,status,sub) {
	var uri = '';
	$('outerbar').style.height='120px';
	switch (app) {
		case 1:
			document.location.href="/" + LANG + "/mail/";
			break;
		case 2:
		case 3:
		case 4:
		case 5:
		case 7:
			if (sub != 1) {
				document.getElementById('ssmenu0').style.display='none';
				if (status == 1) {
					for (a=1; a<=7; a++)
						if ( (a!=app) && (document.getElementById('ssmenu'+a)) )
							document.getElementById('ssmenu'+a).style.display='none';
					document.getElementById('ssmenu'+app).style.display='block';
				} else {
					switch (app) {
						case 2:
							document.location.href="/" + LANG + "/web/subscribe.php";
							break;
						case 3:
							document.location.href="/" + LANG + "/blog/subscribe.php";
							break;
						case 4:
							document.location.href="/" + LANG + "/money/";
							break;
						case 5:
							document.location.href="/" + LANG + "/buddies/";
							break;
					}
				}
			}
			break;
		case 6:
			document.location.href="/" + LANG + "/help/";
			break;
		default:
			return false;
	}
}

function dock_onload(service) {
	var uri=document.location.href.split("/")[4];
	if (service == 5) {
		load_app(5,status_5,subscribe);
	} else {
		switch (uri) {
			case 'web': 
				if (status_2 == 1) load_app(2,status_2,subscribe);
				break;
			case 'blog': 
				if (status_3 == 1) load_app(3,status_3,subscribe);
				break;
			case 'buddies': load_app(5,status_5,subscribe); break;
			case 'video': load_app(7,status_7,subscribe); break;
			default:
				return false;
		}
	}
}

function dock_load(service) {
	var dockPreviousOnload = window.onload;
	window.onload = function () { if(dockPreviousOnload) dockPreviousOnload(); dock_onload(service); }
}

/* FIN DOCK */



// Le flash 'subscribe' lance cette fonction quand l'inscription est validé
function finishSubscribe(){
	location.href = "/" + LANG;
}
// Change le contenu des 'top_list' quand clic sur le tagtorrent
function tagtorrentAction(id) {
	directory_unclick();
	swfWeb.sendXml('/' + LANG + '/xml/home_top.php?num_page=1&type=web&tag_id=' + id);
	swfBlog.sendXml('/' + LANG + '/xml/home_top.php?num_page=1&type=blog&tag_id=' + id);
	swfVideo.sendXml('/' + LANG + '/xml/home_top.php?num_page=1&type=video&tag_id=' + id);
}

// Dimensions du navigateur
var window_width = window.innerWidth;
var window_height = window.innerHeight;
