this.rubover = function(onglet_id) {
	subb = 0;
	$("#onglet li a").hover(function() {
		if (onglet_id==null || $(this).attr('id')!=onglet_id.attr(('id'))) {
			po = $(this).offset();
			px = po.left;
			py = po.top;
			l = $(this).outerWidth(true);
			h = $(this).outerHeight(true);
			//$(this).css({'border-bottom-size':subb+'px','border-bottom-style':'solid','border-bottom-color':'#1296D5'});
			$('body').append('<div id="rub-over"></div>');
			$('#rub-over').css({'top':(py + h + subb) + 'px','left':(px + (l/2)-12) + 'px','display':'block','height':'15px'});
		}
	},
	function(){
		//$(this).css({'border-bottom-size':'0px','border-bottom-style':'','border-bottom-color':''});
		$('#rub-over').remove();
	});
};

/* Affecte la meme hauteur des colonnes de liens pour chaque groupe */
this.heightcol = function() {
	var tGpeHeight = new Array();
	$('.groupe-lien').each(function() {
		tGpeHeight.push($(this).height());
		var tColHeight = new Array();
		$(this).find('.col-lien').each(function() {
			tColHeight.push($(this).height());
		});
		tColHeight.sort().reverse();
		$(this).find('.col-lien').height(tColHeight[0]);	
	});
	tGpeHeight.sort().reverse();
	$('.groupe-lien').height(tGpeHeight[0]);	
}

this.glisstoptaux = function() {
	
	lg_bloc = $('.un-taux').outerWidth(true);
	nb_bloc = $('.liste-gliss .un-taux').length;
	lg_tot = lg_bloc*nb_bloc;
	
	$('#ttd-nav-g,#ttd-nav-d').click(function() {
		xpos = $('.liste .liste-gliss').css('left');
		xpos = parseInt(xpos.substr(0, xpos.length-2));
		duree = 1200;
		if ($(this).attr('id')=='ttd-nav-g') {
			if (xpos<0)
				sens = '+='+lg_bloc;
			else {
				sens = '-='+(lg_tot-(4*lg_bloc));
				duree = 1900;
			}
		}
		else {
			if (xpos>((4*lg_bloc)-lg_tot))
				sens = '-='+lg_bloc;
			else {
				sens = '0px';
				duree = 1900;
			}
		}
		$('.liste-gliss').animate({left: sens}, duree, 'easeInOutBack');
		//togglebtnttd();
	});
	
};

$(document).ready(function(){
	
	$(document).pngFix();
	$("#tabs").tabs();
	
	if(onglet_id!=null) {
		rubover(onglet_id);
	}
	
	//heightcol();
	
	$("#flowpanes")
		.scrollable({circular:true,mousewheel:false,easing:"swing",keyboard:false})
		.navigator({navi:"#flowtabs",naviItem:'a',activeClass:'current',history:true});
		//.autoscroll({autoplay:true,autopause:true,interval:5000});
	var api = $("#flowpanes").data("scrollable");
	$("#flowtabs li").mouseover(function(){
		api.seekTo($(this).index());
	})
	
	
	$(".lancer-enchere")
		.button({icons: {secondary:'ui-icon-triangle-1-e'}})
		.addClass('ui-state-hover')
		.mouseenter(function(){$(this).css('text-decoration','underline')})
		.mouseleave(function(){$(this).addClass('ui-state-hover')});
	$("#lancer-enchere")
		.button()
		.addClass('ui-state-hover')
		.mouseenter(function(){$(this).css('text-decoration','underline')})
		.mouseleave(function(){$(this).addClass('ui-state-hover')});
	
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1 && navigator.appVersion.indexOf("MSIE 8.0") == -1);
	var ie7 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 7.0") != -1);
	
	if (jQuery.browser.msie && (ie55 || ie6 || ie7)) {
		$('#top-promo').css('overflow','hidden');
		$('#top-promo #coin-nouveau').css({'top':'-15px'});
	}
	
	glisstoptaux();
	$('.liste')
		.scrollable({circular: true, mousewheel: false, easing: 'swing', items: '.liste-gliss', next: '#ttd-nav-d', prev: '#ttd-nav-g'})
		.autoscroll({autoplay: true});
	
	$('#pro-inscription')
		.button()
		.addClass('ui-state-hover')
		.mouseenter(function(){$(this).css('text-decoration','underline')})
		.mouseleave(function(){$(this).addClass('ui-state-hover')});
	
	$("#fb_jaime").click(function(){
		
		/*
		$('#dialog')
			.dialog('destroy')
			.empty()
			.append('<p>Vous nous aimez ? Nous vous remercions !<p><p>Profitez d\'une r&eacute;duction sur le d&eacute;p&ocirc;t de votre dossier.</p>')
			.dialog({title:'Merci', width: 460, modal:true})
			.dialog('open');
		$.ajax({
			url: '/ajax/maj-affilie-auto-paiement/',
			data: 'apid='+apid+'&ap='+ap,
			dataType: 'json',
			cache: false,
			success: function(ojs){
				if(ojs!=null) {
					return ojs.ap;
				}
			},
			error: function(){
				$('#dialog')
					.dialog('destroy')
					.empty()
					.append('<p>Une erreur est survenue pendant la mise &agrave; jour de votre paiement.</p><p>Essayez de valider &agrave; nouveau votre formulaire. Si le probl&egrave;me persiste, nous vous invitons &agrave; fermer votre navigateur et &agrave; essayer &agrave; nouveau.<p>')
					.dialog({title: 'Oups !', width: 460, modal:true})
					.dialog('open');
			}
		});
		*/
	});
	
	$('.profil-aff a.btn')
		.button()
		.addClass('ui-state-hover')
		.css({'color':'#FFFFFF'})
		.mouseenter(function(){$(this).css({'text-decoration':'underline'})})
		.mouseleave(function(){$(this).addClass('ui-state-hover')});
	
});
