String.prototype.classExists=function class_exists(classe){
  if(this!=""){
    all_class=this;
    var ar_all_class=all_class.split(' ');
    for(o=0;o<ar_all_class.length;o++){
      if(ar_all_class[o]==classe){
        return true;
        break;
      }
    }
    return false;
  }
  else{
    return false;
  }
}

function startmenu(){
  var all_ext=new Array();
  all_ext=document.getElementById('menu').getElementsByTagName('li');
  for(i=0;i<all_ext.length;i++){
    var the_li=all_ext[i];
    if(the_li.className.classExists('first')){
      the_li.onmouseover=function(){
        if(this.getElementsByTagName('ul').length>0){
          this.getElementsByTagName('ul')[0].style.display="block";
          ul=this.getElementsByTagName('ul')[0];
          lis=ul.getElementsByTagName('li');
          for(li=0;li<lis.length;li++){
            lis[li].style.display="block";
          }
        }
      }
      the_li.onmouseout=function(){
        if(this.getElementsByTagName('ul').length>0){
          this.getElementsByTagName('ul')[0].style.display="none";
        }
      }
    }
  }
}

function start_newWindow(){
  var all_ext=new Array();
  all_ext=document.getElementsByTagName('a');
  for(i=0;i<all_ext.length;i++){
    var the_a=all_ext[i];
    if(the_a.rel=='new_window'){
      the_a.target='_blank';
      the_a.title+=' || nouvelle fenêtre';
    }
  }
}

function get_ajax_link(old_link){
  return old_link.substring(old_link.indexOf('admin', 0));
}

function file(fichier)
     {
     if(window.XMLHttpRequest) // FIREFOX
          xhr_object = new XMLHttpRequest();
     else if(window.ActiveXObject) // IE
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
     else
          return(false);
     xhr_object.open("GET", fichier, false);
     xhr_object.send(null);
     if(xhr_object.readyState == 4) return(xhr_object.responseText);
     else return(false);
}

function init(){
  startmenu();
  start_newWindow();
}

window.onload=function(){
  init();
}

function dgid(what){
	return document.getElementById(what);
}


function disableselect(e){

if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null) {
if (e.which > 2){
return false;
}
}
else
if (e.button>=2)return false;
}

function reEnable(){
return true
}

//if IE4+
document.onselectstart=new Function ("return false")
document.oncontextmenu=new Function ("return false")
//if NS6
if (window.sidebar){

document.onmousedown=disableselect
document.onclick=reEnable
}



function display_message(m) {
$('body').append('<div class="quick-alert"><p class="close-quick-alert"><a href="#" class="close-quick-alert">fermer</a></p>'+m+'</div>');
	$('div.quick-alert a.close-quick-alert').click(function()
		{
			$(this).parent().parent().remove();
			return false;
		}
	);
	$('div.quick-alert').Draggable(
		{snapDistance: 10, opacity: '0.5', zindex: '300'}
	);
}