// JavaScript Document
 // Initialize and render the menu bar when it is available in the DOM

            DIGIPROTEK.util.Event.onContentReady("productsandservices", function () {

                // Animation object

                var oAnim;


                // "beforeshow" event handler for each submenu of the menu bar

                function onMenuBeforeShow(p_sType, p_sArgs) {

                    var oBody,
                        oShadow,
                        oUL;
                
                    if (this.parent) {

                        oShadow = this.element.lastChild;

                        oShadow.style.height = "0px";
                    
                        if (oAnim && oAnim.isAnimated()) {
                        
                            oAnim.stop();
                            oAnim = null;
                        
                        }

                        oBody = this.body;
                        oUL = oBody.getElementsByTagName("ul")[0];
    
                        DIGIPROTEK.util.Dom.setStyle(oBody, "overflow", "hidden");
                        DIGIPROTEK.util.Dom.setStyle(oUL, "marginTop", ("-" + oUL.offsetHeight + "px"));
                    
                    }

                }

                function onTween(p_sType, p_aArgs, p_oShadow) {

                    if (this.cfg.getProperty("iframe")) {
                    
                        this.syncIframe();
                
                    }
                
                    if (p_oShadow) {
                
                        p_oShadow.style.height = this.element.offsetHeight + "px";
                    
                    }
                
                }

                function onAnimationComplete(p_sType, p_aArgs, p_oShadow) {

                    var oBody = this.body,
                        oUL = oBody.getElementsByTagName("ul")[0];

                    if (p_oShadow) {
                    
                        p_oShadow.style.height = this.element.offsetHeight + "px";
                    
                    }

                    DIGIPROTEK.util.Dom.setStyle(oUL, "marginTop", "auto");
                    DIGIPROTEK.util.Dom.setStyle(oBody, "overflow", "visible");
                    
                    if (DIGIPROTEK.env.ua.ie) {
                    
                        DIGIPROTEK.util.Dom.setStyle(oBody, "zoom", "1");
                    
                    }
                    
                }


                // "show" event handler for each submenu of the menu bar

                function onMenuShow(p_sType, p_sArgs) {

                    var oElement,
                        oShadow,
                        oUL;
                
                    if (this.parent) {

                        oElement = this.element;
                        oShadow = oElement.lastChild;
                        oUL = this.body.getElementsByTagName("ul")[0];
                    
                        oAnim = new DIGIPROTEK.util.Anim(oUL, 
                            { marginTop: { to: 0 } },
                            .5, DIGIPROTEK.util.Easing.easeOut);


                        oAnim.onStart.subscribe(function () {
        
                            oShadow.style.height = "100%";
                        
                        });
    

                        oAnim.animate();

    
                        /*
                             Refire the event handler for the "iframe" 
                             configuration property with each tween so that the  
                             size and position of the iframe shim remain in sync 
                             with the menu.
                        */
    
                        if (DIGIPROTEK.env.ua.ie) {
                            
                            oShadow.style.height = oElement.offsetHeight + "px";

                            oAnim.onTween.subscribe(onTween, oShadow, this);
    
                        }
    
                        oAnim.onComplete.subscribe(onAnimationComplete, oShadow, this);
                    
                    }
                
                }


                // "beforerender" event handler for the menu bar

                function onMenuBeforeRender(p_sType, p_sArgs) {

                    var oSubmenuData = {
                    
                        "About us": [ 
                        
                            { text: "What we Offer", url: "what_we_offer.htm" },
                            { text: "Value Proposition", url: "value_proposition.htm" },
                            { text: "History", url: "history.htm" },
                        ],
    
                       "Solutions": [
    
                            { text: "OEM Solutions", url: "OEM_solutions.htm" },
							{ text: "Product  Design & Engineering", submenu: { id: "pim", itemdata: [
        
                                    { text: "Product Engineering", url: "product_engineering.htm" },
                                    { text: "Manufacturing & Assembly", url: "manufacturing_assembly.htm" },
                                    { text: "Electronic Design & Manufacturing",  url: "electronic_manufacturing.htm" },
                                    { text: "Embedded Design & Development", url: "embedded_development.htm" },
									
									{ text: "Industrial Automation", url: "industrial_automation.htm" },
                                    { text: "Analysis, Modeling & Simulation",  url: "analysis_modeling_simulation.htm" },
                                    { text: "Drafting & Mechanical Drawing Services", url: "drafting_mech_services.htm" }
        
                                ] }
                            
                            }, 
                           // { text: "Embedded Solutions", url: "embedded_solns.htm" },
                        ],
                        
                       "Group Policy": [
    
                            { text: "Quality Policy", url: "quality_policy.htm" },
                            { text: "Environmental Policy", url: "environmental_policy.htm" }
                           
                        ],
						
						/*"Global Alliances": [
    
                            { text: "One World Composites", url: "oneworld_composite.htm" }
                                                   
                        ],*/
						
						"Industry Verticals": [
    
                            { text: "Automotive", url: "automotive.htm" },
						//	{ text: "Aerospace", url: "aerospace.htm" },
							{ text: "Industrial", url: "industrial.htm" },
							{ text: "Electronics", url: "electronics.htm" },
							{ text: "Consumer Products", url: "consumer_products.htm" },
                            { text: "Energy", url: "energy.htm" }
                           
                        ],
                        
                        "Support": [
    
                            { text: "Location", url: "location.htm" },
						/*	{ text: "Downloads", submenu: { id: "pim1", itemdata: [
        
                                    { text: "Who we are", url: "downloads/Who_We_Are.pdf" },
                                    { text: "Value Proposition", url: "downloads/DGP_value_proposition.pdf" },
                                    { text: "Advance Composites Design Solns",  url: "downloads/advcomposite_soln.pdf" },
                      				{ text: "General Brochure", url: "downloads/DGP_General_Brochure.pdf" },
                                    { text: "Product Engineering",  url: "downloads/DGP_Prod_engg.pdf" },
                                    { text: "Electronics Engineering", url: "downloads/DGP_electronics_engg.pdf" },
									{ text: "Industrial Automation", url: "downloads/DGP_Industrial _Automation.pdf" }
        
                                ] }
                            
                            }, */
                            { text: "Custom Services", url: "custom_services.htm" },
                        ]
                    
                    };

                    // Add a submenu to each of the menu items in the menu bar

                    this.getItem(7).cfg.setProperty("submenu", { id: "About us", itemdata: oSubmenuData["About us"] });
                    this.getItem(6).cfg.setProperty("submenu", { id: "Solutions", itemdata: oSubmenuData["Solutions"] });
                    this.getItem(5).cfg.setProperty("submenu", { id: "Group Policy", itemdata: oSubmenuData["Group Policy"] });
//                    this.getItem(5).cfg.setProperty("submenu", { id: "Global Alliances", itemdata: oSubmenuData["Global Alliances"] });
					this.getItem(4).cfg.setProperty("submenu", { id: "Industry Verticals", itemdata: oSubmenuData["Industry Verticals"] });
					this.getItem(3).cfg.setProperty("submenu", { id: "Support", itemdata: oSubmenuData["Support"] });
                    this.subscribe("beforeShow", onMenuBeforeShow);
                    this.subscribe("show", onMenuShow);

                }


                // Initialize the root menu bar

                var oMenuBar = new DIGIPROTEK.widget.MenuBar("productsandservices", { autosubmenudisplay: true, hidedelay: 750, lazyload: true });


                // Subscribe to the "beforerender" event

                oMenuBar.beforeRenderEvent.subscribe(onMenuBeforeRender);

                /*
                     Call the "render" method with no arguments since the markup for 
                     this menu already exists in the DOM.
                */

                oMenuBar.render();            
            
            });
