// JavaScript Document
//  Scriptlets code written by Jeremy Edmiston
//  The functions have been adapted from various sources
//  and re-written to provide maximum flexibility
//  and compatability with various browsers.

//Global Declarations
var ie = (document.all) ? true : false;

function toggleClass(objClass){
//  This function will toggle obj visibility of an Element
//  based on Element's Class
//  Works with IE and Mozilla based browsers

  if (getElementByClass(objClass).style.display=="none"){
    showClass(objClass)
  }else{
    hideClass(objClass)
  }
}

function hideClass(objClass){
//  This function will hide Elements by object Class
//  Works with IE and Mozilla based browsers

var elements = (ie) ? document.all : document.getElementsByTagName('*');
  for (i=0; i<elements.length; i++){
    if (elements[i].className==objClass){
      elements[i].style.display="none"
    }
  }
}

function hideClassMenu(){
//  This function will hide Elements by object Class
//  Works with IE and Mozilla based browsers

var elements = (ie) ? document.all : document.getElementsByTagName('*');
  for (i=0; i<elements.length; i++){
    if (elements[i].className=="menuhide"){
      elements[i].style.display="none"
    }
  }
}


function showClass(objClass){
//  This function will show Elements by object Class
//  Works with IE and Mozilla based browsers
var elements = (ie) ? document.all : document.getElementsByTagName('*');
  for (i=0; i<elements.length; i++){
    if (elements[i].className==objClass){
      elements[i].style.display="block"
    }
  }
}

function toggleID(objID){
//  This function will toggle obj visibility of an Element
//  based on Element's ID
//  Works with IE and Mozilla based browsers
var element = (ie) ? document.all(objID) : document.getElementById(objID);
  if (element.style.display=="none"){
    showID(objID)
  }else{
    hideID(objID)
  }
}

function hideID(objID){
//  This function will hide Elements by object ID
//  Works with IE and Mozilla based browsers
var element = (ie) ? document.all(objID) : document.getElementById(objID);
  element.style.display="none"
}

function showID(objID){
//  This function will show Elements by object ID
//  Works with IE and Mozilla based browsers
var element = (ie) ? document.all(objID) : document.getElementById(objID);
  element.style.display="block"
}

function getElementByClass(objClass){
//  This function is similar to 'getElementByID' since there
//  is no inherent function to get an element by it's class
//  Works with IE and Mozilla based browsers
var elements = (ie) ? document.all : document.getElementsByTagName('*');
  for (i=0; i<elements.length; i++){
    //alert(elements[i].className)
    //alert(objClass)
    if (elements[i].className==objClass){
    return elements[i]
    }
  }
}

// cacher les menus au demarrage
// source du code suivant : http://www.webreference.com/programming/javascript/onloads/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(hideClassMenu);

// OU simplement !!!!!!!!! 
//window.onload = hideClassMenu;

// Pop up
function pop_up(lien,windowWidth,windowHeight)
	{
	var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;
	window.open(lien,"_blank","width="+windowWidth+",height="+windowHeight+",left="+centerWidth+",top="+centerHeight+",toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no");
	}

// Arborescence générale
function show(id)
	{
	var d = document.getElementById(id);
	var hid = d.style.display;
	if (d){
		if (hid == "block"){
			d.style.display = 'none';
		}
		else{
			d.style.display = 'block';
	}	}	}
	
function show_only(id)
	{
	var d = document.getElementById(id);
	d.style.display = 'block';
	}
	
function hide_only(id)
	{
	var d = document.getElementById(id);
	d.style.display = 'none';
	}
	
function reset1() {
	//document.getElementById('search_menu2').selectedIndex = 0;
	document.getElementById('search_menu3').value= ''; 
	document.getElementById('search_menu4').value= ''; 
	document.forms['searchsubmit'].submit();
	}
function submitsearchmenu() {
	document.forms['searchsubmit'].submit();
	}
function reset2() {
	document.getElementById('search_menu1').selectedIndex = 0;
	document.getElementById('search_menu3').value= ''; 
	document.getElementById('search_menu4').value= ''; 
	}
function reset3() {
	document.getElementById('search_menu1').selectedIndex = 0;
	//document.getElementById('search_menu2').selectedIndex = 0;
	document.getElementById('search_menu4').value= '';
	}
function reset4() {
	document.getElementById('search_menu1').selectedIndex = 0;
	//document.getElementById('search_menu2').selectedIndex = 0;
	document.getElementById('search_menu3').value= ''; 
	}
	
function reset1_v2() {
	//document.getElementById('search_menu2').selectedIndex = 0;
	document.getElementById('searchnum').value= ''; 
	document.getElementById('searchstr').value= ''; 
	document.forms['searchsubmit'].submit();
	}
function reset3_v2() {
	document.getElementById('searchserie').selectedIndex = 0;
	//document.getElementById('search_menu2').selectedIndex = 0;
	document.getElementById('searchstr').value= '';
	}
function reset4_v2() {
	document.getElementById('searchserie').selectedIndex = 0;
	//document.getElementById('search_menu2').selectedIndex = 0;
	document.getElementById('searchnum').value= ''; 
	}
	
function calc_submit() {
	document.forms['calc'].submit();
	}

// Textarea qui s'etend (forumlaire de contact)
function checkRows(textArea){
	if (navigator.appName.indexOf("Microsoft Internet Explorer") == 0){
		textArea.style.overflow = 'visible';
		return;
		}
	while (
		textArea.rows > 4 &&
		textArea.scrollHeight < textArea.offsetHeight
		){
		textArea.rows--;
		}
	while (textArea.scrollHeight > textArea.offsetHeight){
		textArea.rows++;
		}
	return;
	}

