function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


$(document).ready(function() {
	
	//call the jQuery Hover Over and Out
	$('#t20_userPhoto').hover(over, out);
	//Tell the browser to change the background when hovered over
	function over(event) {
		$('#t20_editProfilePhoto').addClass('hover');
	}
	//tell the browser to change the background to nothing when 
	//going outside the object area
	function out(event) {
	   $('#t20_editProfilePhoto').removeClass('hover');
	}
	
	
	
	
	//Sortable
	$( "#t20_healthIndex" ).sortable({ cursor: 'move', axis: 'y' });
	$( "#t20_healthIndex" ).disableSelection();
	
	/* $( "#t20_healthIndex, #t20_leftColumnCareTeam" ).sortable({
		connectWith: ".connectedSortable",
		cursor: 'move', 
		axis: 'y'
	}).disableSelection(); */
	
	
	//toggle the componenet with class msg_body
	$(".t20_collapseIndexCategory").click(function() {
		
		//Slides the box
		$(this).next(".t20_healthIndexContent").slideToggle(300);
		
		//Changes the icon
		$(this).toggleClass("t20_collapseIndexCategoryClosed");
		
		//Closes the "show more"
		$(".t20_seeMoreContent").hide();
		
		//Reverts the "show more" to original state
		$(".t20_showMoreIndex").removeClass("t20_showMoreIndexOpen");
		
	});
	
	// More
	$(".t20_seeMoreContent").hide();
	
	//toggle the componenet with class msg_body
	$(".t20_showMoreIndex").click(function() {
		$(this).prev("ul").slideToggle(300);
		$(this).toggleClass("t20_showMoreIndexOpen");
	});
	
	
	// This will remove the link from the listing.  This is in place for demo purposes!!!
	$(".t20_healthIndexContent a span").click( function (e) {
		e.stopPropagation();
		$(this).parent().parent().hide();
		//createCookie("test","test", 365);
	});
	
	/* $("#t20_patientColumnLibrary ul li span").hide();
	
	$("#t20_patientColumnLibrary ul li a").hover(function() {
		$(this).next("span").slideToggle(500);
	}); */
	
	// Hide & Show Profile Controls
	$("#t20_profileControlPanel").hide();
	
	
	// For first level navigation
	$("#t20_profileControlHub li").hoverIntent(function(){
		$('ul:first',this).slideDown(500);
	}, function(){
		$('ul:first',this).slideUp(500);
	});
	
	// Hide & Show Profile Controls
	$("#t20_bannerControlPanel").hide();
	
	// For first level navigation
	$("#t20_bannerControlHub li").hoverIntent(function(){
		$('ul:first',this).slideDown(500);
	}, function(){
		$('ul:first',this).slideUp(500);
	});			
			
});
