var swfobject=function(){function h(){if(!H){try{var a=i.getElementsByTagName("body")[0].appendChild(i.createElement("span"));a.parentNode.removeChild(a)}catch(b){return}H=true;a=M.length;for(var c=0;c<a;c++)M[c]()}}function t(a){if(H)a();else M[M.length]=a}function q(a){if(typeof y.addEventListener!="undefined")y.addEventListener("load",a,false);else if(typeof i.addEventListener!="undefined")i.addEventListener("load",a,false);else if(typeof y.attachEvent!="undefined")C(y,"onload",a);else if(typeof y.onload==
"function"){var b=y.onload;y.onload=function(){b();a()}}else y.onload=a}function j(){var a=i.getElementsByTagName("body")[0],b=i.createElement("object");b.setAttribute("type","application/x-shockwave-flash");var c=a.appendChild(b);if(c){var e=0;(function(){if(typeof c.GetVariable!="undefined"){var f=c.GetVariable("$version");if(f){f=f.split(" ")[1].split(",");g.pv=[parseInt(f[0],10),parseInt(f[1],10),parseInt(f[2],10)]}}else if(e<10){e++;setTimeout(arguments.callee,10);return}a.removeChild(b);c=null;
k()})()}else k()}function k(){var a=D.length;if(a>0)for(var b=0;b<a;b++){var c=D[b].id,e=D[b].callbackFn,f={success:false,id:c};if(g.pv[0]>0){var p=v(c);if(p)if(z(D[b].swfVersion)&&!(g.wk&&g.wk<312)){E(c,true);if(e){f.success=true;f.ref=o(c);e(f)}}else if(D[b].expressInstall&&r()){f={};f.data=D[b].expressInstall;f.width=p.getAttribute("width")||"0";f.height=p.getAttribute("height")||"0";if(p.getAttribute("class"))f.styleclass=p.getAttribute("class");if(p.getAttribute("align"))f.align=p.getAttribute("align");
var n={};p=p.getElementsByTagName("param");for(var w=p.length,x=0;x<w;x++)if(p[x].getAttribute("name").toLowerCase()!="movie")n[p[x].getAttribute("name")]=p[x].getAttribute("value");s(f,n,c,e)}else{l(p);e&&e(f)}}else{E(c,true);if(e){if((c=o(c))&&typeof c.SetVariable!="undefined"){f.success=true;f.ref=c}e(f)}}}}function o(a){var b=null;if((a=v(a))&&a.nodeName=="OBJECT")if(typeof a.SetVariable!="undefined")b=a;else if(a=a.getElementsByTagName("object")[0])b=a;return b}function r(){return!N&&z("6.0.65")&&
(g.win||g.mac)&&!(g.wk&&g.wk<312)}function s(a,b,c,e){N=true;U=e||null;W={success:false,id:c};var f=v(c);if(f){if(f.nodeName=="OBJECT"){K=d(f);O=null}else{K=f;O=c}a.id="SWFObjectExprInst";if(typeof a.width=="undefined"||!/%$/.test(a.width)&&parseInt(a.width,10)<310)a.width="310";if(typeof a.height=="undefined"||!/%$/.test(a.height)&&parseInt(a.height,10)<137)a.height="137";i.title=i.title.slice(0,47)+" - Flash Player Installation";e=g.ie&&g.win?"ActiveX":"PlugIn";e="MMredirectURL="+encodeURI(window.location).toString().replace(/&/g,
"%26")+"&MMplayerType="+e+"&MMdoctitle="+i.title;if(typeof b.flashvars!="undefined")b.flashvars+="&"+e;else b.flashvars=e;if(g.ie&&g.win&&f.readyState!=4){e=i.createElement("div");c+="SWFObjectNew";e.setAttribute("id",c);f.parentNode.insertBefore(e,f);f.style.display="none";(function(){f.readyState==4?f.parentNode.removeChild(f):setTimeout(arguments.callee,10)})()}m(a,b,c)}}function l(a){if(g.ie&&g.win&&a.readyState!=4){var b=i.createElement("div");a.parentNode.insertBefore(b,a);b.parentNode.replaceChild(d(a),
b);a.style.display="none";(function(){a.readyState==4?a.parentNode.removeChild(a):setTimeout(arguments.callee,10)})()}else a.parentNode.replaceChild(d(a),a)}function d(a){var b=i.createElement("div");if(g.win&&g.ie)b.innerHTML=a.innerHTML;else if(a=a.getElementsByTagName("object")[0])if(a=a.childNodes)for(var c=a.length,e=0;e<c;e++)!(a[e].nodeType==1&&a[e].nodeName=="PARAM")&&a[e].nodeType!=8&&b.appendChild(a[e].cloneNode(true));return b}function m(a,b,c){var e,f=v(c);if(g.wk&&g.wk<312)return e;if(f){if(typeof a.id==
"undefined")a.id=c;if(g.ie&&g.win){var p="",n;for(n in a)if(a[n]!=Object.prototype[n])if(n.toLowerCase()=="data")b.movie=a[n];else if(n.toLowerCase()=="styleclass")p+=' class="'+a[n]+'"';else if(n.toLowerCase()!="classid")p+=" "+n+'="'+a[n]+'"';n="";for(var w in b)if(b[w]!=Object.prototype[w])n+='<param name="'+w+'" value="'+b[w]+'" />';f.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+p+">"+n+"</object>";P[P.length]=a.id;e=v(a.id)}else{w=i.createElement("object");w.setAttribute("type",
"application/x-shockwave-flash");for(var x in a)if(a[x]!=Object.prototype[x])if(x.toLowerCase()=="styleclass")w.setAttribute("class",a[x]);else x.toLowerCase()!="classid"&&w.setAttribute(x,a[x]);for(p in b)if(b[p]!=Object.prototype[p]&&p.toLowerCase()!="movie"){a=w;n=p;x=b[p];c=i.createElement("param");c.setAttribute("name",n);c.setAttribute("value",x);a.appendChild(c)}f.parentNode.replaceChild(w,f);e=w}}return e}function u(a){var b=v(a);if(b&&b.nodeName=="OBJECT")if(g.ie&&g.win){b.style.display=
"none";(function(){if(b.readyState==4){var c=v(a);if(c){for(var e in c)if(typeof c[e]=="function")c[e]=null;c.parentNode.removeChild(c)}}else setTimeout(arguments.callee,10)})()}else b.parentNode.removeChild(b)}function v(a){var b=null;try{b=i.getElementById(a)}catch(c){}return b}function C(a,b,c){a.attachEvent(b,c);I[I.length]=[a,b,c]}function z(a){var b=g.pv;a=a.split(".");a[0]=parseInt(a[0],10);a[1]=parseInt(a[1],10)||0;a[2]=parseInt(a[2],10)||0;return b[0]>a[0]||b[0]==a[0]&&b[1]>a[1]||b[0]==a[0]&&
b[1]==a[1]&&b[2]>=a[2]?true:false}function J(a,b,c,e){if(!(g.ie&&g.mac)){var f=i.getElementsByTagName("head")[0];if(f){c=c&&typeof c=="string"?c:"screen";if(e)V=A=null;if(!A||V!=c){e=i.createElement("style");e.setAttribute("type","text/css");e.setAttribute("media",c);A=f.appendChild(e);if(g.ie&&g.win&&typeof i.styleSheets!="undefined"&&i.styleSheets.length>0)A=i.styleSheets[i.styleSheets.length-1];V=c}if(g.ie&&g.win)A&&typeof A.addRule=="object"&&A.addRule(a,b);else A&&typeof i.createTextNode!="undefined"&&
A.appendChild(i.createTextNode(a+" {"+b+"}"))}}}function E(a,b){if(X){var c=b?"visible":"hidden";if(H&&v(a))v(a).style.visibility=c;else J("#"+a,"visibility:"+c)}}function Q(a){return/[\\\"<>\.;]/.exec(a)!=null&&typeof encodeURIComponent!="undefined"?encodeURIComponent(a):a}var y=window,i=document,F=navigator,Y=false,M=[function(){Y?j():k()}],D=[],P=[],I=[],K,O,U,W,H=false,N=false,A,V,X=true,g=function(){var a=typeof i.getElementById!="undefined"&&typeof i.getElementsByTagName!="undefined"&&typeof i.createElement!=
"undefined",b=F.userAgent.toLowerCase(),c=F.platform.toLowerCase(),e=c?/win/.test(c):/win/.test(b);c=c?/mac/.test(c):/mac/.test(b);b=/webkit/.test(b)?parseFloat(b.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false;var f=!+"\u000b1",p=[0,0,0],n=null;if(typeof F.plugins!="undefined"&&typeof F.plugins["Shockwave Flash"]=="object"){if((n=F.plugins["Shockwave Flash"].description)&&!(typeof F.mimeTypes!="undefined"&&F.mimeTypes["application/x-shockwave-flash"]&&!F.mimeTypes["application/x-shockwave-flash"].enabledPlugin)){Y=
true;f=false;n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");p[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);p[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);p[2]=/[a-zA-Z]/.test(n)?parseInt(n.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else if(typeof y.ActiveXObject!="undefined")try{var w=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if(w)if(n=w.GetVariable("$version")){f=true;n=n.split(" ")[1].split(",");p=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(x){}return{w3:a,pv:p,wk:b,ie:f,win:e,
mac:c}}();(function(){if(g.w3){if(typeof i.readyState!="undefined"&&i.readyState=="complete"||typeof i.readyState=="undefined"&&(i.getElementsByTagName("body")[0]||i.body))h();if(!H){typeof i.addEventListener!="undefined"&&i.addEventListener("DOMContentLoaded",h,false);if(g.ie&&g.win){i.attachEvent("onreadystatechange",function(){if(i.readyState=="complete"){i.detachEvent("onreadystatechange",arguments.callee);h()}});y==top&&function(){if(!H){try{i.documentElement.doScroll("left")}catch(a){setTimeout(arguments.callee,
0);return}h()}}()}g.wk&&function(){H||(/loaded|complete/.test(i.readyState)?h():setTimeout(arguments.callee,0))}();q(h)}}})();(function(){g.ie&&g.win&&window.attachEvent("onunload",function(){for(var a=I.length,b=0;b<a;b++)I[b][0].detachEvent(I[b][1],I[b][2]);a=P.length;for(b=0;b<a;b++)u(P[b]);for(var c in g)g[c]=null;g=null;for(var e in swfobject)swfobject[e]=null;swfobject=null})})();return{registerObject:function(a,b,c,e){if(g.w3&&a&&b){var f={};f.id=a;f.swfVersion=b;f.expressInstall=c;f.callbackFn=
e;D[D.length]=f;E(a,false)}else e&&e({success:false,id:a})},getObjectById:function(a){if(g.w3)return o(a)},embedSWF:function(a,b,c,e,f,p,n,w,x,L){var R={success:false,id:b};if(g.w3&&!(g.wk&&g.wk<312)&&a&&b&&c&&e&&f){E(b,false);t(function(){c+="";e+="";var G={};if(x&&typeof x==="object")for(var B in x)G[B]=x[B];G.data=a;G.width=c;G.height=e;B={};if(w&&typeof w==="object")for(var S in w)B[S]=w[S];if(n&&typeof n==="object")for(var T in n)if(typeof B.flashvars!="undefined")B.flashvars+="&"+T+"="+n[T];
else B.flashvars=T+"="+n[T];if(z(f)){S=m(G,B,b);G.id==b&&E(b,true);R.success=true;R.ref=S}else if(p&&r()){G.data=p;s(G,B,b,L);return}else E(b,true);L&&L(R)})}else L&&L(R)},switchOffAutoHideShow:function(){X=false},ua:g,getFlashPlayerVersion:function(){return{major:g.pv[0],minor:g.pv[1],release:g.pv[2]}},hasFlashPlayerVersion:z,createSWF:function(a,b,c){if(g.w3)return m(a,b,c)},showExpressInstall:function(a,b,c,e){g.w3&&r()&&s(a,b,c,e)},removeSWF:function(a){g.w3&&u(a)},createCSS:function(a,b,c,e){g.w3&&
J(a,b,c,e)},addDomLoadEvent:t,addLoadEvent:q,getQueryParamValue:function(a){var b=i.location.search||i.location.hash;if(b){if(/\?/.test(b))b=b.split("?")[1];if(a==null)return Q(b);b=b.split("&");for(var c=0;c<b.length;c++)if(b[c].substring(0,b[c].indexOf("="))==a)return Q(b[c].substring(b[c].indexOf("=")+1))}return""},expressInstallCallback:function(){if(N){var a=v("SWFObjectExprInst");if(a&&K){a.parentNode.replaceChild(K,a);if(O){E(O,true);if(g.ie&&g.win)K.style.display="block"}U&&U(W)}N=false}}}}();
(function(h){var t={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},q={array:function(j){var k=["["],o,r,s,l=j.length,d;for(s=0;s<l;s+=1){d=j[s];if(r=q[typeof d]){d=r(d);if(typeof d=="string"){if(o)k[k.length]=",";k[k.length]=d;o=true}}}k[k.length]="]";return k.join("")},"boolean":function(j){return String(j)},"null":function(){return"null"},number:function(j){return isFinite(j)?String(j):"null"},object:function(j){if(j){if(j instanceof Array)return q.array(j);
var k=["{"],o,r,s,l;for(s in j){l=j[s];if(r=q[typeof l]){l=r(l);if(typeof l=="string"){if(o)k[k.length]=",";k.push(q.string(s),":",l);o=true}}}k[k.length]="}";return k.join("")}return"null"},string:function(j){if(/["\\\x00-\x1f]/.test(j))j=j.replace(/([\x00-\x1f\\"])/g,function(k,o){var r=t[o];if(r)return r;r=o.charCodeAt();return"\\u00"+Math.floor(r/16).toString(16)+(r%16).toString(16)});return'"'+j+'"'}};h.toJSON=function(j){var k=isNaN(j)?q[typeof j]:q.number;if(k)return k(j)}})(jQuery);
(function(h){var t=function(){function q(d,m,u){(s[d]=s[d]||[]).push({fn:m,origin:u})}function j(d,m){s[d]=m?h(s[d]||[]).filter(function(u,v){return v.fn!==m}):[]}function k(d,m,u,v,C,z){if(d&&m)if(d.postMessage){callbackID=C||z?l.push({success:C||h.noop,error:z||h.noop})-1:0;d.postMessage(h.toJSON({type:m,data:u||{},cid:callbackID}),v||"*")}}function o(d,m){if(d&&d.id&&l[d.id]){l[d.id][m?"success":"error"](d.result);d.last&&delete l[d.id]}}function r(d){d=d.attr("src").split("/");var m=false;if(d[0]&&
d[2]&&!d[0].indexOf("http"))m=d[0]+"//"+d[2];return m}var s={},l=[0];h(window).bind("message",function(d){try{d=d.originalEvent;var m=h.parseJSON(d.data),u=d.origin,v=d.source,C;if(m&&m.type){var z=s[m.type]||[],J;h(z).each(function(Q,y){J=z.length==Q+1;try{if(!y.origin||y.origin==u){C=y.fn(m.data);m.cid&&k(v,"postMsgSuccess",{id:m.cid,last:J,result:C},u)}else throw Error('postMsg: message origin mismatch: "'+y.origin+'" <=> "'+u+'"');}catch(i){m.cid&&k(v,"postMsgError",{id:m.cid,last:J,result:i.message||
i},u)}})}}catch(E){}});q("postMsgSuccess",function(d){o(d,1)});q("postMsgError",function(d){o(d,0)});return{send:k,bind:q,unbind:j,srcToOrigin:r}}();h.postMsg=t.send;h.extend(h.postMsg,t)})(jQuery);$(document).ready(function(){var h=$("#fb-root"),t=+h.data("debug")||0,q=+h.data("requireConnect")||0;SiteAjax.init(h.data("ajaxBaseURL")||"");Auth.init(q,t);Auth.connect(h.data("uid"));Flash.init("flashContent");Voting.init()});
var Auth=function(){function h(l){var d=!!l;if(o)FB.getLoginStatus(function(m){if(m&&m.session){var u=0;try{if(m&&m.perms)for(var v=s.length;v--;){u=m.perms.indexOf(s[v])>-1;if(!u)break}}catch(C){}if(u)l&&l(m.session);else if(d)SitePopup.ui({method:"permissions.request",perms:s.join(",")});else{u=$("#profileBox");if(u[0]&&u.attr("src")==""){u=document.location;v=[];if(u.search.length)v=jQuery.grep(u.search.replace("?","").split("&"),function(z){return z.indexOf("uid=")!=0});v.push("uid="+m.session.uid);
u.replace("?"+v.join("&"))}}}else j.dialog({width:400,modal:1,resizable:0,draggable:0,closeOnEscape:0,open:function(){var z=$(this).parent().removeClass("ui-widget-content ui-corner-all");$(this).removeClass("ui-dialog-content");$(".ui-dialog-titlebar",z).remove()},close:function(){$(this).dialog("destroy")}})},d);else l&&l()}function t(l){var d=k.get(0);d.innerHTML='<div class="userIco"><img src="http://graph.facebook.com/'+l+'/picture?type=square" alt="" /></div><div class="userName"><fb:name uid="'+
l+'" useyou="false" linked="false" ></fb:name>'+(r?'<br />(<a class="logOut" id="fbLogout">Sign Out</a>)':"")+"</div>";FB.XFBML.parse(d)}function q(l){h();FB.getLoginStatus(function(d){if(!l&&d&&d.session){d=d.session;t(d.uid);q(d.uid)}});$("#fbLogin,#fbLoginViaDialog").unbind("click").click(function(){FB.login(function(d){if(d=d.session){t(d.uid);j.dialog("destroy");q(d.uid)}},{perms:s.join(",")})});r&&$("#fbLogout").unbind("click").click(function(){FB.logout(function(){$(".loginWidget").html('<div class="welcomeMsg">Login to Apps-O-Rama</div><button class="loginBtn" id="fbLogin"></button>');
q(0)})});$("#contactUs").click(function(){h(function(){$(".contact form").submit()})})}var j=$("#forceConnectDialog"),k=$("#loginWidget"),o=0,r=0,s=["publish_stream","email"];return{init:function(l,d){o=l;r=d},connect:q,executeConnect:h}}(),Flash=function(){return{init:function(h){var t=$("#"+h);if(t.length){flashvars={data:t.data("json")};params={quality:"high",bgcolor:"#000000",allowscriptaccess:"sameDomain",allowfullscreen:"true"};attributes={id:"GamePicker",name:"GamePicker",align:"middle"};swfobject.embedSWF("/flash/GamePicker.swf",
h,"998","490","10.0.0","playerProductInstall.swf",flashvars,params,attributes)}}}}(),Voting=function(){function h(o,r,s){var l=q;o.text(l).parent().show();k=setInterval(function(){o.text(--l);if(l<=0){clearInterval(k);SiteAjax.track("trackRedirectOnTimeout",{alias:s},function(){j.href=r})}},1000)}function t(){$("button.voteBtn").click(function(o){o=$(o.target);var r=o.data("pair"),s=o.data("choice"),l=o.data("alias");SiteAjax.post("voteResult",{pair:r,choice:s,alias:l},function(d){if("voteResult"in
d)for(id in d.voteResult)$("#subject"+id).html(d.voteResult[id]);"stream"in d&&SitePopup.ui(d.stream,function(m){h($("#voteTimer"),$("#backToApp").data("href"),l);m&&m.post_id&&SiteAjax.track("trackStreamPublication",{alias:l})});$("#afterVoting .btn").show().click(function(m){var u=$(m.target);switch(u.attr("id")){case "backToApp":SiteAjax.track("trackPlayButtonClick",{alias:l},function(){j.href=u.data("href")});break;case "voteAgain":SiteAjax.track("trackVoteAgainButtonClick",{alias:l},function(){j.reload()})}clearInterval(k)});
$(".voteBox .ctrls").removeClass("voteProcess");$("#voteHeader").text("Vote Results")},function(){$(r).each(function(d,m){$("#subject"+m).text("");$(".voteBox .ctrls").addClass("voteProcess")})})})}var q=10,j=document.location,k;return{init:t}}(),SiteAjax=function(){function h(q,j){t=j}function h(q){t=q}var t="";return{init:h,post:function(q,j,k,o){Auth.executeConnect(function(r){$.ajax({type:"POST",url:t+"/"+q,data:$.extend(j,r?{session:$.toJSON(r)}:{}),dataType:"json",beforeSend:o||$.noop,success:k})})},
track:function(q,j,k){$.ajax({type:"POST",url:t+"/"+q,data:j,dataType:"json",complete:k||$.noop})}}}(),SitePopup=function(){function h(j,k){q.dialog("open");FB.ui(j,function(o){q.dialog("close");k&&k(o)})}function t(j,k,o,r){function s(l){return Math.round(Math.max(0,l))}k=$(window);o=$.param({toolbar:0,status:0,width:o,height:r,top:s((k.height()-r)/2),left:s((k.width()-o)/2)}).replace(/\&/g,",");return window.open(j,"sharer",o).focus()}var q=$("<div/>").appendTo(document.body).dialog({modal:1,closeOnEscape:0,
autoOpen:0,open:function(){$(this).parent().hide()}});return{ui:h,wnd:t}}();$.postMsg.bind("setAppBoxSize",function(h){h&&h.alias&&h.height&&$("#"+h.alias+"Frame").css({height:h.height})});(function(h){h.size()&&$.postMsg.bind("setProfileBoxSize",function(t){t&&h.css({height:Math.max(600,Math.min(2000,parseInt(t.height)+10||0))})},$.postMsg.srcToOrigin(h))})($("#profileBox"));
