
var IE6 = (document.all && /MSIE (5\.5|6)/.test(navigator.userAgent));

function fixIE6() {
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch (e) {
	}
}

/*
 * Hace visibles los PNG despues del filtro de transparencia IE6
 */
if (IE6) {
	fixIE6();

	document.styleSheets[0].addRule('.png', 'visibility: hidden');
	document.styleSheets[0].addRule('.png',
			'behavior: url(/nutricion/scripts/iepngfix.htc)');

	$( function() {
		setTimeout( function() {
			$('.png').each( function() {
				$(this).css('visibility', 'visible');
			});
		}, 30);
	});
}

/*
 * Oculta algunos elementos
 */ 
document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/nutricion/styles/javascript.css\"/>");

/*
 * Marcacion estadistica documentos, enlaces, impresion, 
 * enviar a un amigo y volver
 */
$( function() {
	$('.tracker').click( function() {
		pageTracker._trackPageview($(this).attr('href'));
	});

	$('.tracker-link').click( function() {
		pageTracker._trackPageview("/external-link" + $(this).attr('href'));
	});

	$('.tracker-print').click( function() {
		pageTracker._trackPageview("/print" + requestURI);
		window.print();
	});

	$('.tracker-sendfriend').click( function() {
		pageTracker._trackPageview("/sendfriend" + requestURI);
	});

	$('.tracker-back').click( function() {
		pageTracker._trackPageview("/back" + requestURI);
	});
	return true;
});


/*
 * Simular target ="_blank" y abre los enlaces en ventana nueva
 */
$( function() {
	$('.external').click( function() {
		window.open($(this).attr('href'));
		return false;
	});
});

/*
 * Define el area seleccionable de un bloque con enlace
 */
$( function() {
	function exclude(event) {
		var element = $(event.target);

		if (element.is('.clicable-exclude') || element.is('.clickable-exclude')) {
			return true;
		}
		if (event.target.tagName == 'A' || event.target.tagName == 'INPUT') {
			return true;
		}
	}

	$(".clicable, .clickable").click( function(event) {
		if (exclude(event)) {
			return true;
		}

		$(this).find("a").each( function() {
			var content = $(this);
			var url = content.attr("href");

			if (content.is('.external')) {
				window.open(url);
			} else {
				document.location = url;
			}

			return false;
		});
	});

	$(".clicable, .clickable").mouseover( function(event) {
		if (exclude(event)) {
			return true;
		}

		if ($(this).find("a").size() > 0) {
			$(this).css("cursor", "pointer");
		}
	});

	$(".clicable, .clickable").mouseout( function(event) {
		if (exclude(event)) {
			return true;
		}

		if ($(this).find("a").size() > 0) {
			$(this).css("cursor", "auto");
		}
	});
});

/* zebra */
	$(document).ready( function() {
      $("table.nestle-table").find("tr:nth-child(even)").each(
        function(i) {
            $(this).addClass("even");
        }
      );
    } );
/* swap */
$(document).ready(
  function(){
    $("li").mouseover(
      function(){
       $(this).find("div.webs-img").addClass("hide")
      });
	$("li").mouseout(  
	function(){
       $(this).find("div.webs-img").removeClass("hide")
      }
    );
});

// abre un popup centrado
function popup(url) {
	var aw = screen.availWidth - 10;
	var w = 678;
	var h = 600;
	xc = (aw - w) / 2; // center

	features = 'status=no,scrollbars=yes,menubar=no,toolbar=no,'
			+ 'location=no,directories=no,resizable=yes,copyhistory=no,'
			+ 'width=' + w + ',height=' + h + ',' + 'left=' + xc
			+ ',top=0,screenX=' + xc + ',screenY=0';

	window.open(url, 'popup'+w, features).focus();
}

$( function() {
	$('.window').click( function() {
		urlpop=new String($(this).attr('href'));
		newurl = urlpop.substring(0, urlpop.lastIndexOf("/")+1) + "pop_" + urlpop.substring(urlpop.lastIndexOf("/")+1, urlpop.length);
		popup(newurl);
		return false;
	});
});


/*$( function() {
	$('a.window').each( function() {
		urlpop=new String($(this).attr('href'));
		
		
	});
});*/
/* rounde corner in ie */
/* parece que nofunciona si los elementos tienen !important*/
 /* IE only */
  DD_roundies.addRule('#header ul,li.mapa,.rounded,#header a, #container, .home_content h3', '0 20px 0 0');
  DD_roundies.addRule('#container', '20px');
  DD_roundies.addRule('input.button, a.button', '0 0 7px 7px');
  DD_roundies.addRule('div.link_number', '10px');
  DD_roundies.addRule('div.imc h3', '20px 20px 0 0 ');
  DD_roundies.addRule('.imc-form fieldset', '0 0 20px 20px');
  DD_roundies.addRule('h3.map', '10px 10px 0 0 ');
  DD_roundies.addRule('div.map-content', '0 0 10px 10px');
  DD_roundies.addRule('.dialogos div#productos-background', '0 0 0 20px');
  DD_roundies.addRule('.dialogos div#round-bottom-background', '0 0 0 12px');
 
