<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'APPID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
});
FB.api({ method: 'fql.query', query: 'SELECT uid FROM page_fan WHERE uid=UID AND page_id=PAGEID' },
function(result) {
if (result.length){
//is fan
}
else {
//is not fan
}
})