	jQuery(document).pngie();

	function videoBoxPartners(){
		jQuery("#video-box .partners-video-box").click(function(){
			jQuery("#video-box").animate({height:"580px"}, function(){
				jQuery.scrollTo(jQuery("#video-box"), 500, {easing:'easeInOutQuart', offset:0});
				jQuery('span.closevideo').css({visibility:"visible"});
			} );
			jQuery("#video-box").children(":not(#vb-nav)").remove();
			jQuery("#video-box").append(jQuery("#fake-swap").html());
			videoClosePartners();
		});
	}
	
	function videoClosePartners(){
		jQuery("span.closevideo").click(function(){
			jQuery("#video-box").animate({height:"350px"});
			jQuery("#video-box").children(":not(#vb-nav)").remove();
			var swap  = jQuery("#swap").html();
			jQuery("#video-box").append(swap);
			jQuery.scrollTo(jQuery("#glob"),700,{easing:'easeInOutQuart'});
			jQuery("span.closevideo").css({visibility:"hidden"});
			videoBoxPartners();	
		});
	}
	
	function videoBoxConsumers(){
		jQuery("#video-box .consumers-video-box-2").click(function(){
			jQuery("#video-box").animate({height:"580px"}, function(){
				jQuery.scrollTo(jQuery("#video-box"), 500, {easing:'easeInOutQuart', offset:0});
				jQuery('span.closevideo').css({visibility:"visible"});
			} );
			jQuery("#video-box").children(":not(#vb-nav)").remove();
			jQuery("#video-box").append(jQuery("#fake-swap").html());
			videoCloseConsumers();
		});
	}
	
	function videoCloseConsumers(){
		jQuery("span.closevideo").click(function(){
			jQuery("#video-box").animate({height:"350px"});
			jQuery("#video-box").children(":not(#vb-nav)").remove();
			var swap  = jQuery("#swap").html();
			jQuery("#video-box").append(swap);
			jQuery.scrollTo(jQuery("#glob"),700,{easing:'easeInOutQuart'});
			jQuery("span.closevideo").css({visibility:"hidden"});
			videoBoxConsumers();	
		});
	}
	
	function videoBoxCompany(){
		jQuery("#companyvideobtn").click(function(){
			jQuery("#companyvideobox").animate({height:"380px"}, function(){
				jQuery.scrollTo(jQuery("#companyvideobox"), 500, {easing:'easeInOutQuart', offset:0});
				jQuery('span.closevideo').css({visibility:"visible"});
			} );
			jQuery("#companyvideobox").children(":not(#vb-nav)").remove();
			jQuery("#companyvideobox").append(jQuery("#fake-swap").html());
			videoCloseConsumers();
		});
	}
	
	function videoCloseCompany(){
		jQuery("span.closevideo").click(function(){
			jQuery("#companyvideobox").animate({height:"350px"});
			jQuery("#companyvideobox").children(":not(#vb-nav)").remove();
			var swap  = jQuery("#swap").html();
			jQuery("#companyvideobox").append(swap);
			jQuery.scrollTo(jQuery("#glob"),700,{easing:'easeInOutQuart'});
			jQuery("span.closevideo").css({visibility:"hidden"});
			videoBoxConsumers();	
		});
	}
	
	function scroll(){
		jQuery('a[href^=#]').click(function(){
			cible=jQuery(this).attr('href');
			if(jQuery(cible).length>=1){
				hauteur=jQuery(cible).offset().top;
			}
			else{
			hauteur=jQuery("a[name="+cible.substr(1,cible.length-1)+"]").offset().top;
			}
			jQuery('html,body').animate({scrollTop:hauteur},2000,'easeOutQuint');
			return false;
		});
	
	}

	function activationNav(clName){
		var ourName = "#community-nav li."+clName
		jQuery(ourName).css({"font-weight":"bold"});
		var pos = parseInt(jQuery(ourName).offset().left);
			   
		var w = parseInt(jQuery(ourName).width());
		w = w/2;
		pos = pos + w - fiokNav - 5 +"px";
		jQuery("#community-nav-wrapper").stop(true,true).animate({"background-position": pos +" bottom"},150);
			thisClName = clName
	}


	jQuery(document).ready(function(){
		fiokNav = jQuery('#community-nav-wrapper').offset().left;
		if(jQuery(".vbdiv.active").hasClass("m0"))
		{
			jQuery("span.arrowz").animate({left:"43px" },150);
		}
		if( jQuery(".vbdiv.active").hasClass('m1'))
		{
			jQuery("span.arrowz").animate({left:"143px"},150);
		}


		jQuery('#community-content').hide();
		videoBoxPartners();
		videoBoxConsumers();
		videoBoxCompany();
		scroll();
		
	fiokNav = jQuery('#community-nav-wrapper').offset().left;
	jQuery("#community-nav-wrapper li").hover(function(e){;
		var pos = parseInt(jQuery(this).offset().left);
				 e.stopPropagation();
		var w = parseInt(jQuery(this).width());
		w = w/2;
		pos = pos + w - fiokNav - 5 +"px";
		jQuery("#community-nav-wrapper").stop(true,true).animate({"background-position": pos +" bottom"},150);
	});
	
	jQuery(".vbdiv").hover(function(){
		if(jQuery(this).hasClass("m0"))
		{
			jQuery("span.arrowz").animate({left:"43px" },150);
		}
		if( jQuery(this).hasClass('m1'))
		{
			jQuery("span.arrowz").animate({left:"143px"},150);
		}
	});

	jQuery("#btn-top-nav").click(function(){

		if(!jQuery("#community-content").hasClass('toogled'))
		{
		jQuery("#community-content").addClass('toogled');
		jQuery("#community-content").slideToggle("slow", function(){
					jQuery('#badge-top-nav').animate({'margin-top':'75px'});
				}); return false;
		}
		else
		{
			  jQuery('#badge-top-nav').animate({'margin-top':'-65px'},500, function(){
				
		jQuery("#community-content").slideToggle("slow",function(){		
		jQuery("#community-content").removeClass('toogled');		  
		
		});
		return false;
			 });
		}
		});//click event behaviour
	jQuery('#btn-top-nav').replaceClass({event_type:"click", element_affected:"#btn-top-nav", old_class:"toogle-blue", new_class:"toogle-black"});
	});//ready event behaviour








function affinion_init()
{
    var nbElems = 1;
    fader(nbElems,0);
}


function affinion_middle()
{
}
/**
 * if the flash or the connection is too slow.
 */
function pass()
{
    affinion_init();
}
function fader(nbElems,num)
{
    if(num>=nbElems){return false;}
    else if(num===0){
        jQuery("body").addClass("charged");     
        jQuery("#flash_container").fadeOut(100);
        
        jQuery("#flash_box").fadeOut(200);
        jQuery("#mask").fadeOut(200);
        jQuery("#ipboard_body").css({overflow:"auto"});
                    
                   }
}	

// Set up Sliders
// **************
$(function(){

	$('#slider-homepage').anythingSlider({
		resizeContents      : false, // If true, solitary images/objects in the panel will expand to fit the viewport
		autoPlay            : true,     // If true, the slideshow will start running; replaces "startStopped" option
		buildArrows         : false,      // If true, builds the forwards and backwards buttons
		buildNavigation     : true,      // If true, buildsa list of anchor links to link to each panel
		navigationFormatter : function(index, panel){ // Format navigation labels with text
			return ['1', '2', '3'][index - 1];
		},
		onSlideComplete : function(slider){
			// alert('Welcome to Slide #' + slider.currentPage);
		}
	});

});

