function closeMenu() {
	$('#findFast:visible').slideUp();
	clearTimeout(x);
}
$(function() {
	if ($.browser.msie) {
            $('#findFast').css({'margin-left':'-0px'});
         	$('#timelinePlacement').css({'margin-left':'-20px'});
     if ($.browser.version < 7)
     {
     	$('#sponsorsHeader h4').css({'margin-bottom':'6px'});
     	$('.moreInfo').css({'background-image':'url(images/popup.gif)'});
     	$('.sectionalHeader').css({'border-left':'1px solid #F0F0E8'});
     	$('.sectionalHeader').css({'border-top':'1px solid #F0F0E8'});
     	$('.sectionalHeader').css({'border-right':'1px solid #F0F0E8'});
     	$('.sportsResult').css({'padding':'0px 3% 40px 0px'});
      	$('#timelinePlacement').css({'margin-left':'-10px'});
      	$('#splashinner').css({'position':'absolute'});
    }
    $('#sponsorContent img').css({'position':'relative', 'top':'6px'});
	}
	$('#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) {
 //really quick sorry
         javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("searchGo", "", false, "", "Search.aspx", false, true))  		  }
  		});

  	/* Links */

  	$('#newsLetter').click(function() {
	    $('#splash').show();
	    $('#splashinner').show();
//	    document.cookie='subscribeSplash=Opened;path=/;expires=Thu, 01-Jan-2030 00:00:01 GMT; host=www.specialolympics.org;';
	    $('#videoBox').hide();
  	});
  	$('#pledge_box .close').click(function() {
	    $('#splash').hide();
	    $('#splashinner').hide();
	    document.cookie='subscribeSplash=Filled;path=/;expires=Thu, 01-Jan-2030 00:00:01 GMT; host=www.specialolympics.org;';
	    $('#videoBox').show();
  	});

  	$('#mediaBack').click(function() {
  		history.back();
  	});
  	$('#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 = "/slideshow_neglect.aspx";
  	});
  	
  	 $('#BeAFan').click(function() {
  	 //window.open('https://ssl.charityweb.net/specialolympics/')
  	});
  	  	$('#BeAFan2').click(function() {
  	 //window.open('https://ssl.charityweb.net/specialolympics/')
  	});
  	/*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);
}
