var LeftSidePanel = {
	isLoaded : false,

	init : function() {

        $(".lm_menu_itm").click( function() {
            // no open/close for my email tab
            if ($(this).attr("id") != "myemail") {
				lmMenuItemDiv = $(this).attr("class") + "_" + $(this).attr("id");
				// if empty, then load the information via AJAX JSON
				if ((!LeftSidePanel.isLoaded) && ($(this).attr("id") != "support")) {
					var loadingHtml = '<div id="dvloader"><img src="/_ajaxData/loadingImage.gif" /></div>';
					$("body").append(loadingHtml);
					$("#dvloader").css({
						'top' : $(this).offset().top + 'px',
						'left' : ($(this).offset().left + 30) + 'px',
						'position' : 'absolute',
						'background-color' : '#FFFFFF',
						'border' : '2px solid #666'
					});
	
					// do ajax call to load the information
					$.ajax( {
						url : '/_ajaxData/LeftSidePanel.html',
						success : function(data) {
							$("#dvloader").hide();
							$("#lm_menu_itm_myaccount").html(data.myaccount); 
							$("#lm_menu_itm_myrenew").html(data.myrenew); 
							$("#lm_menu_itm_myprod").html(data.myprod); 
							$("#" + lmMenuItemDiv).slideDown("slow");
							LeftSidePanel.isLoaded = true;
						},
						error : function(XMLHttpRequest, textStatus, errorThrown) {
							$("#dvloader").hide();
						},
						type : "GET",
						cache : false,
						dataType : "json"
					} );
				} else {
					if ($("#" + lmMenuItemDiv).is(':visible')) {
						$("#" + lmMenuItemDiv).slideUp("slow");
					} else {
						$("#" + lmMenuItemDiv).slideDown("slow");
					}
				}

	            return false;
            }
			
        });
    }
};


$(document).ready( function() {
    LeftSidePanel.init();
});

