/* auteur: Stéphane Lorimier */
/* Date de création: 30.05.02 */
// --------------------------------------------------------------------------------------------------------------------
function sortie(formulaire){
		if (formulaire.redirection.selectedIndex != 0){
		location.href = formulaire.redirection.options[formulaire.redirection.selectedIndex].value;
		}	else {
		alert('Veuillez choisir une année.');
		}
}


// --------------------------------------------------------------------------------------------------------------------
function ouvre_fenetre(page, largeur, hauteur, haut, gauche){
		
		if ( haut == 0){
		var haut = TopPosition=(screen.height)?(screen.height-hauteur)/2:100;
		}
		if ( gauche == 0){
		var gauche = LeftPosition=(screen.width)?(screen.width-largeur)/2:100;
		}
		
		msgWindow=window.open(page,"displayWindow","toolbar=0,width="+largeur+",height="+hauteur+",directories=0,status=1,scrollbars=0 ,resize=0,menubar=0, top="+haut+", left="+gauche);
}

//<A onclick="ouvre_fenetre('page', width, height, top, left);" href="javascript:void(0)">Lien</A>
//<A onclick="ouvre_fenetre('page', width, height, 0, 0);" href="javascript:void(0)">Lien</A> // fenêtre centrée


// --------------------------------------------------------------------------------------------------------------------
function FocusText(BoxName){ 
	if (BoxName.value == BoxName.defaultValue){
		BoxName.value = '';
	}
}

function BlurText(BoxName){
	if (BoxName.value == ''){
		BoxName.value = BoxName.defaultValue;
	}
}
// <input onFocus="return FocusText(this);" onBlur="return BlurText(this);" value="Pseudo">




// --------------------------------------------------------------------------------------------------------------------
/*
** <form name="form">
** <input type="text" name="titre" size="56" maxlength="64" onKeyUp="Compter(this,64,form.compte_titre)">
** <input type="text" name="compte_titre" size="3" value="0" style="font: 9px"> caractères (max 64)
*/
function Compter(Target, max, nomchamp){
	StrLen = Target.value.length
		if (StrLen > max ){
		Target.value = Target.value.substring(0,max);
		CharsLeft = max;								
		}else{
		CharsLeft = StrLen;
		}	
	nomchamp.value = CharsLeft;
}
// fin function Compter(Target, max, nomchamp)



// --------------------------------------------------------------------------------------------------------------------
/*
**
**
**
*/
function setPointer(theRow, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()) {
        if (theAction == 'out') {
            newColor = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor = (thePointerColor != '')
                     ? thePointerColor
                     : theDefaultColor;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function



// --------------------------------------------------------------------------------------------------------------------
/*
** Ajuste la taille de la fenêtre à l'image
*/
function adjust_popup()
{
	var w, h, fixedW, fixedH, diffW, diffH;
	
	if (document.all) {
		fixedW = document.body.clientWidth;
		fixedH = document.body.clientHeight;
		window.resizeTo(fixedW, fixedH);
		diffW = fixedW - document.body.clientWidth;
		diffH = fixedH - document.body.clientHeight;
	} else {
		fixedW = window.innerWidth;
		fixedH = window.innerHeight;
		window.resizeTo(fixedW, fixedH);
		diffW = fixedW - window.innerWidth;
		diffH = fixedH - window.innerHeight;
	}
	w = fixedW + diffW;
	h = fixedH + diffH;
	if (h >= screen.availHeight) w += 16;
	if (w >= screen.availWidth)  h += 16;
	w = Math.min(w,screen.availWidth);
	h = Math.min(h,screen.availHeight);
	window.resizeTo(w,h);
	window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}


// --------------------------------------------------------------------------------------------------------------------
/*
** Affiche des éléments sur click d'un case à cocher
** Employé dans => 
** itineraire_choix_nouveau.html
*/
// fonction pour checkbox
function CheckboxClicked(objClicked, ID, nameSubmit)
{
     // Contrôle de l'élément cliqué...
	 //alert(objClicked.checked);
	 if (objClicked.checked == true){
	 document.forms[nameSubmit].onSubmit=return true;
	 alert('Yes');
	 }
     document.getElementById(ID).style.display = (objClicked.checked) ? "none" : "block";  return true;
     
	 
}

// fonction pour checkbox
function LinkClicked(objClicked, ID, visible)
{
         document.getElementById(ID).style.display = (visible== true) ? "block" : "none";  return true;        
}

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