/* global resources */

/* function to simply multiple functions in window.onload
* DOM Scripting (103) :: Simon Willison (http://simon.incution.com) */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}
	else {
		window.onload = function(){
			oldonload();
			func();
		}
	}
}




/* index slideshow stuff 
 * from: http://www.queness.com/post/152/simple-jquery-image-slide-show-with-semi-transparent-caption
 * requires: jQuery 1.3.2 or newer
 */
/*
$(document).ready(function() {		
	
	//Execute the slideShow
	slideShow();

});

function slideShow() {

	//Set the opacity of all images to 0
	$('#col_center div').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#col_center div:first').css({opacity: 1.0});
	
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
	
}

function gallery() {
	var promoTx = new Array ("index_main1", "index_main2", "#index_main3", "index_main4");
	
	var promoImg = new Array ("left_1", "left_2", "index_3", "index_4");
	
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#col_center div.visible')?  $('#col_center div.visible') : $('#col_center div:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('hidden'))? $('#col_center div:first') :current.next()) : $('#col_center div:first'));	
	
	//Get next image caption
	//var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('visible')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('visible');
	
	//Set the opacity to 0 and height to 1px
	/*$('#col_center .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#col_center .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );
	
	//Display the content
	$('#col_center .content').html(caption);
		
}
*/









/* site specific */


/*
 * for swapping the content using the buttons on the index page.
 * t1 = the <div> containing the text
 * t2 = the background image on the left side
 */
function btn_indexSwap(t1, t2){
	// swap text content
	document.getElementById("index_main1").className = "hidden";
	document.getElementById("index_main2").className = "hidden";
	document.getElementById("index_main3").className = "hidden";
	document.getElementById("index_main4").className = "hidden";
	document.getElementById(t1).className = "visible";
	
	// change image
	document.getElementById("left_1").className = "hidden";
	document.getElementById("left_2").className = "hidden";
	document.getElementById("left_3").className = "hidden";
	document.getElementById("left_4").className = "hidden";
	document.getElementById(t2).className = "visible";
	
	
	
	// update nav button color
	var swapNavLinks = document.getElementById("center_switch").getElementsByTagName("a");
	for (var i=0; i<swapNavLinks.length; i++){
		if((t1.substr(-1, 1)) == (i + 1)){
			swapNavLinks[i].firstChild.src = "images/index/rotator_button_on.png";
		}
		else {
		swapNavLinks[i].firstChild.src = "images/index/rotator_button_off.png";
		}
	}
}



function slideshow(){
	
	
	
	
	
	
}



function prep_navRollovers(){
	if(!document.getElementsByTagName || !document.getElementById){
		return false;
	}
	if(document.getElementById("mainNav")){
		var mainNav = document.getElementById("mainNav");
		var navItems = mainNav.getElementsByTagName("a");
		//alert(navItems[1].firstChild.src);
		for (var i=0; i<navItems.length; i++){
			
				navItems[i].onmouseover = function(){
					//alert("this is the foo");
					this.firstChild.src = this.firstChild.src.substring(0, this.firstChild.src.indexOf(".")) + "_over.png";
					//alert(this.firstChild.src);
				}
				navItems[i].onmouseout = function(){
					this.firstChild.src = this.firstChild.src.substring(0, this.firstChild.src.lastIndexOf("_")) + ".png";
				}
		}
	}
}addLoadEvent(prep_navRollovers);
				
				
function prep_devInquiry(){
	if(!document.getElementsByTagName || !document.getElementById){
		return false;
	}
	var theH = document.getElementById("col_center").scrollHeight;
	//alert(theH);
}addLoadEvent(prep_devInquiry);