var doingSearch = false;


function doSearch(oForm, strType, strBase, strCategory, strLocale, strPgsz, strQuery)
{
	if( doingSearch )
	{
		alert( "Tu búsqueda esta en proceso. Refresca la página para entrar otra búsqueda." );
		return false;
	} // endif

	if (strQuery != null)
	{
		// Set query to bypass empty check
		oForm.query.value = strQuery;
		oForm.storequery.value = strQuery;
	}

	if( ( oForm.query.value == null || oForm.query.value == "" ) &&
        strType != "buscar" )
	{
		if( strType != null )
		{
			if (strType == "uniclave")
				alert( "Nuestras UniClaves te dan la oportunidad de encontrar una página en Univision.com o en otros sitios recomendados. Por favor, dinos qué buscas." );
		}
		else
		{
			location.href = "http://www.univision.com/rdt.dyn?trt=31&rid=4000&requrl=http://www.univision.com/content/channel.jhtml?chid=1&schid=12";
		}

		oForm.query.focus();
	}
	else
	{
		if (strType != null)
		{
			oForm.search_type.value = strType;
		}
		if (strBase != null)
		{
			oForm.base.value = strBase;
		}
		if (strCategory != null)
		{
			oForm.category.value = strCategory;
		}
		if (strLocale != null)
		{
			oForm.locale.value = strLocale;
		}
		if (strPgsz != null)
		{
			oForm.pgsz.value = strPgsz;
		}

		if (strQuery != null && strCategory != null)
		{
			// Unset 'query' parameter
			oForm.query.value = "";
		}

		doingSearch = true;
		oForm.submit();
	}

	return false;
}

function setLocale(oForm, strLocale)
{
	oForm.locale.value = strLocale;
}

function setLetter(oForm, strLetter)
{
	oForm.letter.value = strLetter;
}

function searchFocus(oForm)
{
	oForm.query.focus();
}

