if(typeof KIDS=="undefined"||!KIDS){var KIDS={}
}KIDS.IS_DEV=(window.location.hostname.indexOf("localhost")>=0||window.location.hostname.indexOf("d.mtvi.com")>0||window.location.port==9090);
KIDS.IS_QA=window.location.hostname.indexOf("q.mtvi.com")>0;
KIDS.IS_DEV_ENV=KIDS.IS_DEV||KIDS.IS_QA;
KIDS.IS_LIVE=!KIDS.IS_DEV_ENV;
KIDS.IS_DEBUG=KIDS.IS_DEV_ENV&&window&&typeof window.console!=="undefined";
KIDS.namespace=function(e,c){c=c==null?KIDS:c;
var b=e,k=null,g,f,h;
h=e.split(".");
k=c;
for(f=(h[0]==c)?1:0;
f<h.length;
f++){k[h[f]]=k[h[f]]||{};
k=k[h[f]]
}return k
};
KIDS.namespace("utils",KIDS);
KIDS.utils.URL_DEV_NICK="www.nick-d.mtvi.com";
KIDS.utils.URL_QA_NICK="www.nick-q.mtvi.com";
KIDS.utils.URL_LIVE_NICK="www.nick.com";
KIDS.utils.URL_DEV_NICK_GAMES="games.nick-d.mtvi.com";
KIDS.utils.URL_QA_NICK_GAMES="games.nick-q.mtvi.com";
KIDS.utils.URL_LIVE_NICK_GAMES="games.nick.com";
KIDS.utils.isEmptyString=function(a){return a==null||a==undefined||a==""||a==="undefined"
};
KIDS.utils.trim=function(a){return a==null?"":a.replace(/^\s+|\s+$/g,"")
};
KIDS.utils.isValidEmail=function(b){if(KIDS.utils.isEmptyString(b)){return false
}var a=/^([a-z0-9_\-\.%])+\@([A-Za-z0-9_\-\.])+\.([a-z]{2,4})$/i;
return a.test(b)
};
KIDS.utils.getCookie=function(c){if(KIDS.utils.isEmptyString(c)){return null
}var a=document.cookie.toString();
if(a.length>0){var d=a.indexOf(c+"=");
if(d!=-1){d+=c.length+1;
var b=a.indexOf(";",d);
if(b==-1){b=a.length
}return unescape(a.substring(d,b))
}}return null
};
KIDS.utils.getDomain=function(){return window.location.hostname
};
KIDS.utils.getNickDomain=function(){if(KIDS.IS_LIVE){return KIDS.utils.URL_LIVE_NICK
}else{if(KIDS.IS_QA){return KIDS.utils.URL_QA_NICK
}else{return KIDS.utils.URL_DEV_NICK
}}};
KIDS.utils.getNickGamesDomain=function(){if(KIDS.IS_LIVE){return KIDS.utils.URL_LIVE_NICK_GAMES
}else{if(KIDS.IS_QA){return KIDS.utils.URL_QA_NICK_GAMES
}else{return KIDS.utils.URL_DEV_NICK_GAMES
}}};
KIDS.utils.getQueryString=function(c){if(c==null){return""
}var a="";
for(var b in c){if(!b||!c[b]){continue
}if(a!=""){a+="&"
}a+=b+"="+escape(c[b])
}return a
};
KIDS.utils.getGdcXml=function(d,c){var b='<answers collectionID="'+d+'">';
for(var a in c){b+='<answer tag="'+a+'"><![CDATA['+c[a]+"]]></answer>"
}b+="</answers>";
return b
};
KIDS.utils.getSwf=function(a){if(navigator.appName.indexOf("Microsoft")!=-1){return window[a]
}else{if(document[a].length!=undefined){return document[a][1]
}return document[a]
}};
KIDS.utils.trimArray=function(a,c){if(a==null){return null
}for(var b=0;
b<a.length;
b++){a[b]=c?a[b].toLowerCase():a[b];
a[b]=KIDS.utils.trim(a[b])
}return a
};
KIDS.utils.getUrlParts=function(b){var a=b.replace("//","/").split("/");
return a
};
KIDS.utils.getUrlPath=function(c){var b=KIDS.utils.getUrlParts(c);
var d;
if(c.indexOf("http://")>-1){d=b.splice(0,2).join("/")
}var a=b.join("/");
return a
};
KIDS.utils.getContextPath=function(a,b,e,f){var d=getUrlPath(a);
if(e&&d.lastIndexOf(".")>=0){d=d.substring(0,d.lastIndexOf("."))
}b=b==null||b==""?"":b;
var c=new RegExp("^"+b+"/","i");
d=d.replace(c,"");
if(f){d=d.replace(/\/index$/i,"")
}d=d.replace(/\/$/,"");
if(d.indexOf("/")>=0){d=d.replace(/\/$/,"")
}if(d==""){d="hub"
}d=b+"_"+d;
return d
};
KIDS.properties=null;
KIDS.add=function(a,b){if(a==null||a==""){return
}if(KIDS.properties==null){KIDS.properties={}
}KIDS.properties[a]=b
};
KIDS.get=function(a){if(a==null||a==""){return null
}if(KIDS.properties==null){return null
}return KIDS.properties[a]
};
KIDS.utils.printObj=function(b){if(!b){KIDS.utils.doLog(">>PrintObj: invalid: "+typeof(b))
}KIDS.utils.doLog(">>PrintObj: type: "+typeof(b));
if(typeof(b)!="object"){return
}for(var a in b){KIDS.utils.doLog(">>PrintObj: key: "+a+" | "+b[a])
}};
KIDS.utils.doLog=function(){if(!KIDS.IS_DEBUG){return
}if(window.console&&typeof window.console.debug!="undefined"){window.console.debug.apply(window.console,arguments)
}else{if(window.console&&typeof window.console.log!="undefined"){if(window.console.log.apply==="function"){window.console.log.apply(window.console,arguments)
}else{window.console.log(arguments[0])
}}}};
KIDS.utils.isNumeric=function(c){var b=true;
try{b=!isNaN(parseFloat(c))&&isFinite(c)
}catch(a){b=false
}return b
};
KIDS.utils.parseInt=function(c){var a=-1;
try{a=!isNaN(parseInt(c))&&isFinite(c)?parseFloat(c):-1
}catch(b){a=-1
}return a
};
KIDS.utils.parseFloat=function(c){var a=-1;
try{a=!isNaN(parseFloat(c))&&isFinite(c)?parseFloat(c):-1
}catch(b){a=-1
}return a
};
KIDS.utils.openBumper=function(a,e,h,b,g,f,d,c){KIDS.utils.doLog("openBumper: site specific override missing!");
window.open(e)
};
if(typeof NICK=="undefined"||!NICK){var NICK={}
}NICK.namespace=function(a){KIDS.namespace(a,NICK)
};
NICK.namespace("utils",NICK);
NICK.utils.isEmptyString=KIDS.utils.isEmptyString;
NICK.utils.trim=KIDS.utils.trim;
NICK.utils.getCookie=KIDS.utils.getCookie;
NICK.utils.getDomain=KIDS.utils.getDomain;
NICK.utils.printObj=KIDS.utils.printObj;
NICK.utils.getQueryString=KIDS.utils.getQueryString;
NICK.utils.getGdcXml=KIDS.utils.getGdcXml;
NICK.utils.getSwf=KIDS.utils.getSwf;
NICK.utils.trimArray=KIDS.utils.trimArray;
NICK.utils.getUrlParts=KIDS.utils.getUrlParts;
NICK.utils.getUrlPath=KIDS.utils.getUrlPath;
NICK.utils.getContextPath=KIDS.utils.getContextPath;
NICK.add=KIDS.add;
NICK.get=KIDS.get;
NICK.utils.getNickDomain=KIDS.utils.getNickDomain;
NICK.IS_DEV=KIDS.IS_DEV;
NICK.IS_QA=KIDS.IS_QA;
NICK.IS_DEV_ENV=KIDS.IS_DEV_ENV;
NICK.IS_LIVE=KIDS.IS_LIVE;
NICK.IS_DEBUG=NICK.IS_DEV_ENV&&window&&typeof window.console!="undefined";
NICK.utils.URL_DEV_NICK=KIDS.utils.URL_DEV_NICK;
NICK.utils.URL_QA_NICK=KIDS.utils.URL_QA_NICK;
NICK.utils.URL_LIVE_NICK=KIDS.utils.URL_LIVE_NICK;
NICK.utils.URL_SPRING_NICK="spring.nick.com";
NICK.utils.URL_MTVN_D="nick.mtvnimages-d.mtvi.com";
NICK.utils.URL_MTVN_Q="nick.mtvnimages-q.mtvi.com";
NICK.utils.URL_MTVN_L="nick.mtvnimages.com";
NICK.utils.URL_MTVN=null;
NICK.utils.initMtvnImageUrl=function(){var a=document.location.href;
var b=NICK.utils.getUrlParts(a);
if(b[1]=="localhost:9090"){b[1]=NICK.utils.URL_DEV_NICK
}switch(b[1]){case NICK.utils.URL_DEV_NICK:NICK.utils.URL_MTVN=NICK.utils.URL_MTVN_D;
break;
case NICK.utils.URL_QA_NICK:NICK.utils.URL_MTVN=NICK.utils.URL_MTVN_Q;
break;
default:NICK.utils.URL_MTVN=NICK.utils.URL_MTVN_L
}};
NICK.utils.getImage=function(b,c,a){c=c||null;
a=a||null;
return NICK.utils.getMtvnImageUrl(b,c,a)
};
NICK.utils.getMtvnImageUrl=function(d,b,a){if(NICK.utils.isEmptyString(NICK.utils.URL_MTVN)){NICK.utils.initMtvnImageUrl()
}var c=NICK.utils.getUrlPath(d);
c=c!=null&&c.indexOf("/")==0?c:"/"+c;
if(b){c+="?height="+b
}if(a&&!b){c+="?"
}else{if(a){c+="&"
}}if(a){c+="width="+a
}return"http://"+NICK.utils.URL_MTVN+c
};
NICK.utils.doLog=function(a){KIDS.utils.doLog(a)
};
NICK.utils.getUsername=function(){return NICK.utils.getCookie("loggedInScreenName")
};
getUsername=NICK.utils.getUsername;
NICK.utils.getSessionId=function(){return NICK.utils.getCookie("JSESSIONID")
};
getSessionId=NICK.utils.getSessionId;
NICK.utils.hideElement=function(a){if(!a||!$(a)){return
}$(a).setStyle("visibility","hidden")
};
NICK.utils.showElement=function(a){if(!a||!$(a)){return
}$(a).setStyle("visibility","visible");
if($(a).getStyle("display")=="none"){$(a).setStyle("display","block")
}};
NICK.utils.toggleButton=function(b,a){if(!$(b)){return
}$(b).set("disabled",!a)
};
NICK.utils.validateDivIds=function(){if(!NICK.IS_DEBUG){return
}var d=new Object();
var b=document.getElementsByTagName("div");
for(var a=0;
a<b.length;
a++){if(b[a].id==null||b[a].id==""||b[a].id=="FLASH_AD"){continue
}if(d[b[a].id]!=null){alert("Warning: Duplicate element ID found: ["+b[a].id+"]")
}d[b[a].id]=b[a].id
}var c=document.getElementsByTagName("object");
for(var a=0;
a<c.length;
a++){if(c[a].id==null||c[a].id==""||c[a].id=="FLASH_AD"){continue
}if(d[c[a].id]!=null){alert("Warning: Duplicate element ID found: ["+c[a].id+"]")
}d[c[a].id]=c[a].id
}NICK.utils.doLog("validateDivIds: valid")
};
NICK.utils.doBookmark=function(){var b="Nick.com";
var a="http://www.nick.com";
if(document.all){window.external.AddFavorite(a,b)
}else{if(window.sidebar){window.sidebar.addPanel(b,a,"")
}else{if(window.sidebar&&window.sidebar.addPanel){window.sidebar.addPanel(b,a,"")
}}}};
NICK.utils.initTooltip=function(){$(".with-nick-tooltip").unbind("mouseenter").unbind("mouseleave");
$(".with-nick-tooltip").tooltip({contentSelector:".tooltip-content",id:"nick-tooltip",allowAccess:false,followMouse:true,lockTo:"side",lockToElement:"img:first",offsetX:-13})
};
NICK.utils.addTooltip=function(){};
NICK.utils.openNewBumper=function(a,b){NICK.utils.openBumper(a,b,null,null,null,true)
};
NICK.utils.openBumper=function(h,d,c,f,l,j,m,k){var i="http://www.nick.com/common/bumpers/bumperFrameset.jhtml?";
if(NICK.config.SITE_NAME=="nicktoons"){var e="http://www.nick.com/common/bumpers/fullpage/nicktoons.jhtml?"
}else{var e="http://www.nick.com/common/bumpers/fullpage/index.jhtml?"
}var b="wBumper";
var a="advertiser";
c=c!=null&&c;
m=m==undefined?true:m;
switch(h){case"external":i="http://www.nick.com/common/bumpers/go.jhtml?";
i+=f==null?"":("bumper="+escape(f)+"&");
i+=l==null?"":("bumperHeight="+l+"&");
i+=m==undefined?"":("isInHouse="+m+"&");
a="destination";
break;
case"fullPage":i=e;
a="destination";
break;
case"paysite":break;
case"grown-ups":break;
case"launchpad":break;
case"ag":break;
case"sponsor":break;
case"full-redirect":i="/utils/bumper/half-page.html?";
break;
default:h="sponsor";
break
}var g=i+b+"="+h+"&"+a+"="+escape(d);
if(c){g+="&onair_landing=true"
}if(c&&h=="external"){g=e+a+"="+escape(g)
}if(j){window.open(g,"bumper","status=1,scrollbars=1,location=1,resizable=1,toolbar=1,menubar=1")
}else{window.location.href=g
}};
NICK.utils.wrapOPABanner=function(){};
$(document).ready(function(){NICK.utils.initTooltip();
NICK.utils.validateDivIds();
NICK.utils.initComcast();
$(document).bind("tooltip.OPEN",function(b,a){NICK.utils.displayScreenShot(a)
});
$(document).bind("tooltip.CLOSE",function(){$(".tooltip-screenshot").attr("src","")
})
});
NICK.utils.displayScreenShot=function(a){if(a.screenShot!=""){if($(".tooltip-screenshot-"+a.cmsid)){$(".tooltip-screenshot-"+a.cmsid).attr("src",a.screenShot)
}}};
KIDS.utils.openBumper=NICK.utils.openBumper;
NICK.utils.hideSwfs=function(a){if(a){a=a+" "
}else{a=""
}$(a+".swf").not(".swfnohide").find("> *").each(function(){obj=$(this);
obj.css("visibility","hidden")
})
};
NICK.utils.showSwfs=function(a){if(a){a=a+" "
}else{a=""
}$(a+".swf > *").each(function(){obj=$(this);
obj.css("visibility","visible")
})
};
NICK.utils.initComcast=function(){if(typeof projX==="undefined"||!projX){NICK.utils.doLog("NICK.utils.initComcast: projX not found");
return
}NICK.utils.doLog("NICK.utils.initComcast:3: overriding functions");
projX.displayEventPre=function(){NICK.utils.doLog("NICK.utils.initComcast: hide swfs");
NICK.utils.hideSwfs();
return true
};
projX.closeEvent=function(){NICK.utils.doLog("NICK.utils.initComcast: close overlay");
NICK.utils.showSwfs()
}
};
doSwfEmbedCompleteNick=function(a){if(a==null||a.id=="GamePlayer"){return
}var b=document.getElementById("projxalert");
if(b==null||b.style.display=="none"){return
}KIDS.utils.doLog("doSwfObjectEmbed (nick override): alert found: hiding swfs");
NICK.utils.hideSwfs()
};
NICK.utils.openOverlay=function(){NICK.utils.doLog("NICK.utils.openOverlay(): Deprecated. Use: NICK.overlay.open().")
};
NICK.utils.closeOverlay=function(){NICK.utils.doLog("NICK.utils.closeOverlay(): Deprecated. Use: NICK.overlay.close().")
};
NICK.utils.initAdFreePage=function(){if(KIDS.get("adfree")!=="true"){return
}$("a").not(".nick-overlay").not(".no-adfree").not(".o_popup_close").not("[href^=javascript]").bind("click",NICK.utils.doBumperOverride);
$(".brand-mamabar-more-list .bumper").remove()
};
NICK.utils.initAdFreeLinks=function(){NICK.utils.initAdFreePage();
$("#top-menu a").bind("click",NICK.utils.doBumperOverride);
$("#page-menu a").bind("click",NICK.utils.doBumperOverride);
$("#submenu-wrapper a").bind("click",NICK.utils.doBumperOverride);
if($(".nick-footer-siteblock")){$(".nick-footer-siteblock a").bind("click",NICK.utils.doBumperOverrideNewWin);
$(".nick-footer-text a").bind("click",NICK.utils.doBumperOverride);
$(".nick-footer-menu a").bind("click",NICK.utils.doBumperOverride)
}};
NICK.utils.initExternalLinks=function(){$("a[href^='http']").attr("target","_top")
};
NICK.utils.initAGLinks=function(){$("a[href^='http://www.addictinggames.com']").bind("click",NICK.utils.doAGBumperOverride)
};
NICK.utils.doAGBumperOverride=function(a){NICK.utils.openBumper("ag",this.href,null,null,null,true);
return false
};
NICK.utils.doBumperOverride=function(a){NICK.utils.openBumper("fullPage",this.href,null,null,null,false);
return false
};
NICK.utils.doBumperOverrideNewWin=function(a){NICK.utils.openBumper("fullPage",this.href,null,null,null,true);
return false
};
NICK.utils.random=function(a){return Math.floor(a*(Math.random()%1))
};
NICK.utils.randomBetween=function(b,a){return b+NICK.utils.random(a-b+1)
};
NICK.utils.getNoRepeatRandoms=function(d,c){var b=new Array();
var d=Math.min(d,c);
while(b.length<d){var f=NICK.utils.randomBetween(0,c);
var e=false;
for(var a=0;
a<b.length;
a++){if(b[a]==f){e=true
}}if(e==false){b.push(f)
}}return b
};
NICK.utils.timezone=function(){var i=new Date();
var b=new Date(i.getFullYear(),0,1,0,0,0,0);
var g=new Date(i.getFullYear(),6,1,0,0,0,0);
var h=b.toGMTString();
var j=new Date(h.substring(0,h.lastIndexOf(" ")-1));
h=g.toGMTString();
var f=new Date(h.substring(0,h.lastIndexOf(" ")-1));
var e=(b-j)/(1000*60*60);
var d=(g-f)/(1000*60*60);
var c;
if(e==d){c="0"
}else{var a=e-d;
if(a>=0){e=d
}c="1"
}return e
};
NICK.utils.getTimezone=function(){if(NICK.utils.timezone()==-5){return"east"
}else{return"west"
}};
NICK.utils.goMyNick=function(a){if(KIDS.get("adfree")==="true"){NICK.utils.openBumper("fullPage",a,null,null,null,false)
}else{document.location.href=a
}};
NICK.utils.thisMovie=function(a){if(navigator.appName.indexOf("Microsoft")!=-1){return window[a]
}else{if(document[a].length!=undefined){return document[a][1]
}return document[a]
}};
NICK.utils.setCookie=function(a,b){this.setCookie2(a,b,"","","","")
};
NICK.utils.setCookie2=function(c,e,a,g,d,f){var b=c+"="+escape(e)+((a)?"; expires="+a.toGMTString():"")+((g)?"; path="+g:"")+((d)?"; domain="+d:"")+((f)?"; secure":"");
document.cookie=b
};
if(typeof NICK=="undefined"||!NICK){var NICK={}
}NICK.namespace("config");
NICK.config.URL_COMMENT_POST="http://"+NICK.utils.getNickDomain()+"/xml/gdc_json.jhtml?jsonCallback=?";
NICK.config.IMX_RATE="/api/ratings/1.0/rate";
NICK.config.IMX_PUT="/api/imx/1.0/put";
NICK.config.IMX_VIEW_COUNT="/api/imx/1.0/report";
NICK.config.SITE_NAME="nick";
NICK.config.CHANNEL_ID="11";
if(typeof NICK=="undefined"||!NICK){var NICK={}
}(function(){KIDS.namespace("utils",NICK);
KIDS.namespace("request.messages",NICK);
KIDS.namespace("request.errors",NICK);
KIDS.namespace("response.codes",NICK);
NICK.request.errors.SERVER="_ERROR_SERVER";
NICK.request.errors.REQUEST="_ERROR_REQUEST";
NICK.request.errors.RESPONSE="_ERROR_RESPONSE";
NICK.request.errors.URL="_ERROR_URL";
NICK.request.messages.INVALID_RESPONSE="Invalid reponse";
NICK.request.messages.INVALID_URL="Invalid url requested";
NICK.response.codes.OK="ok";
NICK.response.codes.ERROR="error";
NICK.request.doRequest=function(l){var g={type:"GET",url:null,data:null,dataType:"jsonp",async:true,onSuccess:null,onFail:null};
var e=$.extend({},g,l);
var f=function(m){if("jsonp"==e.dataType){k(m)
}else{if("json"==e.dataType){k(m)
}else{if("xml"==e.dataType){d(m)
}else{if("html"==e.dataType){c(m)
}else{KIDS.utils.doLog(">>NICK.request: No response handler for type: "+e.dataType)
}}}}};
var k=function(m){if(m==null){a(b(NICK.request.errors.RESPONSE,NICK.request.messages.INVALID_RESPONSE))
}else{if(m.code==NICK.response.codes.OK){i(m)
}else{if(m.code==NICK.response.codes.ERROR){a(m.errors)
}else{i(m)
}}}};
var d=function(m){if(m==null){a(b(NICK.request.errors.RESPONSE,NICK.request.messages.INVALID_RESPONSE));
return
}else{if($(m).find("response").attr("status")==NICK.response.codes.OK){i(m)
}else{if($(m).find("response").attr("status")==NICK.response.codes.ERROR){var n={};
$(m).find("error").each(function(){n[$(this).attr("name")]=$(this).text()
});
a(n)
}}}};
var c=function(m){if(m==null){a(b(NICK.request.errors.RESPONSE,NICK.request.messages.INVALID_RESPONSE));
return
}else{i(m)
}};
var a=function(m){var n=typeof m=="string"?{request:m}:m;
if(e.onFail){e.onFail(n)
}else{KIDS.utils.doLog("doRequest: Failed: "+m)
}};
var i=function(m){if(e.onSuccess){e.onSuccess(m)
}else{KIDS.utils.doLog("doRequest: OK")
}};
var h=function(o,m,n){a(b(NICK.request.errors.REQUEST,m))
};
var b=function(n,o){var m=new Object();
m[n]=o;
return m
};
if(e.url==null){a(b(NICK.request.errors.URL,NICK.request.messages.INVALID_URL));
return
}try{$.ajax({type:e.type,url:e.url,data:e.data==null?{}:e.data,dataType:e.dataType,async:e.async,success:f,error:h})
}catch(j){KIDS.utils.doLog("NickRequest: error: "+j);
a({_ERROR_SERVER:j})
}}
})();
$(document).ready(function(){$(document).bind("authStatus",function(a){NICK.utils.doLog("authStatus: loggedIn: "+NICK.userData.loggedIn)
});
NICK.login.doNickCheck()
});
NICK.namespace("login.forgot");
var nickLoginUrl="http://"+NICK.utils.getNickDomain()+"/common/login/check.jhtml";
var nickRegUrl="http://"+NICK.utils.getNickDomain()+"/common/registration/register.jhtml";
var nickAuthQuestionUrl="http://"+NICK.utils.getNickDomain()+"/registration/data_files/getUserQuestion.jhtml";
var nickAuthAnswerUrl="http://"+NICK.utils.getNickDomain()+"/registration/data_files/verify_answer.jhtml";
var nickPrepGamesUrl="http://"+NICK.utils.getNickDomain()+"/nicktropolis/game/data/prep_games_js.jhtml";
NICK.login.doNickCheck=function(){if(NICK.userData==undefined){var a={res:"js",login_type:"LOGIN_CHECK"};
NICK.request.doRequest({dataType:"jsonp",url:nickLoginUrl,data:a,onSuccess:function(b){if(b.loggedIn=="true"){NICK.login.prepGamesServer()
}NICK.utils.doLog("doNickCheck: onSuccess : "+b.nickName);
NICK.userData=null;
NICK.userData=b;
$(document).trigger("authStatus",b)
},onFail:function(c){for(var b in c){NICK.utils.doLog("doNickCheck: error: "+b+" - "+c[b])
}}})
}else{$(document).trigger("authStatus")
}};
NICK.login.doLogIn=function(a){NICK.utils.doLog("doLogIn!");
var b={res:"js",screenName:a.username,password:a.password};
NICK.request.doRequest({dataType:"jsonp",url:nickLoginUrl,data:b,onSuccess:function(c){NICK.utils.doLog("doLogIn: onSuccess : "+c.loggedIn);
NICK.userData.nickName=null;
NICK.userData.screenName=null;
NICK.userData=c;
NICK.userData.nickName=(NICK.userData.nickName=="")?NICK.userData.screenName:NICK.userData.nickName;
NICK.utils.doLog("username: "+NICK.userData.nickName);
NICK.utils.doLog("avatar: "+NICK.userData.avatar);
NICK.login.setLoginCookies();
for(var d in c){NICK.utils.doLog("doLogIn: userData: "+d)
}if(c.loggedIn=="true"){$(document).trigger("loggedIn",c);
NICK.login.prepGamesServer();
NICK.club.messages.loginWelcome()
}else{$(document).trigger("logInFail")
}},onFail:function(d){NICK.utils.doLog("doLogIn: onFail");
for(var c in d){NICK.utils.doLog("doLogIn: error: "+c+" - "+d[c])
}}})
};
NICK.login.doLogOut=function(){this.clearLoginCookies();
var a={res:"js",forceLogout:"true"};
NICK.request.doRequest({dataType:"jsonp",url:nickLoginUrl,data:a,onSuccess:function(b){NICK.utils.doLog("doLogOut: onSuccess : "+b.loggedIn);
NICK.userData=b;
$(document).trigger("loggedOut",b)
},onFail:function(c){for(var b in c){NICK.utils.doLog("doLogOut: error: "+b+" - "+c[b])
}}})
};
NICK.login.clearLoginCookies=function(){var a="";
if(KIDS.IS_DEV){a=".nick-d.mtvi.com";
nickserver=KIDS.utils.URL_DEV_NICK
}if(KIDS.IS_QA){a=".nick-q.mtvi.com";
nickserver=KIDS.utils.URL_QA_NICK
}if(KIDS.IS_LIVE){a=".nick.com";
nickserver=KIDS.utils.URL_LIVE_NICK
}NICK.utils.setCookie2("JSESSIONIDGAMES","","","/",a,"");
NICK.utils.setCookie2("mtvnauthcookie","","","/",a,"");
NICK.utils.setCookie2("loggedInScreenName","","","/",a,"");
NICK.utils.setCookie2("avatar","","","/","","")
};
NICK.login.setLoginCookies=function(){NICK.utils.setCookie2("avatar",NICK.userData.avatar,"","/","","")
};
NICK.login.doRegister=function(a){var b=a;
b.res="js";
b.trylogin="true";
NICK.request.doRequest({dataType:"jsonp",url:nickRegUrl,data:b,onSuccess:function(c){NICK.utils.doLog("doRegister: onSuccess : ");
if(c.success=="true"){doRegSuccess(c,a)
}else{doRegFail(c,a)
}},onFail:function(d){for(var c in d){NICK.utils.doLog("doRegister: error: "+c+" - "+d[c])
}}})
};
NICK.login.loginName=function(){var a=NICK.userData.screenName||NICK.userData.nickName;
return a.toLowerCase()
};
NICK.login.forgot.questionData="";
NICK.login.forgot.submitAuthQuestion=function(){NICK.utils.doLog("submitAuthQuestion");
if($("#getQuestionDiv").css("display")!="none"){NICK.login.forgot.submitNickname()
}else{NICK.login.forgot.submitAnswer()
}};
NICK.login.forgot.submitNickname=function(){NICK.overlay.loadingToggle();
var b=$("#usernameField").val();
NICK.utils.doLog("submitNickName: ["+b+"]");
if(NICK.utils.isEmptyString(b)){NICK.overlay.loadingToggle();
$("#failMsg").show().html("Incorrect NickName");
return
}var a={username:$("#usernameField").val(),showComments:"false",responseType:"json"};
NICK.request.doRequest({dataType:"jsonp",url:nickAuthQuestionUrl,data:a,onSuccess:function(c){NICK.overlay.loadingToggle();
NICK.utils.doLog("response question:"+c.question);
if(c.questionid!="null"){NICK.login.forgot.questionData=c;
$("#secretQuestion").html(c.question);
$("#getQuestionDiv").hide();
$("#getAnswerDiv").show();
$("#failMsg").hide()
}else{$("#failMsg").show().html("Incorrect NickName")
}},onFail:function(d){NICK.overlay.loadingToggle();
for(var c in d){NICK.utils.doLog("submitNickname: error: "+c+" - "+d[c])
}}})
};
NICK.login.forgot.submitAnswer=function(){NICK.overlay.loadingToggle();
NICK.utils.doLog("submitAnswer");
var a=$("#answerField").val();
if(NICK.utils.isEmptyString(a)){NICK.overlay.loadingToggle();
$("#failMsg").show().html("Incorrect Answer");
return
}var b={username:NICK.login.forgot.questionData.username,questionid:NICK.login.forgot.questionData.questionid,answer:a,responseType:"json"};
NICK.request.doRequest({dataType:"jsonp",url:nickAuthAnswerUrl,data:b,onSuccess:function(c){NICK.overlay.loadingToggle();
NICK.utils.doLog("response valid:"+c.valid);
if(c.valid=="true"){$("#failMsg").hide();
$("#getAnswerDiv").hide();
$(".o_popup_forgot .actions").hide();
$("#yourPassword").show().html("Your password is: "+c.password)
}else{$("#failMsg").show().html("Incorrect Answer")
}},onFail:function(d){NICK.overlay.loadingToggle();
for(var c in d){NICK.utils.doLog("submitAnswer: error: "+c+" - "+d[c])
}}})
};
NICK.login.prepGamesServer=function(){NICK.request.doRequest({dataType:"jsonp",url:nickPrepGamesUrl,onSuccess:function(a){NICK.utils.doLog("Prep game server completed.");
$(document).trigger("loggedInGames")
},onFail:function(b){for(var a in b){NICK.utils.doLog("Prep Game: error: "+a+" - "+b[a])
}}})
};
if(typeof NICK=="undefined"||!NICK){var NICK={}
}NICK.namespace("sendToFriend");
NICK.utils.validateEmail=function(a){return KIDS.utils.isValidEmail(a)
};
NICK.sendToFriend.URL_WORD_FILTER="http://www.nick.com/dynamo/wordfilter/index.jhtml?name=";
NICK.sendToFriend.goodWordsCounter=0;
NICK.sendToFriend.formSubmitting=false;
NICK.sendToFriend.formLoaded=function(){$("#failMsg").hide();
$("#badwordMsg").hide();
$("#bademailMsg").hide();
$("#emailSentMsg").hide();
$("#badnameMsg").hide();
$("#sendToFriendForm").show();
$("#send-to-a-friend div.loadingAnimation").hide()
};
NICK.sendToFriend.validate=function(){$("#failMsg").hide();
$("#badwordMsg").hide();
$("#bademailMsg").hide();
$("#emailSentMsg").hide();
$("#badnameMsg").hide();
$("#send-to-a-friend div.loadingAnimation").show();
$("#send-to-a-friend div.loadingAnimation h4").html("Validating...");
if($("#yourName").attr("value")==""){$("#failMsg").show();
$("#badnameMsg").show();
$("#yourName").removeClass("textboxerror");
$("#yourName").addClass("textboxerror")
}else{$("#yourName").removeClass("textboxwrapper");
$("#yourName").addClass("textboxwrapper")
}if($("#friendsName").attr("value")==""){$("#failMsg").show();
$("#badnameMsg").show();
$("#friendsName").removeClass("textboxerror");
$("#friendsName").addClass("textboxerror")
}else{$("#friendsName").removeClass("textboxerror");
$("#friendsName").addClass("textboxerror")
}if((!NICK.utils.validateEmail($("#friendsEmail").attr("value")))){$("#failMsg").show();
$("#bademailMsg").show();
$("#friendsEmail").removeClass("textboxerror");
$("#friendsEmail").addClass("textboxerror")
}else{$("#friendsEmail").removeClass("textboxerror");
$("#friendsEmail").addClass("textboxerror")
}NICK.sendToFriend.goodWordsCounter=0;
NICK.sendToFriend.checkBadWord($("#yourName"));
NICK.sendToFriend.checkBadWord($("#friendsName"))
};
NICK.sendToFriend.checkBadWord=function(d){var c=d.attr("value");
var a=NICK.utils.getNickDomain();
var b="http://"+a+"/common/wordfilter/json.jhtml";
NICK.request.doRequest({dataType:"jsonp",url:b,data:{v:"1",word:c},onSuccess:function(f){NICK.utils.doLog("Dirty Word Response:"+f.data[0].code);
if(f.data[0].code=="bad"){d.attr("value","");
NICK.sendToFriend.goodWordsCounter=0;
$("#failMsg").css("display","block");
$("#badwordMsg").css("display","block");
$("#send-to-a-friend div.loadingAnimation").hide()
}else{NICK.sendToFriend.goodWordsCounter++;
$("#send-to-a-friend div.loadingAnimation").hide();
if(NICK.sendToFriend.goodWordsCounter==2&&$("#failMsg").css("display")=="none"){NICK.sendToFriend.goodWordsCounter=0;
NICK.sendToFriend.formSubmitting=true;
var i=$("#friendsEmail").val();
var e=$("#yourName").val();
var g=$("#friendsName").val();
var h=window.location;
NICK.sendToFriend.sendEmail(e,g,i,h)
}}},onFail:function(f){for(var e in f){NICK.utils.doLog("Dirty Word Response: Error: "+e+" - "+f[e])
}}})
};
NICK.sendToFriend.sendEmail=function(b,e,g,f){$("#failMsg").hide();
$("#badwordMsg").hide();
$("#bademailMsg").hide();
$("#emailSentMsg").hide();
$("#badnameMsg").hide();
$("#sendToFriendForm").hide();
$("#send-to-a-friend div.loadingAnimation").show();
var d=NICK.utils.getNickDomain();
if(NICK.config.SITE_NAME=="nicktoons"){var a="http://"+d+"/sbcom/data/sendToFriend/send_nicktoons.jhtml"
}else{var a="http://"+d+"/sbcom/data/sendToFriend/send_nick.jhtml"
}var c=$("<div/>").text(f.toString()).html();
if(NICK.sendToFriend.overrideTemplate==undefined){template=NICK.get("type")
}NICK.request.doRequest({dataType:"jsonp",url:a,data:{email:g,senderName:b,friendsName:e,URLpath:c,etype:template,id:NICK.get("cmsId"),domain:window.location.hostname,section:NICK.get("type")},onSuccess:function(h){NICK.utils.doLog("Email Send Success!");
$("#send-to-a-friend div.loadingAnimation").hide();
$("#sentMessage").show().html("Congrats! This has been sent to your friend.")
},onFail:function(i){$("#sentMessage").show().html("There was an error sending your message. Please try again.");
$("#sendToFriendForm").show();
for(var h in i){NICK.utils.doLog("Bad load: Error: "+h+" - "+i[h]);
alert(i[h])
}}})
};
NICK.namespace("search");
NICK.search.validate=function(){var a=document.getElementById("search-term").value;
if(a.length<=0){return false
}var b="/search/?term="+escape(a);
if(KIDS.get("adfree")==="true"){NICK.utils.openBumper("fullPage",b,null,null,null,false)
}else{document.location.href=b
}return false
};
$(function(){$("a.bumper, #nick-arcade-bumper a").each(function(){$(this).click(function(b){b.preventDefault();
NICK.utils.openBumper("paysite",$(this).attr("href"));
return false
})
});
$("#global-bar .down-arrow-extra").click(function(){var c=0,b=$(this).parent().parent().next();
if(b.size()>0){var c=b.siblings().andSelf().index(b)
}$(this).parent().parent().parent().animate({top:c*-b.height()},"fast")
});
$("#top-menu-more,#global-sites-more").hover(function(){$(this).addClass("hover")
},function(){$(this).removeClass("hover")
});
if($("#submenu-more").size()>0){$("#submenu-more").click(openMoreSubMenu).children("a").removeClass("active")
}$(".png,h1.icon").supersleight({shim:"/assets/transparent.gif",apply_positioning:false});
$(document).bind("authStatus loggedIn loggedOut",function(){a()
});
var a=function(){NICK.utils.doLog("authStatus: setHeaderStatus:"+NICK.userData.loggedIn+NICK.userData.screenName);
if(NICK.userData.loggedIn=="true"){$(".mynick-noauth").hide();
$(".mynick-auth").show();
var c=NICK.userData.nickName;
var b=0;
var d='<div id="mynick-private">';
d+="<h5><a href='javascript:NICK.club.global.gotoProfile()' class=\"profile\">"+c+"</a></h5>";
d+='<a href="#" onclick="NICK.login.doLogOut();" class="logout">Log Out</a>';
d+="<a href='/club/buddies/buddies-request.html'><span id=\"buddyRequestCount\">"+b+"</span></a>";
d+="</div>";
$("#mynick-private").remove();
$("#mynick").append(d);
$("#UAPreview").html(NICK.avatar.image(NICK.utils.getCookie("avatar"),72,50,true))
}else{$(".mynick-auth").hide();
$(".mynick-noauth").show()
}}
});
function openMoreSubMenu(c){c.preventDefault();
var f=$("#submenu-wrapper");
var b=$("#submenu-content");
var d=$("#submenu-more").find("a span");
if(f.hasClass("expanded")){var a="More";
if(d.is(".more-shows")){a="Shows"
}b.slideUp("fast",function(){f.removeClass("expanded")
});
d.text(a);
d.attr("title",a)
}else{f.addClass("expanded");
b.slideDown("fast");
d.text("Close");
d.attr("title","Close")
}}$(document).ready(function(){NICK.utils.doLog("header.js: initLogin!");
$(document).bind("loggedIn",function(){NICK.utils.doLog("header.js: loggedIn")
});
$(document).bind("logInFail",function(){NICK.utils.doLog("header.js: logInFail");
a()
});
var a=function(){$("#loginError").show();
$("#nickLogin").show();
$("#loginLoader").hide()
}
});
function sendLogin(){var a={username:$(".o_popup_login input[name='nickUsername']").val(),password:$(".o_popup_login input[name='nickPassword']").val()};
NICK.login.doLogIn(a)
};
if(typeof NICK=="undefined"||!NICK){var NICK={}
}NICK.namespace("pagination");
NICK.pagination.itemOffset=-1;
NICK.pagination.setItemOffset=function(a){NICK.utils.doLog(">setItemOffSet: "+a);
NICK.pagination.itemOffset=a
};
NICK.pagination.getItemOffset=function(){return NICK.pagination.itemOffset
};
NICK.pagination.goToPage=function(c,a,d,b){NICK.utils.doLog("Pagination!: goToPage: "+d);
d=d==null?"":""+d;
$(document).trigger({type:"pagination_go."+d,page:c,max:a,id:d,sort:b})
};
NICK.pagination.goNext=function(c,a,d,b){NICK.pagination.goToPage(c,a,d,b)
};
NICK.pagination.goPrevious=function(c,a,d,b){NICK.pagination.goToPage(c,a,d,b)
};
$(document).bind("pagination_go.",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
NICK.listings.getDataPages(a.sort,a.page,a.max)
});
$(document).bind("pagination_go.game-browser-pagination",function(b){var c=NICK.pagination.getItemOffset();
if(c<=0){NICK.listings.getDataPages(b.sort,b.page,b.max);
return
}var a=0;
if(b.page==1){a=0
}else{if(b.page<=2){a=c
}else{a=((b.page*b.max-b.max)-c)
}}NICK.utils.doLog("Pagination: "+c+" | "+b.page+" | "+b.max+" | "+a);
NICK.listings.getData(NICK.listings.getUriOverride(),b.sort,a,b.page)
});
$(document).bind("pagination_go.collection-grid-pagination",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
NICK.listings.getDataPages(a.sort,a.page,a.max)
});
$(document).bind("pagination_go.collection-grid-paginationfullEpisodeItem",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
NICK.listings.getDataPages(a.sort,a.page,a.max,{type:"fullEpisodeItem"})
});
$(document).bind("pagination_go.collection-grid-paginationvideoItem",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
NICK.listings.getDataPages(a.sort,a.page,a.max,{type:"videoItem"})
});
$(document).bind("pagination_go.collection-grid-paginationvideoPlaylist",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
NICK.listings.getDataPages(a.sort,a.page,a.max,{type:"videoPlaylist"})
});
$(document).bind("pagination_go.collection-grid-all-paginationfullEpisodeItem",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
NICK.listings.getDataPages(a.sort,a.page,a.max,{type:"fullEpisodeItem",viewType:"collectionAll"})
});
$(document).bind("pagination_go.collection-grid-all-pagination",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
NICK.listings.getDataPages(a.sort,a.page,a.max,{viewType:"collectionAll"})
});
$(document).bind("pagination_go.collection-grid-all-paginationvideoItem",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
NICK.listings.getDataPages(a.sort,a.page,a.max,{type:"videoItem",viewType:"collectionAll"})
});
$(document).bind("pagination_go.collection-grid-all-paginationvideoPlaylist",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
NICK.listings.getDataPages(a.sort,a.page,a.max,{type:"videoPlaylist",viewType:"collectionAll"})
});
$(document).bind("pagination_go.tag-search-pagination",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
l=document.location.href.split("?");
l=l[0];
if(a.page>1){l+="?page="+a.page+"&start="+(a.page-1)*a.max
}document.location.href=l
});
$(document).bind("pagination_go.search-pagination",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id);
l=document.location.href.split("?");
t=l[1].split("&");
t=t[0].split("=");
t=t[1];
getfqterms=l[1].split("&");
fq=0;
for(i=0;
i<getfqterms.length;
i++){fqcheck=getfqterms[i].split("=");
if(fqcheck[0]=="fq"){fq=fqcheck[1]
}}l=l[0];
l+="?term="+t;
if(fq){l+="&fq="+fq
}if(a.page>1){l+="&page="+a.page+"&start="+(a.page-1)*a.max
}document.location.href=l
});
$(document).bind("pagination_go.games-by-show-all-pagination",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id+" | page: "+a.page+" | max: "+a.max);
var b={sort:"",start:(a.page*a.max-a.max),page:a.page};
NICK.request.doRequest({dataType:"html",url:"/ajax/listing-game/games-by-show-all.html",data:b,onSuccess:function(c){$("div.filter-target").html(c)
},onFail:function(d){for(var c in d){NICK.utils.doLog("Sort Response: Error: "+c+" - "+d[c])
}}})
});
$(document).bind("pagination_go.shows-list-pagination",function(a){NICK.utils.doLog("Pagination: event: "+a.type+" | "+a.id+" | page: "+a.page+" | max: "+a.max);
var b={sort:"",start:(a.page*a.max-a.max),page:a.page};
NICK.request.doRequest({dataType:"html",url:"/ajax/listing-video/shows-list.html",data:b,onSuccess:function(c){$("div.filter-target").html(c)
},onFail:function(d){for(var c in d){NICK.utils.doLog("Sort Response: Error: "+c+" - "+d[c])
}}})
});
$(document).bind("pagination_go.comments-pagination",function(a){NICK.utils.doLog("Pagination: Comments event: "+a.type+" | "+a.id+" | page: "+a.page+" | max: "+a.max);
NICK.comments.loadComments(a.type,null,NICK.comments.urlAlias,(a.page*a.max-a.max),20)
});
