jQuery.noConflict();

var api = null;
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
 
 
 function facebook_onlogin(){
	    var id = FB.Facebook.apiClient.get_session().uid;
		window.location.href= 'fb-create-account.jspa?u='+id;

}

 function update_fields(){
	
	try
	{
		FB.Facebook.apiClient.fql_query("SELECT first_name, last_name, pic FROM user WHERE uid="+FB.Facebook.apiClient.get_session().uid,
		 function(rows) {
			jQuery("#fname01").val(rows[0].first_name);
			jQuery("#lname01").val(rows[0].last_name);
			jQuery("input:hidden[name='username']").val(FB.Facebook.apiClient.get_session().uid);

		 });
	 }
	 catch(err)
	 {
		//alert(err);
		if(sPage.substring(3,0) == 'fb-') {
		window.location = "/create-account.jspa";
		}
	 }
}




jQuery(document).ready(function() {



 if(sPage == 'create-account.jspa') {
	$(document.accountform).focusFirstElement();
	FB.Facebook.init("1de659315e79f3f31a0b22743004db3d", "/themes/policy2/xd_receiver.htm", 
	{"ifUserConnected" : facebook_onlogin});
}
  


});




