function twitterCallback(o) {
	o = o[0]; // o is always an array, so just get the first (and only entry)
	var e = document.getElementById('twitter-post');
	e.innerHTML = o.text;
	e.href = 'http://twitter.com/MikaelanTS/status/' + o.id;
}

$(document).ready(function() {

$('div.accordion> div').hide();  
  $('div.accordion> h3').click(function() {
    var $thisHeading = $(this);
    var $nextDiv = $(this).next();
    var $visibleSiblings = $nextDiv.siblings('div:visible');
    if ($visibleSiblings.length ) {
      $visibleSiblings.slideUp(1000, function() {
        $nextDiv.slideToggle(1000).removeClass("selected");
	    $.scrollTo($thisHeading,1000, {offset:-10} );
      });
    } else {
      $nextDiv.slideToggle(1000).addClass("selected");
	  $.scrollTo($thisHeading,1000, {offset:-10} );
    }
  });

$("#email").blur(function()
{
 //remove all the class add the messagebox classes and start fading
 $("#alert-box").removeClass().addClass('messagebox').html('Validating&hellip;').fadeIn("slow");
 //check the email exists or not from ajax
 $.post("/validate-email.php",{ email:$(this).val() } ,function(data)
 {
  if(data=='no') //if email not avaiable
  {
   $("#alert-box").fadeTo(200,0.1,function() //start fading the messagebox
   {
    //add message and change the class of the box and start fading
    $(this).html('').addClass('alert').fadeTo(900,1);
   });
  }
  else
  {
   $("#alert-box").fadeTo(200,0.1,function()  //start fading the messagebox
   {
    //add message and change the class of the box and start fading
    $(this).html('').addClass('boxok').fadeTo(900,1);
   });
  }
 });
});

$(".filled").focus(function() {
	if( this.value == this.defaultValue ) {
		this.value = "";
	}
  }).blur(function() {
	if( !this.value.length ) {
		this.value = this.defaultValue;
	}
  });

$('a.nudge').hover(function() { //mouse in
    $(this).animate({ paddingLeft: '10px' }, 400);
	}, function() { //mouse out
	  $(this).animate({ paddingLeft: 0 }, 400);
  });

$('a[rel="external"]').click( function() {
    window.open( $(this).attr('href') );
    return false;
    });  

if ($.browser.msie && $.browser.version < 7) return;  

$('#navigation li')
    .removeClass('highlight')
    .find('a')
    .append('<span class="hover" />').each(function () {
      var $span = $('> span.hover', this).css('opacity', 0);
      $(this).hover(function () {
        $span.stop().fadeTo(500, 1);
      }, function () {
        $span.stop().fadeTo(1000, 0);
      });
    });

});
