
function submitForm( )
{	
		document.forms['formulaire'].elements.isposted.value=1;		
		document.forms['formulaire'].submit( );
	
	
}
function submitvoteForm( )
{	
		document.forms['formvote'].elements.voteposted.value=1;		
		document.forms['formvote'].submit( );
}

function submitvotethemeForm( )
{	
		document.forms['formvotetheme'].elements.votethemeposted.value=1;		
		document.forms['formvotetheme'].submit( );
}

function submitsortForm( )
{	
		var categorie = document.getElementById('form_sort_select').options[document.getElementById('form_sort_select').selectedIndex].value;
		if( categorie == "-1")
		{
			document.location.href ='index.php?view=showphoto&mode=all';
		}
		else
		{
			document.location.href ='index.php?view=showphoto&mode=all&sort=' + categorie;
		}
}


function submitPhoto( )
{	
	if( document.getElementById('form_titre').value == '')
	{
		alert("Veuillez choisir un titre");
		return false;
	}
	else if( document.getElementById('form_id_categorie').options[document.getElementById('form_id_categorie').selectedIndex].value == '-1')
	{
		alert("Veuillez choisir une catégorie");
		return false;
	}
	else
	{
		document.forms['formulaire'].elements.isposted.value=1;		
		document.forms['formulaire'].submit( );
	}
	
}

function valid_suppress( nom ,  id)
{
	if( confirm('Voulez-vous vraiment supprimer la catégorie "' + nom + '" et toutes les catégories sous-jacentes ?'))
	{
		window.location.href = 'index.php?view=deletecat&id=' +id;
	}
	else
	{
		return false;
	}
}

function hover(obj){
  if(document.all){
    UL = obj.getElementsByTagName('ul');
    if(UL.length > 0){
      sousMenu = UL[0].style;
      if(sousMenu .display == 'none' || sousMenu.display == ''){
        sousMenu.display = 'block';
      }else{
        sousMenu.display = 'none';
      }
    }
  }
}

function setHover(){
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;
  for(i=0; i < nLI; i++){
    LI[i].onmouseover = function(){
      hover(this);
    }
    LI[i].onmouseout = function(){
      hover(this);
    }
  }
}

function displayvote()
{
	document.getElementById('divvote').style.display = 'block';
	document.getElementById('divvote').style.left = getAbsX(document.getElementById('btvote')) + "px";
	document.getElementById('divvote').style.top = getAbsY(document.getElementById('btvote')) - 145 + "px" ;
}

function displayvotetheme()
{
	document.getElementById('divvotetheme').style.display = 'block';
	var taille = getAbsX(document.getElementById('btvote'))- 100;
	document.getElementById('divvotetheme').style.left =  taille + "px";
	document.getElementById('divvotetheme').style.top = getAbsY(document.getElementById('btvote')) - 200 + "px" ;
}

getOffsetPosition = function(inID, inTYPE)
{
 var iVal = 0;
 var oObj = document.getElementById(inID);
 var sType = 'oObj.offset' + inTYPE;
 while (oObj && oObj.tagName != 'BODY') {
  iVal += eval(sType);
  oObj = oObj.offsetParent;
 }
 return iVal;
}

function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }
function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }
function getAbsPos(elt,which) {
   iPos = 0;
   while (elt != null) {
      iPos += elt["offset" + which];
      elt = elt.offsetParent;
   }
   return iPos;
}

function goURLselect() {
	//url=selectaffichage.options[selectaffichage.SelectedIndex].value ;
	//alert(document.forms.formaffichage.selectaffichage.selectedIndex);
	//alert(document.getElementById('selectaffichage').options[document.getElementById('selectaffichage').selectedIndex].value);
url= document.getElementById('selectaffichage').options[document.getElementById('selectaffichage').selectedIndex].value ;
//alert(url);
/*getElementById('tonForm').action=url ;
getElementById('tonForm').submit() ;*/

window.location.href = url;
}

function vote_portfolio(choice)
{
	//alert(choice);
	document.forms['formvoteportfolio'].elements.choix.value= choice;		
		document.forms['formvoteportfolio'].submit( );
}

function submitgestionphotoadmin()
{
	 var mode = document.getElementById('form_choix').options[document.getElementById('form_choix').selectedIndex].value;
	
	 if( (mode == 'sup' && confirm('Etes-vous sûr de vouloir supprimer ces photos ?')) || mode == 'app' )
	 {
		 document.forms['formulaire'].elements.isposted.value=1;		
		 document.forms['formulaire'].submit( );
	 }
	 else
	 {
		 return false;
	 }
}
