// apostropheReady is called at domReady
// it hooks into the a_js javascript framework
// it can be used for progressive enhancements at runtime
// such as Cufon text replacement

function doNav(el, source)
{
    $(el).hover(
        function(){ // Change the input image's source when we "roll on"
            $(this).attr({ hover : $(this).attr('src') });
            $(this).attr({ src : source});
        },
        function(){ // Change the input image's source back to the default on "roll off"
            $(this).attr({ src : $(this).attr('hover') });
        }
    )
}

function apostropheReady()
{
	// top navigation enhancements 
	/*$(".a-nav-main .a-nav-item").hover(function(e){
		e.preventDefault();
		$(this).stop().animate({ 
	    backgroundColor: "#ccc"
	  }, 125 );
	},function(e){
		e.preventDefault();
		$(this).stop().animate({ 
	    backgroundColor: "#efefef"
	  }, 250 );		
	});*/
    
    doNav('#a-button-1-home-col_1-2 li a img', '/images/button-online-support-over.png');
    doNav('#a-button-1-home-col_2-2 li a img', '/images/button-website-design-over.png');
    doNav('#a-button-1-home-col_3-2 li a img', '/images/button-web-marketing-over.png');
    doNav('#a-button-1-home-col_4-2 li a img', '/images/button-ecommerce-over.png');
    
    doNav('#a-button-1-home-col_1-3 li a img', '/images/button-readmore-over.png');
    doNav('#a-button-1-home-col_2-4 li a img', '/images/button-readmore-over.png');
    doNav('#a-button-1-home-col_3-4 li a img', '/images/button-readmore-over.png');
    doNav('#a-button-1-home-col_4-4 li a img', '/images/button-readmore-over.png');
    
    doNav('#a-button-1-home-link_3-1 li a img', '/images/button-quick-quote-over.png');
    doNav('#a-button-1-home-link_2-1 li a img', '/images/button-about-mediatopia-over.png');
    doNav('#a-button-1-home-link_1-1 li a img', '/images/button-contact-us-over.png');
        
    $('#mt-tabs_1 > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
    $('#mt-tabs_2 > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } }); 
    $('#mt-tabs_3 > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } }); 
    $('#mt-tabs_4 > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } }); 
    
    $('.a-nav-item:not(.a-current-page):not(.ancestor) ul').hide();    
    $('.a-nav-item:not(.a-current-page):not(.ancestor)').hover(function(){
        var height = 36*$('ul > li', this).size();
        $('ul', this).stop(false, false).animate({height:height,opacity:1},{queue:false, duration:600, easing: 'easeOutBounce'}).show();
    }, function(){
        $('ul', this).stop(false, false).animate({height:0,opacity:0.5},{queue:false, duration:600, easing: 'easeOutBounce', complete: function() { $(this).hide() } });
    });
    
    $("div.panel_button").click(function(){
		$("div#panel").animate({
			height: "300px"
		})
		.animate({
			height: "250px"
		}, "fast");
		$("div.panel_button").toggle();
	});	
	
   $("div#hide_button").click(function(){
		$("div#panel").animate({
			height: "0px"
		}, "fast");
   });
    
    if($("div.home-readmore-toggle").length > 0) {
        $("div.a-area-mt-home-readmore").hide();
    }
    
    $("div.home-readmore-toggle").click(function(){
        $("div.a-area-mt-home-readmore").slideDown();
        //$(this).slideUp();
        $(this).remove();
        return false;
    });

}


