//Capitalise the string
var rootDir = "/fr";
function toCapital(mystring) {
	var i;
    var localString = mystring;
	var a = localString.split(/\s+/g); // split the sentence into an array of words
    for (i = 0 ; i < a.length ; i ++ ) {

        var firstLetter = a[i].substring(0, 1).toUpperCase();
        var restOfWord = a[i].substring(1, a[i].length).toLowerCase();

        a[i] = firstLetter + restOfWord; // re-assign it back to the array and move on
    }
    return (String(a.join(' '))); // join it back together
}
//menu is a global array variable composed of
//
// 0. language(0=fr, 1=nl)
// 1. URL
// 2. Name to display
function CreateDirectAccessMenu(language){
var fr = 0;
var nl = 1;
var i;
var j;
lang = fr;
titreDefaut = "Accès rapide à...";	
if (language == "nl"){
	lang = nl;
	titreDefaut = "Ga sneller naar...";	
}
var menu=MultiDimensionalArray(2,6,2);
menu[0][0][0]= "/centre/contact/index.htm";
menu[0][0][1]= "Infos Générales";
menu[0][1][0]= "/activites/programme.htm";
menu[0][1][1]= "Programme";
menu[0][2][0]= "/boutique/index.htm";
menu[0][2][1]= "Boutique";
menu[0][3][0]= "/liens/index.htm";
menu[0][3][1]= "Liens";
menu[0][4][0]= "/sitemap/index.php";
menu[0][4][1]= "Plan du site";
menu[0][5][0]= "/application/aide/index.htm";
menu[0][5][1]= "Aide";
document.write('	<form name="accesdirectform">');
document.write('		<select name="accesdirect" id="accesdirect"  onChange="location.href=document.accesdirectform.accesdirect.value" class="accesdirect">');
document.write('			<option value="" selected>' + titreDefaut +'</option>');

for (i=0; i < menu[lang].length; i++)
	{
		document.write('	      	<option value="' + rootDir + menu[lang][i][0] + '">' + menu[lang][i][1] + '</option>');
	}
document.write('    </select>');
document.write('    </form>');
}

//Initialise a javascript array
function MultiDimensionalArray(maxlevel1,maxlevel2, maxlevel3)
{
var i;
var j;
var k;

   var a = new Array(maxlevel1);
   for (i=0; i < maxlevel1; i++)
   {
       a[i] = new Array(maxlevel2);
       for (j=0; j < maxlevel2; j++)
       {
		   a[i][j] = new Array(maxlevel3);
		   for (k=0; k < maxlevel3; k++)
		   {
				 a[i][j][k] = "";
		   }
	    }
   }
   return(a);
} 

function spawn(expr,qty,reversed){
<!-- Creator:Mickweb Javascript (http://www.mickweb.com/) -->
var spawnee=[expr];
for(s=1;s<qty;s++){
spawnee[s]=expr+spawnee[s-1];
}
return reversed? spawnee.reverse() : spawnee();
}

function mw_crumbs(divider,default_page,root){
if(!divider) {divider=" : "}
if(!default_page){default_page="index.html"}
var m=location.toString(),h="";
m=m.substring(m.indexOf("/")+1);
m=m.split("/");
var howmany=spawn("../",m.length,true);
howmany[m.length]=default_page;
h="<a class=\"locationbar\" href=\""+rootDir+"/\">Home</a>"+divider;
for(i=3;i<m.length-1;i++){
var tempCapital = m[i];
tempCapital = toCapital(tempCapital);
h+=("<a class=\"locationbar\" href="+howmany[i+2]+">"+unescape(tempCapital+"</a>"+divider))
}
h += "<em>"+document.title+"</em>";
if(root) {
h=h.replace(eval("/"+location.host+"/"),root)
}
document.write(h);
}


function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  var result = (!r1.test(str) && r2.test(str));
  if (!result){
  	alert("Votre adresse email n'est pas valide");
  }
  return result;
}

/* $Id: functions.js,v 1.34 2003/04/06 19:14:36 garvinhicking Exp $ */


/**
 * Displays an confirmation box beforme to submit a "DROP/DELETE/ALTER" query.
 * This function is called while clicking links
 *
 * @param   object   the link
 * @param   object   the sql query to submit
 *
 * @return  boolean  whether to run the query or not
 */
function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
} // end of the 'confirmLink()' function


/**
 * Displays an error message if a "DROP DATABASE" statement is submitted
 * while it isn't allowed, else confirms a "DROP/DELETE/ALTER" query before
 * sumitting it if required.
 * This function is called by the 'checkSqlQuery()' js function.
 *
 * @param   object   the form
 * @param   object   the sql query textarea
 *
 * @return  boolean  whether to run the query or not
 *
 * @see     checkSqlQuery()
 */
function confirmQuery(theForm1, sqlQuery1)
{
    // Confirmation is not required in the configuration file
    if (confirmMsg == '') {
        return true;
    }

    // The replace function (js1.2) isn't supported
    else if (typeof(sqlQuery1.value.replace) == 'undefined') {
        return true;
    }

    // js1.2+ -> validation with regular expressions
    else {
        // "DROP DATABASE" statement isn't allowed
        if (noDropDbMsg != '') {
            var drop_re = new RegExp('DROP\\s+(IF EXISTS\\s+)?DATABASE\\s', 'i');
            if (drop_re.test(sqlQuery1.value)) {
                alert(noDropDbMsg);
                theForm1.reset();
                sqlQuery1.focus();
                return false;
            } // end if
        } // end if

        // Confirms a "DROP/DELETE/ALTER" statement
        //
        // TODO: find a way (if possible) to use the parser-analyser
        // for this kind of verification
        // For now, I just added a ^ to check for the statement at
        // beginning of expression
        
        //var do_confirm_re_0 = new RegExp('DROP\\s+(IF EXISTS\\s+)?(TABLE|DATABASE)\\s', 'i');
        //var do_confirm_re_1 = new RegExp('ALTER\\s+TABLE\\s+((`[^`]+`)|([A-Za-z0-9_$]+))\\s+DROP\\s', 'i');
        //var do_confirm_re_2 = new RegExp('DELETE\\s+FROM\\s', 'i');
        var do_confirm_re_0 = new RegExp('^DROP\\s+(IF EXISTS\\s+)?(TABLE|DATABASE)\\s', 'i');
        var do_confirm_re_1 = new RegExp('^ALTER\\s+TABLE\\s+((`[^`]+`)|([A-Za-z0-9_$]+))\\s+DROP\\s', 'i');
        var do_confirm_re_2 = new RegExp('^DELETE\\s+FROM\\s', 'i');
        if (do_confirm_re_0.test(sqlQuery1.value)
            || do_confirm_re_1.test(sqlQuery1.value)
            || do_confirm_re_2.test(sqlQuery1.value)) {
            var message      = (sqlQuery1.value.length > 100)
                             ? sqlQuery1.value.substr(0, 100) + '\n    ...'
                             : sqlQuery1.value;
            var is_confirmed = confirm(confirmMsg + ' :\n' + message);
            // drop/delete/alter statement is confirmed -> update the
            // "is_js_confirmed" form field so the confirm test won't be
            // run on the server side and allows to submit the form
            if (is_confirmed) {
                theForm1.elements['is_js_confirmed'].value = 1;
                return true;
            }
            // "DROP/DELETE/ALTER" statement is rejected -> do not submit
            // the form
            else {
                window.focus();
                sqlQuery1.focus();
                return false;
            } // end if (handle confirm box result)
        } // end if (display confirm box)
    } // end confirmation stuff

    return true;
} // end of the 'confirmQuery()' function



/**
 * Displays an error message if the user submitted the sql query form with no
 * sql query, else checks for "DROP/DELETE/ALTER" statements
 *
 * @param   object   the form
 *
 * @return  boolean  always false
 *
 * @see     confirmQuery()
 */
function checkSqlQuery(theForm)
{
    var sqlQuery = theForm.elements['sql_query'];
    var isEmpty  = 1;

    // The replace function (js1.2) isn't supported -> basic tests
    if (typeof(sqlQuery.value.replace) == 'undefined') {
        isEmpty      = (sqlQuery.value == '') ? 1 : 0;
        if (isEmpty && typeof(theForm.elements['sql_file']) != 'undefined') {
            isEmpty  = (theForm.elements['sql_file'].value == '') ? 1 : 0;
        }
        if (isEmpty && typeof(theForm.elements['sql_localfile']) != 'undefined') {
            isEmpty  = (theForm.elements['sql_localfile'].value == '') ? 1 : 0;
        }
        if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined') {
            isEmpty  = (theForm.elements['id_bookmark'].value == null || theForm.elements['id_bookmark'].value == '');
        }
    }
    // js1.2+ -> validation with regular expressions
    else {
        var space_re = new RegExp('\\s+');
        isEmpty      = (sqlQuery.value.replace(space_re, '') == '') ? 1 : 0;
        // Checks for "DROP/DELETE/ALTER" statements
        if (!isEmpty && !confirmQuery(theForm, sqlQuery)) {
            return false;
        }
        if (isEmpty && typeof(theForm.elements['sql_file']) != 'undefined') {
            isEmpty  = (theForm.elements['sql_file'].value.replace(space_re, '') == '') ? 1 : 0;
        }
        if (isEmpty && typeof(theForm.elements['sql_localfile']) != 'undefined') {
            isEmpty  = (theForm.elements['sql_localfile'].value.replace(space_re, '') == '') ? 1 : 0;
        }
        if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined') {
            isEmpty  = (theForm.elements['id_bookmark'].value == null || theForm.elements['id_bookmark'].value == '');
            isEmpty  = (theForm.elements['id_bookmark'].selectedIndex == 0);
        }
        if (isEmpty) {
            theForm.reset();
        }
    }

    if (isEmpty) {
        sqlQuery.select();
        alert(errorMsg0);
        sqlQuery.focus();
        return false;
    }

    return true;
} // end of the 'checkSqlQuery()' function


/**
 * Displays an error message if an element of a form hasn't been completed and
 * should be
 *
 * @param   object   the form
 * @param   string   the name of the form field to put the focus on
 *
 * @return  boolean  whether the form field is empty or not
 */
function emptyFormElements(theForm, theFieldName)
{
    var isEmpty  = 1;
    var theField = theForm.elements[theFieldName];
    // Whether the replace function (js1.2) is supported or not
    var isRegExp = (typeof(theField.value.replace) != 'undefined');

    if (!isRegExp) {
        isEmpty      = (theField.value == '') ? 1 : 0;
    } else {
        var space_re = new RegExp('\\s+');
        isEmpty      = (theField.value.replace(space_re, '') == '') ? 1 : 0;
    }
    if (isEmpty) {
        theForm.reset();
        theField.select();
        alert(errorMsg0);
        theField.focus();
        return false;
    }

    return true;
} // end of the 'emptyFormElements()' function


/**
 * Ensures a value submitted in a form is numeric and is in a range
 *
 * @param   object   the form
 * @param   string   the name of the form field to check
 * @param   integer  the minimum authorized value
 * @param   integer  the maximum authorized value
 *
 * @return  boolean  whether a valid number has been submitted or not
 */
function checkFormElementInRange(theForm, theFieldName, min, max)
{
    var theField         = theForm.elements[theFieldName];
    var val              = parseInt(theField.value);

    if (typeof(min) == 'undefined') {
        min = 0;
    }
    if (typeof(max) == 'undefined') {
        max = Number.MAX_VALUE;
    }

    // It's not a number
    if (isNaN(val)) {
        theField.select();
        alert(errorMsg1);
        theField.focus();
        return false;
    }
    // It's a number but it is not between min and max
    else if (val < min || val > max) {
        theField.select();
        alert(val + errorMsg2);
        theField.focus();
        return false;
    }
    // It's a valid number
    else {
        theField.value = val;
    }

    return true;
} // end of the 'checkFormElementInRange()' function


/**
 * Ensures the choice between 'transmit', 'zipped', 'gzipped' and 'bzipped'
 * checkboxes is consistant
 *
 * @param   object   the form
 * @param   string   a code for the action that causes this function to be run
 *
 * @return  boolean  always true
 */
function checkTransmitDump(theForm, theAction)
{
    var formElts = theForm.elements;

    // 'zipped' option has been checked
    if (theAction == 'zip' && formElts['zip'].checked) {
        if (!formElts['asfile'].checked) {
            theForm.elements['asfile'].checked = true;
        }
        if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
            theForm.elements['gzip'].checked = false;
        }
        if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
            theForm.elements['bzip'].checked = false;
        }
    }
    // 'gzipped' option has been checked
    else if (theAction == 'gzip' && formElts['gzip'].checked) {
        if (!formElts['asfile'].checked) {
            theForm.elements['asfile'].checked = true;
        }
        if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
            theForm.elements['zip'].checked = false;
        }
        if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
            theForm.elements['bzip'].checked = false;
        }
    }
    // 'bzipped' option has been checked
    else if (theAction == 'bzip' && formElts['bzip'].checked) {
        if (!formElts['asfile'].checked) {
            theForm.elements['asfile'].checked = true;
        }
        if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
            theForm.elements['zip'].checked = false;
        }
        if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
            theForm.elements['gzip'].checked = false;
        }
    }
    // 'transmit' option has been unchecked
    else if (theAction == 'transmit' && !formElts['asfile'].checked) {
        if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
            theForm.elements['zip'].checked = false;
        }
        if ((typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked)) {
            theForm.elements['gzip'].checked = false;
        }
        if ((typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked)) {
            theForm.elements['bzip'].checked = false;
        }
    }

    return true;
} // end of the 'checkTransmitDump()' function


/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, 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;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // 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

/*
 * Sets/unsets the pointer and marker in vertical browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 *
 * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)
 */
function setVerticalPointer(theRow, theRowNum, theAction, theDefaultColor1, theDefaultColor2, 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 {
        domDetect    = false;
    } // end 3

    var c = null;
    // 5.1 ... with DOM compatible browsers except Opera
    for (c = 0; c < rowCellsCnt; c++) {
        if (domDetect) {
            currentColor = theCells[c].getAttribute('bgcolor');
        } else {
            currentColor = theCells[c].style.backgroundColor;
        }

        // 4. Defines the new color
        // 4.1 Current color is the default one
        if (currentColor == ''
            || currentColor.toLowerCase() == theDefaultColor1.toLowerCase() 
            || currentColor.toLowerCase() == theDefaultColor2.toLowerCase()) {
            if (theAction == 'over' && thePointerColor != '') {
                newColor              = thePointerColor;
            } else if (theAction == 'click' && theMarkColor != '') {
                newColor              = theMarkColor;
                marked_row[theRowNum] = true;
            }
        }
        // 4.1.2 Current color is the pointer one
        else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
                 && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
            if (theAction == 'out') {
                if (c % 2) {
                    newColor              = theDefaultColor1;
                } else {
                    newColor              = theDefaultColor2;
                }
            }
            else if (theAction == 'click' && theMarkColor != '') {
                newColor              = theMarkColor;
                marked_row[theRowNum] = true;
            }
        }
        // 4.1.3 Current color is the marker one
        else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
            if (theAction == 'click') {
                newColor              = (thePointerColor != '')
                                      ? thePointerColor
                                      : ((c % 2) ? theDefaultColor1 : theDefaultColor2);
                marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                      ? true
                                      : null;
            }
        } // end 4

        // 5. Sets the new color...
        if (newColor) {
            if (domDetect) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            }
            // 5.2 ... with other browsers
            else {
                theCells[c].style.backgroundColor = newColor;
            }
        } // end 5
    } // end for

     return true;
 } // end of the 'setVerticalPointer()' function

/**
 * Checks/unchecks all tables
 *
 * @param   string   the form name
 * @param   boolean  whether to check or to uncheck the element
 *
 * @return  boolean  always true
 */
function setCheckboxes(the_form, do_check)
{
    var elts      = (typeof(document.forms[the_form].elements['selected_db[]']) != 'undefined')
                  ? document.forms[the_form].elements['selected_db[]']
                  : (typeof(document.forms[the_form].elements['selected_tbl[]']) != 'undefined')
          ? document.forms[the_form].elements['selected_tbl[]']
          : document.forms[the_form].elements['selected_fld[]'];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function


/**
  * Checks/unchecks all options of a <select> element
  *
  * @param   string   the form name
  * @param   string   the element name
  * @param   boolean  whether to check or to uncheck the element
  *
  * @return  boolean  always true
  */
function setSelectOptions(the_form, the_select, do_check)
{
    var selectObject = document.forms[the_form].elements[the_select];
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    } // end for

    return true;
} // end of the 'setSelectOptions()' function

/**
  * Allows moving around inputs/select by Ctrl+arrows
  *
  * @param   object   event data   
  */
function onKeyDownArrowsHandler(e) {
    e = e||window.event;
    var o = (e.srcElement||e.target);
    if (!o) return;
    if (o.tagName != "TEXTAREA" && o.tagName != "INPUT" && o.tagName != "SELECT") return;
    if (!e.ctrlKey) return;
    if (!o.id) return;

    var pos = o.id.split("_");
    if (pos[0] != "field" || typeof pos[2] == "undefined") return;

    var x = pos[2], y=pos[1];
    
    // skip non existent fields
    for (i=0; i<10; i++)
    {
        switch(e.keyCode) {
            case 38: y--; break; // up
            case 40: y++; break; // down
            case 37: x--; break; // left
            case 39: x++; break; // right
            default: return;
        }

        var id = "field_" + y + "_" + x;
        var nO = document.getElementById(id);
        if (nO) break;
    }
    
    if (!nO) return;
    nO.focus();
    if (nO.tagName != 'SELECT') {
        nO.select();
    }
    e.returnValue = false;
}

/**
  * Inserts multiple fields.
  *
  */
function insertValueQuery() {
    var myQuery = document.sqlform.sql_query;
    var myListBox = document.sqlform.dummy;

    if(myListBox.options.length > 0) {
        var chaineAj = "";
        var NbSelect = 0;
        for(var i=0; i<myListBox.options.length; i++) {
            if (myListBox.options[i].selected){
                NbSelect++;
                if (NbSelect > 1)
                    chaineAj += ", ";
                chaineAj += myListBox.options[i].value;
            }
        } 

        //IE support
        if (document.selection) {
            myQuery.focus();
            sel = document.selection.createRange();
            sel.text = chaineAj;
            document.sqlform.insert.focus();
        }
        //MOZILLA/NETSCAPE support
        else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart == "0") {
            var startPos = document.sqlform.sql_query.selectionStart;
            var endPos = document.sqlform.sql_query.selectionEnd;
            var chaineSql = document.sqlform.sql_query.value;
        
            myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
        } else {
            myQuery.value += chaineAj;
        }
    }
}

/**
  * listbox redirection
  */
function goToUrl(selObj, goToLocation){
    eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'");
}

/*
* open windows
*/
function showPhoto(imageURL,commentaire){
	photoParamName='cheminphoto';
	CommentaireParamName='commentaire';
	newImageURL = rootDir + imageURL;
	newFullURL = rootDir + '/php/photo.php?' + photoParamName + '=' + newImageURL + '&' + CommentaireParamName + '=' + commentaire;
    window.open(newFullURL,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400');
}

function createHeader(){
document.write('<!-- HEADER START -->');
document.write('<table class="body" cellspacing="0" cellpadding="0"> ');
document.write('   <tr class="top"> ');
document.write('      <td class="tl">&nbsp; ');
document.write('         <!-- <a href="/"><img src="/fr/images/gif/samyelogo.gif" width="125" height="126" border="0"></a> --> ');
document.write('      </td> ');
document.write('      <td class="tm"> ');
document.write('         <table> ');
document.write('            <tr> ');
document.write('               <td class="tmTitre"> <img src="/fr/images/jpg/samyetitre.jpg" alt="Centre d\'études tibétaines - Titre" /> ');
document.write('                  <!-- ');
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="327" height="28">');
document.write('			<param name="movie" value="/fr/swf/titrecentre.swf" />');
document.write('			<param name="quality" value="high" />');
document.write('			<param name="LOOP" value="false" />');
document.write('			<embed src="/fr/swf/titrecentre.swf" width="327" height="28" align="top" loop="False" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
document.write('		  </object>');
document.write('	--> ');
document.write('               </td> ');
document.write('               <td class="extensible">&nbsp;</td> ');
document.write('               <td class="search" align="left" rowspan="2"> ');
document.write('<!-- SiteSearch Google -->');
document.write('<FORM method="GET" action="http://www.google.be/custom">');
document.write('<TABLE cellspacing="0"  style="border-width:0px;align:left;">');
document.write('<tr style="vertical-align:top;">');
document.write('<td>');
document.write('<A HREF="http://www.google.com/search">');
document.write('<IMG SRC="http://www.google.com/logos/Logo_25blk.gif"  ALT="Google" style="border-width:0px;vertical-align:middle;" /></A>');
document.write('</td>');
document.write('<td>');
document.write('<input type="text" name="q" size="25" maxlength="255" value=""/>');
document.write('<input type="hidden" name="sa" value="Google Search"/>');
document.write('<button class="go" type="submit" name="sa" >&nbsp;</button>');
//document.write('<input type="hidden" name="cof" value="S:http://www.samye.be;VLC:#967DFF;AH:center;BGC:#FFFFCD;LH:80;LC:#9A0000;L:http://www.samye.be/fr/images/jpg/samye-google.jpg;ALC:#9A0000;LW:400;T:#000000;AWFID:397d2fc98b6d95ba;" />');
//document.write('<input type="hidden" name="domains" value="samye.be" /><br/>');
document.write('<input type="radio" name="sitesearch" value="" style="background-color:#9A0000;border-width:0px;"/><span class="localisation">Tout le web</span>');
document.write('<input type="radio" name="sitesearch" value="samye.be" style="background-color:#9A0000;border-width:0px;" checked /><span class="localisation">samye.be</span>');
document.write('<input type="hidden" name="client" value="pub-8058805063011934"></input>');
document.write('<input type="hidden" name="forid" value="1"></input>');
document.write('<input type="hidden" name="ie" value="ISO-8859-1"></input>');
document.write('<input type="hidden" name="oe" value="ISO-8859-1"></input>');
document.write('<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1;"></input>');
document.write('<input type="hidden" name="hl" value="fr"></input>');

document.write('</td></tr></table>');
document.write('</form>');
document.write('<!-- SiteSearch Google -->');
document.write('               </td> ');
document.write('            </tr> ');
document.write('            <tr> ');
document.write('               <td class="localisation" colspan="2"><span class="localisation">Vous êtes ici:');
document.write('                  <script language="JavaScript" type="text/javascript" >mw_crumbs(\' &raquo; \',\'index.htm\',\'Samye Dzong Bruxelles\');</script> ');
document.write('                  </span></td> ');
document.write('            </tr> ');
document.write('         </table> ');
document.write('      </td> ');
document.write('      <td class="tr">&nbsp;</td> ');
document.write('   </tr> ');
document.write('   <tr> ');
document.write('      <td class="ml"> ');
document.write('         <table class="leftmenu"> ');
document.write('            <tr> ');
document.write('               <td class="fastmenu"> ');
document.write('                  <script language="JavaScript" type="text/javascript" >CreateDirectAccessMenu(\'fr\');</script> ');
document.write('               </td> ');
document.write('            </tr> ');
document.write('            <tr> ');
document.write('               <td class="extensible" style="padding-top:30px;vertical-align:bottom;"> ');
document.write('                     <img src="/fr/images/jpg/gyourme.jpg" width="125px" border=0 /><br/> ');
document.write('                     <div style="width:125px;text-align:center;">le vendredi 4 mai 2007 à 19h45<br/><a href="/fr/activites/gyourme.html" class="textualmenu">Chants pour l Éveil</a><br/>Concert exceptionnel donné par <br/>Lama Gyourmé et Jean-Philippe Rykiel<br/>Au Théatre 140 - Avenue E. Plasky, 140 - 1030 Bruxelles<br/>Réservations à la <a href="http://www.fnac.be/" class="textualmenu">FNAC</a> et au <a href="/fr/centre/contact/index.htm" class="textualmenu">centre</a>.</div>&nbsp;');
document.write('                  </td> ');
document.write('            </tr> ');
document.write('            <!--<tr>');
document.write('               <td class="extensible"> ');
document.write('                     <img src="/fr/images/gif/samyetribune.gif" border=0 /><br/> ');
document.write('                     <div style="width:125px;text-align:center;"><a href="/fr/centre/samyetribune/index.htm" class="textualmenu">SamyeTribune<br/>GRATUIT!</a></div>&nbsp;');
document.write('                  </td> ');
document.write('            </tr>--> ');
document.write('            <!-- TR just to perform automatic fill-in when table expands vertically--> ');
document.write('            <!--tr> ');
document.write('               <td class="extensible">');
document.write('                     <div style="width:125px;text-align:center;">NOUVEAU!<br/><a href="http://www.dupkang.com" class="textualmenu" target="_blank"><img src="/fr/images/png/dupkang.png" /><br/>Dupkang</a>: le shop du centre vient de réouvrir. Visitez son <a href="http://www.dupkang.com" class="textualmenu" target="_blank">site web</a>!</div><br/>');
document.write('            	</td> ');
document.write('            </tr--> ');
document.write('            <tr> ');
document.write('               <td class="extensible">');

document.write('               <!--script type="text/javascript">');
document.write('               google_ad_client = "pub-8058805063011934";');
document.write('               google_ad_width = 120;');
document.write('               google_ad_height = 240;');
document.write('               google_ad_format = "120x240_as";');
document.write('               google_ad_type = "text";');
document.write('               google_ad_channel ="";');
document.write('               google_color_border = "660000";');
document.write('               google_color_bg = "7D2626";');
document.write('               google_color_link = "FFFFFF";');
document.write('               google_color_url = "DAA520";');
document.write('               google_color_text = "BDB76B";');
document.write('               </script>');
document.write('               <script type="text/javascript"');
document.write('                 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">');
document.write('               </script-->');

document.write('                     <!--div style="width:125px;text-align:center;"><a href="/fr/site/news/index.htm" class="textualmenu">Les Nouveautés!</a></div--><br/>');
document.write('            	</td> ');
document.write('            </tr> ');
document.write('            <tr> <td>&nbsp;</td>');

document.write('            </tr> ');
document.write('         </table> ');
document.write('      </td> ');
document.write('      <td class="mm"> ');
document.write('<!-- HEADER END -->');
}


//
function createFooter(){
document.write('<!-- FOOTER START -->');
document.write('      </td> ');
document.write('      <td class="mr">&nbsp;</td> ');
document.write('   </tr> ');
document.write('   <tr class="bottom"> ');
document.write('      <td class="bl">&nbsp;</td> ');
document.write('      <td class="bm"> ');
document.write('         <table class="bottommenu" align="center"> ');
document.write('            <tr> ');
document.write('               <td>Menu Textuel: [ <a href="/" class="textualmenu">Home</a> ] [ <a href="/fr/centre/index.htm" class="textualmenu">Samye Dzong</a> ] [ <a href="/fr/lamas/index.htm" class="textualmenu">Lamas</a> ] [ <a href="/fr/bouddhisme/index.htm" class="textualmenu">Bouddhisme</a> ] [ <a href="/fr/activites/index.htm" class="textualmenu">Activités</a> ]<br /> ');
document.write('                  Tout contenu de ce site (sauf spécifié) &copy; Samyedzong Brussels<br /> ');
document.write('                  Commentaires peuvent être adressés au <a href="mailto:webmaster@samye.be" class="textualmenu">webmaster</a> </td> ');
document.write('            </tr> ');
document.write('            <tr> ');
document.write('               <td> ');
document.write('                  <div align="center">Designed by:&nbsp;<a href="http://www.stass.be" target="_blank"><img src="/fr/images/jpg/stass.jpg" align="absmiddle" alt="Stass Visual Arts" title="Site de Stass Visual Arts" height="20" border="0"/></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Engineered by:&nbsp;<a href="http://dixite.com" target="_blank"><img src="/fr/images/jpg/dixite.jpg" height="20" align="absmiddle" alt="Dixite" title="Site de Dixite" border="0"/></a></div> ');
document.write('               </td> ');
document.write('            </tr> ');
document.write('         </table> ');
document.write('      </td> ');
document.write('      <td class="br">&nbsp;</td> ');
document.write('   </tr> ');
document.write('</table> ');
document.write('<!-- FOOTER END -->');
}