// JavaScript Document
//gestionnaire de skin
var mooSwitcher;
var nbSkin;
var progressBar;
var SkinSwitcherInit = function() {
	var sizeBodyContainer = $('bodyContainer').getSize();
	$$('#bodyContainer div.bodySkin').each(function(item, index){
		item.setStyle("height",sizeBodyContainer.y);
		item.fade('hide');
	});
	$('skin_0').fade('in');
	myCurrentSkinIndex = 0;
};

function initSwitcherNoFlashProgBar() {
	//prog bar
	progressBar = new dwProgressBar({
	    container: $('progress-bar'),
		startPercentage: 0,
		speed:750,
		boxID: 'box',
		percentageID: 'perc',
		displayID: 'text',
	    displayText: true
	});
	
	var loader = new Asset.images(images_annonce, {
		onProgress: function(counter,index) {
			progressBar.set((counter) * (100 / images_annonce.length));
    	},
	    onComplete: function() {
    		//alert("Complete");
    		var i = 0;
    		images_annonce.each(function(image) {
	    		var a = new Element('a',{id:'annonce_'+i,href: url_annonce[i]}).inject($("skinSwitcherNoFlashBox"));
	    		new Element('img',{ src:image,  style:'border:0px;' }).inject(a);
	    		i ++;
	    	});
	    	initSwitcherNoFlash((images_annonce.length - 1));
	    	$('progress-bar').setStyle("display","none");
	    }
	});
}

function initSwitcherNoFlash(nbSkin) {
	mooSwitcher = new noobSlide({
		box: $('skinSwitcherNoFlashBox'),
		items: $$("#skinSwitcherNoFlashBox a"),
		size: 962,
		addButtons: {
			previous: $('btNavPrev'),
			next: $('btNavNext'),
			stop: $('btNavPause')
		},
		autoPlay: true
	});
}
function initVignetteFamille() {
	 var list = $$('#vignetteFamille a');
	 if (!Browser.ie6 && !Browser.ie7 && !Browser.ie8){
	  list.addEvents({
		  mouseenter: function(){
		  this.getElement("img").addClass("in").addClass("ombre_portee_longue");
		  
	  },

	    mouseleave: function(){
		  this.getElement("img").removeClass("in").removeClass("ombre_portee_longue");
	    }
		
	 });
	 }
	
}
function SkinSwitcherToUrl() {
	location.href = myTabUrl[myCurrentSkinIndex];	
}

function fadeSkin() {
	$(arguments[0]).fade('in');
	var TabCurrentSkinVal = arguments[0].split('_');
	myCurrentSkinIndex = TabCurrentSkinVal[1];
	if(arguments.length > 1) {	
		$(arguments[1]).fade('out');	
	}
}
function logonEspaceMembre() {
	$("espaceMebreFormConnexion").submit();
}

function afficherInscriptionNewsletter() {
	afficher_contenu("/index/afficherInscriptionNewsletter/", "rub_newsletter", "");
		
}

function afficherActualite() {
	afficher_contenu("/index/afficherBlockActualite/", "contentActualite", "");
}
function afficherBonneAffaire() {
	afficher_contenu_callback("/index/afficherBlockBonneAffaires/", "containerBonneAffaire", "","initNoobSlideBonneAffaire();");
}
function initNoobSlideBonneAffaire() {
	var nS4 = new noobSlide({
		box: $('contentBonneAffSlide_content'),
		items: $$('#contentBonneAffSlide_content div'),
		size: 336,
		addButtons: {
			previous: $('bonneAffSlide_bt_prev'),
			next: $('bonneAffSlide_bt_next')
		}
	});
	
}
