// Изменение видимости компаний и напрвлений деятельности

var currentType = 'act';

function setDirections(type, obj, other_obj) {	
	
	if(currentType != type) {
	
		var obj_txt = jQuery('#' + obj).text();
		var other_obj_txt = jQuery('#' + other_obj).text();
		
		jQuery('#' + obj).html('<span>' + obj_txt + '</span>');
		jQuery('#' + other_obj).html('<a href="#">' + other_obj_txt + '</a>');		
	
		if(type == 'act') {
		
			jQuery('#directions div.companies').css('display', 'none');
			jQuery('#directions div.activities').css('display', 'block');	
			
		}
		
		if(type == 'comp') {
		
			jQuery('#directions div.activities').css('display', 'none');
			jQuery('#directions div.companies').css('display', 'block');	
			
		}
		
		currentType = type;
		
	}
	
}

function hideForm() {	
	$("#bubbles_content").fadeOut(300, function(){
		$("#back-window").hide();
	});
}

var current_top_position = 0;

function loadBubbles(href, position) {
	
	if(current_top_position > 0) {
	
		jQuery('#top_' + current_top_position).removeClass("active");
		
	}
	
	jQuery('#top_' + position).addClass("active");	
	current_top_position = position;
	
	if(position == 1) {
		
		jQuery('#corner_id').css('left', '110px');
		
	}
	
	if(position == 2) {
		
		jQuery('#corner_id').css('left', '305px');
		
	}
	
	if(position == 3) {
		
		jQuery('#corner_id').css('left', '475px');
		
	}
	
	if(position == 4) {
		
		jQuery('#corner_id').css('left', '645px');
		
	}
	
	$("#bubbles_content").fadeIn(300, function(){
		$("#back-window").show();		
		jQuery("#bubbles_load").html('<h2>Загрузка</h2>Подождите, идёт загрузка данных...');
		jQuery("#bubbles_load").load(href);
		
	});
	return false;
	
}

$(document).ready(function(){
	$("#back-window").bind("click", function(){
		hideForm();
	});
});



