function initCombos(){
	try {
		setTabs(1);//para bloco Locais & Serviços da capa.
	} catch(e) {
	}
	try {
		setTabs(2);//para bloco Cultura & Lazer da capa.
	} catch(e) {
	}
}

/* Busca dados para popular combos do bloco no topo da capa do Hagah*/
function setTabs(tipo){
	var url="";
	var ajax = openAjax();
		
	var c = document.cookie;
	var start = c.indexOf("(", c.indexOf("hagah2.prefs"));
	var regionId = c.substring(start + 1, c.indexOf(")", start));
	
	start = c.indexOf("(", c.indexOf("regionSearch")) + 1;
	var locale = c.substring(start, c.indexOf(")", start));
	
	if(locale == ""){
		start = c.indexOf("(", c.indexOf("local")) + 1;
		locale = c.substring(start, c.indexOf(")", start));
	}
	
	if(tipo == 1) url="http://www.hagah.com.br/jsp/locales.jsp?action=locales&regionId=" + regionId + "&locale=" + locale;
	else if(tipo == 2) url="http://www.hagah.com.br/jsp/locales.jsp?isLocale=false&regionid=" + regionId + "&locale=" + locale;
	
	if ( document.all ) ajax.open("GET",url,true);// IE - Sincrono
	else ajax.open("GET",url,true);// Demais - Assincrono

	ajax.onreadystatechange =  function(){		
		if (ajax.readyState == 4) {
			if (ajax.status == 200) {
				if(tipo == 1) loadLocaisFrontPage(ajax.responseXML);
				else if(tipo == 2) loadRoteirosFrontPage(ajax.responseXML);
			}			
		}
	}				
	ajax.send(null);
}

/*Popula combos de Locais do bloco na capa genérica do Hagah*/
function loadLocaisFrontPage(response){
	loadLocales(response, document.getElementById("selectLocais"));	
}

function loadLocales(response, selectLocais) {
	var regn_city_name = response.getElementsByTagName("regn_city_name");
	var regn_city_id = response.getElementsByTagName("regn_city_id");
	var is_region = response.getElementsByTagName("is_region");
	
	selectLocais.options.length = 0;
	
	for(var i =0; i<regn_city_name.length; i++){
		selectLocais.options.length++;
		var localidade = regn_city_name.item(i).firstChild.nodeValue;
		if(is_region.item(i).firstChild.nodeValue == "true"){
			selectLocais.options[selectLocais.options.length - 1].style.color = "#0000FF";
			selectLocais.options[selectLocais.options.length - 1].text = localidade;
		} else {
			selectLocais.options[selectLocais.options.length - 1].style.color = "#000000";
			selectLocais.options[selectLocais.options.length - 1].text = localidade;
		}
		selectLocais.options[selectLocais.options.length - 1].value = regn_city_id.item(i).firstChild.nodeValue;
		if(regionC == regn_city_id.item(i).firstChild.nodeValue) selectLocais.options[selectLocais.options.length - 1].selected = true;
	}
}

/*Popula combos de Roteiros do bloco na capa genérica do Hagah*/
function loadRoteirosFrontPage(response){
	var selectDatas = document.getElementById("selectDatas");
	var selectCategorias = document.getElementById("selectCategorias");
	
	selectDatas.options.length = 0;
	selectCategorias.options.length = 0;
	
	var inty_name = response.getElementsByTagName("inty_name");
	var inty_id = response.getElementsByTagName("inty_id");
	
	var date_id = response.getElementsByTagName("date_id");
	var description = response.getElementsByTagName("description");
	var date_id_selected = response.getElementsByTagName("date_id_selected");
	
	for(var i =0; i<date_id.length; i++){	
		selectDatas.options.length++;
		var data = description.item(i).firstChild.nodeValue;
		selectDatas.options[selectDatas.options.length - 1].text = data;
		selectDatas.options[selectDatas.options.length - 1].value = date_id.item(i).firstChild.nodeValue;
	}
	selectDatas.options[0].selected = true;	
	for(var i =0; i<inty_id.length; i++){
		if(i == 0){
			selectCategorias.options.length++;
			selectCategorias.options[selectCategorias.options.length - 1].text = "Todas";
		}
		selectCategorias.options.length++;
		var categoria = inty_name.item(i).firstChild.nodeValue;
		selectCategorias.options[selectCategorias.options.length - 1].text = categoria;
		selectCategorias.options[selectCategorias.options.length - 1].value = inty_id.item(i).firstChild.nodeValue;
	}
	
	//---- GM0011 -----
	loadLocales(response, document.getElementById("selectLocais2"));
	//---- /GM0011 ----
}

//---- GM0011 -----
function validateHomeForm(form, isValidatingQuery) {
	return true;
}
//---- GM0011 -----

function send(ev){
	if(document.all){
		if (event.keyCode == 13){
			if ( window.event.srcElement.form.region.selectedIndex==0 ) {
				alert("Selecione uma localidade.");
				window.event.srcElement.form.reqion.focus();
			}else{
				window.event.srcElement.form.submit();
			}
		}
	}else{
		if (ev.which == 13){
			if ( ev.target.form.region.selectedIndex==0 ) {
				alert("Selecione uma localidade.");
				ev.target.form.region.focus();
			}else{
				ev.target.form.submit();
			}
		}
	}
}






















