	jQuery.fn.inputFocus = function() {
		jQuery(this).each(function() {
			jQuery(this).focus()
		});
	} // end plugin
	
	jQuery.fn.registerLink = function() {
		jQuery(this).each(function() {
			   jQuery(this).click(function() {
				parent.location='register-step1.php'
				}); 
		});
	} // end plugin
	
	jQuery.fn.confirmDelete = function() {
		jQuery(this).each(function() {
			jQuery(this).click(function() {							   	
				confirm("delete");
			}); 
		});
	} // end plugin
	
	jQuery.fn.inboxReply = function() {
		jQuery(this).each(function() {							   
			jQuery(this).click(function() {
				jQuery.scrollTo('#reply', 4000);
				//jQuery(this).removeClass("enabled").addClass("disabled");
			}); //end click
			jQuery(this).hover(
				 function () {
					 if (jQuery(this).hasClass("enabled")){
						jQuery(this).addClass("hover");
					} //end if
				  }, 
				  function () {
					jQuery(this).removeClass("hover");
				  }
				); //end hover			
		}); //end each
	} // end plugin
	
	jQuery.fn.profileStatus = function() {
		jQuery(this).each(function() {							  
			jQuery(this).find("#status-fieldset").hide();			
			  jQuery(this).find("p.update-status").hover(
				  function () {
					jQuery(this).addClass("hover");
				  }, 
				  function () {
					jQuery(this).removeClass("hover");
				  }
				); //end hover
			jQuery(this).find("p.update-status").click(function() {	
				jQuery(this).hide();
				jQuery(this).parent().find("p.profile-status-msg").hide();			
				jQuery(this).parent().parent().find("fieldset").show();
				jQuery(this).parent().parent().find("textarea").focus();
			}); //end click
			jQuery("form#status_submit").submit(function(){
				jQuery("form#status_submit input.submit").hide();
				jQuery("form#status_submit .form-item:last").append("<img src='images/loading.gif' class='loading' alt='Saving' title='Saving'>");
				jQuery.post("includes/status_update.php",{
					profilestatus: jQuery("textarea#profile-status").val()
				}, function(xml) {
					jQuery("#status-fieldset").hide();
					jQuery("p.profile-status-msg").text($("bmi",xml).text());
					jQuery("p.profile-status-msg").show();
					
					if(jQuery("textarea#profile-status").val().length == 0 ){
						jQuery("p.update-status").text("What are you doing at the moment?").show();		
					}else{
						jQuery("p.update-status").text("Update Status").show();		
					}
					jQuery("form#status_submit input.submit").show();
				});
				return false;
			}); //end submit
		}); // end each
	} // end plugin	

	jQuery.fn.calculateBMI = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				weight : 'input#kgs_show',
				height : 'p.disabled-textbox.bmi-height',
				bmi : 'p.disabled-textbox.bmi-result'
			},options||{});
			jQuery(settings.weight).focus();
			function calculate(){
				if (jQuery(settings.weight).val().length != 0){
					var calcuate = jQuery(settings.height).text() / 100;
					calcuate = jQuery(settings.weight).val() / (calcuate * calcuate);
					jQuery(settings.bmi).text(Math.round(calcuate*10)/10);		
				}
			}
			jQuery(settings.weight).keyup(function() {								
				calculate();											  
			});
			calculate();	
		}); // end each
	} // end plugin

	jQuery.fn.calculateImperialBMI = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				stones : 'input#stone',
				pounds : 'input#pounds',
				height : 'input[name="bmi-height"]',
				bmi : 'p.disabled-textbox.bmi-result'
			},options||{});
			jQuery(settings.stones).focus();
			function calculate(){
				if (jQuery(settings.stones).val().length != 0){
					calcuate = (((jQuery(settings.stones).val() * 14) + (jQuery(settings.pounds).val() * 1)) * 703) / (jQuery(settings.height).val() * jQuery(settings.height).val());
					jQuery(settings.bmi).text(Math.round(calcuate*10)/10);		
				}
			}
			jQuery(settings.stones).keyup(function() {								
				calculate();											  
			});
			jQuery(settings.pounds).keyup(function() {								
				calculate();											  
			});
			calculate();	
		}); // end each
	} // end plugin

	jQuery.fn.eatHealthyFood = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				calculateBtn : 'div.form-item.calorie-counter input',
				manualEntryTxt : 'div.form-item.calorie-counter p span',
				formItemGroupDiv : 'div.form-item-group',
				contentModule : '.module.tracking-widget .eat-healthy .tracking-widget-results, .module.tracking-widget .eat-healthy .tracking-widget-data ',
				calorieInput: '#food',
				hasValues: false
			},options||{});
				if (settings.hasValues == false){
					jQuery(settings.formItemGroupDiv).hide();
				}else{
					jQuery(settings.contentModule).css("height", "245px");
					jQuery(settings.manualEntryTxt).removeClass("enabled");
				}
				
				//jQuery(settings.calculateBtn).click(function() {
					//window.location ="calorie-counter.php";						   
				//}); // end click
				
				
				jQuery(settings.manualEntryTxt).hover(
				 function () {
					 if (jQuery(this).hasClass("enabled")){
						jQuery(this).addClass("hover");
					} //end if
				  }, 
				  function () {
					jQuery(this).removeClass("hover");
				  }
				); //end hover	
				
				jQuery(settings.manualEntryTxt).click(function() {
					jQuery(settings.formItemGroupDiv).show();										   
					jQuery(this).removeClass("enabled");
					jQuery(settings.contentModule).css("height", "245px")
					jQuery(settings.calorieInput).focus();
				}); // end click
		}); // end each
	} // end plugin		
	
	jQuery.fn.eatHealthyFoodGraph = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				graphLink : 'dl dd'			
			},options||{});
		
				jQuery(settings.graphLink).hover(
				 function () {
					 if (jQuery(this).hasClass("enabled")){
						jQuery(this).addClass("hover");
					} //end if
				  }, 
				  function () {
					jQuery(this).removeClass("hover");
				  }
				); //end hover	
		}); // end each
	} // end plugin		
	
	
	
	jQuery.fn.yourPersonalProfile = function() {
		jQuery(this).each(function() {							  
			jQuery(this).find("fieldset").hide();
			jQuery(this).find("div.module-footer a").click(function() {	
				jQuery(this).parent().parent().parent().find("div.module-content p").hide();
				jQuery(this).parent().parent().parent().find("fieldset").show();
			});
		});
	} // end plugin	
	
	jQuery.fn.initalSliderValue = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
			silderInfoBox :'span.ui-slider-tooltip.ui-component-content'
		},options||{});			
			jQuery(this).parent().find(settings.silderInfoBox).text(jQuery(this).val());
		}); // end each
	} // end plugin	
	
	jQuery.fn.inboxHover = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				inboxTable : 'table.inbox'
			},options||{});					  
			jQuery(settings.inboxTable + " tr").hover(
				  function () {
					jQuery(this).addClass("hover");
				  }, 
				  function () {
					jQuery(this).removeClass("hover");
				  }
			); //end hover
		}); // end each
	} // end plugin	
	
	jQuery.fn.itemHover = function(options) {
		jQuery(this).each(function() {							   		  
			jQuery(this).hover(
				  function () {
					jQuery(this).addClass("hover");
				  }, 
				  function () {
					jQuery(this).removeClass("hover");
				  }
			); //end hover
		}); // end each
	} // end plugin	

	jQuery.fn.uploadAvatar = function() {
		jQuery(this).each(function() {							   		  
			jQuery("div.avatar-upload").hide();	
			
			jQuery("p.upload").click(function() {	
				jQuery("div.avatar-upload").slideDown("slow");	
				jQuery(this).addClass("disabled");
				jQuery(this).removeClass("enabled");
			}); // end click	

			jQuery("p.delete").click(function() {	
				if(jQuery("input#delete_avatar:checked").length == 1){
					jQuery("input#delete_avatar").attr('checked', false);			
				}else{
					jQuery("input#delete_avatar").attr('checked', true);
					jQuery("img.user-image").slideUp("slow");	
					jQuery(this).addClass("disabled");
					jQuery(this).removeClass("enabled");						
				}
				
			}); // end click	
			
				jQuery("p.upload, p.delete").hover(
				 function () {
					 if (jQuery(this).hasClass("enabled")){
						jQuery(this).addClass("hover");
					} //end if
				  }, 
				  function () {
					jQuery(this).removeClass("hover");
				  }
				); //end hover			
		}); // end each
	} // end plugin	
	
	
	jQuery.fn.selectButtonActive = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				disabledValue: 0,				 
				buttonClass: 'input.submit'
			},options||{});			 
				jQuery(this).parent().parent().parent().find(settings.buttonClass).click(function() {	
					if (jQuery(settings.buttonClass).hasClass("disabled")){
						return false; //Disable Click						
					}
				}); // end click			
				jQuery(this).change(function() { // On Select change
					if (jQuery(this).val() != settings.disabledValue) {
						jQuery(settings.buttonClass).removeClass("disabled").addClass("enabled")				 
					} else{
						jQuery(settings.buttonClass).addClass("disabled").removeClass("enabled")
						return false; //Disable Click	
					}
				}); // end click
		}); // end each
	} // end plugin

	jQuery.fn.composeButtonActive = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				disabledValue: 0,				 
				buttonClass: 'input.compose'
			},options||{});			 
				jQuery(this).parent().parent().parent().find(settings.buttonClass).click(function() {	
					if (jQuery(settings.buttonClass).hasClass("disabled_compose")){
						return false; //Disable Click						
					}
				}); // end click			
				jQuery(this).change(function() { // On Select change
					if (jQuery(this).val() != settings.disabledValue) {
						jQuery(settings.buttonClass).removeClass("disabled_compose").addClass("enabled")				 
					} else{
						jQuery(settings.buttonClass).addClass("disabled_compose").removeClass("enabled")
						return false; //Disable Click	
					}
				}); // end click
		}); // end each
	} // end plugin
	
	jQuery.fn.ulListHover = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				ulList : 'ul.goal-list'
			},options||{});					  
			jQuery(settings.ulList + " li").hover(
				  function () {
					jQuery(this).addClass("hover");
				  }, 
				  function () {
					jQuery(this).removeClass("hover");
				  }
			); //end hover
		}); // end each
	} // end plugin
	
	jQuery.fn.loadChart = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				goalID : '10',
				memberID : '0',
				chartDiv : 'div.item.ipos-1 div.graph-stats div.module-content',
				onLoadTabName: 'weight',
				width: '0',
				height: '0'
			},options||{});	
			
			function getChart(tabSelect){
				var xmlHttp
				xmlHttp=GetXmlHttpObject()
				
				// detect flash
				var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
				
				if(plugin == null) {
					var noFlashHTML ='<a href="http://get.adobe.com/flashplayer/" target="_blank"><img src="includes/flash_charts/no-flash.gif" style="margin-top:100px" border="0"></a>';
					
					jQuery("div.item.ipos-1 div.graph-stats div.module-content").html(noFlashHTML).show();		
					return false;
				}
				
				if (xmlHttp==null){
					alert ("Browser does not support HTTP Request")
					return;
				}
				
				var url="includes/flash_charts/flash_chart.php"
				
				if (settings.goalID==1){
					//only use for lose weight
					url=url+"?goal_id=1&member_id=" + settings.memberID + "&width=" + settings.width + "&height=" + settings.height + "&chart_name=lose-weight.php~"+ tabSelect;

				}else if (settings.goalID==2){
					//only use for lose weight
					url=url+"?goal_id=2&member_id=" + settings.memberID + "&width=" + settings.width + "&height=" + settings.height + "&chart_name=eat-healthy-food.php~"+ tabSelect;					
				}else{
					url=url+"?goal_id=" + settings.goalID + "&member_id=" + settings.memberID + "&width=" + settings.width + "&height=" + settings.height;
				}
	
				xmlHttp.onreadystatechange=stateChanged 
				xmlHttp.open("GET",url,true)
				xmlHttp.send(null)
			
			function stateChanged(){ 
				if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					jQuery(settings.chartDiv).html(xmlHttp.responseText)
				} 
			}
			
			function GetXmlHttpObject()	{
				var xmlHttp=null;
				
				try	{
					// Firefox, Opera 8.0+, Safari
					xmlHttp=new XMLHttpRequest();
				}
				
				catch (e){
					//Internet Explorer
					try	{
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch (e){
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
				}
				
				return xmlHttp;
			}
		}// end getChart
		
		jQuery("body.lose-weight ul.ui-tabs-nav li a").click(function() {	
				getChart(jQuery(this).text().toLowerCase());																		  
		}); // end click

		jQuery("body.eat-healthy-food div.module.graph-stats dd").click(function() {	
				getChart(jQuery(this).attr("id"));
				jQuery(this).parent().find("dd").addClass("enabled").removeClass("disabled");
				jQuery(this).removeClass("enabled").addClass("disabled");
		}); // end click	
		
		if(settings.goalID==1){
			//only use for lose weight
			getChart(settings.onLoadTabName);
		}
		else if(settings.goalID==2){
			//only use for eat healthy food
			getChart(settings.onLoadTabName);
		}
		else{
			getChart(null);
		}
			
		}); // end each
	} // end plugin
	
	
	jQuery.fn.editProfile = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				editProfileDiv : 'div.module.your-personal-profile',
				editLink : 'p.more-link a',
				alertMessage : 'p.alert-message'
			},options||{});	
			
			function hideShow() {
				//jQuery(this).text("Cancel");	

			} //end function  markRead			
			
			jQuery(settings.editProfileDiv).find(settings.alertMessage + " a").click(function() {	
				jQuery(settings.alertMessage).hide();																	
				//jQuery("#edit-about").hide();
				//jQuery("#about-you").show();		
			}); // end click

			jQuery(settings.editProfileDiv).find(settings.editLink).click(function() {	
				jQuery(this).parent.find("#edit-about").hide();
				jQuery(this).parent.find("#about-you").show();
				//jQuery(this).parent.find(settings.editLink).text("Cancel");															   																					   
			}); // end click
		}); // end each
	} // end plugin		

	jQuery.fn.inboxTools = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				inboxTable : 'table.inbox',
				phpAction : 'input#purpose',
				inboxForm : 'form#inboxForm',
				checkbox : 'td.select-message  input',
				deleteBtn : 'div.module-header ul li.delete',
				readBtn : 'div.module-header ul li.read',
				unreadBtn : 'div.module-header ul li.unread',
				readNo : 0,
				unreadNo : 0,
				isInbox: true				
			},options||{});
			
			function toolStatus() {
				var totalMsgs = jQuery(settings.checkbox + ":checked").length;
					//Mark as unread
					if (jQuery(settings.checkbox + ":checked") && jQuery(this).parent().parent().find("td.status a").hasClass("unread")){
						jQuery(settings.readBtn).removeClass("disabled").addClass("enabled");
						jQuery(settings.readBtn).bind('click', markRead);
						btnHover(settings.readBtn + ".enabled");
						if(jQuery(this).attr('checked')){
							settings.unreadNo = settings.unreadNo + 1;
						} else{
							settings.unreadNo = settings.unreadNo - 1;
							if (settings.unreadNo == 0 ){
								jQuery(settings.readBtn).removeClass("enabled").addClass("disabled");
								jQuery(settings.readBtn).unbind('click', markRead);
							}// end if

						}// end if
					}// end if	
					
					//Mark as read
					if (jQuery(settings.checkbox + ":checked") && jQuery(this).parent().parent().find("td.status a").hasClass("read")){
						jQuery(settings.unreadBtn).removeClass("disabled").addClass("enabled");
						jQuery(settings.unreadBtn).bind('click', markUnread);
						btnHover(settings.unreadBtn + ".enabled");
						if(jQuery(this).attr('checked')){
								settings.readNo = settings.readNo + 1;
							} else{
								settings.readNo = settings.readNo - 1;
								if (settings.readNo == 0 ){
									jQuery(settings.unreadBtn).removeClass("enabled").addClass("disabled");
									jQuery(settings.unreadBtn).unbind('click', markUnread);
								}// end if
							}// end if						
					} // end if	
						
					//Delete Button
					if (jQuery(settings.checkbox + ":checked").length >= 1){	
						if (jQuery(settings.checkbox + ":checked").length == 1 && jQuery(settings.deleteBtn).hasClass("disabled")){
							jQuery(settings.deleteBtn).removeClass("disabled").addClass("enabled");
							jQuery(settings.deleteBtn).bind('click', deleteMsg);
							btnHover(settings.deleteBtn + ".enabled");
						} // end if					
					} else {
						//Delete Button
						jQuery(settings.deleteBtn).removeClass("enabled").addClass("disabled");
						jQuery(settings.deleteBtn).unbind('click', deleteMsg);
					} // end if						
			} // end function toolStatus
			
			function deleteMsg() {
				check = confirm("Are you sure you want to delete it?");
				if (check) {
					if (settings.isInbox){
						jQuery(settings.phpAction).val("delete-inbox");		
					}else{
						jQuery(settings.phpAction).val("delete-sent");
					}
					jQuery(settings.inboxForm).submit();
				}
				return false;								
			} //end function deleteMsg

			function markRead() {
				jQuery(settings.phpAction).val("read");
				jQuery(settings.inboxForm).submit();
				return false;								
			} //end function  markRead

			function markUnread() {
				jQuery(settings.phpAction).val("unread");
				jQuery(settings.inboxForm).submit();
				return false;								
			} //end function markUnread

			function btnHover(hoverClass) {
				jQuery(hoverClass).hover(
					function () {
						if (jQuery(hoverClass).hasClass("enabled")){
							jQuery(hoverClass).addClass("hover");							
						} //end if
					}, 
					 function () {
							jQuery(hoverClass).removeClass("hover");						
					}
				); //end hover
			} //end function btnHover	
			jQuery(":checkbox").click(toolStatus);	
		}); // end each
	} // end plugin		

	jQuery.fn.deleteGoal = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				phpAction : 'input#goals_id',
				goalForm : 'form#delete-goal',
				deleteBtn : 'span.delete'
			},options||{});
	
			jQuery(this).click(function() {
				var deleteID;
				deleteID = jQuery(this).attr("id");
				check = confirm("Are you sure you want to delete this goal?");
			
				if (check) {
					jQuery(settings.phpAction).val(deleteID);
					jQuery(settings.goalForm).submit();
				}
				return false;
			}); //end click
//			jQuery(this).hover(
//				function () {
//					jQuery(this).addClass("hover");							
//				}, 
//				function () {
//					jQuery(this).removeClass("hover");						
//				}
//			); //end hover			
		}); // end each
	} // end plugin		

	jQuery.fn.editActivity = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				phpAction : 'input#activity_id',
				activityForm : 'form#edit_goal',
				editBtn : 'span.edit'
			},options||{});
	
			jQuery(this).click(function() {	
					var editID;
					editID = jQuery(this).attr("id");
					jQuery(settings.phpAction).val(editID);
					jQuery(settings.goalForm).submit();
				
			}); //end click
			jQuery(this).hover(
				function () {
					jQuery(this).addClass("hover");							
				}, 
				function () {
					jQuery(this).removeClass("hover");						
				}
			); //end hover			
		}); // end each
	} // end plugin	

jQuery.fn.hideModule = function(options) {
		jQuery(this).each(function() {							   
			var settings = jQuery.extend({
				hideShowDivLink : 'div.module-header p.more-link span',
				divContainer : 'div.module'
			},options||{});

			jQuery(settings.hideShowDivLink).hover(
				  function () {
					jQuery(this).addClass("hover");
				  }, 
				  function () {
					jQuery(this).removeClass("hover");
				  }
			); //end hover

			jQuery(this).click(function() {	
				if (jQuery(this).parent().parent().parent().parent().find(settings.divContainer).hasClass("closed")){
					//Open
					jQuery(this).parent().parent().parent().find("div.module-content").slideDown("slow");
					jQuery(this).parent().parent().parent().parent().find(settings.divContainer).addClass("open");
					jQuery(this).parent().parent().parent().parent().find(settings.divContainer).removeClass("closed");
					jQuery(this).parent().parent().parent().find(settings.hideShowDivLink).text("Hide");
				}else{
					//Closed
					jQuery(this).parent().parent().parent().find("div.module-content").slideUp("slow");	
					jQuery(this).parent().parent().parent().parent().find(settings.divContainer).addClass("closed");
					jQuery(this).parent().parent().parent().parent().find(settings.divContainer).removeClass("open");
					jQuery(this).parent().parent().parent().find(settings.hideShowDivLink).text("Show");
				}
			}); // end click
		}); // end each
	} // end plugin		
	
	jQuery.fn.hideModuleOpposite = function(options) {

			
			jQuery(this).each(function() {	
									   
				var settings = jQuery.extend({
				hideShowDivLink : 'div.module-header p.more-link span',
				divContainer : 'div.module'
				},options||{});
				
				if (jQuery(this).parent().parent().parent().parent().find(settings.divContainer).hasClass("open")){
				}else{
						jQuery(this).parent().parent().parent().find("div.module-content").slideUp("slow");	
						jQuery(this).parent().parent().parent().parent().find(settings.divContainer).addClass("closed");
						jQuery(this).parent().parent().parent().parent().find(settings.divContainer).removeClass("open");
						jQuery(this).parent().parent().parent().find(settings.hideShowDivLink).text("Show");
				}

			}); // end each
		} // end plugin		

	jQuery.fn.linkscroll = function() {
	  function filterPath(string) {
		return string
		  .replace(/^\//,'')
		  .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
		  .replace(/\/$/,'');
	  }
	  jQuery(this).find('a[href*=#]').each(function() {
		if ( filterPath(location.pathname) == filterPath(this.pathname)
		&& location.hostname == this.hostname
		&& this.hash.replace(/#/,'') ) {
		  var $targetId = jQuery(this.hash), $targetAnchor = jQuery('[name=' + this.hash.slice(1) +']');
		  var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
		   if ($target) {
			 var targetOffset = $target.offset().top;
			 jQuery(this).click(function() {
			   jQuery('html, body').animate({scrollTop: targetOffset}, 1000);
			   return false;
			 });
		  }
		}
	  });// end each
	}// end plugin
	
	
	
	
