/*
	Copyright (C) 2009 2010  BoboTiG

    The JavaScript code in this page is free software: you can
    redistribute it and/or modify it under the terms of the GNU
    General Public License (GNU GPL) as published by the Free Software
    Foundation, either version 3 of the License, or (at your option)
    any later version.  The code is distributed WITHOUT ANY WARRANTY;
    without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.

    As additional permission under GNU GPL version 3 section 7, you
    may distribute non-source (e.g., minimized or compacted) forms of
    that code without the copy of the GNU GPL normally required by
    section 4, provided you include this license notice and a URL
    through which recipients can access the Corresponding Source.
*/

//
// Afficher-cacher un id
//
//
function affCache(idDiv) {
	var div = document.getElementById(idDiv);
	
	if ( div.style.display === '' ) { div.style.display = 'none'; }
	else { div.style.display = ''; }
	return;
}

//
// Afficher-cacher plusieurs id
//
function cache(b, c, d) {
	b = document.getElementById(b);
	c = document.getElementById(c);
	d = document.getElementById(d);
	b.style.display = 'none';
	c.style.display = 'none';
	d.style.display = 'none';
	return;
}

//
// Permet de tester si JavaScript est activé.
//
function test(z) {
	z = document.getElementById(z);
	z.style.display = 'none';
	return;
}

//
// Permet le centrage de la popup
//
function PopupCentrer(page, largeur, hauteur, options) {
	var top = (screen.height-hauteur) / 2;
	var left = (screen.width-largeur) / 2;
	
	window.open(page, '', 'top= ' + top + ', left= ' + left + ', width= '
		+ largeur + ', height = ' + hauteur + ',' + options);
	return;
}

//
// Autoriser les tabulation dans un textarea
//
function insertTab(event,obj) {
    var tabKeyCode = 9;
	var keycode = 0;
	
    if ( event.which ) { keycode = event.which; } // Mozilla
	else { keycode = event.keyCode; } // IE
    if ( keycode == tabKeyCode ) {
        if ( event.type == 'keydown' ) {
            if ( obj.setSelectionRange ) { // Mozilla
                var s = obj.selectionStart;
                var e = obj.selectionEnd;
                obj.value = obj.value.substring(0, s) + "\t" 
					+ obj.value.substr(e);
                obj.setSelectionRange(s + 1, s + 1);
                obj.focus();
            } else if ( obj.createTextRange ) { // IE
                document.selection.createRange().text = "\t";
                obj.onblur = function() {
					this.focus();
					this.onblur = null;
				};
            }
            else {} // Unsupported browsers
        }
        if ( event.returnValue ) { event.returnValue = false; } // IE ?
        if ( event.preventDefault ) { event.preventDefault(); } // DOM
        return false;
    }
    return true;
}

