


//** Dynamic Drive Equal Columns Height script v1.01 (Nov 2nd, 06)
//** http://www.dynamicdrive.com/style/blog/entry/css-equal-columns-height-script/

var ddequalcolumns=new Object()
//Input IDs (id attr) of columns to equalize. Script will check if each corresponding column actually exists:
ddequalcolumns.columnswatch=["leftcolumn", "contentwrapper"]

//Input IDs of Top and Bottom rows (Header and Footer)
ddequalcolumns.rowswatch=["topsection", "footer"]



ddequalcolumns.setHeights=function(reset){

//Calculate total height of header and footer save in variable t, why t?. Good Question.
t=0;
for (var j=0; j<this.rowswatch.length; j++){
if (document.getElementById(this.rowswatch[j])!=null){
var ptop = document.getElementById(this.rowswatch[j]).offsetHeight;
var t = t + ptop;
}

}

//Get padding (top and bottom) set for the body in stylesheet
pad=0
var RefDiv = document.body;
if( window.getComputedStyle ) {
var tpad = getComputedStyle(RefDiv,null).getPropertyValue("padding-top");
var bpad = getComputedStyle(RefDiv,null).getPropertyValue("padding-bottom");
} else if( RefDiv.currentStyle ) {
var tpad = RefDiv.currentStyle.paddingTop;
var bpad = RefDiv.currentStyle.paddingBottom;
}
bpad=parseInt(bpad);
tpad=parseInt(tpad);
pad = bpad+tpad;

//Set tallest to screen height minus header, footer, and any body padding (top and bottom)

var tallest=(document.documentElement.clientHeight)-t-pad;


//var tallest=0
var resetit=(typeof reset=="string")? true : false
for (var i=0; i<this.columnswatch.length; i++){
if (document.getElementById(this.columnswatch[i])!=null){
if (resetit)
document.getElementById(this.columnswatch[i]).style.height="auto"
if (document.getElementById(this.columnswatch[i]).offsetHeight>tallest)
tallest=document.getElementById(this.columnswatch[i]).offsetHeight
}
}
if (tallest>0){
for (var i=0; i<this.columnswatch.length; i++){
if (document.getElementById(this.columnswatch[i])!=null)
document.getElementById(this.columnswatch[i]).style.height=tallest+"px"
}
}
}

ddequalcolumns.resetHeights=function(){
//	alert('resetHeights');
this.setHeights("reset")
}

ddequalcolumns.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
}

//ddequalcolumns.dotask(window, function(){ddequalcolumns.setHeights()}, "load")
//ddequalcolumns.dotask(window, function(){if (typeof ddequalcolumns.timer!="undefined") clearTimeout(ddequalcolumns.timer); ddequalcolumns.timer=setTimeout("ddequalcolumns.resetHeights()", 2000)}, "resize")

 
 //**********************************************************************
//http://www.phpied.com/javascript-include/     (include js and css)
//**********************************************************************
var included_files = new Array();
function include_once(script_filename) {
  if (!in_array(script_filename, included_files)) {
    included_files[included_files.length] = script_filename;
    include_dom(script_filename);
  }
}
function include_dom(script_filename) {
  var html_doc = document.getElementsByTagName('head').item(0);
  t=script_filename.substring(script_filename.lastIndexOf('.')+1);
  if (t=='js'){
    var file = document.createElement('script');
    file.setAttribute('language','javascript');
    file.setAttribute('type','text/javascript');
    file.setAttribute('src',script_filename);
  }else if (t=='css'){
    var file = document.createElement('link');
    file.setAttribute('rel','stylesheet');
    file.setAttribute('type','text/css');
    file.setAttribute('href',script_filename);
  }
  html_doc.appendChild(file);
  return false;
}
function in_array(needle, haystack) {
  for (var i = 0; i < haystack.length; i++) {
    if (haystack[i] == needle) {
      return true;
    }
  }
  return false;
}
//**********************************************************************
/*

include_once('../js/windows_js/javascripts/effects.js'); 
include_once('../js/windows_js/javascripts/window.js'); 
include_once('../js/windows_js/javascripts/window_ext.js'); 
include_once('../js/windows_js/javascripts/debug.js'); 

include_once('../js/windows_js/themes/default.css'); 
include_once('../js/windows_js/themes/alert.css'); 
include_once('../js/windows_js/themes/alphacube.css');
include_once('../js/windows_js/themes/debug.css');	
*/


 function eventSurForm() {

//   Dialog.alert("Add your <b>HTML</b> message here", {windowParameters: {className: "alphacube"}})
//  alert('je suis dans  eventSurForm()');
	if($('user-form')){
		Event.observe('user-form', 'submit',  function(event){openConfirm(event);}, false);
	}
}
 
 
  function openConfirm(event) {

	var url = 'info_panel.php';
	var pars = 'user-name='+escape($F('user-name'));
	//$('user-name').serialize();
	var target = 'popundercontent';
//	alert(pars);


	var myAjax = new Ajax.Updater(target, url, {method: 'get',onComplete: eventSurForm, parameters: pars});

	//alert('je suis dans  openConfirm()');
	Event.stop(event);
	return false;

  // Dialog.confirm("Add your <b>HTML</b> message here<br/>Better than a classic javascript alert?", {top: 10, width:250, className: "alphacube", okLabel: "Yes", cancelLabel:"No"})
 // parameters: $('id_of_form_element').serialize(true)
 }
  


Event.observe(window, 'load', function(){
											ddequalcolumns.setHeights();
											if($('transition')){
												Event.observe('transition','click',function(event){openAjaxConfirm3(event);});
											}
											if($('online')){
												Event.observe('online','click',function(event){openAjaxConfirm5(event);});
											}		
										/*	if($('demoElal')){
												Event.observe('demoElal','click',function(event){openAjaxConfirm2(event);});
											}	*/
										}, false);
Event.observe(window, 'resize',  function(){ddequalcolumns.resetHeights();}, false);

//Event.observe('demo','click',openAjaxConfirm(event),false);









	// Défilement 4 directions multiple

	function Defilant(id, pos_init, pos_min, pos_max, delta, direction) {

	   this.id          = id;

	   this.element     = document.getElementById(id);

	   this.pos_init    = pos_init;

	   this.pos_min     = pos_min;

	   this.pos_max     = pos_max;

	   this.pos_current = pos_init;

	   this.delta       = delta;

	   this.direction   = direction;

	}

       

	Defilant.prototype.defile = function() {

	   if (!this.element) {

	      this.element = document.getElementById(this.id);

	   }

	   if (this.element) {

	      if(this.direction == 'vertical'){

	         if(this.pos_current < (this.pos_min - this.element.offsetHeight) ){

	            this.pos_current = this.pos_init;

	         } else if (this.pos_current > this.pos_max ) {

	            this.pos_current = this.pos_init - this.element.offsetHeight;

	         } else {

	            this.pos_current += this.delta;

	         }

	         this.element.style.top = this.pos_current+"px";

	      } else if(this.direction == 'horizontal') {

	         if(this.pos_current < (this.pos_min - this.element.offsetWidth) ){

	            this.pos_current = this.pos_init;

	         } else if (this.pos_current > this.pos_max ) {

	            this.pos_current = this.pos_init - this.element.offsetWidth;

	         } else {

	            this.pos_current += this.delta;

	         }

	         this.element.style.left = this.pos_current+"px";

	      }

	   }

	}




