String.prototype.startsWith=function(A){return(this.match("^"+A)==A)};String.prototype.endsWith=function(A){return(this.match(A+"$")==A)};String.prototype.trim=function(){return(this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,""))};var intervalH;function watch(A,C){var B=C;function D(){var E=true;for(var F in B){if(B[F].style!=null&&B[F].style.top!=null&&B[F].style.top.substring(0,B[F].style.top.length-2)>0){E=false;break}}if(E==true){MyDebugger.debug("Dialog Closed via X");clearTimeout(intervalH);A.call(null,null)}}return D}function relogIn(B,A){FB.login(function(C){alert("test");B.call(null,A)})}var MyDebugger=function(){return{debug:function(A){}}}();var FacebookApi=function(){var requiredPerms="email";var FBApiInitialized=false;var onFbInitFunctions=new Array();function fbInitializedCallback(){MyDebugger.debug("Begin calling callbacks: "+onFbInitFunctions.length);for(var i=0;i<onFbInitFunctions.length;i++){var current=onFbInitFunctions[i];var parenIndex=current.indexOf("(");if(parenIndex!=-1){var command=current.substring(0,parenIndex);
MyDebugger.debug(onFbInitFunctions[i]+" being executed");eval(onFbInitFunctions[i])}}onFbInitFunctions=new Array();MyDebugger.debug("Done Begin calling callbacks: "+onFbInitFunctions.length)}function makeAsyncRequest(url,callback_function,return_xml){MyDebugger.debug("Start Making Async call");MyDebugger.debug(url);var http_request=false;if(window.XMLHttpRequest){http_request=new XMLHttpRequest();if(http_request.overrideMimeType){http_request.overrideMimeType("text/xml")}}else{if(window.ActiveXObject){try{http_request=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{http_request=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}}}if(!http_request){alert("Unfortunatelly your browser doesn't support this feature.")}if(callback_function){http_request.onreadystatechange=function(){if(http_request.readyState==4){if(http_request.status==200){if(return_xml){if(!http_request.responseXML.documentElement&&http_request.responseStream){http_request.responseXML.load(http_request.responseStream)}if(callback_function!=null){callback_function.call(null,http_request.responseXML)
}}else{if(callback_function!=null){callback_function.call(null,http_request.responseText)}}}else{callback_function.call(null,"error")}}}}http_request.open("GET",url,true);http_request.send(null);MyDebugger.debug("Done Making Async call")}function onFacebookInitialLoginStatus(response){MyDebugger.debug("Facebook Status: "+response.status+"\tFrom: Intial Status");if(document.getElementById("signedIn")!=null&&response.status=="connected"){var signOut=document.getElementById("log_out");if(!signOut){return false}if(signOut.attachEvent){signOut.attachEvent("onclick",logUserOut)}else{signOut.setAttribute("onclick","logUserOut();return false;")}}else{if(response.status=="connected"&&document.URL.startsWith("https")==false){try{makeAsyncRequest("http://"+document.domain+"/FacebookAjax?login=y",checkFacebookInitialStatus)}catch(x){MyDebugger.debug(x.message)}}else{if(response.status=="connected"&&document.URL.endsWith("s-StartRegistration")==true){FB.api("/me?type=small&fields=name,email,picture,friends,id&access_token="+FB.getSession().access_token,"get",function(resp){if(!resp||resp.error){alert("Error occured")
}else{document.getElementById("fb-profile-name").innerHTML=resp.name;document.getElementById("fb-profile-friends").innerHTML=resp.friends.data.length;document.getElementById("fb-profile-img").src=resp.picture;document.getElementById("fb-profile").style.display="";document.getElementById("email_address").value=resp.email;document.getElementById("reg_nickname").value=resp.name;document.getElementById("fb_uid").value=resp.id;document.getElementById("fb_authToken").value=FB.getSession().access_token}})}}}}return{isApiInitialized:function(){return FBApiInitialized},requestFacebookLogIn:function(callback,optionalPerms){var requestedPerms=requiredPerms;if(optionalPerms!=null){requestedPerms+=","+optionalPerms}FB.ui({method:"permissions.request",display:"popup",perms:requestedPerms},function(resp){MyDebugger.debug("Dialog closed via buttons");clearTimeout(intervalH);callback.call(null,resp)})},requestPermissions:function(callback,optionalPerms){var requestedPerms=requiredPerms;if(optionalPerms!=null){requestedPerms+=","+optionalPerms
}FB.ui({method:"permissions.request",display:"popup",perms:requestedPerms},function(resp){MyDebugger.debug("Dialog closed via buttons");clearTimeout(intervalH);callback.call(null,resp)})},getCurrentLogInStatus:function(callback){try{MyDebugger.debug("\tcalling facebook for status: forcing reload status");FB.getLoginStatus(callback,true)}catch(x){MyDebugger.debug("\t: calling facebook for status: error:"+x.message)}},isUserLoggedIn:function(){if(FB.getSession()!=null){return true}else{return false}},requestLoggedInUserDetails:function(callback,isSecure){var totalCalls=2;var count=0;var result=[];if(isSecure==null){isSecure=false}FB.api("/me/statuses","get",function(resp){if(resp==null){resp.error="Unknown issues with statuses"}else{if(resp.error!=null){resp.error=resp.error}else{result.status=resp}}count++;if(count>=totalCalls&&callback){callback.call(null,result)}});var profileApi="/me?type=square&fields=name,picture,friends,location,email";if(isSecure!=null&&isSecure==true){profileApi+="&return_ssl_resources=true"
}FB.api(profileApi,"get",function(resp){if(resp==null){resp.error="Unknown issues with statuses"}else{if(resp.error!=null){resp.error=resp.error}else{result.info=resp}}count++;if(count>=totalCalls&&callback){callback.call(null,result)}})},revokeAppAuthorization:function(callback){FB.api({method:"Auth.revokeAuthorization"},function(resp){if(resp.error_code!=null&&resp.error_code==190){MyDebugger.debug("Forcing reload status");FacebookApi.getCurrentLogInStatus(function(status){FB.api({method:"Auth.revokeAuthorization"},callback)})}callback.call(null,resp)})},revokeAppPermission:function(callback,permission){FB.api({method:"Auth.revokeExtendedPermission",perm:permission},function(resp){MyDebugger.debug("Forcing reload status");FB.api({method:"auth.createToken"},function(response){callback.call(null,resp)})})},changeLoginType:function(callback){MyDebugger.debug("\tchange log in type");MyDebugger.debug("\tchange log in type: call kijiji");FacebookApi.updateKijiji("connected=y&uid="+getUserId(),function(resp){MyDebugger.debug("\tchange log in type: call kijiji: response: "+resp);
if(resp!="ERROR"){var signOut=document.getElementById("log_out").cloneNode(true);if(signOut.attachEvent){signOut.attachEvent("onclick",logUserOut)}else{signOut.setAttribute("onclick","logUserOut();return false;")}document.getElementById("withoutGreetings").innerHTML=resp+"&nbsp;|&nbsp;&nbsp;";document.getElementById("withoutGreetings").appendChild(signOut)}MyDebugger.debug("\tchange log in type: call kijiji: fire call back function");if(callback!=null){callback.call(null,resp)}})},logUserOut:function(callback){FB.logout(callback);return false},updateKijiji:function(params,callback,isSecure){var url;var cacheBuster=Math.floor(Math.random()*100000001);if(isSecure!=null&&isSecure===true){url="https://"+document.domain+"/FacebookAjaxSecure?"+params}else{url="http://"+document.domain+"/FacebookAjax?"+params}url+="&cb="+cacheBuster;makeAsyncRequest(url,callback)},sendPasswordEmail:function(callback){makeAsyncRequest("http://"+document.domain+"/c-SendPassword",callback)},displayFBStatus:function(){try{var str="\tUser Status: "+FB._userStatus+"\n\tSession: "+FB._session+"\n\tHTTPS: "+FB._https+"\n\tOrigin: "+FB.XD.origin+"\n";
MyDebugger.debug(str)}catch(x){MyDebugger.debug("Unable to get status: "+x.message)}},initializeApi:function(appId,channel){MyDebugger.debug("Begin init");FB.init({appId:appId,status:true,cookie:true,xfbml:true,logging:false,channelUrl:channel});try{MyDebugger.debug("begin calling getCurrentLogInStatus");FacebookApi.displayFBStatus();FacebookApi.getCurrentLogInStatus(onFacebookInitialLoginStatus)}catch(x){MyDebugger.debug("calling getCurrentLogInStatus: "+x.description)}FB.XFBML.parse();fbInitializedCallback();FBApiInitialized=true;MyDebugger.debug("Done init")},addFbInitializedCallback:function(f){MyDebugger.debug(f+" loaded to onfbInit");onFbInitFunctions[onFbInitFunctions.length]=f;if(FBApiInitialized==true){fbInitializedCallback()}}}}();window.fbAsyncInit=function(){MyDebugger.debug("fbAsyncInt called");FacebookApi.initializeApi(fb_AppId,fb_Channel);MyDebugger.debug("done fbAsyncInt called")};function logUserOut(A){FacebookApi.logUserOut(function(B){window.location=document.getElementById("log_out").href
});return false}function fbLogUserOut(A){FacebookApi.getCurrentLogInStatus(function(B){if(B.status=="connected"){FacebookApi.logUserOut(function(C){window.location=A})}else{window.location=A}});return false}function checkFacebookInitialStatus(response){MyDebugger.debug("calling checkFacebookInitialStatus");var resp=eval("("+response+")");var signIncontainer=document.getElementById("withoutGreetings");signIncontainer.innerHTML=resp.name+"&nbsp;|&nbsp;";var signOut=document.createElement("a");if(signOut.attachEvent){signOut.attachEvent("onclick",logUserOut)}else{signOut.setAttribute("onclick","logUserOut();return false;")}signOut.setAttribute("href",resp.signOut);signOut.setAttribute("id","log_out");signOut.setAttribute("style","text-decoration:none;color:#003399;");signOut.innerHTML=resp.signOutText;signIncontainer.appendChild(signOut);var isLoggedIn=document.createElement("input");isLoggedIn.setAttribute("type","hidden");isLoggedIn.setAttribute("id","signedIn");signIncontainer.parentNode.appendChild(isLoggedIn);
if(resp.redir!=null){window.location=resp.redir}};
