Type.registerNamespace("GG");
GG.SN=function(){};
GG.SN.prototype={};
var GG_SN_FB_isInitialized=false;
GG.SN.sessionOnReady=function(redirectToReturnUrl){GG.SN.ensureInit(function(){FB.Facebook.get_sessionState().waitUntilReady(function(){GG.SN.sessionIsReady(redirectToReturnUrl);
});
});
};
GG.SN.publishFeedStory=function(form_bundle_id,template_data,fbFeedSize){var json=Sys.Serialization.JavaScriptSerializer.deserialize(template_data);
FB.Connect.showFeedDialog(form_bundle_id,json,null,null,fbFeedSize,FB.RequireConnect.promptConnect);
};
GG.SN.publishCIVote=function(contentID,isGrind){GG.ajax({type:"GET",url:"/services/json/Social.ashx",data:{t:'gfv',cid:contentID,isgrind:isGrind},dataType:"json",success:function(data){if(data){GG.SN.publishFeedStory(GG_SN_FB_contentTemplateID,data,1);
}}});
};
GG.SN.publishCIComment=function(commentID){GG.ajax({type:"GET",url:"/services/json/Social.ashx",data:{t:'gfc',cmid:commentID},dataType:"json",success:function(data){if(data){GG.SN.publishFeedStory(GG_SN_FB_commentTemplateID,data,2);
}}});
};
GG.SN.publishCISubmission=function(contentID){GG.ajax({type:"GET",url:"/services/json/Social.ashx",data:{t:'gfcs',cid:contentID},dataType:"json",success:function(data){if(data){GG.SN.publishFeedStory(GG_SN_FB_contentTemplateID,data,2);
}}});
};
GG.SN.ShowFriends=function(){GG.SN.ensureInit(function(){FB.Facebook.apiClient.friends_getAppUsers(function(result,ex){if(result){result=result+",";	var sideBarFBFriends=document.getElementById("sideBarFBFriends");
if(sideBarFBFriends!=null){GG.ajax({type:"GET",url:String.format("/services/rendercontrol.ashx"),data:{t:'snf',fids:result+","},dataType:"html",success:function(html){sideBarFBFriends.innerHTML=html;
GG.parseFBML();
}});
}}});
});
};
var GG_SN_bioFieldIDs;
GG.SN.setBioFields=function(){GG.SN.ensureInit(function(){var user=FB.Facebook.apiClient.get_session()?FB.Facebook.apiClient.get_session().uid:null;
var api=FB.Facebook.apiClient;
FB.Facebook.apiClient.fql_query("SELECT interests,quotes,about_me,current_location FROM user WHERE uid="+user,function(result,ex){if(result.length>0){if(result[0].interests)$get(txtInterests).value=result[0].interests;
if(result[0].about_me)$get(txtAboutYou).value=result[0].about_me;
if(result[0].quotes)$get(txtQuote).value=result[0].quotes;
if(result[0].current_location.city&&result[0].current_location.state)$get(txtLocation).value=result[0].current_location.city+', '+result[0].current_location.state;
if(result[0].current_location.zip)$get(txtZipCode).value=result[0].current_location.zip;
}});
});
};
var GG_SN_regFieldIDs;
GG.SN.setupNewUser=function(){GG.SN.ensureInit(function(){var user=FB.Facebook.apiClient.get_session()?FB.Facebook.apiClient.get_session().uid:null;
var api=FB.Facebook.apiClient;
FB.Facebook.apiClient.fql_query("SELECT name,birthday,sex,current_location,proxied_email,pic,pic_small,pic_big,pic_square,interests FROM user WHERE uid="+user,function(result,ex){if(result.length>0){if(result[0].name&&$get(txtDisplayName).value=='')$get(txtDisplayName).value=result[0].name;
if(result[0].sex&&result[0].sex=='male'){$get(maleGender).checked=true;
}else if(result[0].sex&&result[0].sex=='female'){$get(femaleGender).checked=true;
}else {$get("GenderDiv").style.backgroundColor="#CCEECC";
$get("GenderRequiredDiv").style.display="block";
$get("GenderRequiredDiv").style.paddingTop="10px";
$get("GenderRequiredDiv").style.paddingBottom="10px";
}if(result[0].current_location.city&&result[0].current_location.state)$get(txtLocation).value=result[0].current_location.city+', '+result[0].current_location.state;
if(result[0].current_location.zip)$get(txtZipCode).value=result[0].current_location.zip;
if(result[0].current_location.country){$get(country).selectedIndex=1;
}$get(txtEmailAddress).value=result[0].proxied_email;
if(result[0].birthday){var dateElements=result[0].birthday.split(" ");
if(dateElements){if(dateElements.length==2){GG.SN.setDropDownElement($get(ddlMonth),dateElements[0]);
GG.SN.setDropDownElement($get(ddlDay),dateElements[1]);
$get("DoBDiv").style.background="#CCEECC";
$get("DoBRequiredDiv").style.display="block";
$get("DoBRequiredDiv").style.paddingTop="10px";
$get("DoBRequiredDiv").style.paddingBottom="10px";
}else if(dateElements.length==3){GG.SN.setDropDownElement($get(ddlMonth),dateElements[0]);
GG.SN.setDropDownElement($get(ddlDay),dateElements[1].replace(",",""));
GG.SN.setDropDownElement($get(ddlYear),dateElements[2]);
}else {$get("DoBDiv").style.background="#CCEECC";
$get("DoBRequiredDiv").style.display="block";
$get("DoBRequiredDiv").style.paddingTop="10px";
$get("DoBRequiredDiv").style.paddingBottom="10px";
}}}$get(fbpic).value=result[0].pic;
$get(fbpic_small).value=result[0].pic_small;
$get(fbpic_big).value=result[0].pic_big;
$get(fbpic_square).value=result[0].pic_square;
$get(fbinterests).value=result[0].interests;
}});
});
};
GG.SN.setDropDownElement=function(documentElement,valueToSelect){for(var i=0;i<documentElement.options.length-1;i++){if(documentElement.options[i].value==valueToSelect){documentElement.options[i].selected=true;
return;
}}};
GG.SN.getUserPictureUrl=function(){GG.SN.ensureInit(function(){var user=FB.Facebook.apiClient.get_session()?FB.Facebook.apiClient.get_session().uid:null;
FB.Facebook.apiClient.fql_query("SELECT pic FROM user WHERE uid="+user,function(result,ex){if(result.length>0){document.getElementById("GG_SN_UserAvatar").src=result[0].pic;
}});
});
};
GG.SN.setWebAddress=function(control,text){control.value=text.replace(/[^a-zA-Z0-9]/g,'').toLowerCase();
};
var GG_SN_currentUserDisplayName="";
GG.SN.getUserDisplayName=function(callback){GG.SN.ensureInit(function(){var user=FB.Facebook.apiClient.get_session()?FB.Facebook.apiClient.get_session().uid:null;
FB.Facebook.apiClient.fql_query("SELECT name FROM user WHERE uid="+user,function(result,ex){if(result.length>0){GG_SN_currentUserDisplayName=result[0].name;
}callback();
});
});
};
GG.SN.showFeedCheckbox=function(){GG.SN.ensureInit(function(){FB.Connect.get_status().waitUntilReady(function(status){if(status!=FB.ConnectState.userNotLoggedIn){checkbox=ge('publish_fb_checkbox');
if(checkbox){checkbox.style.visibility="visible";
}}});
});
};
GG.SN.ensureInit=function(callback){if(GG_SN_FB_isInitialized){callback();
}else {FB_RequireFeatures(["XFBML"],function(){FB.FBDebug.LogLevel=4;
FB.Facebook.init(GG_SN_FB_apiKey,"/Pages/Auth/Connect/xd_receiver.htm");
GG_SN_FB_isInitialized=true;
callback();
});
}};
GG.SN.sessionIsReady=function(redirectToReturnUrl){var rid=FB.Facebook.apiClient.get_session()?FB.Facebook.apiClient.get_session().uid:null;
if(!rid){return;
}GG.ajax({type:"GET",url:"/services/json/Social.ashx",data:{t:'ifr',rid:rid},dataType:"json",success:function(success){if(success){GG.SN.logUserIn(redirectToReturnUrl);
}else {GG.SN.getUserDisplayName(function(){var returnUrl=GG.getQueryString("ReturnUrl");
var url="/Pages/Profile/Private/Registration.aspx?fbuid="+rid+"&displayName="+GG_SN_currentUserDisplayName+"&ReturnUrl="+escape(returnUrl);
window.location=url;
});
}}});
};
GG.SN.logUserIn=function(redirectToReturnUrl){GG.SN.ensureInit(function(){var rid=FB.Facebook.apiClient.get_session()?FB.Facebook.apiClient.get_session().uid:null;
GG.ajax({type:"GET",url:"/services/json/Social.ashx",data:{t:'l',rid:rid},dataType:"json",success:function(success){if(success){var returnUrl=GG.getQueryString("ReturnUrl");
if(returnUrl==""||returnUrl==null){window.location="/";
}else {window.location=unescape(returnUrl);
}}else {window.location="/";
}}});
});
};
GG.SN.logUserOut=function(url){if(url!=null){if(FB.Facebook.apiClient.get_session()){FB.Connect.logout(function(){window.location=url;
});
}else {window.location=url;
}}else {if(FB.Facebook.apiClient.get_session()){FB.Connect.logout();
}}};
GG.SN.promptPermission=function(permission){GG.SN.ensureInit(function(){FB.Connect.showPermissionDialog(permission);
});
};
GG.SN.linkAccount=function(){GG.SN.ensureInit(function(){FB.Connect.get_status().waitUntilReady(function(status){GG.SN.linkAccountCallback();
});
});
};
GG.SN.linkAccountCallback=function(){var remoteUserID=FB.Facebook.apiClient.get_session()?FB.Facebook.apiClient.get_session().uid:null;
if(remoteUserID){GG.ajax({type:"GET",url:"/services/json/Social.ashx",data:{t:'glu',rid:remoteUserID},dataType:"json",success:function(url){window.location.href=url;
}});
}else {setTimeout(arguments.callee,100);
}};
GG.SN.assertProperLogin =function(){try{if(FB.Facebook.apiClient.get_session()==null)GG.CurrentUser.logout();
}catch(e){setTimeout(arguments.callee,50);
}};
GG.SN.registerClass("GG.SN",null);
Type.registerNamespace("GG");
GG.SN.Myspace=function(options){this.options=options;
GG.SN.Myspace.Instance=this;
};
GG.SN.Myspace.Show=function(control){var instance=GG.SN.Myspace.Instance;
if(instance==null){var options={};
instance=new GG.SN.Myspace(options);
instance.login(control);
}return false;
};
GG.SN.Myspace.PublishSubmission=function(contentID){var callback=function(data){if(data){var t=data.Title;
var c=data.Description;
var u=data.Url;
var l=1;
var targetUrl='http://www.myspace.com/index.cfm?fuseaction=postto&'+'t='+encodeURIComponent(t)+'&c='+encodeURIComponent(c)+'&u='+encodeURIComponent(u)+'&l='+l;
window.open(targetUrl);
}};
GG.ajax({type:"GET",url:"/services/json/Social.ashx",data:{t:'gc',cid:contentID},dataType:"json",success:function(data){if(data){callback(data);
}}});
};
GG.SN.Myspace.prototype={login :function(control){var returnUrl=GG.getQueryString("ReturnUrl");
var callback=function(url){var xOffset=(screen.width-580)/2;
var yOffset=(screen.height-410)/2;
var options=[];
options.push("width=580,");
options.push("height=410,");
options.push("left="+xOffset+",");
options.push("top="+yOffset);
window.open(url,'myspace_val',options.join(""));
};
}};
GG.SN.Myspace.registerClass("GG.SN.Myspace");
Sys.Application.notifyScriptLoaded();