/* ===========================================================================
 * SCHEDULE THE BEHAVIOURS
 * =========================================================================== 
 */

var numBannerImages=3; 

 
/*
attachEventListener(window, "resize", resizePage, false);
attachEventListener(window, "load", initPage, false);
attachEventListener(window, "unload", unloadPage, false);

function initPage() 
{	
	initLinks();
	initMenu();
	initIndexLists();
}

function resizePage()
{

}

function unloadPage() 
{

}
*/


$(window).resize(function()
{
});

$(window).unload(function()
{
});

$(document).ready(function()
{
	initLinks();
	initMenu();
	initIndexLists();
});




function initLinks()
{
	if (!document.getElementsByTagName) 
 		return;
 		
 	var b = document.getElementsByTagName("body");
 	theBody = b[0];
 	if(theBody.className.match("popup"))
 	{
	 	is_popup=true;
 		 window.focus();
	}
 
 	var anchors = document.getElementsByTagName("a");
 	for (var i=0; i<anchors.length; i++) 
 	{
   		var anchor = anchors[i];
   		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
   		{
     		anchor.target = "_blank";
 		}	
     	else if (anchor.className.match("print")) 
     	{
        	anchor.onclick = function() 
        	{
          		printPage();
          		return false;
        	};
    	}
    	else if (anchor.className.match("window")) 
     	{
        	anchor.onclick = function() 
        	{
          		popUp(this.getAttribute("href"));
          		return false;
        	};
    	}
    	else if (anchor.className.match("file")) 
     	{
        	anchor.onclick = function() 
        	{
          		window.open(this.getAttribute("href"));
          		return false;
        	};
    	}
    	else if (anchor.className.match("close")) 
     	{
        	anchor.onclick = function() 
        	{
          		window.close();
          		return false;
        	};
    	}
 	}
}



function initMenu() 
{
	var nav = document.getElementById("navigation");
	
	if(nav != null)
	{
		var listItems = nav.getElementsByTagName("li");
	
		for (var i=0; i<listItems.length; i++) 
		{
			listItems[i].onmouseover=function() 
			{
				if(this.className == "")
					this.className="hover";
				else
					this.className+=" hover";
			}
			
			listItems[i].onmouseout=function() 
			{
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
				this.className=this.className.replace(new RegExp("hover\\b"), "");
			}
			
			listItems[i].onfocus=function() 
			{
				if(this.className == "")
					this.className="hover";
				else
					this.className+=" hover";
			}
			
			listItems[i].onblur=function() 
			{
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
				this.className=this.className.replace(new RegExp("hover\\b"), "");
			}
		}
	}
}




function initIndexLists()
{
	var divs = document.getElementsByTagName("div");
	
	for (var j = 0; j < divs.length; j++)
	{
		if(divs[j].className.match("index"))
		{
			var listItems = divs[j].getElementsByTagName("li");
	
			for (var i=0; i<listItems.length; i++) 
			{
				var linkItems = listItems[i].getElementsByTagName("a");
				
				linkItems[0].onmouseover=function() 
				{
					if(this.parentNode.className == "")
						this.parentNode.className="hover";
					else
						this.parentNode.className+=" hover";
				}
				
				linkItems[0].onmouseout=function() 
				{
					this.parentNode.className=this.parentNode.className.replace(new RegExp(" hover\\b"), "");
					this.parentNode.className=this.parentNode.className.replace(new RegExp("hover\\b"), "");
				}
				
				linkItems[0].onfocus=function() 
				{
					if(this.parentNode.className == "")
						this.parentNode.className="hover";
					else
						this.parentNode.className+=" hover";
				}
				
				linkItems[0].onblur=function() 
				{
					this.parentNode.className=this.parentNode.className.replace(new RegExp(" hover\\b"), "");
					this.parentNode.className=this.parentNode.className.replace(new RegExp("hover\\b"), "");
				}
			}
		}
	}
	
	return true;
};



function printPage() 
{
  	if (window.print)
		window.print()
	else
		alert("Sorry, your browser doesn't support the print feature. Use the File menu on your browser to select Print.");
}




$(document).ready(function()
{
	$(".slideshow div.content-image:first").addClass("active");
	$("div.slideshow div.caption").hide();
	
	
	$("div.slideshow div.content-image").mouseenter(
		function () 
		{
			if ($(this).children("div.caption").is(":hidden")) 
			{
				$(this).children("div.caption").slideDown("fast");
			} 
		}
	);
	
	$("div.slideshow div.content-image").mouseleave(
		function () 
		{
			if ($(this).children("div.caption").not(":hidden")) 
			{
				$(this).children("div.caption").slideUp("fast");
			}
		}
	);
});




/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('.slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('.slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('.slideshow DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');
    
    

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 4000 );
});


