/* Jquery EKS (copyright adomasalcore3) 
** Enables the $ from jQuery 
*/
window.$=window.jQuery;
$(document).ready(function(){
	$('a[news-facebook-trigger]').click(function(e){
		e.preventDefault();
		var tlink=$(this).attr('news-facebook-trigger');
		
		var url='https://www.facebook.com/share.php?u='+tlink;
		var title="Share This On Facebook";
		var opts='';
		PopupCenter(url, title, 400, 300, opts);
	});
	$('a[news-twitter-trigger]').click(function(e){
		e.preventDefault();
		var tlink=$(this).attr('news-twitter-trigger');
		
		var title="Share This On Twitter";
		var url='https://twitter.com/intent/tweet?text='+title+'&url='+tlink;
		var opts='';
		PopupCenter(url, title, 400, 300, opts);
	});
});
function PopupCenter(url, title, w, h, opts) {
   var _innerOpts = '';
   if(opts !== null && typeof opts === 'object' ){
       for (var p in opts ) {
           if (opts.hasOwnProperty(p)) {
               _innerOpts += p + '=' + opts[p] + ',';
           }
       }
   }
     // Fixes dual-screen position, Most browsers, Firefox
   var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
   var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;

   var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
   var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

   var left = ((width / 2) - (w / 2)) + dualScreenLeft;
   var top = ((height / 2) - (h / 2)) + dualScreenTop;
   var newWindow = window.open(url, title, _innerOpts + ' width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);

// Puts focus on the newWindow
   if (window.focus) {
       newWindow.focus();
   }
}