// JavaScript Document
var ad = jQuery.noConflict();
ad(document).ready(function(){
	ad('#loading-block').hide();
	ad('.loading-short').hide();
	ad('#indicator-menu').hide();
	ad('#menu-services').fadeIn();
	recreateMenu('menu','top-menu-content');
	recreateMenu('menu-services','content');
})

function showContent(url,idPanel){
	ad('#pre-content').hide();
	var _panel = ad('#'+idPanel)
	var _bg = ad('#bg-'+idPanel);
	var _loading = ad('.'+this.panelId +' .loading-short');
	
	_panel.hide();
	_bg.slideUp();
	_loading.show();
	
	ad.get(url, function(data) {
		_panel.html(data);
		_bg.slideDown(500,function(){
								   _loading.hide();
								   _panel.show();
								   });
		
		
	});
}


function recreateMenu(id,panel){
	ad('#'+id+' a').each(
		function(item){
			var instance = ad(this);
			var lhref = this.href;
			this.lhref = lhref;
			this.panelId = id;
			this.panel = panel;
			this.href = '#'+this.title;
			instance.click(function(){
							showContent(this.lhref,this.panel);
							_instance = ad(this);
							var count = item;
							var jumpInd = (count * 10)+25;
							var _indicator = ad('.'+this.panelId +' .indicator');
							_indicator.css('height','2px');
							_indicator.show().animate({left: jumpInd+'%'}, 500, function() {});
			})
			
			instance.hover(function(){
				var count = item;
				var jumpInd = (count * 10)+25.5;
				var jumpIndM = (count * 10)+25;
				var _indicator = ad('.'+this.panelId +' .indicator-hover');
				_indicator.show().animate({left: jumpInd+'%'}, 100, function() {
																			 _indicator.animate({left: jumpIndM+'%'}, 100);
																			 });
			},
			function(){
				var _indicator = ad('.'+this.panelId +' .indicator-hover');
				_indicator.hide();
			}
			);
			
	});
}