	/**
	* MyMini Theme Scripts
	*/

	/**
	* Animations
	*/

		function optionsCollapse(){
			$('#options').delay(2000).animate({
				height: 64
			}, 500, function() {
				$('#bottom-bar-wrap-options-toggle').show();
			});
			$('#bottom-bar-wrap-options').delay(2000).animate({
				height: 88
			}, 500);
		}

		function twitterCollapse(){
			$('#twitter').delay(2000).animate({
				height: 66
			}, 500, function() {
				scrollMe('twitter');
				$('#bottom-bar-wrap-twitter-toggle').show();
			});
			$('#bottom-bar-wrap-twitter').delay(2000).animate({
				height: 88
			}, 500);
		}
		
		function facebookCollapse(){
			$('#facebook-large').delay(2000).fadeOut(200, function() {
				$('#facebook').fadeIn(200, function() {
					$('#bottom-bar-wrap-facebook-toggle').show();
					$('#bottom-bar-wrap-facebook').animate({
						height: 88
					}, 500);
				});
			});
		}
		
		function twitterHide(){
			$.cookies.set('twitter', 'hide'); 
			
			$('#twitter').clearQueue();
			$('#bottom-bar-wrap-twitter').clearQueue();
			$('#bottom-bar-wrap-twitter-toggle').clearQueue();
			$('#twitter-follow').clearQueue();

			$('#twitter').fadeOut(500);
			$('#bottom-bar-wrap-twitter').fadeOut(500);
			$('#bottom-bar-wrap-twitter-toggle').fadeOut(500);
			$('#twitter-follow').fadeOut(500);
		}

		function twitterShow(){
			$.cookies.set('twitter', 'show'); 

			$('#twitter').clearQueue();
			$('#bottom-bar-wrap-twitter').clearQueue();
			$('#bottom-bar-wrap-twitter-toggle').clearQueue();
			$('#twitter-follow').clearQueue();

			$('#twitter').fadeIn(500);
			$('#bottom-bar-wrap-twitter').fadeIn(500);
			$('#twitter-follow').fadeIn(500);
			
			twitterCollapse();
		}

		function facebookHide(){
			$.cookies.set('facebook', 'hide'); 

			$('#facebook').clearQueue();
			$('#facebook-large').clearQueue();
			$('#bottom-bar-wrap-facebook').clearQueue();
			$('#bottom-bar-wrap-facebook-toggle').clearQueue();

			$('#facebook-large').fadeOut(100);
			$('#bottom-bar-wrap-facebook-toggle').fadeOut(500);
			$('#bottom-bar-wrap-facebook').fadeOut(500);
			$('#facebook').fadeOut(500, function () {

				$('#twitter').clearQueue();
				$('#bottom-bar-wrap-twitter').clearQueue();
				$('#bottom-bar-wrap-twitter-toggle').clearQueue();
				$('#twitter-follow').clearQueue();

				$('#twitter').animate({
				    right: 243
				}, 500);
				$('#twitter-follow').animate({
				    right: 241
				}, 500);
				$('#bottom-bar-wrap-twitter').animate({
				    right: 240
				}, 500);
				$('#bottom-bar-wrap-twitter-toggle').animate({
				    right: 240
				}, 500);
				
			});
		}

		function facebookShow(){
			$.cookies.set('facebook', 'show'); 

			$('#twitter').clearQueue();
			$('#bottom-bar-wrap-twitter').clearQueue();
			$('#bottom-bar-wrap-twitter-toggle').clearQueue();
			$('#twitter-follow').clearQueue();

			$('#twitter').animate({
			    right: 666
			}, 500);
			$('#twitter-follow').animate({
			    right: 666
			}, 500);
			$('#bottom-bar-wrap-twitter').animate({
			    right: 664
			}, 500);
			$('#bottom-bar-wrap-twitter-toggle').animate({
			    right: 664
			}, 500, function() {

				$('#facebook').clearQueue();
				$('#bottom-bar-wrap-facebook').clearQueue();
				$('#bottom-bar-wrap-facebook-toggle').clearQueue();

				$('#facebook').fadeIn(500);
				$('#bottom-bar-wrap-facebook').fadeIn(500);

				twitterCollapse();
				facebookCollapse();
			});
		}


		function pageinit(){
			var twitterStatus = $.cookies.get('twitter');
			var facebookStatus = $.cookies.get('facebook');

			facebookCollapse();
			twitterCollapse();

			if (facebookStatus == 'hide') {  
				facebookHide();
			} else {
				facebookShow();
			};  

			if (twitterStatus == 'hide') {  
				twitterHide();
			} else {
				twitterShow();			
			};  
		}

		$(document).ready(function() {

			$('#twitter-hide').click(function() {
				stopMe();
				twitterHide();
			});

			$('#twitter-show').click(function() {
				scrollMe('twitter');
				twitterShow();
			});

			$('#facebook-hide').click(function() {
				facebookHide();
			});

			$('#facebook-show').click(function() {
				facebookShow();
			});

			$('#bottom-bar-wrap-options-toggle').click(function() {
				$('#options').clearQueue();
				$('#bottom-bar-wrap-options').clearQueue();
				$('#bottom-bar-wrap-options-toggle').hide();
				$('#options').animate({
					height: 131
				}, 500);
				$('#bottom-bar-wrap-options').animate({
					height: 155
				}, 500);
			});

			$('#bottom-bar-wrap-twitter-toggle').click(function() {
				$('#twitter').clearQueue();
				$('#bottom-bar-wrap-twitter').clearQueue();
				$('#bottom-bar-wrap-twitter-toggle').hide();
				$('#twitter').animate({
					height: 286
				}, 500, function() {
					stopMe();
					$('#twitter').scrollTop(0);
				});
				$('#bottom-bar-wrap-twitter').animate({
					height: 300
				}, 500);
			});

			$('#twitter').mouseleave(function() {
				twitterCollapse();
			});

			$('#options').mouseleave(function() {
				optionsCollapse();
			});

			$('#bottom-bar-wrap-facebook-toggle').click(function() {
				$('#facebook').clearQueue();
				$('#facebook-large').clearQueue();
				$('#bottom-bar-wrap-facebook').clearQueue();
				$('#bottom-bar-wrap-facebook-toggle').hide();
				$('#facebook').fadeOut(200, function() {
					$('#bottom-bar-wrap-facebook').animate({
							height: 576
					}, 500, function() {
						$('#facebook-large').fadeIn(200);
					});
				});
			});

			$('#facebook-large').mouseleave(function() {
				facebookCollapse()
			});

			$('#twitter').mouseenter(function() {
				$('#twitter').clearQueue();
				$('#bottom-bar-wrap-twitter').clearQueue();
				stopMe();
			});

			$('#facebook-large').mouseenter(function() {
				$('#facebook').clearQueue();
				$('#facebook-large').clearQueue();
				$('#bottom-bar-wrap-facebook').clearQueue();
			});

		});

	/**
	* Twitter Box auto-scrolling
	*/
	
		var defaultStep=1;
		var step=defaultStep;
		var timer;

		function scrollDiv(id,s){
			var obj=document.getElementById(id);
			var iScrollTop = obj.scrollTop;
			step=s||step;
			if (iScrollTop == 0){
				step=defaultStep;
			}
			else if (obj.clientHeight + iScrollTop - obj.scrollHeight==0){
				var delay=setTimeout(function(){ 
					stopMe();
					obj.scrollTop = 0; 
					scrollDiv(id);
				},2000)
			}
			clearTimeout(timer);
			obj.scrollTop+=step;
			timer=setTimeout(function(){ scrollDiv(id); },150)
		}

		function stopMe(){
			clearTimeout(timer);
		}

		function getSpecs(id){
			var obj=document.getElementById(id);
			var iScrollHeight = obj.scrollHeight;
			var iScrollTop = obj.scrollTop;
			var iClientHeight = obj.clientHeight;
			var iPOS = (iClientHeight + iScrollTop) - iScrollHeight;
			alert("The value of scrollHeight is:" + iScrollHeight + "px" + "\nScrollTop is:" + iScrollTop + "\nViewable height:" + iClientHeight + "\nLeft:" + iPOS)
		}

		function scrollMe(id){
			scrollDiv(id)
		}
