var styleManager = (function () {

    /*
    * Constructor
    */
   function styleButtons() {
        styleManager.styleButton($("#homeButton"),
					   "img/mainNav/home.png",
					   "img/mainNav/homeHover.png");
        styleManager.styleButton($("#clientsButton"),
					   "img/mainNav/clients.png",
					   "img/mainNav/clientsHover.png");
        styleManager.styleButton($("#equipmentButton"),
					   "img/mainNav/equipment.png",
					   "img/mainNav/equipmentHover.png");
        styleManager.styleButton($("#photosButton"),
					   "img/mainNav/photos.png",
					   "img/mainNav/photosHover.png");
        styleManager.styleButton($("#faqButton"),
					   "img/mainNav/faq.png",
					   "img/mainNav/faqHover.png");
        styleManager.styleButton($("#sendMusicButton"),
					   "img/mainNav/sendMusic.png",
					   "img/mainNav/sendMusicHover.png");
        styleManager.styleButton($("#linksButton"),
					   "img/mainNav/links.png",
					   "img/mainNav/linksHover.png");
		styleManager.styleButton($("#contactButton"),
						"img/mainNav/contact.png",
						"img/mainNav/contactHover.png");
   }


    return {
		
		initButtons: function() {
			styleButtons();	
		},
		
        /*
        * Add handlers for image swapping to give a button basic up/over/down/disabled states
        * overState, downState and disabledState are optional
        */
        styleButton: function (button, upState, overState, downState, disabledState) {
            if (button) {
                
                // UP STATE
                if (upState) {
                    button.attr({src: upState });
                }

                // OVER STATE
                if (upState && overState) {
                    button.hover(
						function () {
						    if (button.attr("src") !== disabledState) {
						        $(this).attr({ src: overState });
						    }
						},
						function () {
						    if (button.attr("src") !== disabledState) {
						        $(this).attr({ src: upState });
						    }
						}
					);
                }

                // DOWN STATE
                if (overState && downState) {
                    button.mousedown(
						function () {
						    if (button.attr("src") !== disabledState) {
						        $(this).attr({ src: downState });
						    }
						}
					);
                    button.mouseup(
						function () {
						    if (button.attr("src") !== disabledState) {
						        $(this).attr({ src: overState });
						    }
						}
					);

                }

                // DISABLED STATE
                if (upState && disabledState) {
                    button.bind("disable", function () {
                        if (button.attr("src") !== disabledState) {
                            button.attr({ src: disabledState });
                        }
                    });

                    button.bind("enable", function () {
                        if (button.attr("src") === disabledState) {
                            button.attr({ src: upState });
                        }
                    });
                }
            }
        }
    };
} ());
