// Ice Edge
$(document).ready(function () {
	var animate = true;
	if((navigator.appName=="Microsoft Internet Explorer") && (parseFloat(navigator.appVersion)<=7)){
		animate = false;
	}
	if(window.location.hash == '#results'){
		change($('#contact')[0]);
		window.location.hash="";
	} else {
		active($("#about").addClass("selected"));
		$("#a_cont").fadeIn("slow");
	}

$(document).ready(initializeGrid);
function initializeGrid() {
  $("ul#boxes li img").each(function() {
    var width = $(this).width() / 100 + "em";
    var height = $(this).height() / 100 + "em";
    $(this).css("width",width);
    $(this).css("height",height);
  });
}

$("#team,#contact,#about").click(
	function () {
		change(this);
});
$("#team,#contact,#about").hover(
	function () {
		if(!$(this).hasClass("selected")){
			active(this);
		}
      }, 
    function () {
		if(!$(this).hasClass("selected")){
			inactive(this);
		}
    }
	
);
function active(elem) {
	$(elem).find('img:first').show();
	$(elem).find('img:last').hide();
   	if(animate)
	$(elem).animate({ fontSize: "100px" }, 200 );
}
function inactive(elem) {
	$(elem).find('img:first').hide();
	$(elem).find('img:last').show();
	if(animate)
	$(elem).animate({ fontSize: "75px" }, 200 );
}
function change(elem) {
	$("#t_cont,#c_cont,#a_cont").fadeOut("fast");
	inactive($("#boxes .selected").removeClass('selected'));
	active($(elem).addClass("selected"));
	var section = '#' + elem.id.toString().substr(0,1) + '_cont';
	
	$(section).fadeIn('slow');
}
});