siteGlobal=function(){var a=jQuery;return{init:function(){a(".quickTool h3, .quickTool .section-header, .quickTool .section-hint").live("click",this.quickTools);a.fn.webService=this.webServiceCall;a.fn.expressionWebService=this.expressionWebServiceCall;a(".mates-show-info, .post-user-name-modal").live("click",this.matesShowInfo);a(".menu-profile-add a, .menu-profile-add-editorial a, .add-as-a-mate").live("click",this.matesAddShowInfo);a(".menu-profile-remove a, .menu-profile-remove-editorial a, .remove-as-a-mate").live("click",this.matesRemoveShowInfo);a("#mystuff-toggle").live("click",this.myStuffProfileBoxToggle);a(".delete-select").click(this.deleteSelect);a(".add-me").live("click",this.addMeRollService);a.fn.inputHints=this.inputHints;a("#service-link-send-updates").live("click",this.sendMeUpdates);a(".button-view-stats").live("click",this.loadPageStats);jQuery("#service-link-finish-updates,.modalCloseImg").live("click",function(){jQuery.modal.close()})},webServiceCall:function(c){c=a.extend({type:"GET",dataType:"json"},c);var b=a.ajax({type:c.type,url:c.url,dataType:c.dataType,beforeSend:function(){var e=c.loadingLocation;if(c.loading==true){if(c.loadingText==true){a(e).fadeIn("slow").append('<div class="preloader">Loading, please wait...</div>')}else{var d=a(e).width();var f=a(e).height();if(f<43){var f=43}a(e).css("position","relative");a(e).prepend("<div class='preLoader-overlay' style='width:"+d+"px;height:"+f+"px;'></div>")}a(e).ajaxStop(function(){if(c.loadingText==true){a(".preloader").remove()}else{a(".preLoader-overlay").remove()}})}},success:c.success,error:function(f,d,e){a(".preLoader-overlay").remove()},complete:function(e,g){if(g=="error"&&c.errorLocation!=null){switch(e.status){case 404:a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>The requested service is no longer available</p></div>");if(c.debug==true){console.log("Error Code: "+e.status+" "+e.statusText)}break;case 403:a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>You are not authorized to access this service</p></div>");if(c.debug==true){console.log("Error Code: "+e.status+" "+e.statusText)}break;case 500:a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>There was an internal server error</p></div>");if(c.debug==true){console.log("Error Code: "+e.status+" "+e.statusText)}break;case 204:if(c.errorText==true){var f=c.errorTextContent;a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>"+f+"</p></div>")}else{a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>No content</p></div>")}if(c.debug==true){console.log("Error Code: "+e.status+" "+e.statusText)}break;default:a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>Server Error</p></div>");if(c.debug==true){console.log("Error Code: "+e.status+" "+e.statusText)}break}if(c.errorFadeOut==true){var d=c.errorLocation+" .ajax-error";setTimeout(function(){a(d).fadeOut("slow",function(){a(this).remove()})},10000)}a(".preLoader-overlay").remove()}if(g=="error"&&c.errorHightLightLocation!=null){a(c.errorHightLightLocation).addClass("ajax-error-hightlight")}if(g=="success"&&c.successText==true){a(c.successTextLocation).fadeIn("slow").html(c.successTextContent)}if(g=="success"){switch(e.status){case 404:a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>The requested service is no longer available</p></div>");if(c.debug==true){console.log("Error Code: "+e.status+" "+e.statusText)}break;case 403:a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>You are not authorized to access this service</p></div>");if(c.debug==true){console.log("Error Code: "+e.status+" "+e.statusText)}break;case 500:a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>There was an internal server error</p></div>");if(c.debug==true){console.log("Error Code: "+e.status+" "+e.statusText)}break;case 204:if(c.errorText==true){var f=c.errorTextContent;a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>"+f+"</p></div>")}else{a(c.errorLocation).fadeIn("slow").prepend("<div class='ajax-error'><p>No content</p></div>")}if(c.debug==true){console.log("Error Code: "+e.status+" "+e.statusText)}break}}if(g=="timeout"){b.abort();if(c.errorLocation!=null){a(c.errorLocation).fadeIn("slow").html("<p>There was an internal server error</p>")}a(".preLoader-overlay").remove()}}});if(c.debug==true){if(console){console.debug(c)}}return this},expressionWebServiceCall:function(e){var f=e.expAction;var j=e.objectId;var c=e.objectType;var d=e.extraParam;var h=e.extraParamValue;var b=e.extraParamType;var i=e.extraParamTypeValue;var k=e.dataType;var g="/services/gateway/?service[module]=Expressions&service[action]="+f+"&service[format]="+k+"&params[objectType]="+c+"&params[objectId]="+j+"&params["+d+"]="+h+"&params["+b+"]="+i+"&user[token]="+document.userToken;a(this).webService({type:"POST",url:g,dataType:k,success:e.success,loading:e.loading,loadingLocation:e.loadingLocation})},inputHints:function(b){if(!b){b="blur"}return this.each(function(){var g=a(this),e=g.attr("title"),d=a(this.form),f=a(window);function c(){if(g.val()===e&&g.hasClass(b)){g.val("").removeClass(b)}}if(e){g.blur(function(){if(this.value===""){g.val(e).addClass(b)}}).focus(c).blur();d.submit(c);f.unload(c)}})},sendMeUpdates:function(){if(document.userToken){jQuery("#all-about-alerts-modal").modal({containerCss:{height:330,width:513}});jQuery("#service-link-finish-updates,.modalCloseImg").live("click",function(){jQuery.modal.close()});a(".alertcheckBox input").live("click",function(){var d=a(this).attr("class");var b=a(this).attr("name");var c=".alertcheckBox ."+d;uri="/services/gateway/allabout/"+b+"/"+d+"/addAlert.json?user[token]="+document.userToken;a(this).webService({type:"get",url:uri,dataType:"json",success:function(e){var f=".alertcheckBox ."+d;a(f).attr("disabled",true)},errorHightLightLocation:"."+d})});return false}else{loginModal()}return false},matesShowInfo:function(){a(".showMatesInfoInModalBox").remove();a(".simplemodal-data").remove();if(a(this).attr("class")=="post-user-name-modal"){var b=a(this).attr("rel")}else{var b=a(this).attr("id")}var c="/services/gateway?service[module]=User&service[action]=UserDetails&service[format]=html&params[userId]="+b;a("#site-footer").append("<div class='showMatesInfoInModalBox'></div>");a(".showMatesInfoInModalBox").webService({type:"post",url:c,dataType:"html",loading:true,loadingText:true,loadingLocation:".showMatesInfoInModalBox",success:function(f){a(".showMatesInfoInModalBox").html(f)}});a(".showMatesInfoInModalBox").modal({overlayClose:true});var e=a(".matesShowProfile .profile-tools-status h3").html();var d=a(".matesShowProfile .img-cont").html();a(".menu-profile-shout a").live("click",function(){var g=a(this).parents(".matesShowProfile").find("h3").html();var f=a(this).parents(".matesShowProfile").find(".img-cont").html();a(this).parents(".matesShowProfile").find(".content").fadeIn("slow").html("<div class='shout-mate profile-tools-status'><a class='shout-profile-link clearfix' href='"+document.siteURL+"/people/"+g+"'><div class='img-cont'>"+f+"</div><span class=shout-text>shout at:</span><h3>"+g+"</h3></a><div class=shoutback-textarea><textarea id=shoutBox_CommentArea></textarea><div class=shoutback-postshout><div class='profile-tools-links'><ul><li class=''><a href='#' class='lightBox-postshout'>Post Shout</a></li></ul></div></div></div>");return false});a(".lightBox-postshout").live("click",function(){var f=a("#shoutBox_CommentArea").attr("value");f=encodeURIComponent(f);var g="/services/gateway/?service[module]=Expressions&service[action]=AddTag&service[format]=JSON&params[userId]="+document.jsItemID+"&params[objectType]=User&params[objectId]="+b+"&params[tagValue]="+f+"&params[tagType]=shoutBox&user[token]="+document.userToken;a(this).webService({url:g,dataType:"json",success:function(h){a(".lightBox-postshout").fadeIn("slow").html("Sent");setTimeout("jQuery.modal.close()",500)}});return false});return false},matesAddShowInfo:function(){if(a(this).attr("class")=="service-action-link add-as-a-mate"||a(this).attr("class")=="button add-as-a-mate"){var c=a("#profileImage").attr("title")}else{var c=a(this).parents(".content").find("h3").html()}var b="/services/gateway/buddies/add/"+c+"?user[token]="+document.userToken;a(this).webService({type:"post",url:b,dataType:"html",successText:true,successTextLocation:this,successTextContent:"Added"});return false},matesRemoveShowInfo:function(){if(a(this).attr("class")=="service-action-link remove-as-a-mate"||a(this).attr("class")=="button remove-as-a-mate"){var c=a("#profileImage").attr("title")}else{var c=a(this).parents(".content").find("h3").html()}var b="/services/gateway/buddies/remove/"+c+"?user[token]="+document.userToken;a(this).webService({type:"post",url:b,dataType:"html",successText:true,successTextLocation:this,successTextContent:"Removed"});return false},addMeRollService:function(){var b=a(this).parents(".mates-going").attr("id");var d="#"+b;var c="/services/gateway/?service[module]=Expressions&service[action]=AddTag&service[format]=JSON&params[tagValue]=&params[tagType]=calendar&params[objectType]=WhatsOn&params[objectId]="+b+"&user[token]="+document.userToken;a(this).webService({type:"post",url:c,dataType:"html",success:function(g){var f=d+" .mates-going-addme";var e=d+" .mates-going-count";a(f).remove();a(e).prepend("You and ")}});return false},myStuffProfileBoxToggle:function(){a("#block_My_FasterLouder .content").slideToggle("slow");a("#mystuff-toggle").toggleClass("opened");return false},deleteSelect:function(){a(".message-delete").click()},shoutAtMates:function(c){a(".shout-at-profilepic").live("click",function(){var g=a(this).attr("src");var e=a(this).attr("id");var f=a(this).attr("alt");var d=encodeURIComponent(f);a("#breakout-shout-at-a-mate .content").fadeIn("slow").html("<div class=shout-mate><a class='shout-profile-link clearfix mates-show-info' href='#' id="+e+"><img class=shout-image src="+g+"><span class=shout-text>shout at:</span><h3 id="+e+">"+f+"</h3></a><div class=shoutback-textarea><textarea id=shoutBox_CommentArea></textarea><div class=shoutback-postshout><button class=button-postshout>Post Shout</button></div></div>");return false});a(".button-postshout").live("click",function(){var g=getItem("shoutBox_CommentArea").value;var d=a(".shout-profile-link h3").attr("id");g=encodeURIComponent(g);var f="/services/gateway/?service[module]=Expressions&service[action]=AddTag&service[format]=JSON&params[userId]="+document.loggedinUserId+"&params[objectType]=User&params[objectId]="+d+"&params[tagValue]="+g+"&params[tagType]=shoutBox&user[token]="+document.userToken;a(this).webService({type:"POST",url:f,dataType:"html",success:function(h){}});var e="/services/gateway/?service[module]=User&service[action]=getUserBuddies&service[format]=html&service[templateName]=ShoutAtMate&params[userId]="+document.loggedinUserId+"&params[isMe]=true&params[page]=1&params[offset]=7&user[token]="+document.userToken;a(this).webService({type:"POST",url:e,dataType:"html",success:function(h){a("#breakout-shout-at-a-mate .content").html(h)},loading:true,loadingLocation:"#breakout-shout-at-a-mate .content"});return false});a(".listing-button-reply").live("click",function(){if(a(this).hasClass("opened")){}else{var d=a(this).parent().parent().find(".shouter").html();a(this).addClass("opened");a(this).css("padding-bottom","9px");a(this).parent().parent().append("<div class='reply-box'><span>@ "+d+":<input type='text' class='reply-textfield'><button class='listing-button-shout'>Send</button></span></div>")}return false});a(".listing-button-shout").live("click",function(){var d=a(this).parents(".item-shouts").find("h3").attr("class");var f=a(this).parent().children(".reply-textfield").val();f=encodeURIComponent(f);d=d.match(/[0-9]+/);var e="/services/gateway/?service[module]=Expressions&service[action]=AddTag&service[format]=JSON&params[userId]="+document.loggedinUserId+"&params[objectType]=User&params[objectId]="+d+"&params[tagValue]="+f+"&params[tagType]=shoutBox&user[token]="+document.userToken;a(this).webService({type:"POST",url:e,dataType:"html",success:function(g){}});a(this).parent().fadeOut("slow");a(".listing-button-reply").css("padding-bottom","0px");setTimeout(function(){a(".reply-box").remove()},1500);return false});if(a(".matesincommon").length){userId=a(".matesincommon").attr("id");var b="/services/gateway/?service[module]=User&service[action]=GetMatesInCommon&service[format]=html&params[userId]="+userId+"&params[page]=1&user[token]="+document.userToken;a(this).webService({type:"POST",url:b,dataType:"html",success:function(d){if(d=="No mates in common."){a(".matesincommon").html("<div class='no-content'>No mates in common yet</div>")}else{a(".matesincommon").html(d)}},loading:true,loadingLocation:".matesincommon"})}},quickTools:function(b){a(this).parents().find(".quickTool .section-content").slideToggle(150);if(a(this).parent().hasClass("open")){a(this).parent().removeClass("open");a(this).parent().addClass("closed");a(this).attr("title","Click to open area");a(this).parent().addClass("closed");a(this).parent().find(".section-hint").html("+")}else{a(this).parent().removeClass("closed");a(this).parent().addClass("open");a(this).attr("title","Click to close area");a(this).parent().find(".section-hint").html("-")}return false},loadPageStats:function(d){var b=a(this).attr("id");if(document.jsItemID!=""){var c=document.jsItemID}else{var c=a(this).attr("value")}a("#statsArea").html("Loading stats data...");a("#statsArea").load("/services/graph/"+b+"/"+c);a("#statsArea").modal({autoResize:true,containerCss:{height:400,width:545},overlayClose:true})},interStitialInit:function(d){var c=d.config.bg;var b=d.config.top+"px";a("#interstitial-cont").css({"background-color":c}).scrollTop(0).show();a("body").css("width","100%");a("#site").css("width","100%");a("#ad-close strong").click(this.interStitialClose);if(d.config.adTimer){adTimer=d.config.adTimer;this.interStitialTimer()}},interStitialTimer:function(){if(adTimer==0){this.interStitialClose()}else{if(a.isReady){}a("#ad-timer").html('this ad will close in&nbsp;<em style="color:#7d7d7d;font-size:14px;font-weight:bold">'+adTimer+"</em>&nbsp;seconds");adTimer--;adCountDown=setTimeout("flGlobal.interStitialTimer()",1250)}},interStitialClose:function(b){a("body").css("width","990px");a("#site").css("width","990px");clearTimeout(adCountDown);a("#video-player").css("visibility","visible");a("#interstitial-cont").hide();a("#interstitial-ad").hide()}}}();jQuery(document).ready(function(){siteGlobal.init()});