$(document).ready(function() {
	var subContent 	= $(".sub_content");
	var contentSep	= $(".sub_content_sep");
	var subSections	= $(".sub_menu ul li");
	var balls		= $(".balls");
	var content		= $(".index_content");
	var text		= $(".text_box");
	var image		= $(".image_box");
	
	loadSection(section);
	
	$(subSections).click(function() {
		loadSection(this.id);
	});
	
	function resetMenu()
	{
		$.each(subSections, function(key, value) {
			$(value).removeClass("active");
		});
		
		text.attr("class", "text_box");
		image.attr("class", "image_box");
		
		$("#presentacion").attr("class", "grey first");
		$("#investigaciones").attr("class", "grey");
		$("#aseguradorasymutuas").attr("class", "light_grey");
		$("#empresaseconomicofinanciero").attr("class", "light_grey");
		$("#serviciosglobalesyprivados").attr("class", "light_grey");
		$("#bolsadetrabajo").attr("class", "grey");
		$("#mencioneshonorificas").attr("class", "grey");
		$("#sub_menu_bg").attr("class",  "grey_bg");
	}
	
	function blueMenu()
	{
		$("#sub_menu_bg").attr("class",  "blue_bg");
		$("#aseguradorasymutuas").attr("class", "light_blue");
		$("#empresaseconomicofinanciero").attr("class", "light_blue");
		$("#serviciosglobalesyprivados").attr("class", "light_blue");
	}	
	
	function loadSection(sec)
	{
		resetMenu();
		var _this = document.getElementById(sec);
		
		active = _this.id;
		
		switch(_this.value)
		{
			case 1:
			case 6:
			case 7:
				$(_this).removeClass("grey"); $(_this).addClass("blue");
				contentSep.attr("class", "sub_content_sep blue");
				subContent.attr("class", "sub_content blue");
				break;
				
			case 2:
				blueMenu();
				$(_this).attr("class", "blue");
				contentSep.attr("class", "sub_content_sep blue");
				subContent.attr("class", "sub_content blue");
				break;
				
			case 3:
			case 4:
			case 5:
				blueMenu();
				$(_this).attr("class", "light_light_blue");
				contentSep.attr("class", "sub_content_sep light_light_blue");
				subContent.attr("class", "sub_content light_light_blue");
				text.addClass("blue");
				break;
		}

		//balls.attr("class", "balls sub_menu" + this.value);
		$(_this).addClass("active");
		
		if (_this.value == 6)
		{
			text.addClass("big");
			//image.attr("class", "image_box little image" + this.value);
			image.attr("class", "image_box little image");
		}
		else
		{
			//image.attr("class", "image_box image" + this.value);
			image.attr("class", "image_box image");
		}
		
		content.load("./subsections/" + _this.id + "_content.html");
		text.load("./subsections/" + _this.id + "_image.html");
		$("#balls").load("./subsections/" + _this.id + "_balls.html");
		$("#subsection_image").load("./subsections/" + _this.id + "_photo.html");
		//$("#logo_container").load("./logo.html");
	}
	
});
