// JavaScript Document

/* This algorithm will fail with IE 6+ in 'standards compliant
 mode' if the window is shrunk to 0px by 0px. This is only
 possible when the user actively shrinks the window to hide
 the page within it. Even then, it will just give the height
 of the document instead, so it should not be a problem.
 The following code performs the algorithm as described. */

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  /* Maintenant je vais redimentionner la TD du corps du site
  à la hauteur gébérale moin le haut et le menu du site */ 
  if (sidebar){
    $(sidebar).style.height = myHeight - 260;
  }
}

//Tu lui passe en parametre le lien que tu veux lancer
//et il lel fait pour toi
// EX : onclick="RetourAccueil('<?=$wwwroot?>/index.php'
function RetourAccueil(MonLien){ 
  window.location = MonLien;
}

function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;
}

function getAllChildren(e) {
  // Returns all children of element. Workaround required for IE5/Windows. Ugh.
  return e.all ? e.all : e.getElementsByTagName('*');
}

//KHO DEBUT Surlligné les lignes des chekbox qui ne sont pas cochés...

function ActiverChekbox()
{
  var allForm = document.forms("ChronosUpdateForm");
  var objForm;
  var id;
  for(j=0;j<allForm.length;j++)
  {
    objForm = allForm[j];
    for(i=0;i<objForm.length;i++)
    {
      if(objForm[i].type=="checkbox")
      {
        id =objForm[i].id.substr(20);
        
        if(objForm[i].checked)
        {
          $("validchronostext" + id).style.color = '#666666';
          $("validchronostext" + id).style.textDecorationLineThrough = true
        }
        else
        {

          $("validchronostext" + id).style.color = '#4284B0';
          $("validchronostext" + id).style.textDecorationNone = true;          
        }
      }
    }
  }
}

function toggleBlock(id, linkid)
{
  if (document.getElementById(id).style.display == 'none')
  {
    document.getElementById(id).style.display = 'block';
    document.getElementById(linkid).innerHTML = 'Fermer'
  } else {
    document.getElementById(id).style.display = 'none';
    document.getElementById(linkid).innerHTML = 'Lire la suite'
  }
}


function limiteur(ValMax)
{
maximum = ValMax;
champ = document.entryform.description;
indic = document.entryform.indicateur;

if (champ.value.length > maximum)
  champ.value = champ.value.substring(0, maximum);
else 
  indic.value = maximum - champ.value.length;
}
    
    
//Sert à faire des liste déroulantes dépendantes    
function gestion_list() {
	if (emploi_form.typeemploi.selectedIndex != 0) {
		emploi_form.newemploi.disabled = true;
		document.getElementById("newemploi").style.backgroundColor = '#CCCCCC';		
		//emploi_form.newemploi.value = true;
	}else {
		emploi_form.newemploi.disabled = false;
		document.getElementById("newemploi").style.backgroundColor = '#F4F4F4';	
		//emploi_form.newemploi.value = true;
	}
}

function gestion_list_annuaire() {
	if (entryform.specialite1.selectedIndex != 0) {
	//alert(entryform.specialite1.selectedIndex);
		entryform.new_specialite.disabled = true;
		document.getElementById("new_specialite").style.backgroundColor = '#CCCCCC';
		//emploi_form.newemploi.value = true;
	}else {
		entryform.new_specialite.disabled = false;
		document.getElementById("new_specialite").style.backgroundColor = '#F4F4F4';
		//emploi_form.newemploi.value = true;
	}
}

// begin Current Page Reference
// Cette fonction récupere le nom de la page en cours ex: index pour index.html
function getURL(uri) {
  uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
  uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
  uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
  uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
  pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
  pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
  uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
  uri.file = uri.page;
  if (uri.ext != '') uri.file += '.' + uri.ext;
  if (uri.file == '') uri.page = 'index';
  uri.args = location.search.substr(1).split("?");
  return uri;
}
var uri = new Object();
getURL(uri);
// End Current Page Reference

//Gestion de suppresion des items dans les comptes compte.php
function changeObject(idObj, action, libelleObj)
{
    var objForm = $('aspnetForm');
    var doIt = false;
    
    if(action=="S")
    {
     if (confirm("Voulez vous supprimer cette ligne : " + libelleObj + " ?"))
        doIt = true;
    }else
        doIt = true;
    
    if(doIt)
    {
        objForm.idObj.value = idObj;
        objForm.action.value = action;
        objForm.submit();
    }
}
