//========================================================================
//                Totes Display Control by Section Name
// This file work with Kentico DocType: Broker Totes, Transformation: Tote
//                [2011.06.08 Created by Daisuke Ueda]
//========================================================================
$(document).ready(function(){
	$('div.tote').css("display","none");
	var href = $(location).attr('pathname');
	var sectionHref = href.split("/");

	//If the target page doesn't have sub section, remove the extension
	if (sectionHref[1].lastIndexOf(".") > 0) {
		sectionHref[1] = sectionHref[1].replace(".aspx","");
	}
	sectionHref[1] = sectionHref[1].toLowerCase();
	
	var currTote, flgTote;
	var defaultToteNum = [];
	for(var i=0;i<$("div.tote").size();i++) {
		currTote = $('div.tote:eq(' + i + ')').attr('section');
		
		//Adjust the Text URL with 
		currTote = currTote.replace("/","");
		
		//Check if the tote value matches with the first level folder.
		if (currTote.toLowerCase() == sectionHref[1]) {
			$('div.tote:eq(' + i + ')').css("display","block");
			flgTote = true;
		}
		
		if (currTote == "default") {
			defaultToteNum.push(i);
		}
	}
	//Display default tote
	if (!flgTote && defaultToteNum.length > 0) {
		$.each(defaultToteNum, function(key, value) { 
		  $('div.tote:eq(' + value + ')').css("display","block");
		});
		
	}
});
