// JavaScript Document

$(document).ready(function() {

$("a.fancy").fancybox();

$("a.iframe").fancybox({width: 720, height: 525 ,overlayOpacity: .7, overlayColor: '#000'});

$("a.youtube").click(function() {
	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});

$(function() {
$(".swapper").hover(
function () {
$(this).attr("src", $(this).attr("src").replace(/-off.png/, "-on.png"));
},
function () {
$(this).attr("src", $(this).attr("src").replace(/-on.png/, "-off.png"));
} 
);
});

//home page quote rotation
$('.da-quote').cycle({
		fx: 'fade',
	   timeout: 5000
	});
	
// home page pods
var how_tall = $(".pod-text").height();
//alert(how_tall);
$(".pod-text").css("height",34);
$(".pod-text").css("overflow","hidden");
$('.arrow-down').click(function(){
	//$(this).closest('div').find(".pod-text").animate({height: how_tall + "px"},{duration:300});
	$(this).closest('div').find(".pod-text").animate({height: how_tall + "px"},{duration:300});
	$(this).closest('div').find(".arrow-down").hide();
	$(this).closest('div').find(".arrow-up").show();
});

$('.arrow-up').click(function(){
	$(this).closest('div').find(".pod-text").animate({height:"33px"},{duration:500});
	$(this).closest('div').find(".arrow-up").hide();
	$(this).closest('div').find(".arrow-down").show();
});


function megaHoverOver(){
     $(this).find(".sub").stop().fadeTo('fast', 1).show();
     $(this).closest('li').addClass("hovi");
     $(this).closest('a').addClass("hovi");
	}
	
	function megaHoverOut(){ 
    $(this).closest('li').removeClass("hovi");
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide('fast'); 
	  });
	}
var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 200, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 100, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#navigate li .sub").css({'opacity':'0'});
	$("ul#navigate li").hoverIntent(config);

//loads content from clicking on resource icon (sub resources template)
$('.load-leveler').click(function(){
            $('li').removeClass("on");
			$(this).closest('li').addClass("on");
			$('#resource-block').empty().html('<img src="/templates/common/css/images/ajax-loader.gif" id="ajaxer" />');
				url = $(this).attr('href');
  			$('#resource-block').load(url);
			//alert(url);
				return false;	
			});


$('#search').submit(function(){
			$('#search-results').empty().html('<img src="/templates/common/css/images/ajax-loader.gif" id="ajaxer" />');
			var string = "";
            var match = "";
            var search_string = "";	
			string = $("#string").val();
			match = $('input:radio[name=match]:checked').val();
			search_string = string.replace(/\s/g,'+');
			$('#search-results').load("/search/index.php?string=" + search_string + "&match=" + match);
		   //alert(search_string + match);
			return false;	
			});

/*clear input boxes on focus*/
$('.clear-me').focus(function() {
    $(this).val("");
  });

$('.scroll-me').jScrollPane(		{
			verticalDragMinHeight: 20,
			verticalDragMaxHeight: 20,
			horizontalDragMinWidth: 20,
			horizontalDragMaxWidth: 20,
            verticalGutter: 20,
			horizontalGutter: 20
}
);
  
});//end whole thing




