﻿$(document).ready(function () {
   $('#courseList table tr:even,#roundList table tr:even').addClass('alt');

   $('#courseList table tr,#roundList table tr').hover(
      function () {
        $(this).addClass('hover');
      }, 
      function () {
        $(this).removeClass('hover');
      }
    );

    var screen1On = true;
    var isMacFF2 = false;

    /* FireFox 2 on Mac only */
    if ((navigator.appVersion.indexOf("Mac") != -1) && ($.browser.mozilla == true) && ($.browser.version.substr(0,3) == "1.8")) {
	   $('#scorecard tr.score td').css('padding-top','4px');
	   $('#roundList td .bar').css('margin-top','0');
	   $('#roundList table td').css('padding-bottom','6px').css('padding-top','10px');
	   isMacFF2 = true;
    }

    $('.navBar .next').click(function () {
	  if (!$('.screen1,.screen2').is(':animated')) {
	      if (screen1On == true) {
		    if (!isMacFF2) {
	          $('.screen1').animate({left:"-980px"},500 );
	          $('.screen2').css('left','980px').show().animate({left:"23px"},500);
	        } else {
		      $('.screen1').hide();
		      $('.screen2').css('left','23px').show();
	        }
		    $('.screenIndicator li.one,.screenIndicator li.two,.screenIndicator li.three').removeClass('on');
		    $('.screenIndicator li.four,.screenIndicator li.five,.screenIndicator li.six').addClass('on');
		    screen1On = false;
		  } else {
		   if (!isMacFF2) {
		     $('.screen2').animate({left:"-980px"},500 );
		     $('.screen1').css('left','980px').show().animate({left:"23px"},500);
	       } else {
		     $('.screen2').hide();
		     $('.screen1').show();
		   }
		   $('.screenIndicator li.one,.screenIndicator li.two,.screenIndicator li.three').addClass('on');
		   $('.screenIndicator li.four,.screenIndicator li.five,.screenIndicator li.six').removeClass('on');
		   screen1On = true;
		  }
	   }
	   return false;
	});
	
	$('.navBar .back').click(function () {
      if (!$('.screen1,.screen2').is(':animated')) {
	      if (screen1On == true) {
		    if (!isMacFF2) {
	          $('.screen1').animate({left:"980px"},500 );
	          $('.screen2').css('left','-980px').show().animate({left:"23px"},500);
        	} else {
	          $('.screen1').hide();
			  $('.screen2').css('left','23px').show();
			}
		    $('.screenIndicator li.one,.screenIndicator li.two,.screenIndicator li.three').removeClass('on');
		    $('.screenIndicator li.four,.screenIndicator li.five,.screenIndicator li.six').addClass('on');
		    screen1On = false;
		  } else {
			if (!isMacFF2) {
		      $('.screen2').animate({left:"980px"},500 );
		      $('.screen1').css('left','-980px').show().animate({left:"23px"},500 );
		    } else {
			  $('.screen2').hide();
			  $('.screen1').show();
			}
		    $('.screenIndicator li.one,.screenIndicator li.two,.screenIndicator li.three').addClass('on');
		    $('.screenIndicator li.four,.screenIndicator li.five,.screenIndicator li.six').removeClass('on');
		    screen1On = true;
		  }
		}
	    return false;
	});

    $("a[formToSubmit]").click(function() {
        $("#" + $(this).attr("formToSubmit")).submit();
        return false;
    });

    $("#facebookLink").click(function() {
        var u = location.href;
        var t = document.title;
        window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&amp;t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
        return false;
    });

    $("#twitterLink").click(function() {
        var status = document.title + ' ' + location.href;
        window.open('http://twitter.com/home?status=' + encodeURIComponent(status), 'tweet', 'toolbar=0,status=0,width=786,height=333');
        return false;
    });
});

function twitterShare() {
    var status = document.title + ' ' + location.href;
    window.open('http://twitter.com/home?status=' + encodeURIComponent(status), 'tweet', 'toolbar=0,status=0,width=786,height=333');
    return false;
}
