//jQuery Plugin: Drop Shadow Text
// call like this: $(element).textDropShadow();
(function($) {
 $.fn.textDropShadow = function(){
	 $(this).html('<span><span class="jq-shadow">'+$(this).html()+'</span><span>'+$(this).html()+'</span></span>');
	 return $(this);
 }
})(jQuery);



// Swap images function
function swapImages(){
  var $active = $('#image-container .active');
  var $next = ($('#image-container .active').next().length > 0) ? $('#image-container .active').next() : $('#image-container img:first');
$active.fadeIn(function(){
	$active.fadeOut(2000).removeClass('active');    
    $next.fadeIn(2000).addClass('active');

  });
}


// Swap images function
function swapImages2(){
  var $active = $('#image-container .active');
  var $next = $('#image-container .active');
$active.fadeIn(function(){
$active.removeClass('active'); 	   
    $next.fadeIn('fast').addClass('active');


  });
}



$(document).ready(function(){


// Run our swapImages() function every 5secs
swapImages2();
setInterval('swapImages()', 10000);



if(window.location.pathname.indexOf("/newsletters") < 0)
{
	$('#content table tr:odd').addClass('odd');
	$('#content table tr:even').addClass('even');
	$('#content table tr:eq(0)').removeClass('even').addClass('header');
}


// other Galleria stuff



$(".gallery-link").click(function () {
      $("#galleria-box").fadeIn('slow');
      $("#overlay").fadeIn('slow');
      $("#overlay").fadeTo('fast', 0.80);  
      return false;
    });
    
    

 $("div.image-box a").click(function () {
      // get index number of clicked right col thumbnail
      var gal_index = $("div.image-box a").index(this);
      
      // perform click event on galleria thumbnail using this index number     
	 $('ul.gallery li:eq(' + gal_index + ') img').click(); 
    });
       

$("ul.gallery").before("<div id='overlay'><!-- --></div>");
$("ul.gallery").wrap("<div id='galleria-box'></div>");
$("ul.gallery").after('<p><a class="gallery-back" href="#"><img src="/images/back-button-2.gif" width="64" height="16" alt="go back" /></a></p>');
$("ul.gallery").after('<p class="nav"><a class="prev" href="#" onclick="$.galleria.prev(); return false;">previous</a><a class="next" href="#" onclick="$.galleria.next(); return false;">next</a></p>');

$(".gallery-back").click(function () {
      $("#galleria-box").fadeOut('slow');
      $("#overlay").fadeOut('slow'); 
      return false;
    });





// These add .iehover classes to overcome the lack of :hover support in IE6


	$("#top-nav li").each(function(){
	 	$(this).hover(function() {	
	 		$(this).addClass('iehover');
	    	}, function() { 
	      	$(this).removeClass('iehover');  	
	      	});
	 });
	
	
	
	$("#login").hover(function() {	
			$(this).addClass('iehover');
		}, function() { 
	  	$(this).removeClass('iehover');  	
	});

	

// Vertical menu stuff


/*	var $the_a = $('#sub-nav ul').prev();
	var $all_as = $('#sub-nav a');
	var $all_uls = $('#sub-nav ul');

	$all_uls.addClass('closed'); // Without JS, all submenus are open for accessibility. This closes them.

	 $the_a.toggle(function(){ 	
     	$all_as.removeClass('open');		
		$(this).addClass('open');
		
		$all_uls.removeClass('open');
		$(this).next().addClass('open');
     
   		},function(){
   	
     	$all_as.removeClass('open');
		$all_uls.removeClass('open'); 
   });*/
    	

// Indent text effect

	$("#top-nav>li>a").each(function(){
	 	$(this).textDropShadow();
	 });
	 
	 $("#login p").each(function(){
	 	$(this).textDropShadow();
	 });


	if($.browser.msie){
     $("#top-nav a span span.jq-shadow").css("top","0px"); // IE seems to think 0 = 1
     $("#search-login-form #login p span span.jq-shadow").css("top","3px");
  	}


// .png fix

 //var blank = new Image();
 //blank.src = '/images/blank.gif';
 
 $(document).ready(function() {
   var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
   if (badBrowser) {
     // get all pngs on page
     $('img[src$=.png]').each(function() {
       if (!this.complete) {
         this.onload = function() { fixPng(this) };
       } else {
         fixPng(this);
       }
     });
   }
 });
 
 function fixPng(png) {
   // get src
   var src = png.src;
   // set width and height
   if (!png.style.width) { png.style.width = $(png).width(); }
   if (!png.style.height) { png.style.height = $(png).height(); }
   // replace by blank image
   png.onload = function() { };
   png.src = '/images/blank.gif'; //blank.src;
   // set filter (display original image)
   png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
 }











});

