         var fb_UserID = 0;
		 window.fbAsyncInit = function() {
                FB.init({appId: '123148921040647', status: true, cookie: true, xfbml: true});

                /* All the events registered */
                FB.Event.subscribe('auth.login', function(response) {
                    // do something with response
					login();
                });
                FB.Event.subscribe('auth.logout', function(response) {
                    // do something with response
                    logout();
                });

                FB.getLoginStatus(function(response) {
                    if (response.session) {
                        // logged in and connected user, someone you know
                        login();
                    }
                });
            };
            (function() {
                var e = document.createElement('script');
                e.type = 'text/javascript';
                e.src = document.location.protocol +
                    '//connect.facebook.net/en_US/all.js';
                e.async = true;
                document.getElementById('fb-root').appendChild(e);
            }());

            function login(){
                FB.api('/me', function(response) {
					//window.alert(response.metadata.connections.picture);
					fb_UserID	=	response.id;
					document.getElementById('login').style.display = "block";
	                document.getElementById('login').innerHTML = response.name + " succsessfully logged in!" 
					xmlhttpOpenEX("/facebook_js_login.aspx?fbid=" + response.id + "&rid=" + Math.random(),function() {});

                });
            }
            function logout(){
                document.getElementById('login').style.display = "none";
            }

            //stream publish method
            function streamPublish(name, description, hrefTitle, hrefLink, userPrompt){
                FB.ui(
                {
                    method: 'stream.publish',
                    message: '',
                    attachment: {
                        name: name,
                        caption: '',
                        description: (description),
                        href: hrefLink
                    },
                    action_links: [
                        { text: hrefTitle, href: hrefLink }
                    ],
                    user_prompt_message: userPrompt
                },
                function(response) {

                });

            }
            function showStream(){
                FB.api('/me', function(response) {
                    //console.log(response.id);
                    streamPublish(response.name, 'Greekflix.com contains geeky stuff', 'hrefTitle', 'http://www.greekflix.com', "Share www.greekflix.com");
                });
            }

            function share(){
                var share = {
                    method: 'stream.share',
                    u: 'http://www.greekflix.com/'
                };

                FB.ui(share, function(response) { console.log(response); });
            }

            function graphStreamPublish(){
                var body = 'Reading New Graph api & Javascript Base FBConnect Tutorial from www.greekflix.com';
                FB.api('/me/feed', 'post', { message: body }, function(response) {
                    if (!response || response.error) {
                        alert('Error occured');
                    } else {
                        alert('Post ID: ' + response.id);
                    }
                });
            }
					

            function fqlQuery(){
                FB.api('/me', function(response) {
                     var query = FB.Data.query('select name, hometown_location, sex, pic_square, email from user where uid={0}', response.id);
                     query.wait(function(rows) {
                       
                       document.getElementById('fbinfo').innerHTML =
                         'Your name: ' + rows[0].name + "<br />" + rows[0].email +
                         '<img src="' + rows[0].pic_square + '" alt="" />' + "<br />";
                     });
                });
            }

            function setStatus(){
                status1 = document.getElementById('status').value;
                FB.api(
                  {
                    method: 'status.set',
                    status: status1
                  },
                  function(response) {
                    if (response == 0){
                        alert('Your facebook status not updated. Give Status Update Permission.');
                    }
                    else{
                        alert('Your facebook status updated');
                    }
                  }
                );
            }
				function fbConnected() {
					  FB.getLoginStatus(function(response) {
                    if (response.session) {
                        // logged in and connected user, someone you know
					FB.api('/me?metadata=1', function(response) {
					fb_UserID	=	response.id;
					
					
						var strParams = "fbid=" + encodeURIComponent(response.id) +
					"&fbname=" + encodeURIComponent(response.name) +					
					"&fbFirstname=" + encodeURIComponent(response.first_name) + 
					"&fbLastname=" + encodeURIComponent(response.last_name) +
					"&fbEmail=" + encodeURI(response.email) +
					"&fbBirthday=" + encodeURIComponent(response.birthday) +
					"&fbHometown=" + encodeURIComponent(response.name) +
					"&fbAbout=" + encodeURIComponent(response.about) +
					"&fbWork=" + encodeURIComponent(response.work) +
					"&fbGender=" + encodeURIComponent(response.gender) +
					"&fbLocation=" + encodeURI(response.location) +
					"&fbPicture=" + encodeURIComponent(response.metadata.connections.picture)
					"&command=SUBMIT"
					xmlhttpOpenPOST("/facebook_js_memberload.aspx",strParams,myAnswer);
				
													
                        //window.alert('Welcome to Greekflix.com');

                });
					
					
						
						
                    }
                });				
			}
			
			function myAnswer(strIVText)
			{
				
				if (strIVText == "<br>Yes</br>")
				{
					window.location = 'http://www.greekflix.com/myaccount.aspx';
					
				}
				else
				{					
					jqmWindowOpen('/popup_container.aspx?url=/facebook_connect.aspx');
				}
			}