


Community = new function(){}

Community.Page = new function(){
	this.hostname = window.location.hostname;
	this.path = window.location.pathname;
	this.qs = window.location.search.substring(1);
	this.vars = this.qs.split("&");
	this.baseUrl = (this.hostname.indexOf("mtv-q.mtvi.com") > 0) ? "http://www.mtv-d.mtvi.com" : "http://www.mtv.com";
	this.headTag = document.getElementsByTagName("head").item(0);
	this.cssOverrideSet = false;
	
	this.isFN = false;
	
	this.init = function(){
		Community.Page.updatePage();
		
		Community.Widgets.createFooter('MTVFooter');
		
		if(Community.Page.isFN){
			Community.Widgets.createNav('MTVNav', Community.Widgets.fnHeaderObj);
		}
		else{
			Community.Widgets.createArtistlist('MTVArtistList');
			Community.Widgets.createSearch('MTVSearch');
			Community.Widgets.createNav('MTVNav');
		}
	}
	
	this.createScript = function(url){
		var scriptObj = document.createElement("script");
		scriptObj.setAttribute("type", "text/javascript");
		scriptObj.setAttribute("src", Community.Page.baseUrl+url);

		Community.Page.headTag.appendChild(scriptObj);
	}
	
	this.setHat = function(hatNumber, subset){
		function hatTrick(hatNumber, subset) {
	var total = 66;
	var bodyTag = document.getElementsByTagName('body')[0];
	var classList = bodyTag.className;
	if (classList.indexOf("hat") > -1) {
		var tempClasses = new Array();
		var classes = classList.split(" ");
		var j = 0;
		for(i = 0; i < classes.length; i++) {
			if(classes[i].substr(0,3) != "hat") tempClasses[j++] = classes[i];
		}
		classList = tempClasses.join(" ");
	}

	if (!hatNumber) hatNumber = Math.floor(total*Math.random());
	var newHat = " hat" + hatNumber;
	bodyTag.className = classList + newHat + "";
}
		hatTrick(hatNumber, subset);
	}
	
	this.setDiscussionCSS = function(){
		var catId = "";
		
		for (var i=0; i<Community.Page.vars.length; i++) {
		    var pair = Community.Page.vars[i].split("=");
		    if (pair[0] == "catId") {
		       catId = pair[1];
		    } 
		}
		
		if(catId!==''){
			var categories = Community.Data.discussionCategories;
	
			for(var i=0; i<categories.length; i++){
				if(categories[i].id==catId){
					Community.Page.addCSSLink(categories[i].css);
					Community.Page.cssOverrideSet = true;
				}
			}
		}	
		
		if(!Community.Page.cssOverrideSet) Community.Page.setHat();
	}
	
	this.addCSSLink = function(url){
		var cssUrl = Community.Page.baseUrl + url;
		var linkObj = document.createElement("link");

		linkObj.setAttribute("rel", "stylesheet");
		linkObj.setAttribute("type", "text/css");
		linkObj.setAttribute("href", cssUrl);

		Community.Page.headTag.appendChild(linkObj);
	}
	
	this.handleFnVideoCategory = function(response){
		var categories = response.categories.category
		var category = "";
	
		for (var i=0; i<Community.Page.vars.length; i++) {
		    var pair = Community.Page.vars[i].split("=");
		    if (pair[0] == "category") {
		       category = pair[1];
		    } 
		}

		for(var i=0; i<categories.length; i++){
			if(categories[i].id==category){
				Community.Page.isFN = true;
				Community.Page.addCSSLink('/ontv/fn-mtv/css/hosted_pages.css');
				Community.Page.cssOverrideSet = true;
				Community.Data.fnVideoCategory = categories[i];
			}
		}
		if(!Community.Page.cssOverrideSet) Community.Page.setHat();
	}
	
	this.updatePage = function(){		
		// fn video category pages
		if(Community.Data.fnVideoCategory!="" && document.getElementById("ctl01_ctl00_ctl00_phBody_phBody_phBody_ctl00_ctl01_divAddModuleArea")==null){	
			var category = Community.Data.fnVideoCategory;
			var fnHeader = document.createElement("div");
			fnHeader.className = "fn-header";
			
			var h1 = document.createElement("h1");
			h1.innerHTML = "FN Uploads <em> | " + category.name + "</em>";
			h1.className = "main-title"

			var img = document.createElement("img");
			img.className = "thumb";
			img.setAttribute("src", Community.Page.baseUrl + category.images.img.src);
			
			var div = document.createElement("div");
			div.className = "deck";
				
				if(category.description!=null){
					var p = document.createElement("p");
					p.appendChild(document.createTextNode(category.description));
					div.appendChild(p);
				}
				
				var action = document.createElement("a");
				action.className = "action";
				action.setAttribute("href", Community.Page.baseUrl + "/ontv/fn-mtv/uploads.jhtml");
				action.appendChild(document.createTextNode("Back to all uploads categories"));
				div.appendChild(action);
				
				if(category.videoId!=null){
					var button = document.createElement("a");
					button.setAttribute("href", Community.Page.baseUrl + "/ontv/fn-mtv/upload.jhtml?categoryId=" + category.id);
					button.innerHTML = "<" + "img src=\"" + Community.Page.baseUrl + "/content/ontv/fn-mtv/images/bttn-upload-to-category.gif\"/>";
					div.appendChild(button);	
				}
				
			fnHeader.appendChild(h1);			
			fnHeader.appendChild(img);
			fnHeader.appendChild(div);

			var zone = document.getElementById("ctl01_ctl00_ctl00_phBody_phBody_phBody_ctl00_zone2_zone2");			
			zone.insertBefore(fnHeader, zone.childNodes[0]);
			
		}// fn video category pages
		
		
		// trim non-community greeting
		if(!document.getElementById('ctl01_ctl00_ctl00_phBody_phBody_quickMenu_pnlCommunityMember')){
			var q = document.getElementById('quickmenu');
			var spans = q.getElementsByTagName('span');
			var container;
			
			for (var x=0; x<spans.length; x++){
				if (spans[x].className.indexOf("userGreetingContainer") == 0) container = spans[x];
			}
		
			if(container){
				for (var i=0; i<container.childNodes.length; i++){
					var element = container.childNodes[i];
					if(element.nodeName!='BR' && (!element.className || element.className.indexOf("userGreeting") < 0)) container.replaceChild(document.createTextNode(''), element);
				}
			}
		}
		
		// trim friend request text
		var pnlDelimiter = document.getElementById('ctl01_ctl00_ctl00_phBody_phBody_quickMenu1_pnlDelimiter');
		if(pnlDelimiter){
			for (var i=0; i<pnlDelimiter.childNodes.length; i++){
				var element = pnlDelimiter.childNodes[i];
				if(element.nodeName=='#text'){
					if(element.nodeValue.indexOf('||') >= 0){
						pnlDelimiter.replaceChild(document.createTextNode(' | '), element);
					}
					else pnlDelimiter.removeChild(element);
				}
			}
		}
		
		// add User Search link to Friends page
		if(Community.Page.path.indexOf('FriendsManagement.aspx') > 0 || Community.Page.path.indexOf('FriendsManagment.aspx') > 0){
			var inviteLink = document.getElementById('ctl01_ctl00_ctl00_phBody_phBody_phBody_cFriendManagement_btnReorderFriends');
			
			if(inviteLink){
				var tbody = inviteLink.parentNode.parentNode.parentNode;
				var newTR = document.createElement('tr');
				
				var newTD = document.createElement('td');
				newTD.setAttribute('align', 'right');
				
				var newA = document.createElement('a');
				newA.setAttribute('href', '/-/Community/BrowseUsers.aspx');  
				newA.appendChild(document.createTextNode('Browse Members'));
				
				newTD.appendChild(newA);
				newTR.appendChild(document.createElement('td'));
				newTR.appendChild(newTD);
				tbody.appendChild(newTR);
			}
		}// end user search

		// add Upload links to Feed Detail pages
		if(Community.Page.path.indexOf('/Content/Picture/Pictures.aspx') >0 || Community.Page.path.indexOf('/Content/Video/Videos.aspx') > 0){
			var contentType;
			if(Community.Page.path.indexOf('/Content/Picture/Pictures.aspx') >0) contentType = 'photo';
			else if(Community.Page.path.indexOf('/Content/Video/Videos.aspx') >0) contentType = 'video';
			
			var hook = document.getElementById('ctl01_ctl00_ctl00_phBody_phBody_phBody_contentFilterControl_lbPersonal');
			
			if(hook){
				var sidebar = hook.parentNode.parentNode.parentNode.parentNode;
				
				var a = document.createElement('a');
				var text;
				
				switch(contentType){
					case 'video': 
						a.setAttribute('href', '/-/Content/Video/AddVideo.aspx');
						text = 'Upload Videos';
						break;
					case 'photo': 
						a.setAttribute('href', '/-/Content/Picture/AddPhoto.aspx');
						text = 'Upload Photos';
						break;
					default: break;
				}			
				a.appendChild(document.createTextNode(text));
				
				sidebar.appendChild(a);
			}
		}// end upload links
		
		// discussion boards
		if(Community.Page.path.indexOf('DiscussionBoard.aspx') > 0 && Community.Page.qs.indexOf('catId') >= 0){
			var catId = "";
		
			for (var i=0; i<Community.Page.vars.length; i++) {
			    var pair = Community.Page.vars[i].split("=");
			    if (pair[0] == "catId") {
			       catId = pair[1];
			    } 
			}
			
			var categories = Community.Data.discussionCategories;
	
			for(var i=0; i<categories.length; i++){
				if(categories[i].id==catId){
					var breadcrumb = document.getElementById("ctl01_ctl00_ctl00_phBody_phBody_phBody_fluxBreadCrumbs_rptBreadCrumbs_ctl01_lbBreadCrumb");
	
					breadcrumb.href = Community.Page.baseUrl + categories[i].link.args;
	
					var newChild = document.createTextNode(categories[i].link.content);
					var oldChild = breadcrumb.childNodes[0];
					breadcrumb.replaceChild(newChild, oldChild);
				}
			}
		}// end discussion boards
		
		if(Community.Page.path.indexOf('Topic') > 0){			
			var breadcrumb = "";
			var catId = "";
			
			var tds = document.getElementsByTagName("td");
			
			for(var i=0; i<tds.length; i++){
				if(tds[i].id.indexOf('fluxBreadCrumbs_rptBreadCrumbs_ctl01_tdBreadCrumbCell') > 0){
					breadcrumb = tds[i].getElementsByTagName("a")[0];
				}
				if(tds[i].id.indexOf('fluxBreadCrumbs_rptBreadCrumbs_ctl03_tdBreadCrumbCell') > 0){
					var categoryLink = tds[i].getElementsByTagName("a")[0].href;
					catId = categoryLink.substring(categoryLink.indexOf("catId=")+6, categoryLink.length);
				}
			}
			
			var categories = Community.Data.discussionCategories;
			for(var i=0; i<categories.length; i++){
				if(categories[i].id==catId){
					breadcrumb.href = Community.Page.baseUrl + categories[i].link.args;
	
					var newChild = document.createTextNode(categories[i].link.content);
					var oldChild = breadcrumb.childNodes[0];
					breadcrumb.replaceChild(newChild, oldChild);
				}
			}
		}
		
		
	}// end this.updatePage
	
}

Community.Data = new function(){
	this.discussionCategories = "";
	this.fnVideoCategory = "";

	this.setDiscussionCategories = function(obj){
		Community.Data.discussionCategories = obj.categories.category;
		Community.Page.setDiscussionCSS();
	}
}

Community.Widgets = new function(){
	this.hostname = 'http://www.mtv.com';
	
	this.headerObj = {"div":{"div":[{"script":"injectFluxWidget('QuickMenu', {uri: \"http://www.mtv.com\"}, 'charlie');","ul":{"li":[{"a":{"href":"http://www.mtv.com/ontv/schedule/","content":"TV Schedule"},"id":"tvsched"},{"span":["Find Artists",{"a":[{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=a","content":"A"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=b","content":"B"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=c","content":"C"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=d","content":"D"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=e","content":"E"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=f","content":"F"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=g","content":"G"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=h","content":"H"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=i","content":"I"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=j","content":"J"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=k","content":"K"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=l","content":"L"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=m","content":"M"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=n","content":"N"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=o","content":"O"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=p","content":"P"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=q","content":"Q"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=r","content":"R"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=s","content":"S"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=t","content":"T"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=u","content":"U"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=v","content":"V"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=w","content":"W"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=x","content":"X"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=y","content":"Y"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=z","content":"Z"},{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=#","content":"#"}],"class":"alpha"}]}],"id":"artistlist"},"id":"memberbar"},{"form":{"input":[{"value":"Search","type":"text","onkeypress":"catchEnter(this.form);","onclick":"this.value='';","name":"searchterm","id":"searchmtv-text"},{"type":"image","onclick":"submitSearch(this.form); return false;","src":"/sitewide/images/u/btn-comgo.gif","alt":"Go","id":"searchmtv-btn"}],"action":"/search/","onsubmit":"return false;","name":"search","method":"get","select":{"option":[{"value":"1","content":"All MTV"},{"value":"2","content":"Web"}],"name":"searchtype","id":"searchmtv-select"}},"id":"searchmtv"}],"ul":{"li":[{"a":{"href":"http://www.mtv.com/","class":"n-link","content":"Home","id":"home"},"id":"n-home"},{"a":{"href":"http://www.mtv.com/music/","class":"n-link","content":"Music","id":"music"},"ul":{"li":[{"a":{"href":"http://www.mtv.com/music/","content":"Music Main"},"class":"first "},{"a":{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=a","content":"Artists"},"ul":{"li":[{"a":{"href":"http://www.mtv.com/music/artists/browse.jhtml?chars=a","content":"Browse All Artists"},"class":"first "},{"a":{"href":"http://www.mtv.com/music/artists/","content":"MTV.com Picks"}},{"a":{"href":"http://www.mtv.com/music/artists/most_popular.jhtml","content":"Most Popular Artists"}},{"a":{"href":"http://www.mtv.com/music/artists/new.jhtml","content":"New Artists"}},{"a":{"href":"http://www.mtv.com/music/photos/","content":"Artist Photos"}},{"a":{"href":"http://www.mtv.com/music/add_bio/","content":"A.D.D. Bio"}},{"a":{"href":"http://www.mtv.com/music/firstladies/","class":" last","content":"First Ladies"}}]},"class":"sub"},{"ul":{"li":[{"a":{"href":"http://www.mtv.com/music/video/index.jhtml","content":"MTV.com Video Picks"},"class":"first "},{"a":{"href":"http://www.mtv.com/music/video/premieres.jhtml","content":"Video Premieres"}},{"a":{"href":"http://www.mtv.com/music/video/popular.jhtml","content":"Most Popular Videos"}},{"a":{"href":"http://www.mtv.com/music/playlists/","content":"Playlists"}},{"a":{"href":"http://www.mtv.com/music/yearbook/","content":"Top Videos by Year"}},{"a":{"href":"http://www.mtv.com/music/live_performances/","content":"Live Performances"}},{"a":{"href":"http://www.mtv.com/ontv/dyn/big_ten/series.jhtml","content":"The Big Ten"}},{"a":{"href":"http://www.mtv.com/ontv/dyn/headbangers_ball/series.jhtml","content":"Headbangers Ball"}},{"a":{"href":"http://www.mtv.com/music/playlibs/","content":"Playlibs"}},{"a":{"href":"http://www.mtv.com/ontv/dyn/subterranean/series.jhtml","content":"Subterranean"}},{"a":{"href":"http://www.mtv.com/ontv/dyn/sf/series.jhtml","content":"Sucker Free"}},{"a":{"href":"http://remix.mtv.com","target":"_blank","class":" last","content":"Video Remixer"}}]},"class":"sub","span":"Music Videos"},{"a":{"href":"http://www.mtv.com/ontv/fn-mtv/","content":"FNMTV Premieres"}},{"a":{"href":"http://www.mtv.com/ontv/vma/2008/","content":"2008 Video Music Awards"}},{"a":{"href":"http://www.mtv.com/music/iwantmymusic/","content":"Your Music on MTV?"}},{"a":{"href":"http://soundtrack.mtv.com","target":"_blank","content":"Music in Shows"}},{"a":{"href":"http://www.mtv.com/lyrics/","content":"Lyrics"},"ul":{"li":[{"a":{"href":"http://www.mtv.com/lyrics/index.jhtml","content":"Search for Lyrics"},"class":"first "},{"a":{"href":"http://www.mtv.com/games/arcade/game/play.jhtml?arcadeGameId=10118704","class":" last","content":"Play Lyrics Game"}}]},"class":"sub"},{"ul":{"li":[{"a":{"href":"http://buzzworthy.mtv.com/","target":"_blank","content":"Buzzworthy Blog"},"class":"first "},{"a":{"href":"http://headbangersblog.mtv.com/","target":"_blank","content":"Headbangers Blog"}},{"a":{"href":"http://mp3.rhapsody.com/?pcode=via&cpath=mtv_web&rsrc=mtv_textnavblog","rel":"nofollow","target":"_blank","content":"Play | Rhapsody Blog"}},{"a":{"href":"http://www.subterraneanblog.com/","target":"_blank","content":"Subterranean Blog"}},{"a":{"href":"http://suckerfreeblog.mtv.com/","target":"_blank","content":"Sucker Free Blog"}},{"a":{"href":"http://yourhereblog.mtv.com/","target":"_blank","class":" last","content":"You R Here Blog"}}]},"class":"sub","span":"Music Blogs"},{"ul":{"li":[{"a":{"href":"http://www.mtv.com/ontv/dyn/mtv2_dew_circuit_breakout/series.jhtml","content":"Dew Circuit Breakout"},"class":"first "},{"a":{"href":"http://www.mtv.com/music/discover_download/","content":"Discover & Download"}},{"a":{"href":"http://www.mtv.com/music/mtv_live/","content":"MTV Live"}},{"a":{"href":"http://www.mtv.com/ontv/spankin_new/index.jhtml","content":"Spankin' New Music Week"}},{"a":{"href":"http://www.mtv.com/ontv/dyn/trl/series.jhtml","content":"TRL"}},{"a":{"href":"http://www.mtv.com/music/unplugged/","content":"Unplugged"}},{"a":{"href":"http://www.mtv.com/music/yo_mtv_raps/","class":" last","content":"Yo! MTV Raps"}}]},"class":"sub","span":"Music Series"},{"ul":{"li":[{"a":{"href":"http://www.mtv.com/music/the_leak/","content":"The Leak |Album Previews"},"class":"first "},{"a":{"href":"http://www.mtv.com/music/downloads/","content":"Free Downloads"}},{"a":{"href":"http://www.mtv.com/mtvradio/","content":"MTV Radio"}},{"a":{"href":"http://mp3.rhapsody.com/?pcode=via&cpath=mtv_web&rsrc=mtv_textnavdownloads","target":"_blank","class":" last","content":"Download on Rhapsody"}}]},"class":"sub","span":"Songs"},{"ul":{"li":[{"a":{"href":"http://www.mtv.com/music/rock/","content":"Rock"},"class":"first "},{"a":{"href":"http://www.mtv.com/music/pop/","content":"Pop"}},{"a":{"href":"http://www.mtv.com/music/hiphop/","content":"Hip-Hop"}},{"a":{"href":"http://www.mtv.com/music/soul/","content":"Soul/R&B"}},{"a":{"href":"http://www.mtv.com/music/indie/","class":" last","content":"Indie"}}]},"class":"sub","span":"Genres"},{"a":{"href":"http://www.mtv.com/asm/tours/","content":"Tours"}},{"a":{"href":"http://www.mtv.com/music/charts/","class":" last","content":"Billboard Charts"}}]},"id":"n-music"},{"div":{"div":[{"strong":"Shows","div":[{"a":[{"href":"http://www.mtv.com/ontv/dyn/tila_tequila/series.jhtml","content":"A Shot At Love 2 With Tila Tequila"},{"href":"http://www.mtv.com/ontv/dyn/dance_crew/series.jhtml","content":"America's Best Dance Crew"},{"href":"http://www.mtv.com/ontv/dyn/beavis_and_butthead/series.jhtml","content":"Beavis and Butt Head"},{"href":"http://www.mtv.com/ontv/dyn/busted/series.jhtml","content":"Busted"},{"href":"http://www.mtv.com/ontv/dyn/buzzin/series.jhtml","content":"Buzzin'"},{"href":"http://www.mtv.com/ontv/dyn/homecoming/series.jhtml","content":"Choose or Lose & Kanye West Present: Homecoming"},{"href":"http://www.mtv.com/ontv/dyn/cribs/series.jhtml","content":"Cribs"},{"href":"http://www.mtv.com/ontv/dyn/exiled/series.jhtml","content":"Exiled"},{"href":"http://www.mtv.com/ontv/fn-mtv/","content":"FNMTV Premieres"},{"href":"http://www.mtv.com/ontv/dyn/g_to_gents/series.jhtml","content":"From G's To Gents"},{"href":"http://www.mtv.com/ontv/dyn/rwrr_challenge-gauntlet3/series.jhtml","content":"Gauntlet III"},{"href":"http://www.mtv.com/ontv/dyn/the_hills/series.jhtml","content":"The Hills"},{"href":"http://www.mtv.com/ontv/dyn/high_school_stories/series.jhtml","content":"High School Stories"},{"href":"http://www.mtv.com/ontv/dyn/human_giant/series.jhtml","content":"Human Giant"},{"href":"http://jackassworld.com","content":"Jackass"},{"href":"http://www.mtv.com/ontv/dyn/legally_blonde_search_for_elle_woods/series.jhtml ","content":"Legally Blonde The Musical: The Search For Elle Woods"},{"href":"http://www.mtv.com/ontv/dyn/life_of_ryan/series.jhtml","content":"Life Of Ryan"}],"class":"shows-col1"},{"a":[{"href":"http://www.mtv.com/ontv/dyn/made/series.jhtml","content":"Made"},{"href":"http://www.mtv.com/ontv/dyn/making_the_band_4/series.jhtml","content":"Making The Band 4"},{"href":"http://www.mtv.com/ontv/shorts/","content":"MTV Shorts"},{"href":"http://www.mtv.com/ontv/dyn/sweet_16/series.jhtml","content":"My Super Sweet 16"},{"href":"http://northpalmwrestling.mtv.com/","target":"_blank","content":"North Palm Wrestling"},{"href":"http://www.mtv.com/ontv/dyn/once_upon_a_prom/series.jhtml","content":"Once Upon A Prom"},{"href":"http://www.mtv.com/ontv/dyn/the_paper/series.jhtml","content":"The Paper"},{"href":"http://www.mtv.com/ontv/dyn/pimp_my_ride/series.jhtml","content":"Pimp My Ride"},{"href":"http://www.mtv.com/ontv/dyn/realworld-season20/series.jhtml","content":"Real World: Hollywood"},{"href":"http://www.mtv.com/ontv/dyn/rob_and_big/series.jhtml","content":"Rob and Big"},{"href":"http://www.mtv.com/ontv/dyn/rock_the_cradle/series.jhtml","content":"Rock The Cradle"},{"href":"http://www.mtv.com/ontv/dyn/runs_house/series.jhtml","content":"Run's House"},{"href":"http://www.mtv.com/ontv/spankin_new/index.jhtml","content":"Spankin' New Music Week"},{"href":"http://www.mtv.com/ontv/dyn/trl/series.jhtml","content":"TRL"},{"href":"http://www.mtv.com/ontv/dyn/truelife/series.jhtml","content":"True Life"},{"href":"http://www.mtv.com/ontv/dyn/xeffect/series.jhtml","content":"The X Effect"}],"class":"shows-col2"}],"id":"shows-1"},{"strong":"Specials","a":[{"href":"http://www.mtv.com/ontv/movieawards/2008/","content":"2008 Movie Awards"},{"href":"http://www.mtv.com/ontv/vma/2008/","content":"2008 Video Music Awards"},{"href":"http://think.mtv.com/Campaigns/youngvets/","target":"_blank","content":"Choose or Lose Young Veterans Forum"},{"href":"http://think.mtv.com/Campaigns/myspace/","target":"_blank","content":"MTV/MySpace Dialogues"},{"href":"http://www.mtv.com/ontv/specials/real_world_awards/","content":"Real World Awards Bash"},{"href":"http://www.mtv.com/ontv/spankin_new/spring_2008/","content":"Spankin' New Music Week"},{"href":"http://www.mtv.com/ontv/specials/spring_break/2008/","content":"Spring Break"},{"href":"http://www.mtv.com/music/yo_mtv_raps/","content":"Yo! MTV Raps"}],"id":"shows-2"}],"a":{"href":"http://www.mtv.com/ontv/all/index.jhtml","content":"View All Shows &#187;","id":"shows-all"},"id":"shows-grid"},"a":{"href":"http://www.mtv.com/ontv/","class":"n-link","content":"Shows","id":"shows"},"ul":{"li":[{"a":{"href":"http://www.mtv.com/ontv/schedule/","content":"TV Schedule","id":"n-tvsched"},"class":"first "},{"a":{"href":"http://remotecontrol.mtv.com","target":"_blank","content":"MTV Shows Gossip"}},{"a":{"href":"http://soundtrack.mtv.com","target":"_blank","content":"Music in Shows"}},{"a":{"href":"http://www.mtv.com/ontv/photos/","content":"Show Photos"}},{"a":{"href":"http://www.mtv.com/ontv/castingcall/","content":"Be on MTV"}},{"a":{"href":"http://shop.mtv.com/viewcategory.htm?categoryId=420907","target":"_blank","class":" last","content":"Shop MTV Shows"}}]},"id":"n-shows"},{"a":{"href":"http://www.mtv.com/news/","class":"n-link","content":"News","id":"news"},"ul":{"li":[{"a":{"href":"http://www.mtv.com/news/","content":"News Main"},"class":"first "},{"ul":{"li":[{"a":{"href":"http://www.mtv.com/news/latest/index.jhtml","content":"Breaking News"},"class":"first "},{"a":{"href":"http://www.mtv.com/news/latest/music.jhtml","content":"Music News"}},{"a":{"href":"http://www.mtv.com/news/latest/movies.jhtml","content":"Movie News"}},{"a":{"href":"http://www.mtv.com/news/latest/games.jhtml","content":"Video Game News"}},{"a":{"href":"http://www.mtv.com/news/latest/world.jhtml","class":" last","content":"World/National News"}}]},"class":"sub","span":"Headlines"},{"a":{"href":"http://www.mtv.com/news/video/","content":"Video Updates & Interviews"}},{"a":{"href":"http://newsroom.mtv.com/","target":"_blank","content":"Newsroom Blog"}},{"ul":{"li":[{"a":{"href":"http://yourhere.mtv.com/","target":"_blank","content":"Your Uploads"},"class":"first "},{"a":{"href":"http://yourhereblog.mtv.com/","target":"_blank","class":" last","content":"You R Here Blog"}}]},"class":"sub","span":"Live Music Coverage"},{"ul":{"li":[{"a":{"href":"http://www.mtv.com/news/correspondents/hernandez/","content":"Liz Hernandez"},"class":"first "},{"a":{"href":"http://www.timkashblog.com/","target":"_blank","content":"Tim Kash"}},{"a":{"href":"http://www.mtv.com/news/correspondents/loder/","content":"Kurt Loder"}},{"a":{"href":"http://www.mtv.com/news/correspondents/norris/","content":"John Norris"}},{"a":{"href":"http://www.mtv.com/news/correspondents/pak/","content":"SuChin Pak"}},{"a":{"href":"http://www.mtv.com/news/correspondents/stolz/","content":"Kim Stolz"}},{"a":{"href":"http://www.mtv.com/news/correspondents/sway/","class":" last","content":"Sway"}}]},"class":"sub","span":"MTV Reporters"},{"a":{"href":"http://multiplayerblog.mtv.com","target":"_blank","content":"Video Games Blog"}},{"a":{"href":"http://splashpage.mtv.com","target":"_blank","content":"Comic Book Movies Blog"}},{"a":{"href":"http://think.mtv.com/Campaigns/street-team-08/","target":"_blank","content":"Street Team '08"}},{"a":{"href":"http://www.mtv.com/specials/hottest/mcs/","content":"Hottest MCs"}},{"a":{"href":"#","content":"News Alerts","onClick":"window.open('http://ebm.cheetahmail.com/r/regf2?aid=409502673&n=102&a=0&MTVSOURCE=638520930', 'alertsPop', 'width=690,height=500,resizable=true,scrollbars=1,'); return false;"}}]},"id":"n-news"},{"ul":{"li":[{"a":{"href":"http://www.mtv.com/movies/","content":"Movies"},"ul":{"li":[{"a":{"href":"http://www.mtv.com/movies/","content":"Movies Main"},"class":"first "},{"a":{"href":"http://www.mtv.com/ontv/movieawards/2008/","content":"2008 Movie Awards"}},{"a":{"href":"http://www.mtv.com/news/latest/movies.jhtml","content":"Movies News"}},{"a":{"href":"http://www.mtvmoviesblog.com/","target":"_blank","content":"Movies Blog"}},{"a":{"href":"http://splashpage.mtv.com","target":"_blank","content":"Comic Book Movies Blog"}},{"a":{"href":"http://www.mtv.com/movies/trailer_park/","content":"Trailers"}},{"a":{"href":"http://www.mtv.com/movies/news/loder/","content":"Kurt Loder Film Reviews"}},{"a":{"href":"http://www.mtv.com/movies/summer-movies/","content":"Summer Movies"}},{"a":{"href":"http://www.mtv.com/movies/features_interviews/interviews.jhtml","content":"Interviews"}},{"a":{"href":"http://www.mtv.com/movies/photo/","content":"Red Carpet & On Set Photos"}},{"a":{"href":"http://shop.mtv.com/Movies_stcVVcatId421148VVviewcat.htm","target":"_blank","class":" last","content":"MTV Movies Shop"}}]},"class":"first sub"},{"a":{"href":"http://www.mtv.com/games/video_games/","content":"Video Games"},"ul":{"li":[{"ul":{"li":[{"a":{"href":"http://www.mtv.com/games/video_games/rock_band/index.jhtml","content":"Rock Band"},"class":"first "},{"a":{"href":"http://www.mtv.com/games/video_games/dime/index.jhtml","content":"The Dime"}},{"a":{"href":"http://www.mtv.com/overdrive/?type=1297","content":"Hot Trailers"}},{"a":{"href":"http://www.mtv.com/games/video_games/ghole/index.jhtml","content":"The G-Hole"}},{"a":{"href":"http://www.mtv.com/games/video_games/video_hub/index.jhtml","content":"Trailers and Game Videos"}},{"a":{"href":"http://www.mtv.com/podcasts/","class":" last","content":"Podcast"}}]},"class":"first sub","span":"Features"},{"a":{"href":"http://www.mtv.com/news/latest/games.jhtml","content":"News"},"ul":{"li":[{"a":{"href":"http://multiplayerblog.mtv.com/","target":"_blank","content":"Multiplayer Blog"},"class":"first "},{"a":{"href":"http://multiplayerblog.mtv.com/category/multiplayer-originals","target":"_blank","content":"Multiplayer Video"}},{"a":{"href":"http://www.mtv.com/news/latest/games.jhtml","class":" last","content":"Games News"}}]},"class":"sub"},{"a":{"href":"http://www.mtv.com/games/video_games/gamers_week/index.jhtml","class":" last","content":"Gamer's Week"}}]},"class":"sub"},{"a":{"href":"http://www.mtv.com/games/arcade/","content":"Online Games"},"ul":{"li":[{"a":{"href":"http://www.mtv.com/games/arcade/action/","content":"Action Games"},"class":"first "},{"a":{"href":"http://www.mtv.com/games/arcade/mtv_original/","content":"MTV Original & Show Games"}},{"a":{"href":"http://www.mtv.com/games/arcade/music_rhythm/","content":"Music & Rhythm Games"}},{"a":{"href":"http://www.mtv.com/games/arcade/strategy_puzzle/ ","content":"Strategy & Puzzle Games"}},{"a":{"href":"http://www.mtv.com/games/arcade/quizzes/","class":" last","content":"Quizzes"}}]},"class":"sub"},{"a":{"href":"http://www.mtv.com/thinkmtv/","content":"Activism"}},{"a":{"href":"http://www.mtv.com/mobile/","content":"Mobile"},"ul":{"li":[{"ul":{"li":[{"a":{"href":"http://www.mtv.com/mobile/shows/add_bio/","content":"A.D.D. Bio"},"class":"first "},{"a":{"href":"http://www.mtv.com/mobile/shows/beavis_and_butt_head/","content":"Beavis and Butthead"}},{"a":{"href":"http://www.mtv.com/mobile/shows/the_hills/","content":"The Hills"}},{"a":{"href":"http://www.mtv.com/mobile/shows/kaya/","content":"Kaya"}},{"a":{"href":"http://www.mtv.com/mobile/shows/mtv2/","content":"MTV2"}},{"a":{"href":"http://www.mtv.com/mobile/shows/mtvu/","content":"mtvU"}},{"a":{"href":"http://www.mtv.com/mobile/shows/runs_house/","content":"Run's House"}},{"a":{"href":"http://www.mtv.com/mobile/shows/sucker_free/","content":"Sucker Free on MTV"}},{"a":{"href":"http://www.mtv.com/mobile/shows/trl/index.jhtml","content":"TRL"}},{"a":{"href":"http://www.mtv.com/mobile/shows/yo_momma/index.jhtml","class":" last","content":"Yo Momma"}}]},"class":"first sub","span":"MTV Shows"},{"a":{"href":"http://www.mtv.com/mobile/ringtones/","content":"Ringtones"}},{"a":{"href":"http://www.mtv.com/mobile/graphics/","content":"Graphics"}},{"a":{"href":"http://www.mtv.com/mobile/games/","content":"Games"}},{"a":{"href":"http://www.mtv.com/mobile/alerts/","content":"Alerts"}},{"a":{"href":"http://www.mtv.com/mobile/video/","class":" last","content":"Video"}}]},"class":"sub"},{"a":{"href":"http://www.mtv.com/sweepstakes/","content":"Contest & Sweepstakes"}},{"ul":{"li":{"a":{"href":"http://www.mtv.com/specials/back-to-school/","class":" last","content":"Back To School"},"class":"first "}},"class":"sub","span":{"class":" last","content":"Specials"}}]},"span":{"class":"n-link last","content":"Movies, Games & More"},"id":"n-movies"}],"id":"navlist"},"id":"nav"}};
	
	this.fnHeaderObj = {"div":{"div":{"script":"injectFluxWidget('QuickMenu', {uri: \"http://www.mtv.com\"}, 'charlie');","id":"memberbar"},"ul":{"class":"franchise-nav","li":[{"a":{"href":"http://www.mtv.com/ontv/fn-mtv/","class":"n-link","content":"Home"}},{"a":{"href":"http://www.mtv.com/ontv/fn-mtv/music-videos.jhtml","class":"n-link","content":"Music Videos"}},{"a":{"href":"http://www.mtv.com/ontv/fn-mtv/uploads.jhtml","class":"n-link","content":"Fan Uploads"}},{"a":{"href":"http://www.mtv.com/ontv/fn-mtv/playlists.jhtml","class":"n-link","content":"Classic Videos"}},{"a":{"href":"http://www.mtv.com/ontv/fn-mtv/photos.jhtml","class":"n-link","content":"Photos"}},{"a":{"href":"http://community.mtv.com/Content/Discussions/DiscussionBoard.aspx?catId=19368","target":"_blank","class":"n-link","content":"Message Boards"}},{"a":{"href":"http://www.mtv.com/ontv/fn-mtv/about.jhtml","class":"n-link last","content":"About","id":"about"},"id":"n-about"}],"id":"navlist"},"id":"nav"}};
	
	this.create = function(name, contextNodeID){
		switch(name){
			case 'css': this.addCSS(); break;
			case 'hat': this.setHat(); break;
			case 'nav': Community.Widgets.createNav(contextNodeID); break;
			case 'artistlist': Community.Widgets.createArtistlist(contextNodeID); break;
			case 'footer': Community.Widgets.createFooter(contextNodeID); break;
			case 'search': Community.Widgets.createSearch(contextNodeID); break;
			default: break;
		}
	}
	
	this.createSearch = function(contextNodeID){
		var div = document.createElement('div');
		div.innerHTML = '<' + 'iframe src="' + Community.Widgets.hostname + '/widgets/search/iframe.jhtml" width="321" height="33" frameborder="0" scrolling="no" style="float:right;">search mtv</iframe>';
		var contextNode = document.getElementById(contextNodeID);
		if (contextNode) contextNode.appendChild(div);
	}
	
	this.createNav = function(contextNodeId, headerObj){
		var obj = (headerObj!=null) ? headerObj.div.ul : Community.Widgets.headerObj.div.ul;
		if(obj){
			var container = document.getElementById(contextNodeId); 
			var ul = Community.Widgets.createUL(obj);
			container.appendChild(ul);
			
			var logoLink = document.getElementById("logo-link");
			logoLink.setAttribute("href", obj.li[0].a.href);
		}
	}
	
	this.createFooter = function(contextNodeId){
		var obj = {"div":{"img":{"width":"131","height":"26","border":"0","src":"/sitewide/images/charlie/mtvn.gif"},"p":[{"a":[{"href":"http://labsblog.mtv.com/2007/09/18/mtvcom-community-beta-launch/","target":"_blank","content":"Send Us Feedback"},{"href":"http://www.mtv.com/sweepstakes/","content":"MTV Contests & Sweepstakes"},{"href":"http://shop.mtv.com/","target":"_blank","content":"MTV Shop"},{"href":"http://learn.rhapsody.com/?pcode=via&cpath=mtv_web&rsrc=mtvfooter","target":"_blank","content":"Rhapsody.com"},{"href":"http://www.mtv2.com/","target":"_blank","content":"MTV2"},{"href":"http://www.mtvu.com/","target":"_blank","content":"mtvU"},{"href":"http://www.mtvtr3s.com/","target":"_blank","content":"MTV Tr3s"},{"href":"http://www.mtv.com/sites/","target":"_blank","content":"Directory of MTV Sites"}],"content":["|","|","|","|","|","|","|"]},{"a":[{"href":"http://www.mtv.com/mtvradio/","content":"MTV Radio"},{"href":"http://style.mtv.com/","target":"_blank","content":"MTV Style"},{"href":"https://jobhuntweb.viacom.com/jobhunt/main/jobhome.asp","target":"_blank","content":"MTV Jobs"},{"href":"http://www.mtv.com/rss/","content":"Podcasts"},{"href":"http://www.mtv.com/rss/","class":"rss","content":"RSS","style":"padding-left:16px"},{"href":"http://hatsblog.mtv.com/","target":"_blank","content":"MTV Logo Art"},{"href":"http://ebm.cheetahmail.com/r/regf2?aid=409502673&n=102&a=0","content":"Newsletters","onclick":"window.open('http://ebm.cheetahmail.com/r/regf2?aid=409502673&n=102&a=0', 'alertsPop', 'width=690,height=500,resizable=true,scrollbars=1,'); return false;"},{"href":"http://www.mtv.com/sitewide/sitemap/?searchtype=artist&p=1&q=30","content":"Site Map"}],"content":["|","|","|","|","|","|","|"]},{"a":[{"href":"http://www.mtv.com/sitewide/mtvinfo/terms.jhtml","target":"_blank","content":"Terms of Use"},{"href":"http://www.mtv.com/sitewide/mtvinfo/privacy.jhtml","target":"_blank","content":"Privacy Policy/Your CA Privacy Rights"},{"href":"http://www.mtv.com/sitewide/mtvinfo/copyright_compliance.jhtml","target":"_blank","content":"Copyright Compliance Policy"},{"href":"http://www.mtv.com/sitewide/mtvinfo/user_content.jhtml","target":"_blank","content":"User Content Submission Agreement"},{"href":"http://adspecs.mtvn.com/site/mtv/mtv.html","target":"_blank","content":"Advertising Opportunities"}],"content":["|","|","|","|"]},{"a":[{"href":"http://www.mtv.com/sitewide/mtvinfo/social_project_faq.jhtml","content":"Community FAQ","onclick":"window.open('/sitewide/mtvinfo/social_project_faq.jhtml', 'communityFAQ', 'width=620,height=600,scrollbars'); return false;"},{"href":"http://www.socialproject.com/PrivacyPolicy.html","target":"_blank","content":"Social Project Privacy Policy"},{"href":"http://www.socialproject.com/TermsOfUse.html","target":"_blank","content":"Social Project Terms of Use"}],"content":["|","|"]},{"content":"&#169; 2008 MTV Networks. &#169; and TM MTV Networks. ALL RIGHTS RESERVED. E-commerce on this website is brought to you by MTVN Direct Inc.","id":"copyright"}],"id":"ftr"}};
		if (obj.div){
			var container = document.getElementById(contextNodeId);
			var div = document.createElement('div');
			if(obj.div.id) div.setAttribute('id', obj.div.id);
			
			for (var x=0; x<obj.div.p.length; x++){
				div.appendChild(Community.Widgets.createP(obj.div.p[x]));
			}
			container.appendChild(div);
		}
	}
	
	this.createArtistlist = function(contextNodeId){
		var obj = Community.Widgets.headerObj.div.div[0].ul;
		if(obj){
			var container = document.getElementById(contextNodeId); 
			var ul = Community.Widgets.createUL(obj);
			container.appendChild(ul);
		}
	}
	
	this.createP = function(p){
		var pElement = document.createElement('p');
		if(p.id) pElement.setAttribute('id', p.id);
		if(p['class']) pElement.className = p['class'];
		
		if (p.a){
			for (var x=0; x<p.a.length; x++){
				pElement.appendChild(Community.Widgets.createA(p.a[x]));
				if (x<p.a.length-1) pElement.appendChild(document.createTextNode("|"));
			}
		}
		else{ pElement.innerHTML = p.content; }
		return pElement;
	}
	
	this.createUL = function(ul){
		var ulElement = document.createElement('ul');
		if(ul.id) ulElement.setAttribute('id', ul.id);
		if(ul['class']) ulElement.className = ul['class'];
		if(ul.li.length==undefined) ulElement.appendChild(Community.Widgets.createLI(ul.li));
		else{
			for (var x=0; x<ul.li.length; x++){
				ulElement.appendChild(Community.Widgets.createLI(ul.li[x]));
			}
		}
		return ulElement;
	}
	
	this.createLI = function(li){
		var liElement = document.createElement('li');
		
		if(li.content) liElement.innerHTML = li.content;
		
		if(li.id) liElement.setAttribute('id', li.id);
		if(li['class']) liElement.className = li['class'];

		if(li.a) liElement.appendChild(Community.Widgets.createA(li.a));
		else if(li.span){
			if(li.span instanceof Array){ 
				for (var i=0; i<li.span.length; i++){
					liElement.appendChild(Community.Widgets.createSpan(li.span[i]));
				}
			}
			else liElement.appendChild(Community.Widgets.createSpan(li.span));
		} 
		
		if (li.ul) liElement.appendChild(Community.Widgets.createUL(li.ul));
		if (li.div) liElement.appendChild(Community.Widgets.createDiv(li.div));
		
		if (window.attachEvent){
			liElement.onmouseover=function() {	this.className+=" sfhover";	}
			liElement.onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); }
		}

		return liElement;
	}
	
	this.createDiv = function(div){
		var divElement = document.createElement('div');
		
		if(div.id) divElement.setAttribute('id', div.id);
		if(div['class']) divElement.className = div['class'];
				
		if(div.div instanceof Array){
			for (var i=0; i<div.div.length; i++){
				divElement.appendChild(Community.Widgets.createSubDiv(div.div[i]));
			}
			
		}
		
		if(div.dl instanceof Array){
			for (var i=0; i<div.dl.length; i++){
				var dl = div.dl[i];
				var dlElement = document.createElement('dl');
				if(dl.id) dlElement.setAttribute('id', dl.id);
				if(dl.dt){
					var dtElement = document.createElement('dt');
					dtElement.innerHTML = dl.dt;
					dlElement.appendChild(dtElement);
				}

				if(dl.dd instanceof Array){
					for (var j=0; j<dl.dd.length; j++){
						var ddElement = document.createElement('dd');
						ddElement.appendChild(Community.Widgets.createA(dl.dd[j].a));
						dlElement.appendChild(ddElement);
					}
				}
				
				divElement.appendChild(dlElement);
			}
		}
		
		if(div.a){
			if(div.a instanceof Array){
				for (var i=0; i<div.a.length; i++){
					divElement.appendChild(Community.Widgets.createA(div.a[i]));
				}
			}
			else divElement.appendChild(Community.Widgets.createA(div.a));
		}
		
		return divElement;
	}
	
	this.createSubDiv = function(subDiv){
		
		var subDivElement = document.createElement('div');
		if(subDiv.id) subDivElement.setAttribute('id', subDiv.id);
		if(subDiv['class']) subDivElement.className = subDiv['class'];
		if(subDiv.strong) subDivElement.appendChild(Community.Widgets.createStrong(subDiv.strong));
		
		if(subDiv.a instanceof Array){
			for (var i=0; i<subDiv.a.length; i++){
				subDivElement.appendChild(Community.Widgets.createA(subDiv.a[i]));
			}
		}
		
		if(subDiv.div instanceof Array){
			for (var i=0; i<subDiv.div.length; i++){
				subDivElement.appendChild(Community.Widgets.createSubDiv(subDiv.div[i]));
			}
		}
		
		//if(subDiv.div) subDivElement.appendChild(Community.Widgets.createDiv(subDiv.div));
		
		return subDivElement;
	}
	
	this.createA = function(a){
		var aElement = document.createElement('a');
	
		if(a.id) aElement.setAttribute('id', a.id);
		if(a['class']) aElement.className = a['class'];
		if(a.href) aElement.setAttribute('href', a.href);
		if(a.target) aElement.setAttribute('target', a.target);
		if(a.onclick) aElement.setAttribute('onclick', a.onclick);
		aElement.innerHTML = a.content;
			
		return aElement;
	}
	
	this.createSpan = function(span){
		var spanElement = document.createElement('span');
		
		if(typeof span == 'object'){
			if(span['class']) spanElement.className = span['class'];
			if(span.content) spanElement.innerHTML = span.content;
			if(span.a instanceof Array){
				for(var i=0; i<span.a.length; i++){
					spanElement.appendChild(Community.Widgets.createA(span.a[i]));
					spanElement.innerHTML += "\n";
					spanElement.appendChild(document.createTextNode(""));
				}
			}
		}
		else { spanElement.innerHTML = span + "\n";}
		
		return spanElement;
	}
	
	this.createStrong = function(strong){
		var strongElement = document.createElement('strong');
		strongElement.innerHTML = strong;
		return strongElement;
	}
}

Community.Page.addCSSLink('/sitewide/css/u/screen.css');
Community.Page.addCSSLink('/sitewide/community/css/common.css');

// discussion boards
if((Community.Page.path.indexOf('DiscussionBoard.aspx') > 0 && Community.Page.qs.indexOf('catId') >= 0) || Community.Page.path.indexOf('Topic') > 0){
	Community.Page.createScript("/sitewide/community/json/discussion_categories.jhtml?callback=Community.Data.setDiscussionCategories");
}
else if(Community.Page.path.indexOf('Content/Video/VideoResults.aspx') > 0 && Community.Page.qs.indexOf('category') >= 0){
	Community.Page.createScript("/sitewide/community/json/fn_video_categories.jhtml?callback=Community.Page.handleFnVideoCategory");
}
else{ Community.Page.setHat(); }
