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

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

function FBpoplock_destroyCounter()
{
	
	FBpoplock_jquery1('#counter').countdown('destroy');
	return true;
}

function FBpoplock_dialog_open(dialog)
	{
		FBpoplock_createCookie('FBpoplock_popup_seen',1,0, 0, FBpoplock_expiry_popup);
		dialog.overlay.delay(this.o.delay).fadeIn(0,function()
		{
			dialog.container.show();
			dialog.data.show();
		});
		
	}


function FBpoplock_createCounter(dialog)
	{

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

function FBpoplock_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==FBpoplock_fb_like_url)
		{
			
			FBpoplock_createCookie('FBpoplock_cookie_like',1,0, 0, FBpoplock_expiry_like);
			
		}
		FBpoplock_close();
	
});

function dumpPropsTAF(obj, parent) {
   // Go through all the properties of the passed-in object
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to
      // build the message. Message includes i (the object's property name)
      // then the object's property value on a new line
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they
      // click "CANCEL" then quit this level of recursion
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object
      if (typeof obj[i] == "object") {
         if (parent) { dumpPropsTAF(obj[i], parent + "." + i); } else { dumpPropsTAF(obj[i], i); }
      }
   }
}
