jQuery(function(){
	if (!jQuery.browser.msie) {
		jQuery.root.find("#footer").animate({
			opacity: 0.4
		}, 200).mouseenter(function(){
			jQuery(this).stop().animate({
				opacity: 1
			}, 200);
		}).mouseleave(function(){
			jQuery(this).stop().animate({
				opacity: 0.4
			}, 400);
		});
	}
	
	
	jQuery.root.find('#companyInfo').css("height", 0);
	
	jQuery.root.find("#infoCompanyNav a, #layerNewsletter, #layerTiendas")
		.click(function() {
			
			var id = null;
			var con = null;
			if (!jQuery.browser.msie) {
				id = jQuery(this).attr("href").replace("/","");
				con = jQuery(id);
				var wfh = parseInt(jQuery.root.find('#companyInfo').height(), 10);
				var fh = jQuery.root.find('#footer').get(0).offsetHeight;
				var vid = jQuery.root.find(".companyInfoSection:visible").attr("id");
				var datah = jQuery('#companyInfo').data("height");
				if (!jQuery.root.find(id).data("height")) {
					jQuery.root.find(id).data("height", jQuery.root.find(id).height());
				}
				var ah = jQuery.root.find(id).data("height") + 26;
				
				
				if (wfh == 0) {
					jQuery.root.find(".companyInfoSection").css({
						opacity: 0,
						display: 'none'
					});
					jQuery('#companyInfo')
						.css({
							height:0,
							zIndex:10000
						})
						.animate({
							height: (fh + ah + 20) + 'px',
							opacity: 1
						}, function(){
							if (jQuery.ie) {
								jQuery("#content").css("visibility","hidden");
								jQuery("object").css("display","none");
							}
							jQuery(id).css("display", "block").animate({
								opacity: 1
							});
						})
						.data("height", "");
				}
				else {
					
					
					if (vid && "#" + vid == id) {
						jQuery(id).animate({
							opacity: 0
						}, 200, function(){
							jQuery('#companyInfo').animate({
								
								opacity: 0
							}, 200,function(){
								jQuery(this).css('z-index','-1');
							}).data("height",0);
						});
						if (jQuery.ie) {
							jQuery("#content").css("visibility","visible");
							jQuery("object").css("display","block");
						}
					}
					else {
						jQuery.root.find(".companyInfoSection").css({
							opacity: 0,
							display: 'none'
						});
						
						jQuery('#companyInfo').css("z-index",10000).animate({
							height: (fh + ah + 20) + 'px',
							opacity: 1
						}, function(){
						
							jQuery(id).css("display", "block").animate({
								opacity: 1
							});
						})
						.data("height", "");
					}
				}
			}
			else {
				//jQuery.root.find("#infoCompanyNav a, #layerNewsletter")
				//	.click(function(){
						id  = jQuery(this).attr("href");
						con = jQuery(id);
						
						//jQuery('.companyInfoSection, #newsletter').removeClass("hide");
						con.toggleClass("hide");
						return false;
				//	});
			}
			return false;
		});
			
		
	
	jQuery.root.find(".closeCompanyInfo").click( function() {
		var id= jQuery(this).parent().attr("id");
		jQuery.root.find("#footer a[href=#"+id+"]").click();
		return false;
	});
	
	jQuery("#infoCompanyNav a[href=/faqs]").click(function(){
		document.location = this.href;
		return true;
	});
});
