function login()
{
var viewer  = FB.Facebook.apiClient.fql_query
(
	"SELECT name, first_name, last_name, email_hashes, work_history  FROM user WHERE uid="+FB.Facebook.apiClient.get_session().uid, 
	function(results)
	{
		document.getElementById("m5fbrp__237").value=results[0].first_name;
		document.getElementById("m5fbrp__254").value=results[0].last_name; 
		document.getElementById("m5fbrp__239").value=results[0].work_history[0].company_name;
		document.getElementById("m5fbrp__238").value=results[0].work_history[0].position;
		var inputs = document.getElementsByTagName("input");
		for (i=0; i<inputs.length; i++)
		{
			if (inputs[i].id.indexOf("m5fbrp")!=-1)
			{
				if (inputs[i].value == "")
				{
					inputs[i].style.backgroundColor="#EC120B";
					inputs[i].style.backgroundImage="none";
				}
			}
		}
	}
); 
}

function fb_init()

{
	// Do not forget to change application ID to CIPS's ID!!!
	FB.init("1dbb17683e7ad1a2dbb8e0cebf7afc91", "/xd_receiver.htm");
	document.getElementById("facebook").style.display="block";
}

function get_facebook_id()
{
	uid = FB.Facebook.apiClient.get_session().uid;
//  session_key = FB.Facebook.apiClient.get_session().session_key;
	document.getElementById("facebook2").value=uid;
//	set_cookie ('uid', uid, null, null, null, '/', window.location.host, null);
//	set_cookie ('session_key', session_key);

}


function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure )
{
  var cookie_string = name + "=" + escape ( value );

  if ( exp_y )
  {
    var expires = new Date ( exp_y, exp_m, exp_d );
    cookie_string += "; expires=" + expires.toGMTString();
  }

  if ( path )
        cookie_string += "; path=" + escape ( path );

  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  
  if ( secure )
        cookie_string += "; secure";
  
  document.cookie = cookie_string;
}
