$(document).ready(function(){

	// animation for popup slide in
	$('#uspu').css({opacity:0}); //set the initial opacity of the popup
	$('#closebtn').click(function(){closeAnnouncement(); });
	
	var oHeight = $('#uspu').css('height');
	var oWidth = $('#uspu').css('width');
	var oLeft = $('#uspu').css('left');
	
	setTimeout(openAnnouncement, 1000); //start a timer to run the pop up function
	
	function openAnnouncement(){
		if ($.cookie('announcement') == null || $.cookie('announcement') != 'off'){
			setTimeout(autoCloseAnnouncement, 15000); //start a timer to run the pop up function
			$('#uspu').animate({opacity: 1.0, left: 10},
								  2000,
								  'swing');
		}
	};
	
	function closeAnnouncement(){
		$.cookie('announcement', 'off');
		$('#uspu').animate({opacity: 0, left: 1000},
							  100,
							  'swing');
	};
	
	function autoCloseAnnouncement(){
		$('#uspu').animate({opacity: 0, left: 1000}, 
							  3000,
							  'swing',
							  function (){
								  var cssObj = {
								  'height' : oHeight,
								  'width' : oWidth,
								  'left' : oLeft
								  }
								  $('#uspu').css(cssObj);
							  });
	};
	
	// END animation for popup slide in
});