$.extend({
	isIE : $.browser.msie,
	isIE6 : $.browser.msie && $.browser.version <= 6,
	isIE7 : $.browser.msie && $.browser.version == 7,
	nbDesc : function(a,b){ return b-a; },
	getMax : function(arr){
		arr.sort(this.nbDesc);
		return arr[0];
	}
});
if( $.isIE ) $.getScript('/includes/cobrand/js/ie.js');

/* Sondage
------------------------------------------------------------ */
/*if( !$('#sondage-match').length ){
// Vars
	var id_sondage = $('#sondage-match input[name=sondage]').val();
	var cookie_name = 'SONDAGE_ID_' + id_sondage;
	var urlToRequest = 'http://static.matchfr.in.parismatch.com/includes/Sondages/' + id_sondage + '/';
// Functions
	var _voted = function(){
		if( $.cookie(cookie_name) === null ) return false;
		else if( !$.cookie(cookie_name) ) return false;
		else return true;
	};
	var _verif = function(cb){
		if( $('#sondage-match :radio:checked').val() === undefined ) return false;
		else return true;
	};
	var _success = function(r){
		$('#sondage-loader').prepend(r);
		$('#sondage-match').css({ display: 'block' });
	};
// Load question || ansers
	urlToRequest += (_voted()) ? 'answers.htm' : 'question.htm';
	$.ajax({
		url: urlToRequest,
		dataType: 'html',
		success: function(html){ _success(html); }
	});
// Events
	$('#sondage-match :submit').live('click',function(){
		if( _verif() ){
			$.cookie(cookie_name, 'TRUE',{ expires: 1, path: '/', domain: 'parismatch.com' });
			return true;
		}
		else{
			$('#sondage-loader ul').next('.error').remove().end().after('<p class="error">Merci de choisir une réponse avant de voter.</p>');
			return false;
		}
	});	
}*/

/* ADS
------------------------------------------------------------ */
$.fn.adsLoader = function(){
	var get = function(id){
		return ( null === document.getElementById(id) ) ? false : document.getElementById(id);
	};
	$('div',this).each(function(){
		var cible = get(this.id.substring(5,this.id.length));
		( cible ) ? cible.appendChild(get(this.id)) : $(this).remove();
	});
}
/* Sondages
------------------------------------------------------------ */
$("#sondage-select-category").change(function(event){
	window.location.replace( $("#sondage-select-category option:selected").val() );
});