// ABCTV API.
jQuery.ABCTV = function(){
	var selectors = { 
		'adv': '.ads.right iframe'
	};
	var templates = {
		'adv': '<iframe width="180" scrolling="no" height="500" frameborder="0" marginwidth="0" marginheight="0" src="http://e2.emediate.se/eas?cu=#{adv};cre=mu"><a href="http://e2.emediate.se/eas?cu=#{adv};"><img src="http://e2.emediate.se/eas?cu=#{adv};cre=img" border="0" alt="EmediateAd" width="180" height="500" /></a></iframe>'
	};

	/*
		TODO add some sort of check+api_key to only allow certain callers for this api only.
	*/
	return {
		
		/**
		 * Open an external link in a new window.
		 * 
		 * @param uri
		 *	The uri location to open in a new window.
		 */
		open : function(uri){
			try { open(uri, "ABCTV_WINDOW"); } catch(e){ /* handle error. */ }	
		},
		
		/**
		 * Remote/Synch controll advertisements.
		 *
		 * @param adv
		 *	The adv to open in the top right iframe.
		 */
		advertisement: function(adv){
			try { jQuery(jQuery(selectors['adv']).get(0)).replaceWith(templates['adv'].replace('#{adv}', adv)); } catch(e){ /* handle error. */ }	
		},
		
		/**
		 * Share video.
		 */
		share: function(){
			
		},
		
		/** 
		 * Wether share is enabled for this page or not.
		 * 
		 * @return
		 *	Return true if share is enabled, otherwise false.
		 */
		shareEnabled: function(){
			
		}
	};
}();

