// extend add random
jQuery.extend({random:function(min,max){return Math.round(min+((max-min)*(Math.random()%1)));}});

$(document).ready
(
	function()
	{
		/*
		// Get Google Plus details
		$.ajax
		({
			type: 'get',
			url: 'https://www.googleapis.com/plus/v1/people/'+gid+'?pp=1&key=AIzaSyCQh5nB3pVrXxTtwO_BwAh41q6EuEB-H4M',
			dataType: 'jsonp',
			success: function(data)
			{
				gPlusProcess(data);
			}
		});
		
		// Process google details
		function gPlusProcess(data)
		{
			concole.log(data);
			var username = data['displayName'];
			var googleid = data['id'];
			var gender = data['gender'];
			var photo = data['image']['url'];
			var urls = data['urls'];
			
			$.each
			(
				data['urls'],
				function(key,value)
				{
					var value = value['value'];
					if(value.indexOf("http://twitter.com") != -1)
					{
						var twitterid = value.substr(value.indexOf(".com/") + 5);
						
						// Load apps
						appLoad(googleid,twitterid);
					}
				}
			);
		}
		*/
		
		appLoad(false,false);
		
		function appLoad(gid,tid)
		{
			$(".sTwtIns.m4ikel").tweet
			(
				{
					username: 'm4ikel',
					join_text: "auto",
					avatar_size: 32,
					count: 4,
					auto_join_text_default: "",
					auto_join_text_ed: "",
					auto_join_text_ing: "",
					auto_join_text_reply: "",
					auto_join_text_url: "",
					loading_text: "loading tweets..."
				}
			);
			
			$(".sTwtIns.otys").tweet
			(
				{
					username: 'otys',
					join_text: "auto",
					avatar_size: 32,
					count: 4,
					auto_join_text_default: "",
					auto_join_text_ed: "",
					auto_join_text_ing: "",
					auto_join_text_reply: "",
					auto_join_text_url: "",
					loading_text: "loading tweets..."
				}
			);
		}
		
		animation = false;
		$('#sControl').css('background-position','bottom');
		
		// Slide stars
		function starAni()
		{
			animation = true;
			$('#sStars img').animate
			(
				{
					left: '-100%'
				},100000,'linear',
				function()
				{
					// Restart
					$(this).css('left','0');
					starAni();
				}
			);
		}
		
		// Animation contoller
		$('#sControl').click
		(
			function()
			{
				if(animation)
				{
					animation = false;
					$('#sControl').css('background-position','bottom');
					$('#sStars img').stop();
				}
				else
				{
					$('#sControl').css('background-position','top');
					starAni();
				}
			}
		);
		
		// Hook cleaner
		$('.hook').eq(0).css('margin-right','2%');
		
		// Hook Closer
		$('.hook h2').append('<div class="sClose"></div>');
		$('.hook h2 .sClose').click
		(
			function()
			{
				$(this).parent().parent().hide('slow');
			}
		);
		
		// Hook Switcher
		$('.hook h2').append('<div class="sSwitch"></div>');
		$('.hook h2 .sSwitch').addClass('active');
		$('.hook h2 .sSwitch').click
		(
			function()
			{
				var $this = $(this);
				
				if($this.hasClass('active'))
				{
					$this.removeClass('active');
					$this.parent().parent().find('.inner').hide('slow');
				}
				else
				{
					$this.addClass('active');
					$this.parent().parent().find('.inner').show('slow');
				}
			}
		);
		
		// Odd styling
		$('.hook ul li:odd').addClass('odd');
	}
);
