var $ = YAHOO.util.Dom.get;
var Dom = YAHOO.util.Dom;

//normalize the SITE_FOLDER constant; this constant should be defined in the header before any JS is included
if(SITE_FOLDER != "") {
	SITE_FOLDER = "/" + SITE_FOLDER;
} else {
	SITE_FOLDER = "";
}

YAHOO.namespace ("AWE.Common");

// Initialize the temporary Panel to display while waiting for external content to load
YAHOO.AWE.Common.Wait = function() {
    var waitPanel;
    return {
        init: function() {
            waitPanel = new YAHOO.widget.Panel("wait",
                    {
                        width:"240px",
                        fixedcenter:true,
                        close:false,
                        draggable:false,
                        zindex:4,
                        modal:true,
                        visible:false
                    }
                );

            waitPanel.setHeader("Please wait...");
            waitPanel.setBody('<img src="http://us.i1.yimg.com/us.yimg.com/i/us/per/gr/gp/rel_interstitial_loading.gif" />');
            waitPanel.render(document.body);

            //initiate any other js elements needed by other pages
            try {
                YAHOO.AWE.User.Login.init();
            } catch (err) {
                //ignore this error - YAHOO.AWE.User.Login is not defined on this page
            }

            try {
                YAHOO.AWE.Vehicle.Modify.Popup.init();
            } catch (err) {
                //ignore this error - YAHOO.AWE.Vehicle.Manager is not defined on this page
            }

            try {
                YAHOO.AWE.Vehicle.Manager.init();
            } catch (err) {
                //ignore this error - YAHOO.AWE.Vehicle.Manager is not defined on this page
            }

            try {
                YAHOO.AWE.Vehicle.Export.init();
            } catch (err) {
                //ignore this error - YAHOO.AWE.Vehicle.Export is not defined on this page
            }

            try {
            	YAHOO.AWE.Email.BulkMail.init();
			} catch (err) {
				//ignore this error = YAHOO.AWE.Email.BulkMail is not defined on this page
			}

			try {
            	YAHOO.AWE.Vehicle.Wholesale.Popup.init();
			} catch (err) {
				//ignore this error = YAHOO.AWE.Vehicle.Wholesale.Popup is not defined on this page
			}

            try {
            	YAHOO.AWE.Vehicle.Marketplace.init();
			} catch (err) {
				//ignore this error = YAHOO.AWE.Vehicle.Marketplace is not defined on this page
			}

            try {
            	YAHOO.AWE.Help.Popup.init();
			} catch (err) {
				//ignore this error = YAHOO.AWE.Help.Marketplace is not defined on this page
			}
			
			try {
            	YAHOO.AWE.Twitter.init();
			} catch (err) {
				//ignore this error = YAHOO.AWE.Help.Marketplace is not defined on this page
			}

			try {
            	YAHOO.AWE.Facebook.init();
			} catch (err) {
				//ignore this error = YAHOO.AWE.Help.Marketplace is not defined on this page
			}
        },

        show: function() {
            waitPanel.show();
        },

        hide: function() {
            waitPanel.hide();
        }
    }
}();

YAHOO.util.Event.onDOMReady(YAHOO.AWE.Common.Wait.init);