jQuery(document).ready(function() {
	synchronizeBoxHeights();
	setDefaultCompanyContent();
	//syncNewsContainerHeight();
});

var showing;

function showMenu(menuId, objCaller) {
	
	if(showing == null) {
		jQuery("ul#" + menuId).show("fast");
		jQuery("ul#" + menuId).bind("mouseleave", function() {
			jQuery("ul#" + menuId).hide("fast");
			showing = null;						
		});		
		showing = menuId;
	} else if(showing != menuId)  {
		jQuery("ul#" + showing).hide("fast");	
		jQuery("ul#" + menuId).show("fast");
		showing = menuId;		
	}
}

function hideSubMenuProduct() {
	
	jQuery("ul#sub_menu_productos").hide("fast");	
	showing = null;	
}

var maxHeightBoxes = 0;

function synchronizeBoxHeights() {	
	var arrBoxes = [];
	
	arrBoxes = jQuery("div.boxes div.cont_test");
	
	if(arrBoxes == null) {
		return;	
	}

	jQuery.each(arrBoxes, function() {
		if(jQuery(this).height() > maxHeightBoxes) {
			maxHeightBoxes = jQuery(this).height();	
		}
	});
	
	jQuery.each(arrBoxes, function() {
		jQuery(this).height(maxHeightBoxes);
	});	
}

//*** GENERIC FADE-IN OBJECT FUNCTION ***//

function fadeInObj(idObj) {
	jQuery(idObj).fadeIn("slow");
}

//*** SET DEFAULT CONTENT TO BE VIEWED ON "The_Company" PAGE  ***//

var currentContentId;

function setDefaultCompanyContent() {
	var arrDivs = jQuery("div#company_contents div");
	
	
	jQuery.each(arrDivs, function() {
		if(jQuery(this).attr("default") == "true") {
			jQuery(this).show("slow");
			currentContentId = jQuery(this).attr("id");
		}
	});		
}

function switchContent(newContent) {
	
	if(newContent == currentContentId) {
		return;
	} else {
		jQuery("div#" + currentContentId).hide("slow");
		jQuery("div#" + newContent).show("slow");
		currentContentId = newContent;		
	}	
}

function syncNewsContainerHeight() {
	
	if(jQuery("div.cont_central_blanco") == null && jQuery("div.gray_left_column") == null) {
		return;
	}
	
	
	var ref_container_height = jQuery("div.cont_central_blanco").height();	
	jQuery("div.gray_left_column").height(ref_container_height);	
	
}




