
<!-- Facebook login -->

var loginLocation = null;
var baseUrl = "http://www.savanna.co.za/";

function setBaseUrl( location ) {
  baseUrl = location;
}


function facebook_onlogin( location ){
   loginLocation = location;
   FB.Connect.showPermissionDialog(
   'publish_stream,read_stream,user_photos',
    function(accepted) { window.location = baseUrl; } );
}

function logout( location ){
  FB.Connect.logoutAndRedirect( location );
}

function showLoggedInUser(){
    var user_box = document.getElementById("fb-user-info");
  user_box.innerHTML =

 "<p><fb:profile-pic uid = 'loggedinuser' facebook-logo='true'></fb:profile-pic></p>"
  +"<p>Welcome, <fb:name uid = 'loggedinuser' useyou='false'></fb:name>.</p>"
  +"<p>You are logged in with your Facebook account.</p>";
  
  FB.XFBML.Host.parseDomTree();
}

    $(function(){
            $('a[href*=#]').click(function() {
            if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
                    && location.hostname == this.hostname) {
                            var $target = $(this.hash);
                            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
                            if ($target.length) {
                                    var targetOffset = $target.offset().top;
                                    $('html,body').animate({scrollTop: targetOffset}, 1000);
                                    return false;
                            }
                    }
            });
    });
    
    
    $(document).ready(function(){
         
        $('.toggleField').each( function() {
            if ( $(this).val() == "" )
            {
              $(this).val($(this).attr("title"));
            }
        });
        
        $('.toggleField').focus(function(){
            if ( $(this).val() == $(this).attr("title") )
            {
              $(this).val("");
            }
        })
        .blur(function(){
          if ( $(this).val() == "" )
          {
            $(this).val($(this).attr("title"));
          }
        });
        
        $("#updateProfile").submit(function() { 
          $('.toggleField').each( function() {
           if ( $(this).val() == $(this).attr("title") )
            {
              $(this).val("");
            }
          });
          return true; 
        });

    });
