$(document).ready(function() {

    var isiCallout = $('#importantSafetyCallout').html();
	var headerHeight = 225;
	var defaultHeight = "130px"; // Default height of collapsed view
	var resize = true; // set flag of true so we can resize safety information when opened
	
    if (isiCallout != null) {
        $('body').append($('#importantSafetyCallout'));
		$('#footer').css('margin-bottom', '180px');  // Add enough margin on bottom so you can still see the footer.
    }

    $('#expandSafetyCallout').click(function() {
		if($(this).hasClass('inactiveISI'))
		{
			$('#expandSafetyCallout').removeClass('inactiveISI');
			$('#expandSafetyCallout').addClass('activeISI');

		        if(($.browser.msie === true) && ($.browser.version == '6.0'))        
			{   
				$('select').css("visibility", "hidden");                  
			} 

			var windowHeight = $(window).height();
			var safetyCalloutHeight = windowHeight - headerHeight;

			$('.safetyContent').css({'margin-bottom':'0px', 'border-bottom':'1px solid #c6c6c6'});
			$('.safetyContent').animate({
				height: safetyCalloutHeight + 'px'
			}, 400, function(){
				resize = true;
				$(window).resize(resizeSafetyInformation);
				$(window).scroll(resizeSafetyInformation);	
			});
			return false;
		}
		else if($(this).hasClass('activeISI'))
		{
			resize = false;
			$('#expandSafetyCallout').addClass('inactiveISI');
			$('#expandSafetyCallout').removeClass('activeISI');

			if(($.browser.msie === true) && ($.browser.version == '6.0'))        
			{   
				$('select').css("visibility", "visible");                  
			} 

			$('.safetyContent').css({'margin-bottom':'0px', 'border-bottom':'none'});
			if (jQuery.browser.msie === true) 
			{
				$('.safetyContent').css('margin-bottom','-12px');
			}
			$('.safetyContent').animate({
				height: defaultHeight
			}, 400 );		
		}
		
		 
		
		
	
	});
	
	function resizeSafetyInformation()
		{
			if(resize == false){return false;}
			var windowHeight = $(window).height();
			var safetyCalloutHeight = windowHeight - headerHeight;
			$('.safetyContent').css('height', safetyCalloutHeight);
		}
	
	$('.dagger').click(function() {
		if($('#expandSafetyCallout').hasClass('inactiveISI'))
		{
			$('#expandSafetyCallout').removeClass('inactiveISI');
			$('#expandSafetyCallout').addClass('activeISI');

		        if(($.browser.msie === true) && ($.browser.version == '6.0'))        
			{   
				$('select').css("visibility", "hidden");                  
			} 

			var windowHeight = $(window).height();
			var safetyCalloutHeight = windowHeight - headerHeight;

			$('.safetyContent').css({'margin-bottom':'0px', 'border-bottom':'1px solid #c6c6c6'});
			$('.safetyContent').animate({
				height: safetyCalloutHeight + 'px'
			}, 400, function(){
				resize = true;
				$(window).resize(resizeSafetyInformation);
				$(window).scroll(resizeSafetyInformation);	
			});
			return false;
		}
		else if($(this).hasClass('activeISI'))
		{
			resize = false;
			$('#expandSafetyCallout').addClass('inactiveISI');
			$('#expandSafetyCallout').removeClass('activeISI');

			if(($.browser.msie === true) && ($.browser.version == '6.0'))        
			{   
				$('select').css("visibility", "visible");                  
			} 

			$('.safetyContent').css({'margin-bottom':'0px', 'border-bottom':'none'});
			if (jQuery.browser.msie === true) 
			{
				$('.safetyContent').css('margin-bottom','-12px');
			}
			$('.safetyContent').animate({
				height: defaultHeight
			}, 400 );		
		}
								});

});


