//Default jQuery Easing
jQuery.easing.def = "easeOutQuart";
    
//Default Animation Parameters
var $speed = 300;
var $width_open = '79px';
var $width_closed = '24px';
var $opacities = new Array();
var nav = navigator;
var postmargin = 30;
//Mouse Enter Event Handler Definition
function me_handler(event) {
    var $this = $(this);
    $opacities[$this.index()] = $(this).css("opacity");
    var thisheight = $(this).children('.entry').height() + postmargin;
    //$(this).append(thisheight);
    $this.animate( {"opacity":1}, { queue:false, duration:$speed } )
         .animate( {"height":thisheight + 'px'}, $speed );
    $this.one('mouseleave', ml_handler);
  	};

//Mouse Leave Event Handler Definition    
function ml_handler(event) { 
    var $this = $(this);
    //$opacities[$this.index()] = $(this).css("opacity");
    var thisheight = $(this).children('.posttitle').height();

    $this.animate( {"opacity":$opacities[$this.index()]}, { queue:false, duration:$speed } )
         .animate({"height":thisheight + 'px'}, $speed,function(){
         $this.one('mouseenter', me_handler);
         });
  	};

//Initial function, setting off as soon as DOM is loaded.
$(document).ready(function(){
    if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
        $('.post').css('opacity','1');
        //$('.post').children().css('opacity','.3');
        
        //$('.post').each(function(index) {
           // var thisheight = $(this).children('.entry').children('.excerpt-link').height() + $(this).children('.posttitle').height()+ postmargin;
           // $(this).animate({"height":thisheight + 'px'}, $speed);
          //  });
        
        //$('#sidebar').append('iPhone detected <br/>');
        //$('#sidebar').append(navigator.userAgent);


    } else{
        $('.post').one('mouseenter', me_handler);
        $('#post-first').animate({"height":($('#post-first').children('.entry').children('.excerpt-link').height() + $('#post-first').children('.posttitle').height()+ postmargin) + 'px'}, $speed);
//        $('#sidebar').append(navigator.userAgent);

    }
    });
