function re(i){return document.getElementById(i);}

function homeSearchSel(w){
	switch(w){
		case "l":
		re('hSearch_byTeam').style.display = 'none';
		re('hSearch_byLocation').style.display = 'block';
		re('byLocationImg').src = CONF_ROOTDIR+'img/hSearchToggle_locO_'+CONF_COLOR+'.png';
		re('byTeamImg').src = CONF_ROOTDIR+'img/hSearchToggle_team.png';
		re('hSearchType').value = 'l';
		break;
		case "t":
		re('hSearch_byLocation').style.display = 'none';
		re('hSearch_byTeam').style.display = 'block';
		re('byLocationImg').src = CONF_ROOTDIR+'img/hSearchToggle_loc.png';
		re('byTeamImg').src = CONF_ROOTDIR+'img/hSearchToggle_teamO_'+CONF_COLOR+'.png';
		re('hSearchType').value = 't';
		break;
	}
	return false;
}

function getCities(countryID){
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	var d = xmlhttp.responseText;
	re('ScitiesSelect').innerHTML = d;
    }
  }
xmlhttp.open("GET",CONF_ROOTDIR+"data.php?act=getCities&cid="+countryID,true);
xmlhttp.send();
}

function validateSearch(w){
	switch(w){
	case "home":
	if(re('hSearchType').value == 'l'){
		if(re('hScountry').value == ''){alert('Please select a country');return false;}
	}else{
		if(re('hSteam').value == '' && re('hSt_sport').value == ''){alert('Please select a team and/or sport');return false;}		
	}
	if(re('hSdate').value == ''){alert('Please select a date');return false;}
	if(re('hStodate').value == ''){alert('Please enter a to date');return false;}
	if(re('hSfromdate').value == ''){alert('Please enter a from date');return false;}
	break;
	case "frm_team":case "frm_location":
	if(w == 'frm_team'){var tt = 't';}else{var tt = 'l';}
	
	if(w == 'frm_location'){
		if(re('hSl_country').value == ''){alert('Please select a country');return false;}
	}else{
		if(re('hSt_team').value == ''){
			alert('Please select a team');
			return false;
			}		
	}
	if(re('hS'+tt+'_date').value == ''){alert('Please select a date');return false;}
	if(re('hS'+tt+'_dateto').value == ''){alert('Please enter a to date');return false;}
	if(re('hS'+tt+'_datefrom').value == ''){alert('Please enter a from date');return false;}	
	
	break;
	}
}

function updatetoDate(w,t){
	switch(w){
		case "home":
		var field = 'hStodate';
		break;
		case "frm_location":
		var field = 'hSl_dateto';
		break;
		case "frm_team":
		var field = 'hSt_dateto';
		break;
		}
		
	switch(t){
		case "14":
		var todate = todayPlusFourteen;
		break;
		case "30":
		var todate = todayPlusThirty;
		break;
		case "60":
		var todate = todayPlusSixty;
		break;
		case "custom":
		var todate = '';
		break;
		}
		
	re(field).value = todate;
}
