
window.addEvent('domready', function() {
	
	/** Clignotement */
	
	var blinkingSpeed = 500;
	
	if (document.getElementById('clignotant') != null) {
		startBlinking(blinkingSpeed);
	}
	
	
	/** Partie gauche */
	
	
	
	/*
	var myAccordion = new Accordion($('categorie'), 'span.nom_pays', 'div.liste_club', {
		opacity: false,
	});
	*/
		
	
	
	/*
	var myEl = $('liste_equipes_ligue_2');
	myEl.setStyle('display', 'none');
	
	
	$('ligue_1').addEvent('click', function(e) {
		e.stop();
		var myVerticalSlide = new Fx.Slide('liste_equipes_ligue_1');
		myVerticalSlide.toggle();
		
		var myVerticalSlide = new Fx.Slide('liste_equipes_ligue_2');
		myVerticalSlide.toggle();
	});
	
	$('ligue_2').addEvent('click', function(e) {
		e.stop();
		var myVerticalSlide = new Fx.Slide('liste_equipes_ligue_2');
		myVerticalSlide.toggle();
		
		var myVerticalSlide = new Fx.Slide('liste_equipes_ligue_1');
		myVerticalSlide.toggle();
	});
	*/
	
	/*
	$('ligue_1').addEvent('mouseover', function(e){
		e.stop();
		var myVerticalSlide = new Fx.Slide('equipes_ligue_1');
		myVerticalSlide.toggle();
	});
	
	$('ligue_2').addEvent('mouseover', function(e){
		e.stop();
		var myVerticalSlide = new Fx.Slide('equipes_ligue_2');
		myVerticalSlide.toggle();
	});
	*/
	
})

function startBlinking(blinkingSpeed)
{
	setInterval("blink()", blinkingSpeed);
}


function popup(url, nomFenetre, width, height)
{
	window.open(url, nomFenetre,
	'toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width=' + width + ',height=' + height);
}


function blink()
{
	if ( document.getElementById('clignotant').className == 'invisible' ) {
		document.getElementById('clignotant').className = 'visible';
	}
	else {
		document.getElementById('clignotant').className = 'invisible';
	}
}

function intval(mixed_var, base) {
    var tmp;
    var type = typeof( mixed_var );
    if (type == 'boolean'){
        if (mixed_var == true) {
            return 1;
        } else {
            return 0;
        }
    } else if (type == 'string'){
        tmp = parseInt(mixed_var * 1, 10);
        if (isNaN(tmp) || !isFinite(tmp)){
            return 0;
        } else{
            return tmp.toString(base || 10);
        }
    } else if (type == 'number' && isFinite(mixed_var) ){
        return Math.floor(mixed_var);
    } else{
        return 0;
    }
}

function utf8_encode ( argString ) {
    // Encodes an ISO-8859-1 string to UTF-8  
    // 
    // version: 1006.1915
    // discuss at: http://phpjs.org/functions/utf8_encode    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: sowberry
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman    // +   improved by: Yves Sucaet
    // +   bugfixed by: Onno Marsman
    // +   bugfixed by: Ulrich
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'    
	var string = (argString+''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
 
    var utftext = "";
    var start, end;
    var stringl = 0; 
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {            if (end > start) {
                utftext += string.substring(start, end);
            }
            utftext += enc;
            start = end = n+1;        }
    }
 
    if (end > start) {
        utftext += string.substring(start, string.length);    }
 
    return utftext;
}

function utf8_decode ( str_data ) {
    // Converts a UTF-8 encoded string to ISO-8859-1  
    // 
    // version: 1006.1915
    // discuss at: http://phpjs.org/functions/utf8_decode    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +      input by: Aman Gupta
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Norman "zEh" Fuchs
    // +   bugfixed by: hitwork    // +   bugfixed by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: utf8_decode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'    
	var tmp_arr = [], i = 0, ac = 0, c1 = 0, c2 = 0, c3 = 0;
    
    str_data += '';
    
    while ( i < str_data.length ) {        c1 = str_data.charCodeAt(i);
        if (c1 < 128) {
            tmp_arr[ac++] = String.fromCharCode(c1);
            i++;
        } else if ((c1 > 191) && (c1 < 224)) {            c2 = str_data.charCodeAt(i+1);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i+1);            c3 = str_data.charCodeAt(i+2);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    } 
    return tmp_arr.join('');
}