var configUrl = "http://www.mtv.com"; if(document.domain.indexOf("-d") > 0) configUrl = "http://www.mtv-d.mtvi.com"; if(document.domain.indexOf("-q") > 0) configUrl = "http://www.mtv-q.mtvi.com"; var communityAccess = true; // to disable all Flux widgets, change this value to false. SetCookieUtil("cCommunityPhase", "2"); // enable phase 2 function injectFluxWidget(widgetName, options, version){ var showWidget = "false"; var accessKey = "4e004077-78fa-472b-b70d-185d84a591c9"; //console.log(options.uri); if (widgetName=="Comments3" && GetCookieUtil("cCommunityComments")=="true"){ showWidget = "true"; options.displayUserName = true; options.customize = {markupUrl: configUrl+'/sitewide/community/widgets/comments/comments3.html', scriptUrl: configUrl+'/sitewide/community/widgets/comments/comments3.js'}; } if (widgetName=="FShare2" && GetCookieUtil("cCommunityComments")=="true") { showWidget = "true"; } if (widgetName=="Comments2" && GetCookieUtil("cCommunityComments")=="true"){ showWidget = "true"; if (GetCookieUtil("cCommunityPhase")=="2"){ options.displayUserName = true; switch(version){ case 'charlie': options.customize = {markupUrl: configUrl+'/sitewide/community/widgets/comments/charlie.html', scriptUrl: configUrl+'/sitewide/community/widgets/comments/charlie.js'}; break; case 'fn': options.customize = {markupUrl: configUrl+'/sitewide/community/widgets/comments/fn.html', scriptUrl: configUrl+'/sitewide/community/widgets/comments/charlie.js'}; break; case 'vma': options.customize = {markupUrl: configUrl+'/sitewide/community/widgets/comments/vma.html', scriptUrl: configUrl+'/sitewide/community/widgets/comments/charlie.js'}; break; default: options.customize = {markupUrl: '/sitewide/community/widgets/CustomComments.js'}; break; } } } if (widgetName=="Rating" && GetCookieUtil("cCommunityRating")=="true"){ showWidget = "true"; widgetName = "ContentAction2"; options.accessKey = accessKey; options.showAddToMyProfileButton = false; options.showCommentCount = true; options.hideCommentText = false; options.showRating = true; options.showFlagging = false; options.showPermalink = false; switch(version){ case 'charlie': options.customize = {markupUrl: configUrl+'/sitewide/community/widgets/rating/charlie.html', scriptUrl:configUrl+'/sitewide/community/widgets/rating/content_action2.js'}; break; case 'dance': options.customize = {markupUrl: configUrl+'/sitewide/community/widgets/rating/dance.html', scriptUrl:configUrl+'/sitewide/community/widgets/rating/meter.js'}; break; default: options.customize = {markupUrl: '/sitewide/community/widgets/rating/bravo.html', scriptUrl:'/sitewide/community/widgets/rating/content_action2.js'}; break; } } // override usage for blogs if (widgetName=="Usage" && GetCookieUtil("cCommunityPhase")=="2"){ showWidget = "true"; options.link = options.uri + '#postComment'; options.customize = {markupUrl: configUrl+'/sitewide/community/widgets/usage/charlie.html'} } if (widgetName=="QuickMenu" && GetCookieUtil("cCommunityPhase")=="2"){ widgetName = "QuickMenu2"; showWidget = "true"; options.accessKey = accessKey; options.customize = {markupUrl: configUrl+'/sitewide/community/widgets/quickmenu/charlie.html', scriptUrl: configUrl+'/sitewide/community/widgets/quickmenu/charlie.js'}; } if (widgetName=="ContentAction" && GetCookieUtil("cCommunityPhase")=="2"){ showWidget = "true"; switch(version){ case 'ugc': widgetName = "ContentAction2"; options.accessKey = accessKey; options.showAddToMyProfileButton = true; options.showCommentCount = false; options.hideCommentText = true; options.showRating = false; options.showFlagging = true; options.showPermalink = false; options.customize = {markupUrl: '/sitewide/community/widgets/contentAction/ugc.html'}; break; default: widgetName = "ContentAction2"; options.accessKey = accessKey; options.showAddToMyProfileButton = true; options.customize = {markupUrl: '/sitewide/community/widgets/addToProfile/charlie.html', scriptUrl: '/sitewide/community/widgets/addToProfile/charlie.js'}; break; } } if (showWidget=="true" && communityAccess){ if(typeof Flux!='undefined'){ if (Flux && Flux.Utils.WidgetsLoader) { // Akamai fix Flux.Utils.WidgetsLoader._widgetUrlTemplate.classic = Flux.Utils.WidgetsLoader._widgetUrlTemplate.classic.replace('http://widgets.flux.com/', 'http://widgetsak-mtv.flux.com/'); Flux.Utils.WidgetsLoader._widgetUrlTemplate.pbt = Flux.Utils.WidgetsLoader._widgetUrlTemplate.pbt.replace('http://widgets.flux.com/', 'http://widgetsak-mtv.flux.com/'); Flux.Utils.WidgetsLoader.createWidget(widgetName, options); } } } } function Community() { var fluxAuthTokenCookieName = 'RtxAuth2407'; var communityHostname = 'http://community.mtv.com'; var onFinish = ""; /* dialogue open and close */ this.open = function(page){ if((page=="login" || page=="register") && GetCookieUtil("cCommunityAccess")!="true"){ switch(page){ case 'login': window.open('/sitewide/community/login/', 'loginPopUp', 'width=448,height=309,'); break; case 'register': window.open('/community/account/join.jhtml?serv=&mtvparams=&target=&mesg=', 'loginPopUp', 'width=448,height=309,'); break; default: break; } } else{ if (GetCookieUtil("cCommunityPhase")>=2 && (page=="register" || page=="login" || page=="join")){ this.hostedPageLink(page); } else{ overlayOpen(); window.scrollTo(0,0); this.link(page); } } } this.close = function(){ overlayClose(); this.link('clear'); } this.finish = function(){ this.close(); if (this.onFinish != undefined){ switch(this.onFinish){ case 'reload': window.location.reload(); break; default: window.location.href = this.onFinish; break; } } } /* links */ this.hostedPageLink = function(page, id){ var hostedPage = "/"; switch(page){ case 'discussion': hostedPage = '/-/Content/Discussions/DiscussionBoard.aspx?catId=' + id; break; case 'join': hostedPage = '/-/JoinInterim.aspx?returnPath=' + window.location.href; break; case 'login': hostedPage = '/-/SignUp.aspx?returnPath=' + window.location.href; break; case 'register': hostedPage = '/-/SignUp.aspx?returnPath=' + window.location.href; break; default: break; } window.location.href=communityHostname + hostedPage; } this.link = function(page, version){ if (GetCookieUtil("cCommunityPhase")>=2 && (page=="register" || page=="login" || page=="join")){ this.hostedPageLink(page); } else{ /* temporary iframe fix */ this.hide(document.getElementById('communityUpload')); switch(page){ case 'clear': submit('/sitewide/community/forms/clear.jhtml'); break; case 'join': submit('/sitewide/community/forms/join.jhtml'); break; case 'login': submit('/sitewide/community/forms/login.jhtml'); break; case 'loginFromReg': submit('/sitewide/community/forms/login.jhtml?event=loginFromRegLink'); break; case 'notJoined': submit('/sitewide/community/forms/error.jhtml?errorCode=' + page + '&phase=' + GetCookieUtil("cCommunityPhase") + '&version=' + version); break; case 'notLoggedIn': submit('/sitewide/community/forms/error.jhtml?errorCode=' + page + '&phase=' + GetCookieUtil("cCommunityPhase") + '&version=' + version); break; case 'notVerified': submit('/sitewide/community/forms/error.jhtml?errorCode=' + page + '&phase=' + GetCookieUtil("cCommunityPhase") + '&version=' + version); break; case 'passwordReminder': submit('/sitewide/community/forms/passwordReminder.jhtml'); break; case 'problems': submit('/sitewide/community/forms/problems.jhtml'); break; case 'register': submit('/sitewide/community/forms/register.jhtml'); break; case 'sendValidation': submit('/sitewide/community/forms/sendValidation.jhtml'); break; case 'updateAccount': submit('/sitewide/community/forms/updateAccount.jhtml'); break; case 'updatePassword': submit('/sitewide/community/forms/updatePassword.jhtml'); break; case 'uploadPhoto': submit('/sitewide/community/forms/uploadPhoto.jhtml'); break; case 'uploadSuccess': submit('/sitewide/community/forms/updateAccount.jhtml?action=uploadSuccess'); break; case 'uploadSkip': submit('/sitewide/community/forms/welcome.jhtml?action=register&event=uploadSkip'); break; case 'quit': submit('/sitewide/community/forms/quit.jhtml'); break; case 'welcomeRegister': submit('/sitewide/community/forms/welcome.jhtml?action=register'); break; default: submit(page); break; } } } /* form handlers */ this.handle = function(form, elements){ switch(form){ case 'deactivate': submit('/sitewide/community/forms/do_deactivate.jhtml'); break; case 'join': submit('/sitewide/community/forms/do_join.jhtml', ['firstName', 'lastName', 'username', 'agreeToTerms']); break; case 'login': submit('/sitewide/community/forms/do_login.jhtml', ['loginName', 'password']); break; case 'logout': submit('/sitewide/community/forms/logout.jhtml'); break; case 'passwordReminder': submit('/sitewide/community/forms/do_passwordReminder.jhtml', ['email']); break; case 'register': submit('/sitewide/community/forms/do_register.jhtml', ['email', 'emailConfirm', 'password', 'passwordConfirm', 'loginName', 'firstName', 'lastName', 'birthDateMonth', 'birthDateDay', 'birthDateYear', 'postalCode', 'agreeToTerms']); break; case 'updateAccount': submit('/sitewide/community/forms/do_updateAccount.jhtml', elements); break; case 'updatePassword': submit('/sitewide/community/forms/do_updatePassword.jhtml', ['currentPassword', 'newPassword', 'newPasswordConfirm']); break; case 'unjoin': submit('/sitewide/community/forms/do_unjoin.jhtml'); break; case 'sendValidation': submit('/sitewide/community/forms/do_sendValidation.jhtml', ['email']); break; default: break; } } this.updateWidgets = function(){ submit('/sitewide/community/forms/updateWidgets.jhtml'); } this.logout = function(){ submit('/sitewide/community/includes/logout.jhtml'); } this.pop = function(url, type){ var features; if (type=='legal') features = "width=620,height=600,scrollbars"; if (url=='faq'){ url = "/sitewide/mtvinfo/social_project_faq.jhtml"; features = "width=620,height=600,scrollbars"; } if (url=='betaInvite'){ url = "/community/invite/index.jhtml"; features = "width=344,height=320,menubar=no,status=yes,scrollbars=no"; } window.open(url, '', features); } /* utils */ this.getQuickmenu = function(){ if(GetCookieUtil("cCommunityPhase")=="2"){ this.show(document.getElementById("quickmenu")); } else{ if(GetCookieUtil("cCommunityAccess")=="true") this.loadMamabar(); this.show(document.getElementById("mamabar")); } } this.loadMamabar = function(){ submit('/sitewide/community/includes/mamabar.jhtml', [], false); } this.checkUsername = function(username){ submit('/sitewide/community/forms/checkUsername.jhtml?loginName=' + username); } this.setBetaCookies = function(){ SetCookieUtil('cCommunityAccess', 'true', oneYear); SetCookieUtil('cCommunityComments', 'true', oneYear); SetCookieUtil('cCommunityRating', 'true', oneYear); SetCookieUtil('cCommunityUsage', 'true', oneYear); } this.clearAuthCookie = function(){ if (GetCookieUtil(fluxAuthTokenCookieName)!=null){ var hostname = document.location.hostname; hostname = hostname.substring(hostname.indexOf('www.')+4, hostname.length); SetCookieUtil(fluxAuthTokenCookieName, '', '', '/', hostname); } } this.toggleFormFields = function(inputId, action){ var input = document.getElementById(inputId); var open = document.getElementById(inputId + "Open"); var closed = document.getElementById(inputId + "Closed"); var parentForm = input.form; if (action == 'show'){ /* toggle */ show(open); hide(closed); /* show related fields */ var x = parentForm.getElementsByTagName('tr'); for (var i=0;i= 0){ element.className = element.className.substring(0, element.className.indexOf('hide')); } } function hide(element){ if (element!=null){ element.className = element.className + " hide"; } } function loadingOn(){ var element = document.getElementById('communityLoading'); if (element!=null && element.className.indexOf('hide') >= 0){ element.className = element.className.substring(0, element.className.indexOf('hide')); } } function loadingOff(){ var element = document.getElementById('communityLoading'); if (element!=null){ element.className = element.className + " hide"; } } function submit(url, formElements, async){ var ar = new AjaxRequest(url); if (formElements != undefined){ for (var i=0; i < formElements.length; i++){ ar.addNamedFormElements(formElements[i]); } } if (async!=null){ ar.setAsync(async); } ar.setPreRequest(loadingOn); ar.sendRequest(); ar.setPostRequest(loadingOff); } function overlayOpen(){ if (document.getElementById("embeddedPlayer")) document.getElementById("embeddedPlayer").pausePlayer(); if (document.getElementById("game")) hide(document.getElementById("game")); if (document.getElementById("overlay") && document.getElementById("dialogue")){ document.getElementById("overlay").className = "open"; document.getElementById("overlay").style.height = document.body.offsetHeight + "px"; document.getElementById("dialogue").className= "open"; } } function overlayClose(){ if (document.getElementById("overlay")){ document.getElementById("overlay").className = ""; document.getElementById("overlay").style.height = "0px"; } document.getElementById("dialogue").className= "hide"; if (document.getElementById("game")) show(document.getElementById("game")); } this.setReportingVars = function(){ var vars = ""; var numkeys = 1; var keyvals = new Array(2); var keynames = new Array(2); /* PHASE 1 keynames[0] = "siteFormat"; //prop31 - logged in keynames[1] = "betaUsage"; // prop34 - beta user keyvals[0] = (GetCookieUtil(fluxAuthTokenCookieName) != null) ? 'community' : 'non-community'; keyvals[1] = (GetCookieUtil('cCommunityAccess')=='true') ? 'community' : ''; */ /* PHASE 2 */ keynames[0] = "siteFormat"; //prop31 - logged in keyvals[0] = "not-logged-in"; if (typeof Flux!='undefined' ) keyvals[0] = (Flux.Context.isUserAuthenticated()==true) ? 'logged-in' : 'not-logged-in'; for (var i=0; i