var offerTimer = 0;
var currentTime = 0;
var waitingTime = 225000;
var offerShown= false;

function Progress() {
	currentTime = currentTime + 1000;
	$('#offer-timer').css({width:   (100-((currentTime/waitingTime) * 100)) + '%' });
	


	timeLeft = waitingTime - currentTime;
	
	minutes = Math.floor(timeLeft/60000);

	seconds = ((timeLeft - (minutes * 60000)) / 1000);

	$('#timer-minutes').html(minutes.toString());
	$('#timer-seconds').html(seconds.toString());
	

	if(currentTime >= waitingTime)
	{
		clearInterval(offerTimer);
	}
	
}

$(function(){
	
	$('#close').click(function(e){
		$.unblockUI();	
	});
	$(document.body).hover(
		function(e){
		},
		function(e){


			if(offerShown)
			{
				return false;
			}

			offerShown = true;
			
			$.blockUI({ message: $('#special-offer-popup'), css: { width:'95%', top: '50px', left: '2.5%' } }); 
			setTimeout(jQuery.unblockUI, waitingTime);
			offerTimer = setInterval('Progress()', 1000);




		}
	);	
	
});
