// JavaScript Document
$(function(){
	//#show text resizer
	$('#access').show();
	//#hide sidebar form labels
	$('#sidebar label').hide();
	//#if hcp version, make nav links normal weight on mac/safari so they fit on one line
	/*
	var os = navigator.platform.toLowerCase();
	var userAgent = navigator.userAgent.toString().toLowerCase();
	if(os.indexOf('mac')!=-1 || (userAgent.indexOf('safari') != -1 && userAgent.indexOf('chrome') == -1))
	{
		$('#nav').css('font-weight','normal');
		$('#nav a').css('padding','6px 12px 7px');
	}
	*/
	//#put labels inside inputs in sidebar
	$("#sidebar input").labelify({
		text: "label"
	});
	
	//#handle external links - disclaimer
	var disclaimer = $('<div></div>').html('<p>Links which take you out of Abbott websites are not under the control of Abbott, and Abbott is not responsible for the contents of any such site or any further links from such site. Abbott is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of the linked site by Abbott.</p><p>Do you wish to leave this site and continue to the selected site?</p>').dialog({
			autoOpen: false,
			title: 'AbbottNutrition.ie: External Link',
			modal: true
		});
	
	$("a[href^='http']").not("[href*='abbott']").click(function(e){ 
		e.preventDefault();																	
		var url = $(this).attr('href');
		disclaimer.dialog( 'option', 'buttons', { 'YES': function(){ window.location.href = url; }, 'NO': function(){ $(this).dialog('close'); } });	
		disclaimer.dialog('open');
		//alert('external');
		//return false;
	});
	
	//#add class to email links so they can be styled differently
	//$("a[href^='mailto:']").addClass('mailto');
	//#alternating row colours fix for IE (pump features)
	if(!jQuery.support.opacity)
	{
		//alert('beware IE!');
		//#due to zero based indexing even matches odd rows!
		$('.tablelist ul li:even, .codes tr:odd td, .benefits tr:odd td').css("background-color", "#f3f3f3");	
		$('.tablelist ul li:even').css("background-image","url(/interface/images/icons/tick_pump_grey_bg.gif)");
	}
	
	//#main banners animation (most pages)
	$('#wrap-banner').cycle({
		timeout: 7000,
		speed: 1500,
		pause: 0
	});
})
