YUI({base:"/js/yui/build/", timeout: 10000}).use("node-menunav", function(Y) {
	Y.on("contentready", function () {


	var onIOComplete = function (transactionID, response, submenuNode) { 
			var sHTML = response.responseText; 
			submenuNode.query(".yui-menu-content").set("innerHTML", sHTML); 
			submenuNode.query("ul").addClass("first-of-type"); 
			submenuNode.setStyle("width", "");
			if (Y.UA.ie && Y.UA.ie < 8) { 
				submenuNode.setStyle("width", (submenuNode.get("offsetWidth") + "px")); 
			} 
			var oAnchor = submenuNode.query("a");
			if (oAnchor) {
				try {
					oAnchor.focus();
				}
				catch(ex) { }
			}
		};


        var addSubmenu = function (event, submenuIdBase) { 
			            var oSubmenuNode, 
			                sSubmenuId = submenuIdBase + "-options", 
			                bIsKeyDown = (event.type === "keydown"), 
			                nKeyCode = event.keyCode, 
			                sURI; 
			 
			            if ((bIsKeyDown && nKeyCode === 40) ||  
			                (event.target.hasClass("yui-menu-toggle") &&  
			                (event.type === "mousedown" || event.type === "mouseover" || (bIsKeyDown && nKeyCode === 13)))) { 
			 
			                //  Build the bounding box and content box for the submenu and fill 
			                //  the content box with a "Loading..." message so that the user  
			                //  knows the submenus content is in the process of loading. 
			 
			                oSubmenuNode = Y.Node.create('<div id="' + sSubmenuId + '" class="yui-menu yui-menu-hidden"><div class="yui-menu-content"><p>Loading.</p></div></div>'); 
			                 
			                this.get("parentNode").appendChild(oSubmenuNode); 
			 
			 
			                //  Use Y.io to fetch the content of the submenu 
			 
			                sURI = "http://www.bowling-balls.com/submenus.php?menu=" + sSubmenuId; 
			 
			                YUI({base:"/js/yui/build/", timeout: 10000}).use("io", function(Yio) {
								Yio.io(sURI, { on: { complete: onIOComplete }, arguments: oSubmenuNode })
							});

			 
			                //  Detach event listeners so that this code runs only once  
			     
			                this.detach("mouseover", addSubmenu); 
			                this.detach("mousedown", addSubmenu); 
			                this.detach("keydown", addSubmenu); 
			 
							oSubmenuNode.removeClass('yui-menu-hidden');
							oSubmenuNode.addClass('yui-menu-hidden');
							oSubmenuNode.removeClass('yui-menu-hidden');
			            } 
			         
			};  //addSubmenu


			this.addClass("yui-splitbuttonnav"); 
 
	        var oSubmenuToggles = { 
	                bowlingballs: { label: "Bowling Balls", url: "#exclusive-options" }, 
	                bowlingbags: { label: "Bowling Bags", url: "#exclusive-options" }, 
	                bowlingshoes: { label: "Bowling Shoes", url: "#exclusive-options" }, 
	                bowlingaccessories: { label: "Bowling Accessories", url: "#exclusive-options" }, 
	                bowlingexclusives: { label: "Bowling Exclusives", url: "#exclusive-options" }, 
	            }, 
	            sKey, 
	            oToggleData, 
	            oSubmenuToggle; 
	 

	        this.queryAll(".yui-menu-label").each(function(node) { 
	            sKey = node.get("id").split("-")[0];
	            oToggleData = oSubmenuToggles[sKey]; 
	            oSubmenuToggle = Y.Node.create('<a class="yui-menu-toggle">' + oToggleData.label + '</a>'); 
	 
	            //  Need to set the "href" attribute via the "set" method as opposed to  
	            //  including it in the string passed to "Y.Node.create" to work around a  
	            //  bug in IE.  The MenuNav Node Plugin code examines the "href" attribute  
	            //  of all <A>s in a menu.  To do this, the MenuNav Node Plugin retrieves  
	            //  the value of the "href" attribute by passing "2" as a second argument  
	            //  to the "getAttribute" method.  This is necessary for IE in order to get  
	            //  the value of the "href" attribute exactly as it was set in script or in  
	            //  the source document, as opposed to a fully qualified path.  (See  
	            //  http://msdn.microsoft.com/en-gb/library/ms536429(VS.85).aspx for  
	            //  more info.)  However, when the "href" attribute is set inline via the  
	            //  string passed to "Y.Node.create", calls to "getAttribute('href', 2)"  
	            //  will STILL return a fully qualified URL rather than the value of the  
	            //  "href" attribute exactly as it was set in script. 
	 
	            oSubmenuToggle.set("href", oToggleData.url); 
	 
	 
	            //  Add a "mousedown" and "keydown" listener to each menu label that  
	            //  will build the submenu the first time the users requests it. 
	 
	            node.on("mouseover", addSubmenu, node, sKey); 
	            node.on("mousedown", addSubmenu, node, sKey); 
	            node.on("keydown", addSubmenu, node, sKey); 
	 
	            node.appendChild(oSubmenuToggle); 
	         
	        });
		this.plug(Y.plugin.NodeMenuNav);
	}, "#mainNavigation");
});

YUI({base:"/js/yui/build/", timeout: 10000}).use("io-base", function(Y) {
	Y.on("contentready", function () {
	        /* global listener object */ 
	        var gH = { 
	            start: function(id, args) { }, 
	            complete: function(id, o, args) { }, 
	            success: function(id, o, args) { 
					var messages = [];
					YUI().use('json-parse', function (Y2) { 
						try { 
							messages = Y2.JSON.parse(o.responseText); 
							Y.Node.get('#OrderInfo').set('innerHTML', messages[0].CartLine);
						} 
						catch (e) { 
						} 
					});
	            }, 
	            failure: function(id, o, args) { }, 
	            abort: function(id, args) { } 
	        } 

	        /* attach global listeners */ 
	        Y.on('io:start', gH.start, gH, 'global foo'); 
	        Y.on('io:complete', gH.complete, gH, 'global bar'); 
	        Y.on('io:success', gH.success, gH, 'global baz'); 
	        Y.on('io:failure', gH.failure, gH); 
	        Y.on('io:abort', gH.abort, gH); 

            Y.io('/ajax/getUniqueCustomerDetails.php?rand='+Math.random());
	}, "#header");
});

YUI({base:"/js/yui/build/", timeout: 10000}).use("io-base", function(Y) {
	Y.on("contentready", function () {
		document.getElementById('flashAd').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="780" height="210" id="bowlingball.2009-03-24243241237236232235" align="mid'+'dle">\n<param name="allowScriptAccess" value="sameDomain" />\n<param name="movie" value="/flash/bowlingball.2009-03-24243241237236232235.swf" />\n<param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <param name="wmode" value="transparent" /> <embed src="/fl'+'ash/bowlingball.2009-03-24243241237236232235.swf" quality="high" bgcolor="#ffffff" width="780" height="210" name="bowlingball.2009-03-24243241237236232235" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transpa'+'rent" /> </object>';
	}, "#flashAd");
});


YUI({base:"/js/yui/build/", timeout: 10000}).use("io-base", function(Y) {
	Y.on("contentready", function () {
		Y.Get.script("http://twitter.com/javascripts/blogger.js");
		Y.Get.script("http://twitter.com/statuses/user_timeline/bowlingball.json?callback=twitterCallback2&count=5");
	}, "#twitter_update_list");
});



YUI().use('node', function(Y) { 
	Y.on("contentready", function () {
		$(function() { $("#productPageTabs").tabs(); }) 
	}, '#productPageTabs'); 


});



/*
YUI().use('node', function(Y) { 
    Y.on("click", function () {
		var cb = Y.get("#IncludeDisco");
        var checked;
        if (cb.checked) { checked = 1; }
        else { checked = 0; }
		YUI({base:"/js/yui/build/", timeout: 10000}).use("io-base", function(io) {
	        var gH = { 
	            start: function(id, args) { }, 
	            complete: function(id, o, args) { }, 
	            success: function(id, o, args) { 
                                            document.location=document.location;
	            }, 
	            failure: function(id, o, args) { }, 
	            abort: function(id, args) { } 
		}

        io.Get.Connect.asyncRequest('GET', '/ajax/saveSessionData.php?IncludeDisco='+checked+'&rand='+ Math.random(), {
                                        success: function() {
                                        }
                                    }, null);


		var s = Y.get("#ChangeView");
		alert(s);
			if (s.value) location.href=s.value 
		}, "#IncludeDisco"); 
}); 
*/
