var AZ = {						
	subSection:""
};	

AZ.createSecondaryMenu = function(){
	$('#company .secondaryMenuDiv .secondaryMenu').empty()
	$('#company .secondaryMenuDiv .secondaryMenu').load('content/' + lang + '/company.html ul.secondaryMenuUL');	
		setTimeout(function(){				
			$('nav.secondaryMenu a').each(function() {	
				if($(this).attr('id') == PO.subSection+'-link'){
					$(this).parent().siblings().find("a").removeClass('selected');
					$(this).addClass('selected');
				}
            });
			if(PO.subSection == ''){
				$('nav.secondaryMenu a:first').addClass('selected');
			}
		}, 400);
};

AZ.loadSection = function(){
	var divs;
	$.ajax({
	  type: "GET",
		 url: 'content/' + lang + '/company.html',
		 context:$('#company'),
		 dataType: "html",
		 success: function(h) {
			if(PO.subSection == ''){
				divs = $(h).filter(function(){ return $(this).is('div.section:first') });
			}else{
				divs = $(h).filter(function(){ return $(this).is('div#'+PO.subSection) });
			}
			var htmlText = $(divs[0]).html();
			$(this).find('h1').html($(h).filter('h1').html());
			Cufon.replace('h1');
			$(this).find('#companyContentContainer').html($(divs[0]).html());
			
			PO.sectionLoaded = true;
			if(BGO.imageLoaded && !PO.showingSplashPage){
				PO.animateSection();
				return;
			}	
		 }
	}); //close $.ajax
	AZ.checkScrollbars();
		
	if ($('#companyContent').fleXcroll){
		document.getElementById('companyContent').fleXcroll.setScrollPos(0,0);
		fleXenv.updateScrollBars();
	}
	setTimeout(AZ.checkScrollbars, 3000);
};

AZ.loadSubSection = function(){
	$.ajax({
	  type: "GET",
		 url: 'content/' + lang + '/company.html',
		 context:$('#company'),
		 dataType: "html",
		 success: function(h) {
			divs = $(h).filter(function(){ return $(this).is('div#'+PO.subSection) });
			var htmlText = $(divs[0]).html();
			var content = $(this).find('#companyContent');
			var contentDiv = $(this).find('#companyContentContainer');
			
			//contentDiv.slideUp(500, function(){
				contentDiv.hide().html($(divs[0]).html()).show();					 
				//contentDiv.html($(divs[0]).html()).slideDown(500, function(){
					fleXenv.fleXcrollMain("companyContent");
					fleXenv.updateScrollBars();
				//});			  
			//})
						
		 }
	}); //close $.ajax
}

AZ.checkScrollbars = function(){
	$('#companyContent').css('height', $(document).height()-(($(document).height()/3)+100));
	if(!document.getElementById('companyContent').fleXcroll){
		fleXenv.fleXcrollMain("companyContent");
	}
	fleXenv.updateScrollBars();
}
