// DOM Ready
$(function() {


		// For use within normal web clients 
		var isiPad = navigator.userAgent.match(/iPad/i) != null;
		
		// For use within iPad developer UIWebView
		// Thanks to Andrew Hedges!
		var ua = navigator.userAgent;
		var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua);


		var $el, leftPos, newWidth;
        $mainNav2 = $("#example-two");
  
    
    /*
        EXAMPLE TWO
    */
   
    
    $mainNav2.append("<li id='magic-line-two'></li>");
    
    var $magicLineTwo = $("#magic-line-two");
    
    $magicLineTwo
        .width($(".current_page_item_two").width())
        .height($mainNav2.height())
        .css("left", $(".current_page_item_two a").position().left)
        .data("origLeft", $(".current_page_item_two a").position().left)
        .data("origWidth", $magicLineTwo.width())
        .data("origColor", $(".current_page_item_two a").attr("rel"));
             
    $("#example-two a").live('mouseenter',function() {
        $el = $(this);
        leftPos = $el.position().left;
        newWidth = $el.parent().width();
        $magicLineTwo.stop().animate({
            left: leftPos,
            width: newWidth,
            backgroundColor: $el.attr("rel")
        });});
		
    $("#example-two a").live('mouseleave', function() {
		if($(this).parent().attr('class') == 'current_page_item_two'){
			$magicLineTwo
				  .width($(".current_page_item_two").width())
				  .height($mainNav2.height())
				  .css("left", $(".current_page_item_two a").position().left)
				  .data("origLeft", $(".current_page_item_two a").position().left)
				  .data("origWidth", $magicLineTwo.width())
				  .data("origColor", $(".current_page_item_two a").attr("rel"));
			
		}else{
			$magicLineTwo.stop().animate({
				left: $magicLineTwo.data("origLeft"),
				width: $magicLineTwo.data("origWidth"),
				backgroundColor: $magicLineTwo.data("origColor")
			});
		}//else
		});
    
	
    /* Kick IE into gear */
    $(".current_page_item_two a").mouseenter();
    
});
