$(document).ready(function() {
						   
	$('div.rub a').click(function() {
		id = $(this).attr('id');
		$('div[id^=div_], div[id^=div_] .canBeHided').hide();
		$('#div_'+id).fadeIn();
		$('#'+id+'_prochains_matchs').fadeIn();
		$('div.rub a').attr('class', '');
		$(this).attr('class', 'visited');	
	});
	$('.mini_rub a').click(function() {
		$('.mini_rub a').attr('class', '');
		$(this).attr('class', 'visited');
		title = $(this).attr('title');
		$('div[id^=div_] .canBeHided').hide();
		$('#'+title).fadeIn();
	});
	$('div[id^=div_], div[id^=div_] .canBeHided').hide();
	$('#div_1').fadeIn();
	$('#1_prochains_matchs').fadeIn();
	$('a[id=1], a[title=1_prochains_matchs]').attr('class', 'visited');	
						   
	/* Deroulement des menus */
/*	$('#menus h4').click(function() {
		var element = $(this).parent();
		if (element.attr('class') == 'non_dev') {
			element.find('ul').slideDown();
			element.removeClass('non_dev');
		} else {
			element.find('ul').slideUp();
			element.addClass('non_dev');
		}
	});*/
	/* Emulation du li:hover pour IE */
	var to_garde = '';
	$('#menu li').each(function() {
		if ($(this).attr('class') == 'liHover') {
			to_garde = $(this).children().html();
		}
	});
	$('#menu li').hover(function() {
		$(this).addClass('liHover');
	},
	function() {
		if ($(this).children().html() != to_garde) {
			$(this).removeClass('liHover');
		}
	});
	/* Transformation des Hx pour meilleure présentation */
	$('h1 span').hide();
	$('h1').each(function() {
		if ($(this).attr('class') != 'H1lotofoot' && $(this).attr('class') != 'parier' && $(this).parent().attr('class') != 'noH1' && $(this).parent().attr('class') != 'part2' && $(this).parent().parent(). attr('id') != 'contenu-nstyle'
			&& $(this).attr('id') != 'noStyle' && $(this).parent().attr('class') != 'bleuH1') {
			more = "";
			if ($(this).attr('class').length == 11) {
					more = '&bgcolor=' + $(this).attr('class');
			}
			if ($(this).attr('title').length > 0) {
					more = '&logo=' + $(this).attr('title');
			}
			if ($(this).children().length == 1) {
				texte = $(this).children().html();
				texte = texte.replace(/"/g, '-quot-');
				$(this).attr('style', 'background-image: url("/font/head1.php?texte='+texte+more+'");cursor:pointer;');
				url = $(this).children().attr('href');
				$(this).attr('onclick', 'window.location.replace("'+url+'")');
				$(this).html('');
			} else {
				texte = $(this).html();
				texte = texte.replace(/"/g, '-quot-');
				$(this).attr('style', 'background-image: url("/font/head1.php?texte='+texte+more+'")');
				$(this).html('');
			}
		}
	});
	$('h2').each(function() {
		if ($(this).parent().attr('class') != 'deroule' && $(this).attr('class') != 'nodecoH2' && $(this).parent().attr('class') != 'noH2' && $(this).parent().attr('id') != 'contenu-nstyle' &&
			$(this).parent().attr('class') != 'noH1' && $(this).parent().attr('class') != 'methode') {
			more = "";
			if ($(this).attr('class').length == 11) {
					more = '&bgcolor=' + $(this).attr('class');
			}
			if ($(this).attr('title').length > 0) {
					more = '&logo=' + $(this).attr('title');
			}
			if ($(this).children().length == 1) {
				texte = $(this).children().html();
				texte = $(this).find('a').html();
				texte = texte.replace(/"/g, '-quot-');
				$(this).attr('style', 'background-image: url("/font/head2.php?texte='+texte+more+'");cursor:pointer;');
				url = $(this).find('a').attr('href');
				$(this).attr('onclick', 'window.location.replace("'+url+'")');
				$(this).html('');
			} else {
				texte = $(this).html();
				texte = texte.replace(/"/g, '-quot-');
				$(this).attr('style', 'background-image: url("/font/head2.php?texte='+texte+more+'")');
				$(this).html('');
			}
		}
	});
	$('h3[class=decoPHP]').each(function() {
		if ($(this).children().length == 1) {
				texte = $(this).children().html();
				$(this).attr('style', 'background-image: url("/font/head3.php?texte='+texte+'");cursor:pointer;');
				url = $(this).children().attr('href');
				$(this).attr('onclick', 'window.location.replace("'+url+'")');
				$(this).html('');
			} else {
				texte = $(this).html();
				$(this).attr('style', 'background-image: url("/font/head3.php?texte='+texte+'")');
				$(this).html('');
			}
	});
	// "Hide" de tous les menus à la base
	$('div[class=non_dev] ul').each(function() {
		if (to_see == false || to_see != $(this).attr('title')) {
			$(this).hide();
		} else {
			$(this).hide();
			$(this).slideDown();
			$(this).parent().removeClass('non_dev');
		}
	});
	// Element xAjax
	$('.xAjax ul.liens li').click(function() {
		var id = $(this).find('a').attr('class');
		$(this).parent().parent().find('div').each(function() {
			thisClass = $(this).attr('class');
			if (thisClass != 'actu_div' && thisClass != 'noH2' && thisClass != 'podium' && thisClass != 'tablePronosticHome') $(this).hide();
		});
		$(this).parent().find('li').removeClass('select');
		$('div[id='+id+']').removeClass('hide');
		$('div[id='+id+']').show();
		$(this).addClass('select');
	});
	$('.xAjaxHome a[rel=onglet]').click(function() {
		var id = $(this).attr('class');
		$('div[id^=onglet]').hide();
		$('div[id='+id+']').removeClass('hide');
		$('div[id='+id+']').show();
	});
	// Decors tableau
	$('.table table, .tableAutresMatchs table').each(function() {
		var modulo = 0;
		$(this).find('thead').find('td').each(function() {
			if (modulo % 2) {
				$(this).addClass('modCol');
			}
			modulo++;
		});
		var modulo = 0;
		$(this).find('tr').find('td').each(function() {
			if (modulo % 2) {
				$(this).addClass('modColTD');
			}
			modulo++;
		});
	});
//	premier = true;
	$('.table table tr:even').each(function() {
//		if (premier) {
//			premier = false;
//		} else {
			$(this).addClass('modTR');
//		}
	});
	
	
	premier = false;
	$('.tbookmakers tr:even').each(function() {
		if (premier) {
			premier = false;
		} else {
			$(this).addClass('modTR');
		}
	});
	
	/*$('.tablePronostic table tr').each(function() {
		thisModulo = 0;
		$(this).find('td').each(function() {
			if (thisModulo%2 && $(this).attr('class').length == 0) $(this).addClass('mod');
			thisModulo++;
		});
	});*/
	
	// Arrondir des divs
	$('.table, .bg_contenu, .tablePronostic, .cnews, .tableLotofoot, .tableAutresMatchs, .filter, .xAjaxBleu').corner();
	$('.boxe_grise').corner().parent().css('padding', '2px').corner("round 10px");
	$('.titre_bleu').corner().parent().css('padding', '2px').corner("round 10px");
	$('#arrondiL').corner('tl');
	$('#arrondiR').corner('tr');
	$('.cote').corner('bottom');
	// Deroule contenu (ex: page pronostic)
	$('.deroule h2').click(function() {
		var id = $(this).attr('id');
		if ($(this).attr('class') == 'open') {
			$(this).removeClass('open');
			$('div[id=div'+id+']').slideUp();
		} else {
			$(this).addClass('open');
			$('div[id=div'+id+']').slideDown();
		}
	});
	
	$('.tableLotofoot tr:even').addClass('modulo');
	
	// Input arrondi
	$('#contenu table[class!=noDecoInput] input[type=text]').each(function() {
		if ($(this).attr('class') != 'PASDEDECO') $(this).wrap('<div class="input"></div>');
	});
	$('#contenu table[class!=noDecoInput] input[type=password]').wrap('<div class="input"></div>');
	$('#contenu input[type=submit]').each(function() {
		if ($(this).attr('class') != 'PASDEDECO') $(this).addClass('inputSubmit');
	});
	
	$('#bwin p').hover(function() {
		$(this).addClass('pHover')
	}, 
	function() {
		$(this).removeClass('pHover');
	});
	onglet('parier_football');
	
	$('.infoBulleHover').hover(function() {
		message = $(this).find('img').attr('title');
		divChildren = $(this).find('div');
		divChildren.addClass('infoBulle');
		var ok = 'lol';
	},
	function() {
		divChildren = $(this).children();
		divChildren.removeClass('infoBulle');
	});
	
	$('.depliTR').hide();
	
	$('.xAjaxBleu span').click(function() {
		div = 'div_' + $(this).attr('id');
		$('.xAjaxBleu span').attr('class', ' ');
		$(this).attr('class', 'selected');
		$('.xAjaxBleu ul').hide();
		$('.xAjaxBleu ul[id='+div+']').fadeIn();
	});
	
	// Dépli dans la partie recherche
	$('a[class=clickToSeeMoreLink]').click(function() {
		idDiv = 'div' + $(this).attr('id');
		$('div#'+idDiv).css('height', 'auto');
		$(this).hide();
	});
	// Dépli dans la partie actualités
	$('a.clickToSeeMoreLinkSearch').click(function() {
		idUL = 'UL' + $(this).attr('id');
		$('ul[id='+idUL+'] li.toHide').css('display', 'block');
		$('ul[id='+idUL+']').parent().css('height', 'auto');
		$(this).hide();
	});
	$('.calculer_mises_pronostic').css('cursor', 'pointer');
	idBoxCalculetteActif = false;
	$('.calculer_mises_pronostic').click(function(e) {
		boxCalculetteElm = $('.boxCalculette');
		if ($(this).attr('id') == idBoxCalculetteActif) {
			boxCalculetteElm.hide();
			clearTimeout(checkMise);
			idBoxCalculetteActif = false;
		} else {
			idBoxCalculetteActif = $(this).attr('id');
			x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
			alert(x);
//			x -= 230;
			y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
			y -= 30;
			fiabilite = $(this).attr('alt');
			boxCalculetteElm.attr('style', 'margin-left:'+x+'px;top:'+y+'px;display:block;');
			checkMise = setTimeout("calculMiseBox('"+fiabilite+"')", 200);
		}
	});
	$('.boxCalculette i.ferme').click(function() {
		if (idBoxCalculetteActif != false) {
			boxCalculetteElm.hide();
			clearTimeout(checkMise);
			idBoxCalculetteActif = false;
		}
	});
	if(navigator.appName.substring(0,3) == "Net")
	document.captureEvents(Event.MOUSEMOVE);
});
function calculMiseBox(fiabilite) {
	mises = new Array();
	mises['1'] = 1;
	mises['1_5'] = 1.5;
	mises['2'] = 2;
	mises['2_5'] = 3;
	mises['3'] = 5;
	mises['3_5'] = 8;
	mises['4'] = 10;
	mises['4_5'] = 15;
	mises['5'] = 20;
	elmInputMise = $('.boxCalculetteAMiser');
	capital = parseFloat($('#boxCalculetteInput').attr('value'));
	if (!isNaN(capital)) {
		valToPut = mises[fiabilite] + "% soit environ:<br /><b>";
		valToPut += Math.round(mises[fiabilite] / 100 * capital);
		valToPut += '&euro;</b>';
		elmInputMise.html(valToPut);
	}
	checkMise = setTimeout("calculMiseBox('"+fiabilite+"')", 200);
}

function pop_info(url) {
	window.open(url,"Informations sur un pronostic","menubar=no, status=no, scrollbars=no, menubar=no, width=500, height=423");
}

function onglet(div_to_see) {
	$('div[id^=parier_]').hide();
	$('div[id='+div_to_see+']').show();
}