/*

	Filename             sitewide.js
	Detail               Site functionality
	Author:              thunder::tech inc.
	License:             CLIENT is defined as the owner of online property from which this file resides or this code is referenced in.
						 ADDITIONAL PARTY is defined as anyone other than thunder::tech or CLIENT.
						 No right is granted to ADDITIONAL PARTY to sell, distribute, modify or otherwise transfer the following source code without explicit written permission by CLIENT or thunder::tech.

*/

/*  ================================
     Sitewide JavaScript
    ================================ */

thunder.client.project.pageLoaded = function()
{
	//thunder.client.modify.rollImages();
	//thunder.client.modify.linkOptions();
	//thunder.client.modify.tabSet();
	//thunder.client.modify.treeMenu();
	//thunder.client.modify.selfLabelFields();
	//thunder.client.modify.requireFields();
	//thunder.client.workarounds.alphaImages();
}

$(thunder.client.project.pageLoaded);

function navOn(temp, temp2) {	
	//safe function to show an element with a specified id
	var x=temp.getElementsByTagName('ul');
	if(x[0])
	{
		x[0].style.display = 'block';
	}
	x = temp.getElementsByTagName('a');
	if(x[0])
	{
		x[0].className = temp2;
	}
	x = temp.getElementsByTagName('img');
	if(x[1])
	{
		x[0].src = "images/navoverleft.gif";
		x[1].src = "images/navoverright.gif";
	}
}

function navOff(temp, temp2) {
	var x=temp.getElementsByTagName('ul');
	//safe function to hide an element with a specified id
	if(x[0])
	{
		x[0].style.display = 'none';
	}
	x = temp.getElementsByTagName('a');
	if(x[0])
	{
		x[0].className = temp2;
	}
	x = temp.getElementsByTagName('img');
	if(x[1])
	{
		x[0].src = "images/clear.gif";
		x[1].src = "images/clear.gif";
	}
}


/*** 
    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 IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // 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() {
    if($("#slideshow")){ setInterval( "slideSwitch()", 5000 ); }
});
