box.dom(function(){
    
    /*album left leftNav slide action*/
    if(box.dom("#contextual").length > 0) {
        //get height of each block, to make jquery slide smoothly and delete the last hr
        box.dom('#contextual dd').each(function() {
            var current = $(this);
            current.css("height", current.height());
            box.dom(this).find('div.hr:last').remove();
            //special class if dd contains only one link
            if(current.find('a').size() == 1 ) {
                current.prev().addClass('directLink');
            }
        });
        
        //insert link to each dt, to make keyboard access
        // box.dom('dt').each(function () {
        //     box.dom(this).wrapInner("<a href=\"#\"></a>");
        // });
        
        //initial display status of each board
        box.dom("#contextual dd").hide();
        box.dom(".titleON + dd").show();
        //hide dd if it contains only one link
        box.dom(".directLink + dd").hide();
        
        //on board click, deal with slide
        box.dom("#contextual dt , #contextual .titleON, #contextualBlue dt , #contextualBlue .titleON").click(function(){
            if(box.dom(this).attr("class") == "") {
                box.dom("#contextual .titleON ~ dd, #contextualBlue .titleON ~ dd").slideUp(800);
                box.dom("#contextual dt").removeClass("titleON");
                box.dom(this).addClass("titleON").next("dd").slideDown(600);
            }
        });
        
        //add slide effect when link clicked
        box.dom('dt a').click(function(e) {
            if(!(box.dom(this).parent().hasClass('directLink'))){
                e.preventDefault();
                box.dom(this).parent("dt").click();
            }
        });
    }
    
    /*album navalb onclick url redirection*/
    if(box.dom("#navAlb").length > 0){
        box.dom("#navAlb li").click(function() {
            var url = box.dom(this).find("a").attr("href");
            window.location.href = url;
        });
    }
    
    /*faq slideUp and slideDown*/
    /*hide .blockHide*/
    if(box.dom(".item").length > 0) {    
        box.dom(".item  div").addClass("blockHide");
        
        // dafault tab open
        var activeTab = window.location.hash;
        if (box.dom(activeTab).length > 0) {
            box.dom(activeTab).children("div").slideDown(70).removeClass("blockHide");
            box.dom(activeTab).children("h4").addClass("questionSelected");
            box.dom(activeTab).children("h3").addClass("questionSelected");
            
			var tagTitle = box.dom(activeTab).children("h4").text().toLowerCase().replace(/ /g,"-");
			tagTitle = cleanString(tagTitle);
			if (tagTitle != '' && typeof(sitestatTag) !== 'undefined' && typeof(googleTag) !== 'undefined')
			{
				sitestat( sitestatTag + "." + tagTitle);
				rollupTracker._trackPageview(googleTag + "/" + tagTitle);
			}
        }
        
        box.dom(".item em , .item h3 , .item h4").click(function() {
            if(box.dom(this).siblings("div").attr("class") == "") {
                box.dom(this).parent(".item").children("div").slideUp(70).addClass("blockHide");
                box.dom(this).parent(".item").children("h4").removeClass("questionSelected");
                box.dom(this).parent(".item").children("h3").removeClass("questionSelected");
            } else {
                box.dom(this).parent(".item").children("div").slideDown(70).removeClass("blockHide");
                box.dom(this).parent(".item").children("h4").addClass("questionSelected");
                box.dom(this).parent(".item").children("h3").addClass("questionSelected");
				var tagTitle=box.dom(this).parent(".item").children("h4").text().toLowerCase().replace(/ /g,"-");
				tagTitle = cleanString(tagTitle);
				if (tagTitle != '' && typeof(sitestatTag) !== 'undefined' && typeof(googleTag) !== 'undefined')
				{
					sitestat( sitestatTag + "." + tagTitle);
					rollupTracker._trackPageview(googleTag + "/" + tagTitle);
				}
            }
        });
        box.dom(".item h3").hover(function() {
            box.dom(this).parent(".item").children("h3").addClass("hover");
        }, function() {
            box.dom(this).parent(".item").children("h3").removeClass("hover");
        });
        box.dom(".item h4").hover(function() {
            box.dom(this).parent(".item").children("h4").addClass("hover");
        }, function() {
            box.dom(this).parent(".item").children("h4").removeClass("hover");
        });
    }
    
    if(box.dom("#surveyForm").length > 0) {
        // box.ui('form').create({
        //     element: '#surveyForm'
        // }).addReplacement();
    }
    
    if(box.dom("#voteData").length > 0) {
        $("#voteData ul li").each(function(i) {
            $(this).children().children(".voteBar").children("span").css("width",$(this).children().children(".data").html());
        });
    }
    
    if(box.dom("#clubSessionsContent").length > 0) {
        for(i = 1; i < box.dom('#clubSessionsContent .category').length; i++) {
            if(i%3 == 0) {
                box.dom('#clubSessionsContent .category:eq(' + i + ')').before('<div style="clear:both;"></div>');
            }
        }
    }
    
    jQuery('a.pushGalliaLait2').click(function() {
    	rollupTracker._trackEvent('pushs','push-produits','http://www.laboratoire-gallia.com/7-9-mois/bebe-nutrition/lait-2eme-age');
    });
});
