// JavaScript Document

$(document).ready(function(){
	
	var i = 2;
	var splashLength = $("#splash li").size();
	
	/*
	$.timer(8000, function (timer) {
			
		var splashImage = $("#image-" + i).attr("src"); 
			
		if (i == splashLength) {
			i = 1;
		}
		else {
			i++;
		}
		
		$("#splash").css('background-image','url(' + splashImage + ')', 'height', '400', 'width', '1280').stop().hide().fadeIn("slow");
		//$("#splash-image").attr({src: splashImage}).stop().hide().fadeIn("slow");

	});
	*/
	
	$('a.map').click(function(event) {
		
		var map = $(this).attr("href");

		//$.modal('<iframe src="' + map + '" height="550" width="900" style="border:0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0">', {
		$("#map").modal({
			closeClass: "modalClose",
			containerCss:{
				backgroundColor:"#fff",
				height:550,
				padding:0,
				width:900
			},
			overlayClose:false
		});
		
		return false;
	});
		
	$('a.careers').click(function(event) {
		
		var page = $(this).attr("href");

		$.modal('<iframe src="' + page + '" height="550" width="960" style="border:0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0">', {
			closeClass: "modalClose",
			containerCss:{
				backgroundColor:"#fff",
				height:550,
				padding:0,
				width:960
			},
			overlayClose:false
		});
		
		return false;
	});
	
	$('.location a').click(function(event) {
		
		var page = $(this).attr("href");

		$.modal('<iframe src="' + page + '" height="600" width="500" style="border:0" frameborder="0" scrolling="no" marginheight="0" marginwidth="0">', {
			closeClass: "modalClose",
			containerCss:{
				backgroundColor:"#fff",
				height:600,
				padding:0,
				width:500
			},
			overlayClose:false
		});
		
		return false;
	});
	
	var viewportheight = $(window).height();
	var pageheight = $("#header").height() + ($("#rest").height() - 35);
	
	if (pageheight < viewportheight) {
		$("#copy").css({height: (viewportheight - pageheight)});
	}
	
	$('#legend input').click(function() {
		//alert($(this).val());
		if ($(this).val() == "1") {
			$('#map').fadeIn("slow").css("background-image", "url(/images/map.png)");
		}
		else if ($(this).val() == "2") {
			$('#map').fadeIn("slow").css("background-image", "url(/images/map-fire.png)");
		}
		else if ($(this).val() == "3") {
			$('#map').fadeIn("slow").css("background-image", "url(/images/map-alarm.png)");
		}
		//$('#map').fadeIn("slow");
	});
	
});
	
sfHover = function() {
	var sfEls = document.getElementById("services").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


