function time() 
{
	window.setTimeout("time()",2000);+1
	today = new Date();
	self.status = today.toLocaleString(); 
}

//actions confirme
function suppr(cc, id, section, legend)
{
	if(confirm(legend))
	{
		window.location = '?cc=' + cc + '&id=' + id + '&num=' + section + '&action=del';
	}
}

function subsuppr(cc, id, section, legend)
{
	if(confirm(legend))
	{
		window.location = '?cc=' + cc + '&id=' + id + '&num=' + section + '&action=subdel';
	}
}
function modif(cc, id, section, legend)
{
	if(confirm(legend))
	{
		window.location = '?cc=' + cc + '&id=' + id + '&num=' + section + '&action=modif';
	}
}
function active(cc, id, section, legend)
{
	if(confirm(legend))
	{
		window.location = '?cc=' + cc + '&id=' + id + '&num=' + section + '&action=show';
	}
}

function desactive(cc, id, section, legend)
{
	if(confirm(legend))
	{
		window.location = '?cc=' + cc + '&id=' + id + '&num=' + section + '&action=hide';
	}
}
function valid(cc, id, section, comment, legend)
{
	if(confirm(legend))
	{
		window.location = '?cc=' + cc + '&id=' + id + '&num=' + section + '&com=' + comment + '&action=valid';
	}
}
function unvalid(cc, id, section, comment, legend)
{
	if(confirm(legend))
	{
		window.location = '?cc=' + cc + '&id=' + id + '&num=' + section + '&com=' + comment + '&action=unvalid';
	}
}

function backNoSave(cc, id, legend)
{
	if(confirm(legend))
	{
		window.location = '?cc=' + cc + '&id=' + id ;
	}
}

//Fcts smiley
function smiley(smiley_n)
{
	if (!document[nomForm].infoF.disabled)    
		document[nomForm].infoF.value += smiley_n + " ";
}

//Fcts genre => info
function enableFiche(cat)
{
		document[nomForm].infoF.disabled = false;
		document[nomForm].Image.disabled = false;
		var theobj = document.getElementById("altGenre");
		theobj.className = "showIf"; 
	    switch(cat){
			case 0:
				document[nomForm].genreAlt.disabled = false;
				theobj.className = "showNow";
				if (document[nomForm].genreAlt.value.length == 0) {document[nomForm].infoF.disabled = true; document[nomForm].Image.disabled = true;} 
				break;
			case 1:
				//texte spécifique à rajouter
				break;			
		}
}

// Fcts Add options to select
nomForm = "form1"; 
function selectGenre(cat)
{
	clear_mnu('genreF'); 
	
	b = new Array(); 
    i = 0; 
	// Creation du menu 
    if (cat != 0) {create_mnu('genreF',cat);}
}

function opt(txt, val)
{     
    // mise en tableau des objet Option 
    b[i] = new Option(txt, val); 
    i++; 
} 

function clear_mnu(nomMenu)
{ 
    for(j=document[nomForm][nomMenu].length; j >= 0; j--){ 
        // on efface les objets Option 
        document[nomForm][nomMenu].options[j] = null; 
    } 
	document[nomForm][nomMenu].disabled = true;
	document[nomForm].infoF.disabled = true;
	document[nomForm].Image.disabled = true;
	document[nomForm].genreAlt.disabled = true;
} 

function create_mnu(nomMenu,cat)
{ 
    for(k=0; k < genreval[cat].length; k++){ 
        // on applique au menu select les objets Option contenu dans l'array a 
        document[nomForm][nomMenu].options[k] = genreval[cat][k]; 
    } 
	document[nomForm][nomMenu].disabled = false;    
	
	var theobj = document.getElementById("altGenre");
	if (document[nomForm][nomMenu].options[document[nomForm][nomMenu].selectedIndex].index != 0) 
	{
		document[nomForm].infoF.disabled = false; 
		document[nomForm].Image.disabled = false;
		theobj.className = "showIf"; 
	} else {
		document[nomForm].genreAlt.disabled = false;
		theobj.className = "showNow";
		if (document[nomForm].genreAlt.value.length != 0){ document[nomForm].infoF.disabled = false; }
	}
} 

function checkInfoF()
{ 
		var nomMenu="genreF";
		if (document[nomForm].genreAlt.value.length != 0)
		{
			document[nomForm].infoF.disabled = false; 
			document[nomForm].Image.disabled = false;
		} else if (document[nomForm][nomMenu].options[document[nomForm][nomMenu].selectedIndex].index == 0){
			document[nomForm].infoF.disabled = true; 
			document[nomForm].Image.disabled = true;
		}
}

//Fcts images
function uploaderImage(nomAncre,where,id, dir, height, width, theight, twidth)
{
	void MM_openBrWindow('test/admin/Picindex.php?formfield='+ nomAncre +'&link='+ where + '&id='+ id + '&dir='+ dir + '&height='+ height + '&width='+ width + '&twidth='+ twidth + '&theight='+ theight,'upload','width=600,height=480,resizable=1,toolbar=0,directories=0,scrollbars=1,status=0,screenX=0,screenY=0,top=0,left=0','1');
}

function setItem(itemField, itemValue)
{
  var oSel = document.getElementById('uploadImField');
  //si menu déroulant alors, il faut activer ces lignes
  //var oOpt = new Option(itemValue,itemValue,false,true);
  //var oIdx = oSel.options.length;
  //oSel.options[oIdx] = oOpt;
  //oSel.selectedIndex = oIdx;
 oSel.value=itemValue;

  setImageSrc(itemField, itemValue);
}

function setImageSrc(imgField, imgFile)
{
  var imgId = imgField.replace(/^(formvars|new)/i, "img");
  var oImg = document.getElementById(imgId);
 if (oImg != null) {
    var oSrc = oImg.src;
	//alert (oImg.src);
    //oImg.src = oSrc.replace(/(\/divx\/upload\/.*\/)([^\/]+)(\/?)$/i, "$1"+imgFile);
	oImg.src="http://www.divxovore.com/divx/upload/"+imgFile;
	//alert (oImg.src);
  }
}


//Fcts preview
function preview(formu,which,action)
{
	formu.action = 'preview.php?template='+which;
	formu.target = '_blank';
	formu.submit();
	//rechange l'action du form
	formu.action = action ;
	formu.target = '_self';
}

//Fcts images
function show_comments(num,type)
{
	void MM_openBrWindow('http://www.divxovore.com/Newmail/Comments.php?num='+ num +'&type='+ type +'','comments','width=600,height=480,resizable=1,toolbar=0,directories=0,scrollbars=1,status=0,screenX=0,screenY=0,top=0,left=0','1');
}
function dead_link(num,type)
{
	if (confirm("Attention: si vous utilisez un autre programme que eMule ou eDonkey, ce lien peut vous paraître mort.\n Pour le récupérer dans ce cas:\n - Sous IE: faites clic droit, \'Copier le raccourci\'... \n - Sous Mozilla: faites clic droit, \'Propriété\' et copier le lien depuis \'Propriété du lien\'...\n ...Enfin, collez le lien dans votre programme P2P fonctionnant avec les liens \'ed2k\'.\n Vous pouvez consulter les FAQ sur ce site pour plus d'information.\n\n Malgré ces procédures, le lien vous paraît-il toujours mort?"))
	{
		void MM_openBrWindow('http://www.divxovore.com/Newmail/Deadlink.php?num='+ num +'&type='+ type +'','deadlink','width=1,height=1,resizable=0,toolbar=0,directories=0,scrollbars=1,status=0,screenX=0,screenY=0,top=0,left=0','1');
	}
}
function post_contact(num,type)
{
	window.location = 'http://www.divxovore.com/index2.php?cc=Form&num=' + num + '&type=' + type + '';
}

function changeGenre(cat,genre)
{
	window.location = 'index.php?cc=' + cat + '-' + genre +'-1';
}
function changeGenreX(cat,genre)
{
	window.location = 'index2.php?cc=' + cat + '-' + genre +'-1';
}
function changeCat(cat,nb)
{
	window.location = 'index.php?cc=Latest--' + nb;
}
//Fcts pop-up
function MM_openBrWindow(theURL,winName,features,returni) 
{ //v2.0
  var popwin;
  popwin=window.open(theURL,winName,features);
  if (popwin != null) {
        popwin.opener=self;
        popwin.focus();
    } else {
        alert("Impossible d\'ouvrir une pop-up. Si vous avez un bloqueur de pop-up installé, veuillez les autoriser sur ce site.");
    }
	
	if (returni==1)
	{
		return false;
	}
}
