// JavaScript Document - GENERAL

<!--RANDOM-->
function random_nbr(min_nbr,max_nbr){
	return Math.round((Math.random() * (max_nbr - min_nbr)) + min_nbr);
}

<!--SHOW HIDE-->
function show_hide(Id){	
	obj_status = document.getElementById(Id).style.visibility;
	if(obj_status=="hidden"){document.getElementById(Id).style.visibility = "visible";}
	if(obj_status=="visible"){document.getElementById(Id).style.visibility = "hidden";}	
}

<!--LOAD PAGE-->
function load_page(new_location){
	window.location = new_location;
}

<!--CHANGE CLASS-->
function changeClass(object, newClass){
	object.className = newClass;
}

<!--CHANGE CLASS BY ID-->
function changeClassID(id, newClass){
	document.getElementById(id).className=newClass;
}

//---------------------------------------------------------------------------------------------------------------------------------------

function multipleOf(nbrX, nbrY){
	//if X is a multiple of Y return true
	nbr = nbrX/nbrY;
	nbrInteger = Math.floor(nbrX/nbrY);
	if(nbr==nbrInteger){
		//It's a round number, so it was a multiple
		return true;
	}
	else{return false;}

}

//---------------------------------------------------------------------------------------------------------------------------------------
function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

/*
function defineTopLeft(w,h) {
	//defines the variable left and top when we wants to center a pop up
	var the_left = (screen.width - w) / 2;
	var the_top = (screen.height - h) / 2;
}
*/

//OPEN POPUP SWF IN THE CENTER AND WITHOUT MARGINS -----------------------------------------------------------------------------------------

function open_centered(the_type, the_link, the_name, the_width, the_height){
	var the_left = (screen.width - the_width) / 2;
	var the_top = (screen.height - the_height) / 2;
	var openedWindow=window.open('', removeSpaces(the_name),'width='+the_width+', height='+the_height+', top='+the_top+', left='+the_left+', screenX='+the_top+', screenY='+the_left+', resizable=0');
		
	openedWindow.document.write('<html><head><title>'+the_name+'</title>');
	openedWindow.document.write('</head><body style="margin: 0px; padding: 0px; cursor=pointer" onClick="window.close();">');
	if(the_type == 'swf'){
		openedWindow.document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+the_width+'" height="'+the_height+'">'+
         	'<param name="movie" value="'+the_link+'">'+
          	'<param name="quality" value="high">'+
          	'<embed src="'+the_link+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+the_width+'" height="'+the_height+'"></embed></object>');
	}
	else{
		openedWindow.document.write('<img src="'+the_link+'" alt="Fermer">');
	}	
  
  	openedWindow.document.write('</body></html>');
}

//CHANGE THE VALUE WRITEN IN A DIV -------------------------------------------------------------------------------------------------------


var ns4 = (document.layers)? true:false;         //NS 4
var ie4 = (document.all)? true:false;            //IE 4
var dom = (document.getElementById)? true:false; //NS 6 ou IE 5

function SetDiv(ID,Content) {
      if (dom) {
      document.getElementById(ID).innerHTML = Content;
         return;
      }
      if (ie4) {
          document.all[ID].innerHTML = Content;
         return;
      }
      if (ns4) {
          with (eval('document.'+ID+'.document')) {
             open();
             write(Content);
             close();
         }
         return;
      }
   }
   
/*Check all elements of a form fields must be separated by a ", "*/
<!--
function checkAll(formName,fieldList,change){
	var tableFields = new Array();
	tableFields = fieldList.split(", ");
	var newState;
	if (change=="uncheck"){
		newState = false;
	}
	else{
		newState = true;
	}
	for (iField = 0; iField < tableFields.length; iField++){
		objCheckBoxes = document.forms[formName].elements[tableFields[iField]];	
		objCheckBoxes.checked = newState;
	}
}
