var lidoli = lidoli || {};
lidoli.widgets = lidoli.widgets || {};
(function($) {
	lidoli.widgets.popup =
	{
		popup:undefined,
		init: function() {
	        var me = this;
	        $('.wg_lidoli_lk').click(function() {
	            var rel = eval('(' + $(this).attr('rel') + ')');
	            me.open(rel.url, rel.width, rel.height);
	            return false;
	        });
	    },
		open: function(url,width,height)
		{
			this.popup = window.open(url,'','height='+height+', width='+width+',toolbar=0,menubar=0,location=0,scrollbars=0');
		}
	};
	
    lidoli.widgets.modal =
	{
	    init: function() {
	        var me = this;
	        $('.wg_lidoli_lk').click(function() {
	            var rel = eval('(' + $(this).attr('rel') + ')');
	            me.open(rel.url, rel.width, rel.height);
	            return false;
	        });
	    },
	    open: function(url, width, height) {
	        var isiPad = navigator.userAgent.match(/iPad/i) != null;
	        var isAndroid = navigator.userAgent.match(/Android/i) != null;
	        var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
	        if (isiPad || isAndroid || isiPhone || screen.width < 700) {
	            window.open(url);
	        }
	        else {
	            $.fancybox({
				        'width': width,
				        'height': height,
				        'autoScale': false,
				        'transitionIn': 'none',
				        'transitionOut': 'none',
				        'type': 'iframe',
				        'href': url,
				        'padding': 0,
				        'margin': 20,
				        'scrolling': 'no'
				    });
	        }
	        return false;
	    }
	};
})(jQuery);

