function closeMenu() {
	$('#findFast:visible').slideUp();
	clearTimeout(x);
}
$(function() {
	if ($.browser.msie) {
            $('#findFast').css({'margin-left':'-0px'});
     if ($.browser.version < 7)
     {
     	$('#sponsorsHeader h4').css({'margin-bottom':'6px'});
     	$('.moreInfo').css({'background-image':'url(images/popup.gif)'});
     	$('#topQuote').css({'height':'165px'});
     	$('#topQuote .quote').css({'font-size':'1.2em'});
     	$('#topQuote .quote strong').css({'font-size':'1.3em'});
     	$('#topQuote .quote strong').css({'line-height':'20px'});
    }
	}
	$('#allSports li').hover(
				function() {
				var offset = $(this).offset();
				var new_top = offset.top - 35;
				var new_left = offset.left - 262;
				var x = $(this).children('.moreInfo').html();
							$('#popup').css({'display': 'block',
																'top': new_top,
															'left': new_left});
				$('#popup').html(x);
				}
				,
				function() {
					
				});
	$('#popup').mouseover(function() {
		$('#popup').show();
	});
	$('#popup').mouseout(function() {
		$('#popup').hide();
	});
	$('#allSports').mouseover(function() {
		$('#popup').show();
	});
	$('#allSports').mouseout(function() {
		$('#popup').hide();
	});
	$('#findbut img').click(function () {
		$('#findFast').slideDown();
		x = setTimeout("closeMenu()", 10000);
		$("body").unbind("click");
	});
	$('#buttonReplacement').click(function () {
		$('#findFast').slideUp();
	});
	
	$('#findFast').mouseout(function() {
		$("body").bind("click", function()
		{
			$('#findFast:visible').slideUp();
			$("body").unbind("click");
		});
	});
	$('#findFast').mouseover(function() {
		$("body").unbind("click");
	});
	$('#searchBox input').click(function() {
	if ($('#searchBox input').val() == 'Search Special Olympics')
       {
           //$('#searchBox input').val('');
       }
    });
    $('#searchBox input').blur(function() {
	if ($('#searchBox input').val() == '')
       {
           //$('#searchBox input').val('Search Special Olympics');
       }
    });
    $('#searchBox input').bind("keypress", function(e) {
  		if (e.keyCode == 13) {
  			alert('submit!');
  		  }
  		});
  	/* Links */

	/*
  	$('#newsLetter').click(function() {
  		window.location.href = "newsletter.html";
  	});
	*/

  	$('#help').click(function() {
  		window.location.href = "/";
  	});
  	$('#get').click(function() {
  		window.location.href = "/";
  	});
  	$('#FandM .FMphoto').click(function() {
  		window.location.href = "/";
  	});
  	$('#FandM .FMvideo').click(function() {
  		window.location.href = "/";
  	});
  	/* $('#World').click(function() {
  		window.location.href = "/world_of_neglect.html";
  	});
  	$('#BeAFan').click(function() {
  		window.location.href = "/be_a_fan.html";
  	});
  	  	$('#BeAFan2').click(function() {
  		window.location.href = "/be_a_fan.html";
  	});*/
  	/*var savedFontSize = readCookie('soifontsize');
  	var originalFontSize = $('html').css('font-size');
    if (savedFontSize != null)
    {
    	$('html').css({'font-size': savedFontSize + 'px;'});
    }
    $(".resetFont").click(function(){
    $('html').css('font-size', originalFontSize);
  }); */
  // Increase Font Size
  $(".increaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum + 2;    
    $('html').css('font-size', newFontSize);
    createCookie('soifontsize', newFontSize, 365);
  	return false;   
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum - 2;
    if (newFontSize < 10)
    {
    	newFontSize = 10;
    }
    $('html').css('font-size', newFontSize);
    createCookie('soifontsize', newFontSize, 365);
    return false;
  });
});


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}