// JavaScript Document
$(document).ready(function () {
    if ($("body.L0_Home").length > 0) {


/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:0,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);

/* asfdasfdasfd */

/*
        $("#ctagrid .container").hoverIntent(function () {
            $('img.a', this).fadeOut('fast')
        }, function () {
            $('img.a', this).show()
        });
*/

	function showpane(){ $('img.a', this).fadeOut('fast');}
	function hidepane(){ $('img.a', this).fadeIn('fast');}
	var config = {    
		 over: showpane, // function = onMouseOver callback (REQUIRED)    
		 timeout: 5, // number = milliseconds delay before onMouseOut    
		 out: hidepane // function = onMouseOut callback (REQUIRED)    

	};
	$("#ctagrid .container").hoverIntent( config );
    // scrollable on the homepage
	$("#homescroll").scrollable({circular: true}).autoscroll({interval:8000, autoplay: true }).navigator({
	// ul.tabs now functions as our navigator
	navi:'ul.tabs'
});

/* occasionally does not load so it's causing an issue */
//function hasBorderRadius() {
//
//  var d = document.createElement("div").style;
//
//  if (typeof d.borderRadius !== "undefined") return true;
//
//  if (typeof d.WebkitBorderRadius !== "undefined") return true;
//
//  if (typeof d.MozBorderRadius !== "undefined") return true;
//
//  return false;
//
//};
//
//if (hasBorderRadius()) { // 1
//
//  $("img.roundedCorners").each(function() { // 2
//
//    $(this).wrap('<div class="roundedCorners" />'); // 3
//
//    var imgSrc = $(this).attr("src"); // 4
//
//    var imgHeight = $(this).height(); // 4
//
//    var imgWidth = $(this).width(); // 4
//
//    $(this).parent()
//
//      .css("background-image", "url(" + imgSrc + ")")
//
//      .css("background-repeat","no-repeat")
//
//      .css("height", imgHeight + "px")
//
//      .css("width", imgWidth + "px"); // 5
//
//    $(this).remove(); // 6
//
//  });
//
//}

  }


    if ($("div.storiespage").length > 0) {

        $("#slider").easySlider({
            auto: false,
            prevText: '&laquo; Previous Story',
            nextText: 'Next Story &raquo;',
            controlsBefore: '<p class="pager">',
            controlsAfter: '</p>',
            speed: 400,
            pause: 4000,
            numeric: false,
            continuous: false
        });
        $("#slider2").easySlider({
            auto: false,
            prevText: '&laquo; Previous Story',
            prevId: 'prevBtn2',
            nextText: 'Next Story &raquo;',
            nextId: 'nextBtn2',
            controlsBefore: '<p class="pager">',
            controlsAfter: '</p>',
            speed: 400,
            pause: 4000,
            numeric: false,
            continuous: false
        });
        $("#slider3").easySlider({
            auto: false,
            prevText: '&laquo; Previous Story',
            prevId: 'prevBtn3',
            nextText: 'Next Story &raquo;',
            nextId: 'nextBtn3',
            controlsBefore: '<p class="pager">',
            controlsAfter: '</p>',
            speed: 400,
            pause: 4000,
            numeric: false,
            continuous: false
        });
    }


});
