
_g=new(function(){var eventList={};this.namespace=function(nspace){var parts=nspace.split('.');var ns=window;for(var i=0,len=parts.length;i<len;i++){ns=ns[parts[i]]=ns[parts[i]]||{};}
return ns;};this.isUrl=function(target){if(target==null||target.length==0)
return false;if(target.charAt(target.length-1)=='#')
return false;if(target.indexOf('javascript:')==0)
return false;return true;};this.getUrlParams=function(url,decode){var qs=(url.toString()||window.location.toString());qs=qs.slice(qs.indexOf('?')+1);var parts=qs.split('&');var params={};if(parts[0].indexOf('=')>-1){for(var i=0;i<parts.length;i++){var keyval=parts[i].split('=');var key=keyval[0];params[key]=params[key]||[];params[key].push(decode===false?keyval[1]:decodeURIComponent(unescape(keyval[1])));}}
return params;};this.getHostName=function(){var host="";var monIdx=window.location.host.lastIndexOf(".monster");if(monIdx>-1){return window.location.host.substr(monIdx);}else{monIdx=window.location.host.toLowerCase().lastIndexOf(".careerone");if(monIdx>-1){return window.location.host.substr(monIdx);};};var hostArray=window.location.host.split(".");while(hostArray.length>2){hostArray.shift();}
for(var i=0;i<hostArray.length;i++){host+="."+hostArray[i];}
return host;};this.handleError=function(error){if(error.description)
alert(error.description);window.location='/error.aspx?M='+error.module+'&G='+error.id+'&N='+error.name;};this.getEvent=function(name){eventList[name]=eventList[name]||new Event(name);return eventList[name];};function Event(name){this.name=name;};Event.prototype={eventElement:'body',bind:function(fn){$(this.eventElement).bind(this.name,fn);},unbind:function(fn){$(this.eventElement).unbind(this.name,fn);},trigger:function(){$(this.eventElement).triggerHandler(this.name,arguments);}};this.getAppliedClosure=function(ctx,fn){if(arguments.length>2){var args=Array.prototype.slice.call(arguments,2);return function(){return fn.apply(ctx,args.concat(Array.prototype.slice.call(arguments)));};}
else{return function(){return fn.apply(ctx,arguments||[]);};}};})();_g.security=new(function(){var calledFn;var loginFn;this.level={none:1,low:2,high:3};this.getUserLevel=function(){var userSecurityLevelControl=$("#UserSecurityLevelControl");var userSecurityLevel=this.level.none;if(userSecurityLevelControl){var userSecurityLevel=parseInt(userSecurityLevelControl.val());}
return userSecurityLevel;};this.getUrlLevel=function(url,secConfig){var uri=parseUri(url.toLowerCase());if(uri.host.length){for(var i=0;i<secConfig.length;i++){if(secConfig[i].domain==uri.host||(secConfig[i].domain.indexOf(uri.host)>=0&&secConfig[i].domain.indexOf('?ch')>0)){if(uri.path.length){if(secConfig[i].slhigh.indexOf(uri.path+" ")>=0)return this.level.high;if(secConfig[i].sllow.indexOf(uri.path+" ")>=0)return this.level.low;if(secConfig[i].slnone.indexOf(uri.path+" ")>=0)return this.level.none;}
var highLength=(secConfig[i].slhigh.indexOf('* ')>0)?this.getWCMatchLength(secConfig[i].slhigh,uri):0;var lowLength=(secConfig[i].sllow.indexOf('* ')>0)?this.getWCMatchLength(secConfig[i].sllow,uri):0;var noneLength=(secConfig[i].slnone.indexOf('* ')>0)?this.getWCMatchLength(secConfig[i].slnone,uri):0;if(highLength>0&&highLength>=lowLength&&highLength>=noneLength)
return this.level.high;if(lowLength>0&&lowLength>highLength&&lowLength>=noneLength)
return this.level.low;if(noneLength>0&&noneLength>highLength&&noneLength>lowLength)
return this.level.none;switch(secConfig[i].dsl){case'high':return this.level.high;case'low':return this.level.low;default:return this.level.none;}}}}
return this.level.none;};this.getWCMatchLength=function(secConfig,uri){var slevel=secConfig.split(" ");var result=0;for(var i=0;i<slevel.length;i++){if(slevel[i].charAt(slevel[i].length-1)=='*'){var wcIndex=slevel[i].indexOf('*');if(wcIndex>result){var wcString=slevel[i].substring(0,wcIndex);if(uri.path.indexOf(wcString)==0)result=wcIndex;}}}
return result;};this.isUserKnown=function(){return(this.getUserLevel()>this.level.none);};this.regLoginMethod=function(fn){loginFn=fn;};this.checkCall=function(urlLevel,fn,loginOverrideFn){if(urlLevel<=this.getUserLevel()){fn();}else{if(loginOverrideFn){calledFn=fn;loginOverrideFn();}
else if(loginFn){calledFn=fn;loginFn();}else{_g.handleError({description:'_g.security.regLoginMethod not set.'});}}};this.call=this.checkCall;this.onLoginSuccess=function(){return _g.getEvent('__onloginsuccess');};this.onLoginCancel=function(){return _g.getEvent('__onlogincancel');};this.loginSuccess=function(){var proceed=calledFn?calledFn():true;calledFn=null;if(proceed!==false)
this.onLoginSuccess().trigger();};this.loginCancel=function(){calledFn=null;this.onLoginCancel().trigger();};})();_g.login={onSuccess:_g.security.onLoginSuccess,onCancel:_g.security.onLoginCancel,success:function(){_g.security.loginSuccess();},cancel:function(){_g.security.loginCancel();}};if(typeof addMonsterReady!=="function"){addMonsterReady=function(func){$(document).ready(func);};}
