function get_states()
{
	$('span_city').innerHTML = '&nbsp;';
	$('span_state').innerHTML = '&nbsp;';
	$('span_neighbour').innerHTML = '&nbsp;';
	var selectedIndex = $('pais').selectedIndex;
	var countryCode = $('pais').options[selectedIndex].value;
	new Ajax.Updater('span_state', '../ajax/states.select.php?pais=' + countryCode, { method: 'post' });
	$('resultados').innerHTML = '<table width="518" border="0"><tr><td align="center" height="100"><img src="/img/loading.gif"/></td></tr></table>';
	new Ajax.Updater('resultados', '../ajax/results.php?pais=' + countryCode, { method: 'post' });
}

function get_cities()
{
	$('span_neighbour').innerHTML = "&nbsp;";
	$('span_city').innerHTML = "&nbsp;";
	var selectedIndex = $('pais').selectedIndex;
	var countryCode = $('pais').options[selectedIndex].value;
	var selectedIndex = $('estado').selectedIndex;
	var stateCode = $('estado').options[selectedIndex].value;
	new Ajax.Updater('span_city', '../ajax/cities.select.php?estado=' + stateCode + '&pais=' + countryCode, { method: 'post' });
	$('resultados').innerHTML = '<table width="518" border="0"><tr><td align="center" height="100"><img src="/img/loading.gif"/></td></tr></table>';
	new Ajax.Updater('resultados', '../ajax/results.php?estado=' + stateCode + '&pais=' + countryCode, { method: 'post' });
}

function get_neighbours()
{
	var selectedIndex = $('pais').selectedIndex;
	var countryCode = $('pais').options[selectedIndex].value;
	var selectedIndex = $('estado').selectedIndex;
	var stateCode = $('estado').options[selectedIndex].value;
	var selectedIndex = $('ciudad').selectedIndex;
	var cityCode = $('ciudad').options[selectedIndex].value;
	new Ajax.Updater('span_neighbour', '../ajax/neighbour.select.php?ciudad='+ cityCode +'&estado=' + stateCode + '&pais=' + countryCode, { method: 'post' });
	$('resultados').innerHTML = '<table width="518" border="0"><tr><td align="center" height="100"><img src="/img/loading.gif"/></td></tr></table>';
	new Ajax.Updater('resultados', '../ajax/results.php?ciudad='+ cityCode +'&estado=' + stateCode + '&pais=' + countryCode, { method: 'post' });
}

function get_results()
{
	var selectedIndex = $('pais').selectedIndex;
	var countryCode = $('pais').options[selectedIndex].value;
	var selectedIndex = $('estado').selectedIndex;
	var stateCode = $('estado').options[selectedIndex].value;
	var selectedIndex = $('ciudad').selectedIndex;
	var cityCode = $('ciudad').options[selectedIndex].value;
	var selectedIndex = $('barrio').selectedIndex;
	var neighbourCode = $('barrio').options[selectedIndex].value;
	$('resultados').innerHTML = '<table width="518" border="0"><tr><td align="center" height="100"><img src="/img/loading.gif"/></td></tr></table>';
	new Ajax.Updater('resultados', '../ajax/results.php?barrio='+ neighbourCode +'&ciudad='+ cityCode +'&estado=' + stateCode + '&pais=' + countryCode, { method: 'post' });
}

function updateContent(key)
{
	$('content').innerHTML = '<table width="100%"><tr><td align="center"><img src="/img/loading.gif"/></td></tr></table>';
	if(key == 'inicio') new Ajax.Updater('content', 'internas/inicio.php', { method: 'post' });
	if(key == 'contacto') new Ajax.Updater('content', 'internas/contacto.php', { method: 'post' });
	if(key == 'canchas') new Ajax.Updater('content', 'internas/canchas.php', { method: 'post' });
}

function updateContent2(url)
{
	new Ajax.Updater('content', url);
}

function buscarCancha()
{
	$('content').innerHTML = '<table width="100%"><tr><td align="center"><img src="/img/loading.gif"/></td></tr></table>';
	var pars = "buscador=" + $('buscador').value + "&buscar=" + $('buscar').value;
	new Ajax.Updater('content', 'internas/buscacancha.php', { method: 'post', parameters: pars });
}

function checkBuscar()
{
	var buscador = $('buscador').value;
	if(buscador.length < 4)
	{
		alert('Ingresa un criterio de mas de 3 letras');
		return false;
	}
	else{
		return true;
	}
}

function sendContact()
{
	var pars = "nombre=" + $('nombre').value + "&Submit=" + $('Submit').value;
	pars = pars + "&ciudad=" + $('ciudad').value + "&pais=" + $('pais').value;
	pars = pars + "&email=" + $('email').value + "&comentario=" + $('comentario').value;
	new Ajax.Updater('content', 'internas/contacto.php', { method: 'post', parameters: pars });
}
