
	// function to remove the pop up wither on Like button click or after the timer has run out.
var social_traffic_typhoon_jquery1 = jQuery.noConflict();

function social_traffic_typhoon_close(){
	
	
	social_traffic_typhoon_jquery1('#counter').countdown('destroy');
	
	jQuery(function ($) {
		$.modal.close();
	});
	
}

function social_traffic_typhoon_destroyCounter()
{
	
	social_traffic_typhoon_jquery1('#counter').countdown('destroy');
	return true;
}

function social_traffic_typhoon_dialog_open(dialog)
	{
		social_traffic_typhoon_createCookie('social_traffic_typhoon_popup_seen',1,0, 0, social_traffic_typhoon_expiry_popup);
		dialog.overlay.delay(this.o.delay).fadeIn(0,function()
		{
			dialog.container.show();
			dialog.data.show();
		});
		
	}


function social_traffic_typhoon_createCounter(dialog)
	{

		var delay = parseInt(this.o.counterDelay) + parseInt(this.o.delay/1000);
		social_traffic_typhoon_destroyCounter();
		social_traffic_typhoon_jquery1('#counter').countdown({until: '+'+ delay +'s', format: 'S', compact: true, description: '', onExpiry: social_traffic_typhoon_close});
		//return true;
	}

function social_traffic_typhoon_createCookie(name,value,days, hours, seconds) {
	if (days>0 || hours >0 || seconds > 0) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000) +(hours*60*60*1000)+(seconds*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

 FB.Event.subscribe('edge.create', function(response) {
	
		// If they did, close the pop up
		if(response==social_traffic_typhoon_fb_like_url)
		{
			
			social_traffic_typhoon_createCookie('social_traffic_typhoon_cookie_like',1,0, 0, social_traffic_typhoon_expiry_like);
			
		}
		social_traffic_typhoon_close();
	
});


