package com.netgrind.web {
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.net.navigateToURL;
	import flash.net.URLRequest;
	
	/**
	 * ...
	 * @author netgrind
	 */
	public class Socialify {
		
		
		public static function tweetify(button:DisplayObject,tweet:String, related:Array = null):void {
			var url:String = 'https://twitter.com/share?url=' + tweet;
			if (related) {
				url += '&related=';
				for (var i:int = 0; i < related.length; i++) {
					url += related[i];
					if (i != related.length - 1) {
						url += ',';
					}
				}
			}
			button.addEventListener(MouseEvent.CLICK, function():void {navigateToURL(new URLRequest(url)) });
		}
		
		public static function facebookify(button:DisplayObject, link:String):void {
			var url:String = 'https://www.facebook.com/sharer/sharer.php?u=' + link;
			button.addEventListener(MouseEvent.CLICK, function():void {navigateToURL(new URLRequest(url)) });
		}
		
		public static function redditify(button:DisplayObject, link:String):void {
			var url:String = 'http://www.reddit.com/submit?url=' + link;
			button.addEventListener(MouseEvent.CLICK, function():void {navigateToURL(new URLRequest(url)) });
		}
		
		static public function linkify(button:DisplayObject, url:String):void {
			button.addEventListener(MouseEvent.CLICK, function():void {navigateToURL(new URLRequest(url)) });
		}
	}
	
}