var feli;
var t;
var n=0;
var speed = 400 //1sec;.
var bl_max = 5;
var editodata;
function blinkText() {
	n++;
	feli = document.getElementById('felicitations');
	if (jQuery("#felicitations").size() < 1) return 0;
	feli.style.visibility=(feli.style.visibility=="hidden")?"visible":"hidden";
	if(bl_max<0 || (n/2)<bl_max){
		//n/2 because we count show and hide together.
		t=setTimeout("blinkText()",speed);
	} else {
	}
}

function blinkNv(){
	nv = document.getElementById('nouveau_txt');
	if (jQuery("#nouveau_txt").size() < 1) return 0;
	nv.style.visibility=(nv.style.visibility=="hidden")?"visible":"hidden";
}
/* input type file styled */
function fileStyling (elt) {
	if (jQuery(elt).size() < 1) return 0;
	jQuery(elt).appendTo("#badgePhotoFileField");
	SI.Files.stylizeById('file');
	 //     jQuery(elt).filestyle({
	 //     image: "img/bt_photobadge.gif",
	 //     imageheight : 42,
	 //     imagewidth : 46,
	 //     width : 0
	 // });
	// 
	// return jQuery(elt).size();
}

/* adding choices in fonctionBadge select */
function moreFonctionBadgeChoices (elt) {
	if (jQuery(elt).size() < 1) return 0;
	jQuery("#moreChoiceContainer").hide();
	var newOpt = document.createElement("option");
	newOpt.value = "Autre";
	newOpt.innerHTML = "----Je cree mon poste----";
	jQuery(elt).prepend(newOpt);
 	jQuery(elt).selectOptions("Service Process");
   	jQuery(elt).change( function () {
		if (jQuery(elt+" option:selected").attr("value") == "Autre") {
			jQuery("#moreChoice").attr("value","");
   			jQuery("#moreChoiceContainer").show();
		};
	});
	jQuery("#badgeCreation").submit(function(){
		newTxt = jQuery("#moreChoice").attr("value");
		if (newTxt != null) {
			jQuery(elt).addOption(newTxt, newTxt);
			jQuery("#moreChoiceContainer").hide();
		}
		return true;
	})
    jQuery("#moreChoiceContainer img").click(function(){
		newTxt = jQuery("#moreChoice").attr("value");
		if (newTxt != null) {
			jQuery(elt).addOption(newTxt, newTxt);
			jQuery("#moreChoiceContainer").hide();
		}
	});
	return jQuery(elt).size();
}
function confirmSuppress(){
		var agree=confirm("Êtes vous sûr de vouloir supprimer votre badge ?\nVous pourrez le réactiver en cliquant sur le lien\nqui vous a été envoyé par email");
		if (agree)
			return true;
		else
			return false;
}
function showSpinner(){
	if(jQuery("#felicitations").size()){
	// jQuery("#edito").css("visibility","visible");
		setTimeout("hideSpinner()",4000);
	}
}
function hideSpinner(){
	jQuery("#spinner").css("display","none");
	//.fadeOut(1000)
}
/* Only initialize functions for all pages if needed */
jQuery(document).ready(function() {
	$("body").addClass("dynamic");
	initBlinkText = blinkText();
	initSpinner = showSpinner();
	t2=setInterval("blinkNv()",speed);

	$(function() {
		$('.lb2').lightBox({containerResizeSpeed:100, txtOf:"sur",overlayOpacity:0.3 });
		$('.lb1').lightBox({containerResizeSpeed:100, txtOf:"sur",overlayOpacity:0.3 });
		$('.lb').lightBox({containerResizeSpeed:100, txtOf:"sur",overlayOpacity:0.3 });
	});
	
	if(!jQuery.browser.mozilla && !jQuery.browser.opera){
	}
	$("#btn_supprimer").click(confirmSuppress);
	
	$("#photoBadgeWrapper").hover(function () {
      $(this).addClass("hover");
    }, function () {
      $(this).removeClass("hover");
    }).click(function(){
		$(this).addClass("ready");
	});
    initMoreFonctionBadgeChoices = moreFonctionBadgeChoices("#fonctionBadge");
    initFileStyling = fileStyling("#photoBadgeWrapper");
});














//END 