/*
 * Helper scripts
 */

var delayMS=3000;

function bsSetCookie(id){
setCookie("bsjs","bs"+id,0,"/");
}

function setCookie(_63,_64,_65,_66,_67,_68){
var _69=new Date();
_69.setTime(_69.getTime());
if(_65){
_65=_65*1000;
}
var _6a=new Date(_69.getTime()+(_65));
document.cookie=_63+"="+escape(_64)+((_65)?";expires="+_6a.toGMTString():"")+((_66)?";path="+_66:"")+((_67)?";domain="+_67:"")+((_68)?";secure":"");
}
function getCookie(_6b){
if(document.cookie.length>0){
c_start=document.cookie.indexOf(_6b+"=");
if(c_start!=-1){
c_start=c_start+_6b.length+1;
c_end=document.cookie.indexOf(";",c_start);
if(c_end==-1){
c_end=document.cookie.length;
}
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}


function imgSwap(_c9,_ca,_cb){
if(typeof _ca=="string"){
_ca=document.getElementById(_ca);
}
if(typeof _c9=="string"){
_c9=document.getElementById(_c9);
}
if(typeof _cb=="undefined"){
var _cb=_c9.href;
}
var _cc=_c9.firstChild;
while(_cc.nodeName!="IMG"){
if(_cc==_c9.lastChild){
return false;
}else{
_cc=_cc.nextSibling;
}
}
_ca.title=_cc.title;
_ca.alt=_cc.alt;
_ca.removeAttribute("width");
_ca.removeAttribute("height");
_ca.src=_cb;
return true;
}

function popupFacebookLogin(_d8){
FB.Connect.requireSession();
FB.Facebook.get_sessionState().waitUntilReady(function(){
document.location.href="/";
});
return false;
}
function fbWelcomePopup(){
FB.Facebook.get_sessionWaitable().waitUntilReady(Delegate.create(null,function(_d9){
FB.IFrameUtil.CanvasUtilServer.run(true);
var _da=document.createElement("div");
_da.setAttribute("iframeHeight","453px");
_da.setAttribute("iframeWidth","474px");
var _db=new FB.UI.PopupDialog("Invite Your Friends to Connect",_da,false,false);
_db.get_offset().y=-226;
_db.setContentWidth(474);
var _dc=_db._createCrossDomainClosingLink();
_da.setAttribute("fbml","<fb:fbml>"+"<h3>Welcome <fb:name uid=\"loggedinuser\" linked=\"false\" useyou=\"false\"/></h3>"+"<fb:connect-form action=\""+_dc+"\" view=\"dialog\" />"+"</fb:fbml>");
_db.show();
FB_RequireFeatures(["XFBML"],function(){
var _dd=new FB.XFBML.ServerFbml(_da);
FB.XFBML.Host.addElement(_dd);
});
}));
}
function popupRequestForm(){
FB.IFrameUtil.CanvasUtilServer.run(true);
var _de=document.createElement("div");
_de.setAttribute("iframeHeight","560px");
_de.setAttribute("iframeWidth","630px");
var _df=new FB.UI.PopupDialog("Invite Your Friends to Join Playuh.com",_de,false,false);
_df.setContentWidth(630);
_df.setContentHeight(560);
_df.set_placement(FB.UI.PopupPlacement.center);
_de.setAttribute("fbml","<fb:fbml>"+"<fb:request-form style=\"width:630px; height:560px;\" action=\""+document.location.href+"\"\tmethod=\"POST\" invite=\"false\" type=\"Playuh Friend\" "+"content=\"I'd like to add you as a friend on Playuh.com: <fb:req-choice url='http://www.playuh.com/?ttag=fbc&ref=fbinvite' label='Confirm' />\">"+"<fb:multi-friend-selector\tshowborder=\"false\" actiontext=\"Invite your friends to Playuh.com\" rows=\"5\" bypass=\"cancel\"\tshowborder=\"false\" />"+"</fb:request-form>"+"</fb:fbml>");
_df.show();
FB_RequireFeatures(["XFBML"],function(){
var _e0=new FB.XFBML.ServerFbml(_de);
FB.XFBML.Host.addElement(_e0);
});
}
function popupFacebookInvite(){
FB.Facebook.get_sessionState().waitUntilReady(Delegate.create(null,function(_e1){
FB.Facebook.apiClient.connect_getUnconnectedFriendsCount(function(o,e){
if(o>1){
FB.Connect.inviteConnectUsers();
}else{
popupRequestForm();
}
});
}));
return false;
}
function doLogout(){
if(typeof (FB)!="undefined"&&FB.Connect){
FB.Connect.logout(function(){
asyncRequestAndRedirect("/logout");
});
}else{
asyncRequestAndRedirect("/logout");
}
return false;
}
function FBconnectFeed(_e4,_e5){
if(!(typeof (FB)!="undefined"&&FB.Connect&&FB.Connect.get_status().get_isReady())){
_e5();
}else{
var _e6=_e4.bodygeneral;
var _e7=_e4.template_id;
delete _e4.bodygeneral;
delete _e4.template_id;
delete _e4.template;
_e4["appurl"]="http://www.playuh.com";
FB.Connect.showFeedDialog(_e7,_e4,null,_e6,FB.FeedStorySize.shortStory,FB.RequireConnect.doNotRequire,_e5);
}
return false;
}
function unlinkItemFromFCO(fid,_e9,rid,_eb){
var _ec=document.location;
var _ed="/action/editrelated.form?cmd=remove"+"&id="+fid+"&type="+_e9+"&rid="+rid+"&rtype="+_eb+"&next="+encodeURIComponent(_ec);
document.location.href=_ed;
}


