observe_login_link = function () {
	
	// login link
	jQuery ('.jsLogin').click (function (event) {
		event.preventDefault ();
		var popover = environmentManager.create_popover ("login");
		popover.attach_to_element ($(this), { xSourcePoint: "middle", xDestPoint: "middle", ySourcePoint: "top", yDestPoint: "top", xPixelOffset: 0, yPixelOffset: -35 });
		popover.get_content_block_object ()
			.set_content_source_url ("/accounts/ajax_login.php");
//			.set_content_html ("hello there");
		popover.get_shell_object ()
			.set_title ("Log in to Me &amp; My Body")
			.set_width ("425px");
		popover.show ();
	});

	return true;
}












jQuery ().ready (function () {
	observe_login_link ();
	observe_hover_elements ();
	observe_block_links ();
	observe_tell_a_friend_link_2 ();
	observe_update_account ();
	observe_delete_account ();
	observe_create_account ();
	observe_ask_a_question();

	jQuery (".jsTicker").liScroll ({travelocity: 0.02});	// start the horizontal scroller
	return true;
});

// observe elements on the page that should get a hover class upon mouseover
observe_hover_elements = function () {
	// jQuery version
	jQuery ('.jsHover').mouseover (function () {
		jQuery (this).addClass ('hoverOn');
		jQuery (this).removeClass ('hoverOff');
    });
	jQuery ('.jsHover').mouseout (function () {
		jQuery (this).removeClass ('hoverOn');
		jQuery (this).addClass ('hoverOff');
    });
	jQuery ('.jsHover').addClass ('hoverOff');
	return true;
}

function observe_block_links () {
	// watch for block link clicks
	jQuery ('.jsBlockLink').click (function () {
		var destination = jQuery (this).find ('a').attr ('href');

		if (typeof (destination) != 'undefined')
			window.location = destination;
    });
	jQuery ('.jsBlockLink').addClass ('blockLink');
	return true;
}

// observe the links on the page that cause a "tell a friend" popover to appear
observe_tell_a_friend_link_2 = function () {
	jQuery ('.jsTellAFriendContactList').click (function (e) {
		var popover = environmentManager.create_popover ("tellAFriendContactList");
		popover.attach_to_element (this, { xSourcePoint: "middle", xDestPoint: "middle", ySourcePoint: "top", yDestPoint: "top", xPixelOffset: -100, yPixelOffset: -20 });
		popover.get_content_block_object ()
			.set_content_source_url ("/accounts/ajax_tell_a_friend_contact_list.php");
//			.set_content_html ("hello there");
//			.set_content_source_dom_id ("template_listAllSales");
		popover.get_shell_object ()
//			.set_use_title_bar (false)
			.set_title ("Tell A Friend")
			.set_width ("650px");
		popover.show ();
	});
}


// observe the links on the page that cause a "tell a friend" popover to appear
observe_create_account = function () {
	jQuery ('.jsCreateAccount').click (function (e) {
		var popover = environmentManager.create_popover ("createAccount");
		popover.attach_to_element (this, { xSourcePoint: "middle", xDestPoint: "middle", ySourcePoint: "top", yDestPoint: "top", xPixelOffset: 300, yPixelOffset: -50 });
		popover.get_content_block_object ()
			.set_content_source_url ("/accounts/ajax_create_account.php");
//			.set_content_html ("hello there");
//			.set_content_source_dom_id ("template_listAllSales");
		popover.get_shell_object ()
//			.set_use_title_bar (false)
			.set_title ("Create an account")
			.set_width ("700px");
		popover.show ();
	});
}


// observe the links on the page that cause a "tell a friend" popover to appear
observe_update_account = function () {
	jQuery ('.jsEditAccount').click (function (e) {
		var popover = environmentManager.create_popover ("editAccount");
		popover.attach_to_element (this, { xSourcePoint: "middle", xDestPoint: "middle", ySourcePoint: "top", yDestPoint: "top", xPixelOffset: 0, yPixelOffset: -150 });
		popover.get_content_block_object ()
			.set_content_source_url ("/accounts/ajax_update_account.php",{accountId: this.id});
//			.set_content_html ("hello there");
//			.set_content_source_dom_id ("template_listAllSales");
		popover.get_shell_object ()
//			.set_use_title_bar (false)
			.set_title ("Update account")
			.set_width ("555px");
		popover.show ();
	});
}


// observe the links on the page that cause a "tell a friend" popover to appear
observe_delete_account = function () {
	jQuery ('.jsDeleteAccount').click (function (e) {
		var popover = environmentManager.create_popover ("deleteAccount");
		popover.attach_to_element (this, { xSourcePoint: "middle", xDestPoint: "middle", ySourcePoint: "top", yDestPoint: "top", xPixelOffset: -100, yPixelOffset: -20 });
		popover.get_content_block_object ()
			.set_content_source_url ("/accounts/ajax_delete_account.php",{accountId: this.id});
//			.set_content_html ("hello there");
//			.set_content_source_dom_id ("template_listAllSales");
		popover.get_shell_object ()
//			.set_use_title_bar (false)
			.set_title ("Delete account")
			.set_width ("500px");
		popover.show ();
	});
}


observe_ask_a_question = function () {
	jQuery ('.jsAskQuestion').click (function (e) {
		var popover = environmentManager.create_popover ("AskQuestion");
		popover.attach_to_element (this, { xSourcePoint: "middle", xDestPoint: "middle", ySourcePoint: "top", yDestPoint: "top", xPixelOffset: 0, yPixelOffset: -20 });
		popover.get_content_block_object ()
			.set_content_source_url ("/accounts/ajax_ask_a_question.php");
//			.set_content_html ("hello there");
//			.set_content_source_dom_id ("template_listAllSales");
		popover.get_shell_object ()
//			.set_use_title_bar (false)
			.set_title ("Ask a Question")
			.set_width ("550px");
		popover.show ();
	});
}
