(function($){
	
	var win = null;
	
	$.fn.vkAction = function(options,callback){
		
		// Default parameters of the tweet popup:
		
		options = $.extend({
			url:window.location.href
		}, options);
		
		return this.click(function(e){
			
			if(win){
				// If a popup window is already shown,
				// do nothing;
				e.preventDefault();
				return;
			}
			
			var width	= 550,
				height	= 350,
				top		= (window.screen.height - height)/2,
				left	= (window.screen.width - width)/2; 
			
			var config = [
				'scrollbars=yes','resizable=yes','toolbar=no','location=yes',
				'width='+width,'height='+height,'left='+left, 'top='+top
			].join(',');
	
			// Opening a popup window pointing to the twitter intent API:
			// win = window.open('http://twitter.com/intent/tweet?'+$.param(options),
			win = window.open('http://vkontakte.ru/share.php?url=http://anklav.org&title=Анклав - Всё только началось!&description=Сингл "Всё Только Началось" является характерной визитной карточкой будущего альбома Борец Против Своего Времени. Одноименная заглавная песня сингла полностью передаёт настроение предстоящего альбома. Это жёсткая, быстрая, отчаянная музыка и злободневные актуальные тексты. В сингл также вошла кавер-версия группы АНКЛАВ на песню ВЛАДИМИРА ВЫСОЦКОГО "Королевское Шествие". Удивительно, но композиция, написанная Высоцким для детской музыкальной сказки "Алиса в стране чудес", в наше время звучит особенно современно, к сожалению, современно. Послушать и скачать можно на www.anklav.org',// +$.param(options),
						'VkontakteWindow',config);
			// href='http://vkontakte.ru/share.php?url=".$url."&description=".urlencode($row['full'])."&title=".$title."' target='_blank'>
			// Checking whether the window is closed every 100 milliseconds.
			(function checkWindow(){
				
				try{
					// Opera raises a security exception, so we
					// need to put this code in a try/catch:
					
					if(!win || win.closed){
						throw "Closed!";
					}
					else {
						setTimeout(checkWindow,100);
					}
				}
				catch(e){
					// Executing the callback, passed
					// as an argument to the plugin.
					
					win = null;
					callback();
				}
				
			})();
			
			e.preventDefault();
		});
		
	};
	
	$.fn.fbAction = function(options,callback){
		
		// Default parameters of the tweet popup:
		
		options = $.extend({
			url:window.location.href
		}, options);
		
		return this.click(function(e){
			
			if(win){
				// If a popup window is already shown,
				// do nothing;
				e.preventDefault();
				return;
			}
			
			var width	= 550,
				height	= 350,
				top		= (window.screen.height - height)/2,
				left	= (window.screen.width - width)/2; 
			
			var config = [
				'scrollbars=yes','resizable=yes','toolbar=no','location=yes',
				'width='+width,'height='+height,'left='+left, 'top='+top
			].join(',');
	
			// Opening a popup window pointing to the twitter intent API:
			// win = window.open('http://twitter.com/intent/tweet?'+$.param(options),
			win = window.open('http://www.facebook.com/sharer.php?u=www.anklav.org/index.php',// +$.param(options),
						'TweetWindow',config);
			// href='http://vkontakte.ru/share.php?url=".$url."&description=".urlencode($row['full'])."&title=".$title."' target='_blank'>
			// Checking whether the window is closed every 100 milliseconds.
			(function checkWindow(){
				
				try{
					// Opera raises a security exception, so we
					// need to put this code in a try/catch:
					
					if(!win || win.closed){
						throw "Closed!";
					}
					else {
						setTimeout(checkWindow,100);
					}
				}
				catch(e){
					// Executing the callback, passed
					// as an argument to the plugin.
					
					win = null;
					callback();
				}
				
			})();
			
			e.preventDefault();
		});
		
	};
	
	$.fn.ljAction = function(options,callback){
		
		// Default parameters of the tweet popup:
		
		options = $.extend({
			url:window.location.href
		}, options);
		
		return this.click(function(e){
			
			if(win){
				// If a popup window is already shown,
				// do nothing;
				e.preventDefault();
				return;
			}
			
			var width	= 550,
				height	= 350,
				top		= (window.screen.height - height)/2,
				left	= (window.screen.width - width)/2; 
			
			var config = [
				'scrollbars=yes','resizable=yes','toolbar=no','location=yes',
				'width='+width,'height='+height,'left='+left, 'top='+top
			].join(',');
	
			// Opening a popup window pointing to the twitter intent API:
			// win = window.open('http://twitter.com/intent/tweet?'+$.param(options),
			win = window.open('http://www.livejournal.com/update.bml?event=Сингл "Всё Только Началось" является характерной визитной карточкой будущего альбома Борец Против Своего Времени. Одноименная заглавная песня сингла полностью передаёт настроение предстоящего альбома. Это жёсткая, быстрая, отчаянная музыка и злободневные актуальные тексты. В сингл также вошла кавер-версия группы АНКЛАВ на песню ВЛАДИМИРА ВЫСОЦКОГО "Королевское Шествие". Удивительно, но композиция, написанная Высоцким для детской музыкальной сказки "Алиса в стране чудес", в наше время звучит особенно современно, к сожалению, современно. Послушать и скачать можно на www.anklav.org&subject=Анклав - Всё только началось',// +$.param(options),
						'TweetWindow',config);
			// href='http://vkontakte.ru/share.php?url=".$url."&description=".urlencode($row['full'])."&title=".$title."' target='_blank'>
			// Checking whether the window is closed every 100 milliseconds.
			(function checkWindow(){
				
				try{
					// Opera raises a security exception, so we
					// need to put this code in a try/catch:
					
					if(!win || win.closed){
						throw "Closed!";
					}
					else {
						setTimeout(checkWindow,100);
					}
				}
				catch(e){
					// Executing the callback, passed
					// as an argument to the plugin.
					
					win = null;
					callback();
				}
				
			})();
			
			e.preventDefault();
		});
		
	};
})(jQuery);
