var league = "hat";

function league_switch()
{
  if(league == "hat"){
	document.getElementById("league_club_nav").style.display = ""; 
	document.getElementById("league_open_nav").style.display = "none"; 
	document.getElementById("league_club").style.display = ""; 
	document.getElementById("league_open").style.display = "none"; 
	league = "club";
  }
  else {
	document.getElementById("league_club_nav").style.display = "none"; 
	document.getElementById("league_open_nav").style.display = ""; 
	document.getElementById("league_club").style.display = "none"; 
	document.getElementById("league_open").style.display = ""; 
	league = "hat";
  }
}

function fade(eid){
    var element = document.getElementById(eid);
    if(element == null)
        return;
    element.style.display = "";
}

/*
<a href="javascript:media_menu('1')">
<div id="about1" style="display: none">
*/

/* current page detector */
function extractPageName(hrefString)
{
	var pre = hrefString.split('?');
	var arr = pre[0].split('/');
	var poo = "";
	for (var i = 1; i < arr.length; i++){
		var poo = poo + arr[i].toLowerCase();
	}
	return poo;
//	return  (arr.length < 2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase();
}
 
function setActiveMenu(arr, crtPage)
{
	if(crtPage == "www.dublinsummerleague.com"){
		crtPage = "www.dublinsummerleague.comindex.php";
	} else if(crtPage == "dublinsummerleague.com"){
		crtPage = "dublinsummerleague.comindex.php";		
	}
	for (var i=0; i < arr.length; i++)
	{	
		if(extractPageName(arr[i].href) == crtPage)
		{
			if (arr[i].tagName != "DIV")
			{
				arr[i].className = "current";
				arr[i].parentNode.className = "current";
				}
		}
	}
}
 
function setPage()
{
	hrefString = document.location.href ? document.location.href : document.location;
	if (document.getElementById("tabnav") !=null )
	setActiveMenu(document.getElementById("tabnav").getElementsByTagName("a"), extractPageName(hrefString)); //getElementsByTagName("a")
}


//time to recentness converter
var fuzzyFacebookTime = (function(){
 
  fuzzyTime.defaultOptions={
    // time display options
    relativeTime : 48,
    // language options
    monthNames : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
    amPm : ['AM', 'PM'],
    ordinalSuffix : function(n) {return ['th','st','nd','rd'][n<4 || (n>20 && n % 10<4) ? n % 10 : 0]}
  }
 
  function fuzzyTime (timeValue, options) {
 
    var options=options||fuzzyTime.defaultOptions, 
        date=parseDate(timeValue),
        delta=parseInt(((new Date()).getTime()-date.getTime())/1000),
        relative=options.relativeTime,
        cutoff=+relative===relative ? relative*60*60 : Infinity;
 
    if (relative===false || delta>cutoff)
      return formatTime(date, options)+' '+formatDate(date, options);
 
    if (delta<60) return 'less than a minute ago';
    var minutes=parseInt(delta/60 +0.5);
    if (minutes <= 1) return 'about a minute ago';
    var hours=parseInt(minutes/60 +0.5);
    if (hours<1) return minutes+' minutes ago';
    if (hours==1) return 'about an hour ago';
    var days=parseInt(hours/24 +0.5);
    if (days<1) return hours+' hours ago';
    if (days==1) return formatTime(date, options)+' yesterday';
    var weeks=parseInt(days/7 +0.5);
    if (weeks<2) return formatTime(date, options)+' '+days+' days ago';
    var months=parseInt(weeks/4.34812141 +0.5);
    if (months<2) return weeks+' weeks ago';
    var years=parseInt(months/12 +0.5);
    if (years<2) return months+' months ago';
    return years+' years ago';
  }
 
  function parseDate (str) {
    var v=str.replace(/[T\+]/g,' ').split(' ');
    return new Date(Date.parse(v[0] + " " + v[1] + " UTC"));
  }
 
  function formatTime (date, options) {
    var h=date.getHours(), m=''+date.getMinutes(), am=options.amPm;
    return (h>12 ? h-12 : h)+':'+(m.length==1 ? '0' : '' )+m+' '+(h<12 ? am[0] : am[1]);
  }
 
  function formatDate (date, options) {
    var mon=options.monthNames[date.getMonth()],
        day=date.getDate(),
        year=date.getFullYear(),
        thisyear=(new Date()).getFullYear(),
        suf=options.ordinalSuffix(day);
 
    return mon+' '+day+suf+(thisyear!=year ? ', '+year : '');
  }
 
  return fuzzyTime;
 
}());

function HideAll () {
document.getElementById("hat").style.display = "none";
document.getElementById("womens").style.display = "none";
document.getElementById("both").style.display = "none";
}
function leagueSelect(){
	HideAll();
	var Selected = document.paypal.os0.selectedIndex;
    var id = document.paypal.os0.options[Selected].value;
	if(id == "Co-ed And Women's Summer League"){
		document.getElementById('both').style.display = "";
	}
	else if (id == "Women's Summer League"){
		document.getElementById('womens').style.display = "";
	}
	else {
		document.getElementById('hat').style.display = "";
	}
}
