function show(id){
	document.getElementById(id).style.display='';
}
function hide(id){
	document.getElementById(id).style.display='none';
}

var satB=new Array();
satB.push({
	'opponent':'Olimpia',
	'location':'Soccer City',
	'year':2011,
	'month':10,
	'day':22,
	'hour':16,
	'minute':00});
satB.push({
	'opponent':'Interpol A',
	'location':'Soccer City',
	'year':2011,
	'month':10,
	'day':29,
	'hour':17,
	'minute':00});
satB.push({
	'opponent':'Tyskie',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':05,
	'hour':16,
	'minute':00});
satB.push({
	'opponent':'SPK',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':12,
	'hour':17,
	'minute':00});
satB.push({
	'opponent':'FC Fire',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':19,
	'hour':16,
	'minute':00});
satB.push({
	'opponent':'Classic Fire',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':26,
	'hour':18,
	'minute':00});
satB.push({
	'opponent':'Polonia 94',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':03,
	'hour':16,
	'minute':00});
satB.push({
	'opponent':'OLIMPIA',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':10,
	'hour':16,
	'minute':00});
satB.push({
	'opponent':'INTERPOL A',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':17,
	'hour':17,
	'minute':00});
/*satB.push({
	'opponent':'Polonia 94',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':26,
	'hour':18,
	'minute':00});
satB.push({
	'opponent':'Zawisza',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':03,
	'hour':15,
	'minute':00});
satB.push({
	'opponent':'SPK',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':10,
	'hour':15,
	'minute':00});
satB.push({
	'opponent':'Interpol A',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':17,
	'hour':17,
	'minute':00});
satB.push({
	'opponent':'Tyskie',
	'location':'Soccer City',
	'year':2012,
	'month':01,
	'day':07,
	'hour':15,
	'minute':00});
satB.push({
	'opponent':'Olimpia',
	'location':'Soccer City',
	'year':2012,
	'month':01,
	'day':14,
	'hour':15,
	'minute':00});
satB.push({
	'opponent':'FC Fire',
	'location':'Soccer City',
	'year':2012,
	'month':01,
	'day':21,
	'hour':16,
	'minute':00});
satB.push({
	'opponent':'Polonia 94',
	'location':'Soccer City',
	'year':2012,
	'month':01,
	'day':28,
	'hour':18,
	'minute':00});
satB.push({
	'opponent':'Zawisza',
	'location':'Soccer City',
	'year':2012,
	'month':02,
	'day':04,
	'hour':15,
	'minute':00});
satB.push({
	'opponent':'SPK',
	'location':'Soccer City',
	'year':2012,
	'month':02,
	'day':11,
	'hour':15,
	'minute':00});
satB.push({
	'opponent':'Interpol A',
	'location':'Soccer City',
	'year':2012,
	'month':02,
	'day':18,
	'hour':17,
	'minute':00});
satB.push({
	'opponent':'Tyskie',
	'location':'Soccer City',
	'year':2012,
	'month':02,
	'day':25,
	'hour':15,
	'minute':00});
satB.push({
	'opponent':'Olimpia',
	'location':'Soccer City',
	'year':2012,
	'month':03,
	'day':03,
	'hour':15,
	'minute':00});
satB.push({
	'opponent':'FC Fire',
	'location':'Soccer City',
	'year':2012,
	'month':03,
	'day':10,
	'hour':16,
	'minute':00});
satB.push({
	'opponent':'Polonia 94',
	'location':'Soccer City',
	'year':2012,
	'month':03,
	'day':17,
	'hour':18,
	'minute':00});
satB.push({
	'opponent':'Zawisza',
	'location':'Soccer City',
	'year':2012,
	'month':03,
	'day':24,
	'hour':15,
	'minute':00});*/

var satA=new Array();
satA.push({
	'opponent':'SPK',
	'location':'Soccer City',
	'year':2011,
	'month':10,
	'day':22,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Interpol B',
	'location':'Soccer City',
	'year':2011,
	'month':10,
	'day':29,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'FC Fire',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':05,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Olimpia',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':12,
	'hour':19,
	'minute':00});
satA.push({
	'opponent':'Tyskie',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':19,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Polonia 94',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':26,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Classic Fire',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':03,
	'hour':18,
	'minute':00});
satA.push({
	'opponent':'SPK',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':10,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Interpol B',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':17,
	'hour':17,
	'minute':00});
/*satA.push({
	'opponent':'Zawisza',
	'location':'Soccer City',
	'year':2011,
	'month':11,
	'day':26,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Polonia 94',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':03,
	'hour':16,
	'minute':00});
satA.push({
	'opponent':'Olimpia',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':10,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Interpol B',
	'location':'Soccer City',
	'year':2011,
	'month':12,
	'day':17,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'FC Fire',
	'location':'Soccer City',
	'year':2012,
	'month':01,
	'day':07,
	'hour':16,
	'minute':00});
satA.push({
	'opponent':'SPK',
	'location':'Soccer City',
	'year':2012,
	'month':01,
	'day':14,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Tyskie',
	'location':'Soccer City',
	'year':2012,
	'month':01,
	'day':21,
	'hour':18,
	'minute':00});
satA.push({
	'opponent':'Zawisza',
	'location':'Soccer City',
	'year':2012,
	'month':01,
	'day':28,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Polonia 94',
	'location':'Soccer City',
	'year':2012,
	'month':02,
	'day':04,
	'hour':16,
	'minute':00});
satA.push({
	'opponent':'Olimpia',
	'location':'Soccer City',
	'year':2012,
	'month':02,
	'day':11,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Interpol B',
	'location':'Soccer City',
	'year':2012,
	'month':02,
	'day':18,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'FC Fire',
	'location':'Soccer City',
	'year':2012,
	'month':02,
	'day':25,
	'hour':16,
	'minute':00});
satA.push({
	'opponent':'SPK',
	'location':'Soccer City',
	'year':2012,
	'month':03,
	'day':03,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Tyskie',
	'location':'Soccer City',
	'year':2012,
	'month':03,
	'day':10,
	'hour':18,
	'minute':00});
satA.push({
	'opponent':'Zawisza',
	'location':'Soccer City',
	'year':2012,
	'month':03,
	'day':17,
	'hour':17,
	'minute':00});
satA.push({
	'opponent':'Polonia 94',
	'location':'Soccer City',
	'year':2012,
	'month':03,
	'day':24,
	'hour':16,
	'minute':00});*/

var thursday=new Array();
thursday.push({
	'opponent':'Sporting FC',
	'location':'Hershey',
	'year':2011,
	'month':09,
	'day':29,
	'hour':23,
	'minute':40});
thursday.push({
	'opponent':'GFC',
	'location':'Hershey',
	'year':2011,
	'month':10,
	'day':06,
	'hour':23,
	'minute':40});
thursday.push({
	'opponent':'Cowie United',
	'location':'Hershey',
	'year':2011,
	'month':10,
	'day':12,
	'hour':23,
	'minute':40});
thursday.push({
	'opponent':'Fuego',
	'location':'Hershey',
	'year':2011,
	'month':10,
	'day':19,
	'hour':21,
	'minute':45});
thursday.push({
	'opponent':'ROUH FC',
	'location':'Hershey',
	'year':2011,
	'month':10,
	'day':27,
	'hour':19,
	'minute':55});
thursday.push({
	'opponent':'Bullets',
	'location':'Hershey',
	'year':2011,
	'month':11,
	'day':03,
	'hour':19,
	'minute':00});
thursday.push({
	'opponent':'FK Bosna',
	'location':'Hershey',
	'year':2011,
	'month':11,
	'day':10,
	'hour':18,
	'minute':05});
thursday.push({
	'opponent':'Sporting FC',
	'location':'Hershey',
	'year':2011,
	'month':11,
	'day':16,
	'hour':23,
	'minute':35});
thursday.push({
	'opponent':'GFC 2.0',
	'location':'Hershey',
	'year':2011,
	'month':11,
	'day':23,
	'hour':22,
	'minute':40});
thursday.push({
	'opponent':'Cowie United',
	'location':'Hershey',
	'year':2011,
	'month':11,
	'day':30,
	'hour':21,
	'minute':45});
thursday.push({
	'opponent':'Fuego',
	'location':'Hershey',
	'year':2011,
	'month':12,
	'day':07,
	'hour':20,
	'minute':50});
thursday.push({
	'opponent':'ROUH FC',
	'location':'Hershey',
	'year':2011,
	'month':12,
	'day':14,
	'hour':19,
	'minute':55});
thursday.push({
	'opponent':'Bullets',
	'location':'Hershey',
	'year':2011,
	'month':12,
	'day':22,
	'hour':19,
	'minute':00});
thursday.push({
	'opponent':'FK Bosna',
	'location':'Hershey',
	'year':2011,
	'month':12,
	'day':29,
	'hour':19,
	'minute':00});

maps=new Array();
maps.push({
	'location':'David Morrison Stad',
	'map':'http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr=43.710147,-79.75553&hl=en&geocode=&mra=mift&mrsp=1&sz=17&sll=43.709594,-79.755024&sspn=0.00577,0.009645&ie=UTF8&ll=43.710401,-79.755571&spn=0.01154,0.01929&t=h&z=16'
});
maps.push({
	'location':'Clarkson',
	'map':'http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr=43.500668,-79.647007&hl=en&geocode=&mra=mift&mrsp=1&sz=18&sll=43.500262,-79.646716&sspn=0.002895,0.004823&ie=UTF8&ll=43.501033,-79.647059&spn=0.01158,0.01929&t=h&z=16'
});
maps.push({
	'location':'Croatian Centre Norval',
	'map':'http://maps.google.com/maps?q=9118+Winston+Churchill+Blvd,+Norval,+Halton+Regional+Municipality,+Ontario+L0P+1K0,+Canada&hl=en&sll=43.632239,-79.831308&sspn=0.006295,0.006295&ie=UTF8&view=map&f=d&daddr=9118+Winston+Churchill+Blvd,+Norval,+ON+L0P+1K0,+Canada&geocode=CUd97NqOPvn5FW_GmQId9N49-w&ll=43.632627,-79.831381&spn=0.02311,0.038581&t=h&z=15'
});
maps.push({
	'location':'Dr. Dobkin',
	'map':'http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr=43.579406,-79.635141&hl=en&geocode=&mra=mift&mrsp=1&sz=17&sll=43.57893,-79.63455&sspn=0.005783,0.009645&ie=UTF8&ll=43.579645,-79.635108&spn=0.011565,0.01929&t=h&z=16'
});
maps.push({
	'location':'Dobkin',
	'map':'http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr=43.579406,-79.635141&hl=en&geocode=&mra=mift&mrsp=1&sz=17&sll=43.57893,-79.63455&sspn=0.005783,0.009645&ie=UTF8&ll=43.579645,-79.635108&spn=0.011565,0.01929&t=h&z=16'
});
maps.push({
	'location':'Century',
	'map':'http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr=43.710147,-79.75553&hl=en&geocode=&mra=mift&mrsp=1&sz=17&sll=43.709594,-79.755024&sspn=0.00577,0.009645&ie=UTF8&ll=43.710401,-79.755571&spn=0.01154,0.01929&t=h&z=16'
});
maps.push({
	'location':'Fallingbrook',
	'map':'http://maps.google.com/maps?f=d&source=s_d&saddr=&daddr=43.587401,-79.681327&hl=en&geocode=&mra=mift&mrsp=1&sz=17&sll=43.586826,-79.681488&sspn=0.002735,0.009291&ie=UTF8&ll=43.587556,-79.68137&spn=0.002735,0.009291&t=h&z=17'
});
maps.push({
	'location':'NORTH PARK',
	'map':'http://maps.google.com/maps?q=north+park,+oakville&daddr=Oakville,+ON,+Canada&hl=en&ll=43.468245,-79.755378&spn=0.025384,0.038581&sll=43.600991,-79.606106&sspn=0.355469,0.358328&doflg=ptk&view=map&geocode=CcGk9Sjx_gfDFeRFlwIdbwc_-yGJ_kX23WzHQA&t=h&z=15'
});
maps.push({
	'location':'North Park',
	'map':'http://maps.google.com/maps?q=north+park,+oakville&daddr=Oakville,+ON,+Canada&hl=en&ll=43.468245,-79.755378&spn=0.025384,0.038581&sll=43.600991,-79.606106&sspn=0.355469,0.358328&doflg=ptk&view=map&geocode=CcGk9Sjx_gfDFeRFlwIdbwc_-yGJ_kX23WzHQA&t=h&z=15'
});
maps.push({
	'location':'Memorial Park',
	'map':'http://maps.google.ca/maps?daddr=Mississauga,+ON&ll=43.579785,-79.705478&spn=0.00314,0.016276&cid=0,0,17188031573557664851&fb=1&gl=ca&geocode=2853624710243421690,43.579933,-79.707033&t=h&z=17'
});
maps.push({
	'location':'Streetsville Memorial',
	'map':'http://maps.google.ca/maps?daddr=Mississauga,+ON&ll=43.579785,-79.705478&spn=0.00314,0.016276&cid=0,0,17188031573557664851&fb=1&gl=ca&geocode=2853624710243421690,43.579933,-79.707033&t=h&z=17'
});


function nextGame(fixtures,id){
	var now=new Date();
	for(a=0;a<fixtures.length;a++){
		fixture=fixtures[a];
		upcomingFixture='';
		
		var then=new Date(fixture.year,fixture.month-1,fixture.day,fixture.hour,fixture.minute,0,0);
		if(now.getTime()-then.getTime()<0){
			countDown(fixture.year,fixture.month,fixture.day,fixture.hour,fixture.minute,fixture.location,fixture.opponent,id);
			return;
		}
	}
}

function countDown(year,month,day,hour,minute,location,opponent,id){
	//set dates
	var now=new Date();
	var then=new Date(year,month-1,day,hour,minute,0,0);
	//set some variables
	var secondsInDay=86400;
	var secondsInHour=3600;
	var secondsInMinute=60;
	//calculate totals
	var seconds=parseInt((then.getTime()-now.getTime())/1000);
	var days=parseInt(seconds/secondsInDay);
	var secondsInDays=days*secondsInDay;
	var hours=parseInt((seconds-secondsInDays)/secondsInHour);
	var secondsInHours=hours*secondsInHour;
	var minutes=parseInt((seconds-secondsInDays-secondsInHours)/secondsInMinute);
	var secondsInMinutes=minutes*secondsInMinute;
	seconds=parseInt(seconds-secondsInDays-secondsInHours-secondsInMinutes);
	//display
	timeAttributes=document.getElementById(id).childNodes;
	for(a=0;a<timeAttributes.length;a++){
		timeAttribute=timeAttributes[a];
		if(timeAttribute.className=='days'){
			timeAttribute.innerHTML=days;
		}
		else if(timeAttribute.className=='hours'){
			timeAttribute.innerHTML=hours;
		}
		else if(timeAttribute.className=='minutes'){
			timeAttribute.innerHTML=PadLeft(minutes,2);
		}
		else if(timeAttribute.className=='seconds'){
			timeAttribute.innerHTML=PadLeft(seconds,2);
		}
		else if(timeAttribute.className=='location'){
			if(timeAttribute.innerHTML==''){
				mapExists=0;
				for(b=0;b<maps.length;b++){
					map=maps[b];
					if(map.location==location){
						mapExists=1;
						mapLink=document.createElement('a');
						mapLink.setAttribute('href', map.map);
						mapLink.setAttribute('target', '_blank');
						mapLink.innerHTML=location;
					}
				}
				if(mapExists){
					timeAttribute.appendChild(mapLink);
				}
				else{
					timeAttribute.innerHTML=location;
				}
			}
		}
		else if(timeAttribute.className=='opponent'){
			timeAttribute.innerHTML=opponent;
		}
		else if(timeAttribute.className=='date'){
			timeAttribute.innerHTML=
			year+'-'+
			PadLeft(month,2)+'-'+
			PadLeft(day,2)+' '+
			PadLeft(hour,2)+':'+
			PadLeft(minute,2);
		}
	}
	//loop
	setTimeout("countDown("+year+","+month+","+day+","+hour+","+minute+",'"+location+"','"+opponent+"','"+id+"')",1000);
}

//left pad string
function PadLeft(n, totalDigits) 
{ 
	n = n.toString(); 
	var pd = ''; 
	if (totalDigits > n.length) 
	{ 
		for (i=0; i < (totalDigits-n.length); i++) 
		{ 
			pd += '0'; 
		} 
	} 
	return pd + n.toString(); 
} 

function showSchedule(fixtures,inId){
	//add headings
	table=document.createElement('table');
	tbody=document.createElement('tbody');
	row=document.createElement('tr');
	divider=document.createElement('th');
	divider.innerHTML='Date';
	row.appendChild(divider);
	divider=document.createElement('th');
	divider.innerHTML='Location';
	row.appendChild(divider);
	divider=document.createElement('th');
	divider.innerHTML='Opponent';
	row.appendChild(divider);
	tbody.appendChild(row);
	for(a=0;a<fixtures.length;a++){
		//add body
		fixture=fixtures[a];
		row=document.createElement('tr');
		divider=document.createElement('td');
		divider.innerHTML=
			fixture.year+'-'+
			PadLeft(fixture.month,2)+'-'+
			PadLeft(fixture.day,2)+' '+
			PadLeft(fixture.hour,2)+':'+
			PadLeft(fixture.minute,2);
		row.appendChild(divider);
		divider=document.createElement('td');
		
		mapExists=0;
		for(b=0;b<maps.length;b++){
			map=maps[b];
			if(map.location==fixture.location){
				mapExists=1;
				mapLink=document.createElement('a');
				mapLink.setAttribute('href', map.map);
				mapLink.setAttribute('target', '_blank');
				mapLink.innerHTML=fixture.location;
			}
		}
		if(mapExists){
			divider.appendChild(mapLink);
		}
		else{
			divider.innerHTML=fixture.location;
		}
		
		
		
		row.appendChild(divider);
		divider=document.createElement('td');
		divider.innerHTML=fixture.opponent;
		row.appendChild(divider);
		tbody.appendChild(row);
	}
	//add table
	table.appendChild(tbody);
	document.getElementById(inId).appendChild(table);
}
