function detect_device() {
    if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
        return 'iPhone';
    }
    
    if(navigator.userAgent.match(/iPad/i)) {
        return 'iPad';
    }
    
    return 'computer';
}

function isIDevice() {
    return detect_device()=='iPad' || detect_device()=='iPhone';
}

$(document).ready(function(){
    if(!isIDevice()) {
    	/* Do the bubble dance */
    	$(".bubble").hoverIntent(function() {
    		var bpos = $(this).offset();
    		var bsize = $(this).width();
    		var btype = $(this).attr("rel");
    		$(this).after('<img src="/images/'+btype+'.png" class="tip" style="left:'+(bpos.left + bsize)+'px;top:'+(bpos.top - 42)+'px">');
		
    		$(this).next("img").stop(true, true).animate({opacity: "show", marginTop: 10}, "slow");
    	}, function() {
    		$(this).next("img").animate({opacity: "hide", marginTop: 0}, "fast", function(){ $(this).remove(); });
    	});
	
    	$(".bubble").click(function() { 
    		$(this).next("img").animate({opacity: "hide", marginTop: 0}, "fast");
    	});
    }
	
	
    /* Index card */
	$(".indexcard div").equalHeight();
	
	$(".indexcard").each(function() {
		$(this).append('<p class="info">click icon or links for details <img src="/images/info.png"></p>');
	});
	
	
    /* Sidebar back links */
	var navLinkToHighlight = $("#nav-bloghome").length ? "#nav-bloghome" : "#nav-home";

    $("h1 a").hover(function() {
      $(navLinkToHighlight).addClass('hover');
    }, function() {
      $(navLinkToHighlight).removeClass('hover');
    });


    /* Search */
    $('.search').typeSearch();        	
});
