function openPopup(URLaction){
	popup = window.open(URLaction,"francebillet","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,top=0,left=0,copyhistory=0,channelmode=0,titlebar=0,width=600,height=600,top=50,left=0");
}

function checksubmit(d) {
	if(!d) {
		d=document.forms["searchFullTextForm"];
	}
	if(!d || !d.search){
		return false;
	}
	
	var value=d.search.value.replace(/^\s*/, '').replace(/\s*$/, '').toLowerCase(); 
	if (value.length==0) { 
		alert('Vous devez saisir au moins un mot.'); 
		return false;
	} 
	else { 
		for (var i=0; i<value.length; i++) { 
			if ('?????? abcdefghijklmnopqrstuvwxyz0123456789\''.indexOf(value.charAt(i))==-1) { 
				alert('Ne mettez pas de caract?re \''+value.charAt(i)+'\''); 
				return false; 
			} 
		} 
		d.submit(); 
		return true;
	}
}

function validateEmail(textfield) {
	if (textfield == null)
		return false;
		
	var regex = /^([a-zA-Z0-9]+(([\.\-\_]?[a-zA-Z0-9]+)+)?)\@(([a-zA-Z0-9]+[\.\-\_])+[a-zA-Z]{2,4})$/;
	
	if (regex.test(textfield))
		return true;
	else {
		alert ("format incorrect");
		return false;
	}
}

// JScript File
function getElement(id) {
	var element_style=null
	if (document.getElementById) {
		element_style=document.getElementById(id);
	} else if (document.all) {
		element_style=document.all[id];
	} else if (document.layers) {
		element_style=document.layers[id];
	} 
	return element_style;
}

function writeFlash(url, width, height){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('       codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"');
	document.write('          width="'+width+'"');
	document.write('         height="'+height+'">');
	document.write('   <param name="movie" ');
	document.write('         value="'+url+'" />');
	document.write('   <param name="quality"');
	document.write('         value="high" />');
	document.write('   <embed src="'+url+'" ');
	document.write('      quality="high" ');
	document.write('  pluginspage="http://www.macromedia.com/go/getflashplayer" ');
	document.write('         type="application/x-shockwave-flash"');
	document.write('        width="'+width+'"');
	document.write('       height="'+height+'">');
	document.write('   </embed>');
	document.write('</object>');
}

/**
 * Gestion des noeuds HTML
 */

function nextNode(elem) {
   do { elem=elem.nextSibling; } while (elem && elem.nodeType!=1);
   return elem;
}

function prevNode(elem) {
   do { elem=elem.previousSibling; } while (elem && elem.nodeType!=1);
   return elem;
}

function firstChild(elem) {
   elem = elem.firstChild;
   while (elem && elem.nodeType!=1) elem=elem.nextSibling;
   return elem;
}

function lastChild(elem) {
   elem = elem.lastChild;
   while (elem && elem.nodeType!=1) elem=elem.previousSibling;
   return elem;
}

function addEvent( obj, type, fn ) {
	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
   } else if (obj.attachEvent) {	
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function getMouseCoords(ev) {
   ev = ev || window.event;
   if (ev.pageX || ev.pageY) {
      return {x:ev.pageX, y:ev.pageY};
   } else return {
      x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
      y:event.clientY + document.body.scrollTop - document.body.clientTop
   };
}

function getBlockCoords(elem) {
      var parent = elem.offsetParent;
      var offsetLeft = elem.offsetLeft;
      var offsetTop = elem.offsetTop;
      while (parent) {
         offsetLeft += parent.offsetLeft;
         offsetTop += parent.offsetTop;
         parent = parent.offsetParent;
      }
      return {x:offsetLeft, y:offsetTop};
}

function split(assertion, indexable) {
   var i;
   var ret=[];
   var previous=null;
   var currentGroup=[];
   for (i=0; i<indexable.length; ++i) {
      if (i!=0 && !assertion(previous, indexable[i])) {
         ret.push(currentGroup);
         currentGroup=[];
      }
      currentGroup.push(indexable[i]);
      previous = indexable[i];
   }
   ret.push(currentGroup);
   return ret;
}

function filter(assertion, indexable) {
   var i=0;
   var ret=[];
   for (i=0; i<indexable.length; ++i) {
      if (assertion(indexable[i])) {
         ret.push( indexable[i]);
      }
   }
   return ret;
}

function getFirst(assertion, indexable) {
   function currified() {
      for (var i=0; i<arguments[0].length; ++i) {
         if (assertion(arguments[0][i])) {
            return arguments[0][i];
         }
      }
   }
   return arguments.length>1?currified(arguments[1]):currified;
}


function hasClass(className, elem) {
   var constraint = new RegExp("\\b"+className+"\\b");
   if (elem) {
      return constraint.test(elem.className);
   } else {
      return function() {
         return constraint.test(arguments[0].className);
      }
   }
}

function defined(arg) {
   return arg!=null;
}

function isNext(elem, other) {
   return nextNode(elem) == other;
}

function alignBlockBottoms(blocks) {
   var i;
   var heights = [];
   /* First collect the maximum value for bottom bound of each block */
   for (i=0; i<blocks.length; ++i) {
      heights.push(getBlockCoords(blocks[i]).y + blocks[i].offsetHeight);
   }
   var maxHeight = Math.max.apply(this, heights);
   /* Then extends the padding of each block with a spacer */
   for (i=0; i<blocks.length; ++i) {
      if (maxHeight != heights[i]) {
         var spacer = document.createElement("div");
         spacer.style.height = (maxHeight - heights[i])+"px";
		 spacer.style.fontSize = "1%";
         blocks[i].appendChild(spacer);
      }
   }
}

/**********
* $n : objet de parcours du DOM, facile. Les fonctions ne font que les nodes HTML
***********/
var $n = {
	/* 	hasAttributes : retourne true si l'element passe en parametre correspond a tous les attributs passes, on peut aussi donner des attributs que l'on ne veut pas, afin de filtrer tous les &eacute;lements
		ex : if (hasAttributes(div, {nodeName:"div", className:"foobar"), {className:"idontwant"} ) doStuff();
		ici on recherche tous les DIV qui on la classe "foobar", mais on ne prend pas ceux qui ont la classe "idontwant" ex : <div class="foobar idontwant"> ne sera pas recupere.
	*/
	hasAttr : function(n, a, not) {
		var re, at;
		if (n.nodeType!=1) return false;
		function check(attr) {
			for (var i in attr) {
				at = (typeof n[i]) !="undefined" ? n[i] : n.getAttribute(i);
				re = attr[i] instanceof RegExp ? re : new RegExp("\\b" + attr[i] + "\\b","i");
				if (!at || !re.test(at)) 
					return false;
			}
			return true;
		};
		if (not && check(not))	return false;
		if (check(a)) return true;
		return false;
	},
	/* getByTagName : equivalent a element.getElementsByTagName, mais compatible avec IE5 et IE5.5 pour l'histoire du "*" */
	getByTagName : function(n, tag) {
		return  (tag=="*") ? (n.all ? n.all : n.getElementsByTagName("*")) : n.getElementsByTagName(tag);
	},
	/* fonction qui retourne le premier element correspondant aux attributs donnes */
	node : function(n, a, not) {
		return $n.nodes(n, a, not, true);
	},
	/* fonction qui retourne tous les elements correspondant selon "a" */
	nodes : function(n, a, not, oneNode, arrElms) {
		var aRetElms=[];
		if (!a) a = {};
		if (typeof a == "string") a = {nodeName:a}; //si une chaine de caract&egrave;res pass&eacute;e en param&egrave;tre, cela signifie qu'on ne veut que r&eacute;cup&eacute;rer des tags
		if (a.nodeName && a.nodeName=="*") delete a.nodeName;
		var elms = arrElms || $n.getByTagName(n, (a.nodeName || "*"));
		for (var i=0; i<elms.length; i++) {
			var x = elms[i];
			if ($n.hasAttr(x, a, not)) {
				if (oneNode) return x;
				else aRetElms.push(x);
			}
		}
		if (oneNode) return null;
		return aRetElms;
	},
	/* childs : retourne tous les noeuds enfants de l'element  */
	childs : function(n, a, not) {
		return $n.nodes(n, a, not, false, n.childNodes);
	},
	firstChild : function(n, a, not) {
		return $n.nodes(n, a, not, true, n.childNodes);
	},
	lastChild : function(n, a, not) {
		var node = $n.nodes(n, a, not, false, n.childNodes);
		return node[node.length-1];
	},
	move : function(n, a, not, action) {
		while (n) {
			if ($n.hasAttr(n, a, not)) return n;
			n = n[action];
		}
		return null;
	},
	after : function(n, a, not) { 
		return $n.move(n, a, not, "nextSibling");
	},
	before : function(n, a, not) {
		return $n.move(n, a, not, "previousSibling");
	},
	parent : function(n, a, not) {
		return $n.move(n, a, not, "parentNode");
	}
}
/* fonctions raccourcis */
var getNode = $n.node,
	getNodes = $n.nodes,
	getChildNodes = $n.childs,
	getNextSibling = $n.after,
	getPreviousSibling = $n.before,
	getParent = $n.parent,
	hasAttributes = $n.hasAttr,
	getElementsByTagName = $n.getByTagName;

/********
* onglets
********/
var tabs = {
	blockClass : "(sub)?tabs(gris)?(noir)?",
	headClass : "tabshead",
	tabContainerClass : "tabscontainer",
	tabContentClass : "tabcontent",
	currentTabClass : "current",
	currentTabContentClass : "tabcurrent",
	init : function(elm) {
		var ul = getNode(elm, {nodeName:"ul"});
		if (!ul) return;
		var a = ul.getElementsByTagName("a");
		for (var i=0; i<a.length; i++) {
			if (!hasAttributes(a[i], {className:"nochange"}))  {
				a[i].onclick = function() {
					tabs.change(this);
					return false;
				}
				this.size(a[i], ul);
			}
		}
	},
	size : function(a, ul) {
		a.style[heightPropertyToUse] = a.offsetHeight + (ul.offsetHeight-a.offsetHeight) - getVStyles(a) + "px";
	},
	change : function(elm) {
		/*alert("CHANGE");*/
		var i, n, tabs, ul, li, body, tabCtns, current=0, block;
		ul = getParent(elm, {nodeName:"ul", className:this.headClass});
		li = getParent(elm, {nodeName:"li"});
		tabs = ul.getElementsByTagName("li");
		block = getParent(ul, {nodeName:"div", className:this.blockClass});
		// get What is the index of the new Tab and remove otherClass "current"
		for (var i=0; i<tabs.length; i++) {
			if (tabs[i]==li) {
				current = i;
				this.addClass(li, this.currentTabClass);
			} else {
				this.removeClass(tabs[i], this.currentTabClass);
			}
		}
		//get the tabCtn blocks, and show the contentTab that is match with clicked tab
		body = getNode(block, {nodeName:"div", className:this.tabContainerClass});
		tabCtns = getChildNodes(body, {nodeName:"div", className:this.tabContentClass});
		for (i=0; i<tabCtns.length; i++) {
			n = tabCtns[i];
			this.removeClass(n, this.currentTabContentClass);
			if (i==current) {
				this.addClass(n , this.currentTabContentClass);
			}
		}
	},
	addClass : function(elm, className) {
		elm.className += " " + className;
	},
	removeClass : function(elm, className) {
		elm.className = elm.className.replace(new RegExp("\\b" + className + "\\b","g"), "");
	}
}


/* inputValue : function
	Permet de mettre le texte par defaut d'un champ de type texte.
*/ 
function inputValue(elm, state) {
	elm.oldValue=elm.value;
	elm.onfocus=function() {
		if (!this.isChecking && this.value==this.oldValue) this.value='';			
	}
	elm.onblur=function() {
		if(this.value=='') this.value=this.oldValue;
	}
	if (!elm.isChecking) elm.onfocus();
}

addEvent(window, "load", (function() {
var all = document.getElementsByTagName("div");
   var blocks = filter(hasClass("oneOfThree"), all);
   var groups = split(isNext, blocks);
   for (var i=0; i<groups.length; ++i) {
      for (var j=0; j<groups[i].length; ++j) {
         groups[i][j] = getFirst(
            hasClass("blk_content"),
            groups[i][j].getElementsByTagName("div")
         );
     }
      alignBlockBottoms(filter(defined, groups[i]));
   }
}));