Shadowbox.init({
	language:   'en',
	players:    ['img','swf','flv','html','iframe']
})

function showlarrytab(x){
	$(".larrytabs .buttons li").removeClass("sel");
	$(".larrytabs .buttons li."+x).addClass("sel");
	  
	$(".larrytabs > div").hide();
	$(".larrytabs > div."+x).fadeIn();
}
	
	
$(document).ready(function(){

	//==============================================
	//  Color fade animation for nav
	//==============================================
	
	$('.topleftnav li:not(.sel)').hover(
		function () { $(this).stop().animate({ backgroundColor: "#ABD8F4" }, 200); }, 
		function () { $(this).stop().animate({ backgroundColor: "#6CAEDF" }, 200); }
	).click( function() { window.location=$(this).find("a").attr("href"); return false; } );
	
	
	$('.bottomleftnav li:not(.sel)').hover(
		function () { $(this).stop().animate({ backgroundColor: "#033C66" }, {queue:false,duration:200}); }, 
		function () { $(this).stop().animate({ backgroundColor: "#004B8D" }, {queue:false,duration:500}); }
	).click( function() { window.location=$(this).find("a").attr("href"); return false; } );

	$('.rightnav li:not(.sel)').hover(
		function () { $(this).stop().animate({ backgroundColor: "#931602" }, {queue:false,duration:200}); }, 
		function () { $(this).stop().animate({ backgroundColor: "#BA1F00" }, {queue:false,duration:500}); }
	).click( function() { window.location=$(this).find("a").attr("href"); return false; } );
	
	
	var topcolors = ["#c1dff5","#f9bcb3","#f9df98","#b8edb4","#fff39d"];
	var last;
	 $(".topnav li").each(function(i){
	 	if($(this).hasClass(".sel")){
			$(this).animate({ backgroundColor: topcolors[i] }, {queue:false,duration:10});
		}else{
			
			$(this)
			.mouseenter( function() { 
				$(this).stop().animate({ backgroundColor: topcolors[i] }, {queue:false,duration:200}); 
			})
			.mouseleave( function() { 
				$(this).stop().animate({ backgroundColor: "#FFFFFF" }, {queue:false,duration:500}); 
			})
			.click( function() { 
				window.location= $(this).find("a").attr("href"); return false; 
			});
		}
		
	} );

	
	$(".justifyme").vjustify();

	$('#homeflash').flash({ src: 'flash/homeflash.swf',width: 840,height: 246 }); 

	
	//==============================================
	//  fix backround image not centering perfectly
	//  when browser window is odd number
	//==============================================
	widthadjust();
	$(window).bind("resize", widthadjust);
	
	
	//==================================
	//
	//   larry tabs
	//
	//==================================
	$(".larrytabs").each(function(i){
		
		var buttonlist = "";
		
		// just used for map thing:
		var hasflashmap = 0;
		if($(this).hasClass("flashmap")){ hasflashmap = 1; }
		//alert(hasflashmap);
		
		// find out if any div is selected yet
		//$(this).find("> div ");
		
		var notfirst = 0;  // there is a better way to only show first item!
		var sel;
		var selclass;
		var thisclass;
		$(this).find("> div").each(function(i){
		$(this).hide();
			// > to select the first div, and not any divs inside of it
			thisclass = $(this).attr('class').split(' ').slice(0,1);
			if(notfirst == 0){ 
				sel = this; 
				selclass = thisclass;
				//alert("FIRST");
			}else{
				if($(this).hasClass("sel")){ sel = this; selclass = thisclass; }
			}
			buttonlist = buttonlist + "<li class='"+ thisclass +"' ><a href='#' >" + $(this).attr('rel') + "</a></li>";	
			notfirst = 1;
			
		});
		
		$(sel).fadeIn("medium");
		
		buttonlist = "<ul class='buttons'>"+buttonlist+"</ul>";
		$(this).prepend(buttonlist);
		$(this).find(".buttons").slideDown("normal");
		
		$(this).find(".buttons a").each(function(i){
			
			$(this).click( function() { 
				x = $(this).parent().attr('class');
				if(hasflashmap == 1){ callJavascript(x); }
				if( $(this).parent().hasClass("sel") ){ 
				}else{
					showlarrytab(x);
				}
				
				return false;
			});
			
			if($(this).parent().attr('class') == selclass){ 
				$(this).parent().addClass("sel"); 
			}

		});
		
		//alert("SELCLASS = "+selclass);
		
	} );

});
