//*********************************************************************

//	Menu Class

//*********************************************************************

// Create the Application Class
YAHOO.cb.Menu = function(inObj) {
	this.menu_menubar = null;
	this.applicationScope = inObj;
	this.init();
};

YAHOO.cb.Menu.prototype.menu_menubar = null;
YAHOO.cb.Menu.prototype.applicationScope = null;

//*********************************************************************

//	Init

//*********************************************************************
YAHOO.cb.Menu.prototype.init = function() { 
	
	if ( this.menu_menubar == null ) {
		

		// ::TODO:: where are these gifs?
	    YAHOO.widget.MenuBarItem.prototype.SUBMENU_INDICATOR_IMAGE_PATH = "promo/m/irs/blank.gif";
	    YAHOO.widget.MenuBarItem.prototype.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH = "promo/m/irs/blank.gif";
	    YAHOO.widget.MenuBarItem.prototype.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH = "promo/m/irs/blank.gif";
	    var aItemData = [
	
	        { text:"File", submenu:{  id:"filemenu", itemdata:[
	                { text:"Open", submenu: { id:"openFile", itemdata: [
	                        { text:"Images", disabled: false },
	                        { text:"Writing" },
	                        { text:"Music" },
	                        
	                        { text:"Code", submenu: { id:"codeSub", itemdata: [
		                        { text:"YUI YouTube Class", URL:"example_YouTube.html", target:"_blank"}
		                         ] }
	                        },
	                        { text:"Video", submenu: { id:"videoSub", itemdata: [
		                        { text:"Brandston"},
		                        { text:"Ask a Ninja"}
		                         ] }
	                        }
	                    ] } 
	                },
	                
		        { text: "Logon", disabled: false }

				] }
			},
	
	        { text:"Bookmarks", submenu:{  id:"bookmarksmenu", itemdata:[
	                { text:"Stuff to Read", submenu: { id:"news", itemdata: [
	                        { text:"Tech Crunch", url:"http://www.techcrunch.com/", target:"_blank" },
	                        { text:"Blog Maverick", url:"http://www.blogmaverick.com", target:"_blank" },
	                        { text:"Think Vitamin", url:"http://www.thinkvitamin.com/", target:"_blank" }
	                    ] } 
	                },
	                
	                { text:"Jerks", submenu: { id:"friends", itemdata: [
	                        { text:"Kennewick Man", url:"http://www.myspace.com/kennewickman", target:"_blank" }
	                    ] } 
	                },
	                
	                { text:"My Junk", submenu: { id:"myjunk", itemdata: [
	                        { text:"My Blog", url:"http://www.circuitbeta.com/blog", target:"_blank" },
	                        { text:"Pandora", url:"http://www.pandora.com/people/CircuitBeta", target:"_blank" },
	                        { text:"last.fm", url:"http://www.last.fm/user/CircuitBeta/", target:"_blank" },
	                        { text:"mySpace", url:"http://www.myspace.com/circuitbeta", target:"_blank" },
	                        { text:"Faces", url:"http://circuitbeta.faces.com", target:"_blank" },
	                        { text:"email", url:"mailto:circuitbeta@yahoo.com", target:"_blank" }
	                    ] } 
	                },
	                
			        { text: "Development Tools", url:"http://www.communitymx.com/content/article.cfm?cid=F3ECF", target:"_blank" },
	                
	            ] }
	        },
	        
	        { text: "Blog", url:"http://www.circuitbeta.com/blog", target:"_blank" },
	
	        { text: "Help", url:"http://www.google.com/search?hl=en&q=help+sex+life&btnG=Google+Search", target:"_blank" }
	
	    ];
		this.menu_menubar = new YAHOO.widget.MenuBar("main_menubar", { itemdata:aItemData, zIndex:5000, lazyLoad:false });

		// this.menu_menubar.getItem(0).clickEvent.subscribe(this.openLogon, this, true);
		// this.menu_menubar.getItem(1).clickEvent.subscribe(this.openWriting, this, true);
		// this.menu_menubar.clickEvent.subscribe(this.onMenuItemClick, this, true);
		// ::TODO:: This is retarded
		this.menu_menubar.getItem(0).cfg.getProperty("submenu").getItem(1).clickEvent.subscribe(this.openLogon, this, true);
		this.menu_menubar.getItem(0).cfg.getProperty("submenu").getItem(0).cfg.getProperty("submenu").getItem(0).clickEvent.subscribe(this.openImage, this, true);
		this.menu_menubar.getItem(0).cfg.getProperty("submenu").getItem(0).cfg.getProperty("submenu").getItem(1).clickEvent.subscribe(this.openWriting, this, true);
		this.menu_menubar.getItem(0).cfg.getProperty("submenu").getItem(0).cfg.getProperty("submenu").getItem(2).clickEvent.subscribe(this.openMusic, this, true);
		this.menu_menubar.getItem(0).cfg.getProperty("submenu").getItem(0).cfg.getProperty("submenu").getItem(4).cfg.getProperty("submenu").getItem(0).clickEvent.subscribe(this.openVideoBrandston, this, true);
		this.menu_menubar.getItem(0).cfg.getProperty("submenu").getItem(0).cfg.getProperty("submenu").getItem(4).cfg.getProperty("submenu").getItem(1).clickEvent.subscribe(this.openVideoNinja, this, true);

		this.menu_menubar.render("menuTarget");
	}
}

YAHOO.cb.Menu.prototype.openLogon = function() { 
	this.applicationScope.logon.init();
}

YAHOO.cb.Menu.prototype.openWriting = function() {
	this.applicationScope.writing.loadContent("content/Demand.html");
}

YAHOO.cb.Menu.prototype.openMusic = function() { 
	this.applicationScope.facesMusic.loadContent("content/music.html");
}

YAHOO.cb.Menu.prototype.openVideoBrandston = function() { 
	this.applicationScope.youTubeManager.loadPlayer('http://www.youtube.com/v/hotXDpfhIEE');
	
}

YAHOO.cb.Menu.prototype.openVideoNinja = function() { 
//	this.applicationScope.youtubeplayer.init('http://www.youtube.com/v/qRuKMB9CpIo');
	this.applicationScope.youTubeManager.loadPlayer('http://www.youtube.com/v/qRuKMB9CpIo');
}

YAHOO.cb.Menu.prototype.openImage = function() { 
	this.applicationScope.imageViewerManager.loadImage();
}



