function openLicenceVierge(e, dispatch, lsl_icod, returnMapping, returnDispatch, openerForm, openerDispatch)  {
	var url = "TlicLicenceVierge.do";
	url += "?dispatch=" + dispatch;
	url += "&returnMapping=" + returnMapping;
	url += "&returnDispatch=" + returnDispatch;
	url += "&openerForm=" + openerForm;
	url += "&openerDispatch=" + openerDispatch;
	url += "&lsl_icod=" + lsl_icod;
	openPopup(url, 1024, 768, 1, e);
}

/**
 * TOOLS
 */
 
function afficherTitre(){
	alert("bobo");
}
 
function get_form_element(form_name, element_name) {
	return document.forms[form_name].elements[element_name];
}
function get_form_element_from(p_opener, p_formName, p_elementName) {
	return p_opener.document.forms[p_formName].elements[p_elementName];
}


function get_element(id) {
	if (document.getElementById) { return document.getElementById(id); }
	else if (document.all) { return document.all(id); }
	else if (document.layers) { return document.layers[id]; }
	else { return false; }
}
function get_element_from_opener(opener, id) {
	if (document.getElementById) { return opener.document.getElementById(id); }
	else if (document.all) { return opener.document.all(id); } 
	else if (document.layers) { return opener.document.layers[id]; }
	else { return false; }
}
function get_elements_by_tag_name(p_sName) {
	if (document.getElementsByTagName) { return document.getElementsByTagName(p_sName); }
	else { return false; }
}
function get_elements_by_tag_name_from(p_oFrom, p_sName) {
	if (p_oFrom.getElementsByTagName) { return p_oFrom.getElementsByTagName(p_sName); }
	else { return false; }
}


/* hides <select> and <applet> objects (for IE only) */
function hideElement( elmID, overDiv ) {
    var elms = get_elements_by_tag_name(elmID);
    if (!elms) {
        return false;
    }
    
    for( i = 0; i < elms.length; i++ ) {
      obj = elms.item(i);
      if( !obj || !obj.offsetParent ) {
        continue;
      }
    
      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
      objLeft   = obj.offsetLeft;
      objTop    = obj.offsetTop;
      objParent = obj.offsetParent;
    
      while( objParent.tagName.toUpperCase() != "BODY" ) {
        objLeft  += objParent.offsetLeft;
        objTop   += objParent.offsetTop;
        objParent = objParent.offsetParent;
      }
    
      objHeight = obj.offsetHeight;
      objWidth = obj.offsetWidth;
    
      if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
      else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
      else if( overDiv.offsetTop >= ( objTop + objHeight ));
      else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
      else {
        obj.style.visibility = "hidden";
      }
    }
}

/*
* unhides <select> and <applet> objects (for IE only)
*/
function showElement( elmID ) {
    var elms = get_elements_by_tag_name(elmID);
    if (!elms) {
        return false;
    }

    for( i = 0; i < elms.length; i++ ) {
      obj = elms.item(i);

      if( !obj || !obj.offsetParent ) {
        continue;
      }

      obj.style.visibility = "";
    }
}

function afterSave() { 
	window.close();
	var previousHref = "";
	if (afterSave.arguments[0]) 
	{
		previousHref = arguments[0];
	}
	else 
	{
		previousHref = window.opener.location.href;
		if (previousHref.indexOf("dispatch")==-1) {
			previousHref += "?dispatch=load";
		}
	alert(previousHref);
	}
	// si la page précédente a été affichée après un 'POST' le paramètre dispatch n'existe pas
	window.opener.location.href = previousHref;
	alert(previousHref);
	window.opener.focus(); 
}

function sizeDiv(id,entete,pForm,pField,widthDiv){
	var size = document.forms[pForm].elements[pField].value;
	
	document.getElementById(id).style.width = widthDiv;
	if(size==0){
		document.getElementById(id).style.height = entete + "px";
	}
	if(size>0 && size<11){
		document.getElementById(id).style.height = entete + (size *24) +"px";
	}
	if(size>10){
		document.getElementById(id).style.height = "300px";
	}
}

function resizeDiv(tableId,divId,maxheigth){ 
	oTable = document.getElementById(tableId);
	var h;
	var l;

	if (oTable != null) {
	
		if (oTable.innerHeight) h = oTable.innerHeight;
		else if (oTable.offsetHeight) h = oTable.offsetHeight;
						
		if (oTable.innerWidth) l = oTable.innerWidth;
		else if (oTable.offsetWidth) l = oTable.offsetWidth;
				
		if (h <= maxheigth )  maxheigth = h;
		document.getElementById(divId).style.height = maxheigth;
		document.getElementById(divId).style.width = l + 15;
	}
}


/**
 * ERROR
 */
// appellée sur le onSubmit de la page d'erreur
// vérifie que l'utilisateur ne se trouve pas sur une popup -> fermeture popup
function checkWindow(p_oForm) { if (window.opener) { window.opener.parent.location.href = p_oForm.action; window.close(); window.opener.focus(); } return true; }

/**
 * SELCTIONNER Tous / Aucun
 */
// coche toutes les cases p_sElementName de p_sFormName
function selectAll(p_sElementName, p_sFormName) { checked(true, p_sElementName, p_sFormName); }
// décoche toutes les cases p_sElementName de p_sFormName
function unselectAll(p_sElementName, p_sFormName) { checked(false, p_sElementName, p_sFormName); }
function checked(value, p_sElementName, p_sFormName) { var form = document.forms[p_sFormName]; for (var i=0; i<form.length; i++) {	var element = form.elements[i]; if (element.name==p_sElementName && element.type=="checkbox") { element.checked = value; } } }

/**
 * SUBMIT
 */
 
             						
function confirmsuppr(pform,pchaine){
	if (confirm(pchaine + " ?")) {
		return pform.submit();
	}
	return false;
}


function confirmSupprParam(pform,pchaine,pmillesime){
	if (confirm(pchaine + " ?")) {
		window.location.href="TciPoidsLiguesParm.do?dispatch=supprimerParam&millSisport="+pmillesime;
	}
}

function confirmSupprArbChaise(pform,pchaine,pren_iid,pParam){
	if (confirm(pchaine)) {
		window.location.href="TciProgArbitreInsert.do?dispatch=supprimerChaise&ren_iid="+pren_iid+"&param="+pParam;
	}
}

function confirmSupprArbLigne(pform,pchaine,pren_iid,pParam){
	if (confirm(pchaine)) {
		window.location.href="TciProgArbitreInsert.do?dispatch=supprimerLigne&ren_iid="+pren_iid+"&param="+pParam;
	}
}

function confirmAct(pform,pchaine,act){
	if (confirm(pchaine + " ?")) {
		pform.elements["dispatch"].value = act
		pform.submit();
		
	}
}


function confirmBox(pForm,pChaine){
	if( confirm(pChaine)){
		pForm.submit();
	}
}


function confirmcloture(pform){
			
	var liste = pform.elements["listAction"] ;
	var test = liste.options[liste.selectedIndex].text ;
						
	if (confirm("Confirmez-vous la " + test +" des épreuves sélectionnées ?")) {
		pform.elements["dispatch"].value = "cloturer"
		pform.submit();
	}
}


/**
 * Validation de champs
 */

function verif_ccp(sCp,sParam){
			
	if (sCp == null || sCp =='')
		{alert("Vous devez saisir un code postal");return false;}
	else if (sCp.length != 5)
		{alert("Le code postal doit avoir 5 caractères");return false;}
	else
		openPopup('TlicListeVille.do?dispatch=load&Cp='+sCp+'&param='+sParam, 450, 350, 2, event);
}

/**
 * Confirm Box
 */
 
// demande de confirmation : si 'text' confirmé -> goto 'url'
function confirmUrl(text, url) {
	if (confirm(text)) { window.location = url; }
}



/**
 * Change URL
 */

function changeUrl(param){
    var s_entree = document.forms['TciEntreeTableauForm'].elements['entreeDisp'].value;
        
    window.location = param+'&no_entree='+s_entree;
}

function validActionTab(pForm,pChaineV){

    var action = pForm.elements['listAction'].value;
    var epr_iid_sel = pForm.elements['nae_icod'].value;
    var typTetSer = pForm.elements['type_tete_serie'].value;
    var joueurAffect = pForm.elements['joueur_aff'].value;

		if(action == '1'){
    		openPopup('TciTeteSerieAffect.do?dispatch=load&epr_iid='+ epr_iid_sel +'&typ_tet_ser=' + typTetSer +'&joueurAff=' + joueurAffect , 650, 175, 1, event);
    	}

    	if(action == '2'){
    		if (confirm('Confirmez-vous la suppression des entrées du tableau ?'))
    		window.location = 'TciEntreeTableau.do?dispatch=vider&action=2&epr_iid='+ epr_iid_sel;
	    	}

    	if(action == '3'){
    		if (confirm('Confirmez-vous la clôture du tableau ?'))
    		window.location = 'TciEntreeTableau.do?dispatch=vider&action=3&epr_iid='+ epr_iid_sel;
    	}
    }
    
/**
 * Inactivation de champs
 */
 
 function inactivefield(p_form){
		
			if (p_form.elements['car_atype_remu'].value == "J") {
				p_form.elements['car_dcfor_set_ch'].disabled =true;
				p_form.elements['car_dcfor_set_li'].disabled =true;
			}
			if (p_form.elements['car_atype_remu'].value == "S") {
				if (p_form.elements['car_atype_arb'].value == "C") {
					p_form.elements['car_dcforfait_jour'].disabled =true;
					p_form.elements['car_dcfor_set_li'].disabled =true;
					//on réactive le champ au cas ou il aurait été désactivé lors d'une erreur de sélection de type de rémunération
					p_form.elements['car_dcfor_set_ch'].disabled=false;
					p_form.elements['car_dcfor_set_ch'].focus();
				}
				if (p_form.elements['car_atype_arb'].value == "L") {
					p_form.elements['car_dcfor_set_ch'].disabled =true;
					p_form.elements['car_dcforfait_jour'].disabled =true;
					//on réactive le champ au cas ou il aurait été désactivé lors d'une erreur de sélection de type de rémunération
					p_form.elements['car_dcfor_set_li'].disabled=false;
					p_form.elements['car_dcfor_set_li'].focus();
				}
			}
		}
 

/**
 * Cocher des radio button
 */
								
function check(pform,a,b,a1,b1){
								
				var param = document.forms[pform].elements[a].value;
				var param2 = document.forms[pform].elements[b].value;
												
				switch(param) {
            		case "W":
            		 document.forms[pform].elements[a1][0].checked=true;break;
           			case "A":
           			 document.forms[pform].elements[a1][1].checked=true;break;
            		case "R":
            		 document.forms[pform].elements[a1][2].checked=true;break;
           			case "D":
           			 document.forms[pform].elements[a1][3].checked=true;break;
            		case "":
            		 document.forms[pform].elements[a1][4].checked=true;break;
            	}
            	switch(param2) {
            		case "V":
            		 document.forms[pform].elements[b1][0].checked=true;break;
           			case "D":
           			 document.forms[pform].elements[b1][1].checked=true;break;
				}
			}

/**
 * MENU
 */
function menuOnClick(p_oElement) {
	var aLink = get_elements_by_tag_name("a");
	if (!aLink) { return false; }
	for (var i=0; i<aLink.length; i++) { if (aLink[i].className == "treeView2") { aLink[i].style.color = ""; } }
	p_oElement.style.color = "red";
}

function menuOnLoad() { }

/**
 * DOUBLE LINK
 */
function openHomologation(url) { parent.frames[0].location.href = "top.do?dispatch=load"; parent.frames[2].location.href = url; }

/**
 * FRAME REFRESH
 */
function windowLocation(p_sUrl) { parent.location.href = p_sUrl; }

function topRefresh() { parent.frames[0].location.href = "top.do?dispatch=load"; }

function openHomol() { parent.frames[0].location.reload(); parent.frames[1].location.reload(); }
function openPhase() { parent.frames[0].location.reload(); }

function afterSave() { 
	window.close();
	var previousHref = "";
	if (afterSave.arguments[0]) 
	{
		previousHref = arguments[0];
	}
	else 
	{
		previousHref = window.opener.location.href;
		if (previousHref.indexOf("dispatch")==-1) {
			previousHref += "?dispatch=load";
		}
	}
	// si la page précédente a été affichée après un 'POST' le paramètre dispatch n'existe pas
	window.opener.location.href = previousHref;
	window.opener.focus(); 
}

/**
 * POPUP
 */
var popup = new Array();
// ouvre une modal
function openPopup(p_sUrl, p_sWidth, p_sHeight, p_iLevel, e) {
	var x = (screen.availWidth - p_sWidth) / 2;
	var y = (screen.availHeight - p_sHeight) / 2;
	popup[p_iLevel] = window.open(p_sUrl, 'popup'+p_iLevel, 'scrollbars=1, directories=0, location=0, menubar=0, status=1, toolbar=0, resizable=1, width=' + p_sWidth + ', height=' + p_sHeight + ', top=' + y + ', left=' + x); 	
	popup[p_iLevel].scrollbars = true;
	popup[p_iLevel].focus();
}

// vérifie l'existance d'une modal - A REVOIR
function checkModal() {
	if (window.popup) {
		window.popup.focus();
	}
}

/**
 * AIDE A LA SAISIE DES SCORES
 */

	function chooseScore(pForm,pElements,pts1,pts2){
		var set_id = document.forms[pForm].elements[pElements].value;
		document.forms[pForm].elements['jeux_s'+set_id+'_j1'].value= pts1;
		document.forms[pForm].elements['jeux_s'+set_id+'_j2'].value= pts2;
	}
	function chooseScoreInv(pForm,pElements,pts1,pts2){
		var set_id = document.forms[pForm].elements[pElements].value;
		document.forms[pForm].elements['jeux_s'+set_id+'_j1'].value= pts2;
		document.forms[pForm].elements['jeux_s'+set_id+'_j2'].value= pts1;
	}
	
	function gridScoreShow(div_id,pForm,pElements,set_id){
		var x= 110;
		var y= 103;
			
		document.getElementById(div_id).style.visibility='visible';
		document.forms[pForm].elements[pElements].value=set_id;
		document.getElementById(div_id).style.left = (set_id * x-20) + "px";
		document.getElementById(div_id).style.top = y + "px";
	}
	
	function chooseScoreMass(pForm,pElements,pElements2,pts1,pts2){
		var set_id = document.forms[pForm].elements[pElements].value;
		var ren_iid = document.forms[pForm].elements[pElements2].value;
		
		document.forms[pForm].elements['jeux_s'+set_id+'_j1_'+ren_iid].value= pts1;
		document.forms[pForm].elements['jeux_s'+set_id+'_j2_'+ren_iid].value= pts2;
	}
	function chooseScoreMassInv(pForm,pElements,pElements2,pts1,pts2){
		var set_id = document.forms[pForm].elements[pElements].value;
		var ren_iid = document.forms[pForm].elements[pElements2].value;
		
		document.forms[pForm].elements['jeux_s'+set_id+'_j1_'+ren_iid].value= pts2;
		document.forms[pForm].elements['jeux_s'+set_id+'_j2_'+ren_iid].value= pts1;
	}
	function gridScoreMassShow(div_id,pForm,pElements,pElements2,pRen_iid,pNumero,set_id){
		var x= 110;
		var y= 13;
		hideElement( 'select', div_id );
		
		document.getElementById(div_id).style.visibility='visible';
		document.forms[pForm].elements[pElements].value=set_id;
		document.forms[pForm].elements[pElements2].value=pRen_iid;
		document.getElementById(div_id).style.left = (set_id * x+200) + "px";
		document.getElementById(div_id).style.top = y+(pNumero * 63) + "px";
	}
	
	function gridPrintShow(div_id,pForm,ID_Anchor,Name_Anchor){
		this.ID_Anchor = ID_Anchor;
		this.Name_Anchor = Name_Anchor;
		this.div_id = div_id;
		this.h = 0;
				
		setToAnchor();				
		document.getElementById(div_id).style.visibility='visible';
	}

	/*function setToAnchor(ID_Anchor,Name_Anchor,this.ID_DIV){*/
	function setToAnchor(){
	//Fonction permettant de positionner un DIV à une position occupée par une ancre

	var ns4 = (document.layers)? true:false;   //NS 4 
	var ie4 = (document.all)? true:false;   //IE 4 
	var dom = (document.getElementById)? true:false;   //DOM 

	var DivLeft = 0;   //Position du Div par rapport au côté gauche de la page 
	var DivTop = 0;   //Position du Div par rapport au haut de la page 
	    if (dom) {
	        pos = document.getElementById(this.ID_Anchor);
	        DivLeft = getLeft(pos);
	        DivTop = getTop(pos);
	        document.getElementById(this.div_id).style.left = DivLeft;
	        document.getElementById(this.div_id).style.top = DivTop - h;
        }
	    else if (ie4) {
	        pos = document.all[this.ID_Anchor];
	        DivLeft = getLeft(pos);
	        DivTop = getTop(pos);
	        document.all[this.div_id].style.posLeft = DivLeft;
	        document.all[this.div_id].style.posTop = DivTop - h;
        }
   	 	else if (ns4){
	        pos = document.anchors[this.Name_Anchor];
	        DivLeft = pos.x;
	        DivTop = pos.y;
	        document.layers[this.div_id].pageX = DivLeft;
 	       document.layers[this.div_id].pageY = DivTop - h;
        }
}

function getLeft(MyObject)
//Fonction permettant de connaître la position d'un objet
//par rapport au bord gauche de la page.
//Cet objet peut être à l'intérieur d'un autre objet.
    {
    if (MyObject.offsetParent)
        return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
    else 
        return (MyObject.offsetLeft);
    } 
function getTop(MyObject)
//Fonction permettant de connaître la position d'un objet
//par rapport au bord haut de la page.
//Cet objet peut être à l'intérieur d'un autre objet.
    {
    if (MyObject.offsetParent)
        return (MyObject.offsetTop + getTop(MyObject.offsetParent));
    else
        return (MyObject.offsetTop);
    }

/**
 * CALENDAR
 */
var calendar_handler = false;

function oCal(cal_id, form_name, element_name)
{
	this.id           = cal_id;
	this.form_name    = form_name;
	this.element_name = element_name;

	this.coordX = 0;
	this.coordY = 0;

	this.date     = new Date();
	this.nav_date = new Date();

	this.div_id        = 'cal_contener';
	this.nav_form_name = 'cal_nav';

	// action executée lors du choix d'une date
	this.action = '';

	this.months = new Array(12);
	this.months[0] = 'Janvier';
	this.months[1] = 'F&eacute;vrier';
	this.months[2] = 'Mars';
	this.months[3] = 'Avril';
	this.months[4] = 'Mai';
	this.months[5] = 'Juin';
	this.months[6] = 'Juillet';
	this.months[7] = 'Aout';
	this.months[8] = 'Septembre';
	this.months[9] = 'Octobre';
	this.months[10]= 'Novembre';
	this.months[11]= 'D&eacute;cembre';

	this.days = new Array(6);
	this.days[7] = 'D';
	this.days[1] = 'L';
	this.days[2] = 'M';
	this.days[3] = 'M';
	this.days[4] = 'J';
	this.days[5] = 'V';
	this.days[6] = 'S';

	this.init    = oCal_init;
	this.initNav = oCal_initNav;
	this.navSynchro = oCal_navSynchro;
	this.changeNavDate = oCal_changeNavDate;
	this.chooseDate    = oCal_chooseDate;
	this.buildMonth = oCal_buildMonth;
	this.build      = oCal_build;
	this.show = oCal_show;
	this.hide = oCal_hide;
	this.move = oCal_move;

}

function oCal_init()
{
	var element_date = get_form_element(this.form_name, this.element_name);
	if (!element_date)
	{
		return alert('Erreur: élement date absent du formulaire !');
	}

	var date_value = element_date.value;
	var date_split = date_value.split("/");
	if (date_split.length==3)
	{
		var day   = date_split[0];
		var month = parseInt(date_split[1]) - parseInt(1);
		var year  = date_split[2];
		this.date.setDate(day);
		this.date.setMonth(month);
		this.date.setYear(year);
	}
}

function oCal_navSynchro()
{
	var day   = this.date.getDate();
	var month = this.date.getMonth();
	var year  = this.date.getYear();
	if(parseInt(year)<200) year += parseInt(1900);
	this.nav_date.setDate(day);
	this.nav_date.setMonth(month);
	this.nav_date.setYear(year);
}

function oCal_initNav(day, month, year)
{
	this.nav_date.setDate(day);
	this.nav_date.setMonth(month);
	this.nav_date.setYear(year);
}

function oCal_changeNavDate(year_diff)
{
	var month = get_form_element(this.nav_form_name, 'month').value;
	var year = get_form_element(this.nav_form_name, 'year');
	year = parseInt(year.value) + parseInt(year_diff);

	this.initNav(1, month, year);
	
	this.show();	
}

function oCal_chooseDate(day, month, year)
{
	month = parseInt(month) + parseInt(1) ;

	if (day<10)
	{
		day = "0" + day;
	}

	if (month<10)
	{
		month = "0" + month;
	}

	var date_format = day + "/" + month + "/" + year;
	get_form_element(this.form_name, this.element_name).value = date_format;

	this.hide();
}

function oCal_buildMonth(current_month)
{
	var html = '';

	for(var i=0; i<12; i++)
	{
		if (i==current_month) var selected = ' selected';
		else                  var selected = '';
		html += '<option value="' + i + '"' + selected + ' class="option_month">' + this.months[i] + '</option>'
	}
	return html;
}

function oCal_build()
{
	var current_date  = this.date.getDate();
	var current_month = this.date.getMonth();
	var current_year  = this.date.getYear();
	if (parseInt(current_year)<200) current_year += parseInt(1900);

	var nav_month = this.nav_date.getMonth();
	var nav_year  = this.nav_date.getYear();
	if (parseInt(nav_year)<200) nav_year += parseInt(1900);

	var new_date   = new Date(nav_year, nav_month, 1);
	var first_day  = new_date.getDay();
	if (first_day==0) first_day=7;
	var this_date   = 1;

	var html = '';

	html += '<FORM name="' + this.nav_form_name + '"><TABLE class="calendar">';

	// navigation
	html += '<TR><TD class="calendar_head" align="center">';
	html += '<TABLE><TR>';
	html += '<TD><SELECT name="month" onchange="calendar_handler.changeNavDate(0);" class="calendar_month">' + this.buildMonth(nav_month) + '</SELECT></TD>';
	html += '<TD><INPUT name="year" value="' + nav_year + '" size="6" readonly class="calendar_year"><INPUT type="button" value="-" onclick="calendar_handler.changeNavDate(-1);" class="calendar_nav"><INPUT type="button" value="+" onclick="calendar_handler.changeNavDate(1);" class="calendar_nav"></TD>';
	html += '</TR></TABLE>';
	html += '</TD></TR>';

	html += '<TR><TD align="center">';
	html += '<TABLE width="100%" class="calendar_day">';
	html += '<TR>';
	for(var weekday=1; weekday<8; weekday++)
	{	
		html += '<TD class="calendar_day_label">' + this.days[weekday] + '</TD>';
	}
	html += '</TR>';
	for(var week=0; week<6; week++)
	{
		html += '<TR>';
		for (var weekday=1; weekday<8; weekday++)
		{
			var aDate = new Date(nav_year, nav_month, this_date);

			if ((week==0 && weekday<first_day) || (aDate.getMonth()!=nav_month))
			{
				var print_date = '&nbsp; ';
			}
			else
			{
//				var print_date = '<A href="javascript:calendar_handler.chooseDate(' + this_date + ', ' + nav_month + ' , ' + nav_year + ');" class="calendar">' + this_date + '</A>';
				var print_date = '<A href="javascript:calendar_handler.chooseDate(' + this_date + ', ' + nav_month + ' , ' + nav_year + ');'+ this.action +'" class="calendar">' + this_date + '</A>';

				this_date++;
			}

			if (weekday==6 || weekday==7)
				var class_name = "calendar_day_date_week";
			else
				var class_name = "calendar_day_date";

			if (aDate.getDate()==current_date && nav_month==current_month && nav_year==current_year)
				class_name += " this_day";

			html += '<TD class="'+class_name+'">' + print_date + '</TD>';
		}
		html += '</TR>';
	}
	html += '</TABLE>';
	html += '</TD></TR>';

	html += '<TR><TD class="calendar_close"><A href="javascript:void(0);" onclick="calendar_handler.hide();" class="calendar_close">Fermer</A>&nbsp;';
	html += '</TD></TR>';

	html += '</TABLE></FORM>';

	get_element(this.div_id).innerHTML = html;
}

function oCal_show(event)
{
	this.build();

	var div_contener = get_element(this.div_id);

	if (!div_contener)
	{
		return alert('Erreur: object de navigation non défini !');
	}

	div_contener.style.visibility = "visible";

	if (event)
	{
		this.move(div_contener, event);
	}

}

function oCal_hide()
{
	get_element(this.div_id).style.visibility = "hidden";
}

function oCal_move(element_div, event)
{
	if (event.pageX)        var left = event.pageX;
	else if (event.clientX) var left = event.clientX;
	else                    var left = 100;

	if (event.pageY)        var top = event.pageY;
	else if (event.clientY) var top = event.clientY;
	else                    var top = 100;

	if (!event.pageY)
	{
		left -= document.body.scrollLeft;
		top  += document.body.scrollTop;
	}

/*	left = left - 200; // afin d'afficher le pickup date dans la colonne des libellés (empeche l'affichage sous un <SELECT>)
	top = top + 10;*/
	left = left + this.coordX;
	top = top + this.coordY;

	element_div.style.left = left + "px";
	element_div.style.top = top + "px";
}

function calendar_show(cal_id, form_name, element_name, event, x, y,action)
{
	var coordX = 0;
	if (calendar_show.arguments[4]) coordX = x;
	else                            coordX = -150;
	var coordY = 0;
	if (calendar_show.arguments[5]) coordY = y;
	else                            coordY = 55;


	calendar = new oCal(cal_id, form_name, element_name);
	calendar.coordX = coordX;
	calendar.coordY = coordY;
	calendar.action=action;
	calendar_handler = calendar;
	calendar_handler.init();
	calendar_handler.navSynchro();
	calendar_handler.show(event);
}

/* Fonction hide/show toggle  dynamique */
function toggle(target)
  {
     obj = get_element(target)
 	 if (obj.style.display=='none')
	 	obj.style.display='inline';
	 else
	 	obj.style.display='none';
  }
  
  
/**
 * Tabs code.
 */
function selectTab(tabGroupId, tabGroupSize, selectedTabId, enabledStyle, disabledStyle, errorStyle) {
	// first unselect all tab in the tag groups.
	for (i=0;i<tabGroupSize;i++) {
		element = document.getElementById("tabs" + tabGroupId + "head" + i);
		if (element.classNameErrorStdLayout) {
			element.className = errorStyle;
			element.style.color = "";
			document.getElementById("tabs" + tabGroupId + "tab" + i).style.display = "none";		
		} else if (element.className == enabledStyle) {
			element.className = disabledStyle;
			element.style.color = "";
			document.getElementById("tabs" + tabGroupId + "tab" + i).style.display = "none";
		}
	}
	if (document.getElementById("tabs" + tabGroupId + "head" + selectedTabId).className==errorStyle) {
		document.getElementById("tabs" + tabGroupId + "head" + selectedTabId).classNameErrorStdLayout = new Object();
	}
	document.getElementById("tabs" + tabGroupId + "head" + selectedTabId).className = enabledStyle;
	document.getElementById("tabs" + tabGroupId + "head" + selectedTabId).style.cursor = "default";
	document.getElementById("tabs" + tabGroupId + "tab" + selectedTabId).style.display = "";
}
function onTabHeaderOver(tabGroupId, selectedTabId, enabledStyle) {
	element = document.getElementById("tabs" + tabGroupId + "head" + selectedTabId);
	if (element.className == enabledStyle) {
		element.style.cursor = "default";
	} else {
		element.style.cursor = "hand";
	}
}

/**
 * logout
 */
function onSessionTimeout() {
    // url
    var href = window.location.href;

    // fenêtre principale
    var firstOpener = returnFirstOpener(window);
    var parentFrame = firstOpener.parent;

    if (firstOpener == window && parentFrame == window) {
        return true;
    }

    // vérifie l'existance de frames
    if (parentFrame) {
        firstOpener.parent.location.href = href;
    }
    else {
        firstOpener.location.href = href;
    }
}

function returnFirstOpener(p_window) {
    if (p_window.opener) {
        p_window.close();
        p_window.opener.focus();
        return returnFirstOpener(p_window.opener);
    }
    else {
        return p_window;
    }
}