// JavaScript Document
$(document).ready(function() {

var currentItem = "string";
var maindiv = $('div#wrapper');

function getHash() {
  var hash = window.location.hash.substring(1);
 
  if (hash.length > 1){
  	currentItem = hash;
    bringInContent();
  }
  
}


getHash();

$('body').hover(
	function(){
		initializeScroll();
	},
	function(){
	}
	);

function initializeScroll()
	{	
	 $('.scroll-pane').jScrollPane({
		 showArrows: true,
		 verticalDragMinHeight: 97,
		 verticalDragMaxHeight: 97
		 });
	 }


function menuHoverIn()
	{   
		$('#word'+currentItem).fadeIn('fast');
		maindiv.removeClass();
		maindiv.addClass(currentItem);
		
	}
	
function menuHoverOut()	
	{
		maindiv.removeClass(currentItem);
		$('div#'+'word'+currentItem).fadeOut('fast');
		
	}
	
function bringInContent()
	{	
		if (!$('a#'+currentItem).hasClass('active')){
			$('div.infodiv').fadeOut(0);
			$('div#'+currentItem+'info').fadeIn('slow');
			$('#leftnav a').removeClass();
			$('a#'+currentItem).addClass('active');
			window.location.hash=currentItem;
	}
	}

		
 

 
 	$('#leftnav a').click(
		function(){
			$('div#rightcover').fadeIn(0);
		}
		);
 
  	$('a#parenting').hover(
		function(){
			currentItem="parenting",
			menuHoverIn()
		},
		function(){
			currentItem="parenting",
			menuHoverOut()
		}
		);
	
	$('a#parenting').click(
		function(){
			 currentItem="parenting",
	  		 bringInContent(),
			 initializeScroll();
		}
		);
		
		
	$('a#babytalk').hover(
		function(){
			currentItem="babytalk",
			menuHoverIn()
		},
		function(){
			currentItem="babytalk",
			menuHoverOut()
		}
		);
	
	$('a#babytalk').click(
		function(){
			 currentItem="babytalk",
	  		 bringInContent(),
			 initializeScroll();
			}
		);	
		
		
		
	$('a#parentingdotcom').hover(
		function(){
			currentItem="parentingdotcom",
			menuHoverIn()
		},
		function(){
			currentItem="parentingdotcom",
			menuHoverOut()
		}
		);
	
	$('a#parentingdotcom').click(
		function(){
			 currentItem="parentingdotcom",
	  		 bringInContent(),
			 initializeScroll();
			}
		);	
		
	$('a#conceive').hover(
		function(){
			currentItem="conceive",
			menuHoverIn()
		},
		function(){
			currentItem="conceive",
			menuHoverOut()
		}
		);
	
	$('a#conceive').click(
		function(){
			currentItem="conceive",
	  		bringInContent(),
			initializeScroll();
		}
		);	
		
	$('a#workingmother').hover(
		function(){
			currentItem="workingmother",
			menuHoverIn()
		},
		function(){
			currentItem="workingmother",
			menuHoverOut()
		}
		);
	
	$('a#workingmother').click(
		function(){
			currentItem="workingmother",
	  		bringInContent(),
			initializeScroll();
		}
		);	
		
	$('a#marketingservices').hover(
		function(){
			currentItem="marketingservices",
			menuHoverIn()
		},
		function(){
			currentItem="marketingservices",
			menuHoverOut()
		}
		);
	
	$('a#marketingservices').click(
		function(){
			currentItem="marketingservices",
	  		bringInContent(),
			initializeScroll();
		}
		);	
		
	$('a#awardsandbuzz').hover(
		function(){
			currentItem="awardsandbuzz",
			menuHoverIn()
		},
		function(){
			currentItem="awardsandbuzz",
			menuHoverOut()
		}
		);
	
	$('a#awardsandbuzz').click(
		function(){
			currentItem="awardsandbuzz",
	  		bringInContent(),
			initializeScroll();
		}
		);							

	$('div#logo').click(
		function(){
			$('div.infodiv').fadeOut('slow');
			$('a').removeClass('active');
			$('div#rightcover').fadeOut(0);
		}
		);


//Twitter Feeds
	//our twitter ids and options
	var data = {
		twitterIds:[
		'18784113'//parenting
		],
		options:{
			maxTweets:5
		}
	};
	
	//jsonP call to our twitter endpoint
	$.get(
		'http://smfsvc.com/websvc/social/twitter/twitterFeedReader/endpoint.getTwitterFeeds.v1.php',
		data,
		function(rs) {
 			var vfaText = '';
			for (var i = 0; i<5;i++) {
				vfaText += '<div><div class="tweetext">'+rs[0].tweets[i].description+' '+'<span style="color:#AAA; font-size:10px;">'+rs[0].tweets[i].pubDate+'</span></div></div>';
			}
 			$('#tweet_tpg').html(vfaText);
			//Cycle through the twitter feeds
			$('#tweet_tpg').cycle({
				cleartype:true,
				cleartypeNoBg:true,
				fx:'fade',
				speed:700,
				next:'#twitter_next', 
				prev:'#twitter_prev',
				timeout:6000
			});
		},
		dataType = 'jsonp'
	);


    $('#slideshow').cycle({
		cleartype: true,
		cleartypeNoBg: true,
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout: 6000,
		speed: 1000,
		next:'#twitter_next1', 
		prev:'#twitter_prev1'
	});	



});
