<!--
		var g_gadgets = [];
		g_gadgets['destaques'] = {page_selected: 0, xml_file: '', item_selected: 0, itens: null, last_op_time: new Date()};		
		g_gadgets['anuncio_onibus'] = {page_selected: 0, xml_file: 'gadgetultimosanuncios', item_selected: 0, itens: null, last_op_time: new Date()};		
		g_gadgets['rodoviarios'] = {page_selected: 0, xml_file: 'gadgetrodoviarios', item_selected: 0, itens: null, last_op_time: new Date()};		
		g_gadgets['urbanos'] = {page_selected: 0, xml_file: 'gadgeturbanos', item_selected: 0, itens: null, last_op_time: new Date()};				
		g_gadgets['microonibus'] = {page_selected: 0, xml_file: 'gadgetmicroonibus', item_selected: 0, itens: null, last_op_time: new Date()};		
		g_gadgets['vans'] = {page_selected: 0, xml_file: 'gadgetvans', item_selected: 0, itens: null, last_op_time: new Date()};		
		
		

		var g_updater_timer = null;
		var g_updater_timer_update_interval = 60000;
		var g_walker_timer = null;
		var g_walker_timer_walk_interval = 3000;

		function homegadgetsInitializer(){
				loadAnuncio('anuncio_onibus', 0);
				startUpdater();
		}

		function startUpdater(){
				stopUpdater();
				g_updater_timer = setInterval(updaterHandler, g_updater_timer_update_interval);
				g_walker_timer = setInterval(walkerHandler, g_walker_timer_walk_interval);
		}

		function stopUpdater(){
				if (g_updater_timer)
						clearInterval(g_updater_timer);
				if (g_walker_timer)
						clearInterval(g_walker_timer);
		}

		function gobk(gadget){
				gad = g_gadgets[gadget];
				gad.last_op_time = new Date();
				gad.item_selected--;
				loadAnuncio(gadget, gad.item_selected);
				return false;
		}

		function gofw(gadget){
				gad = g_gadgets[gadget];
				gad.last_op_time = new Date();
				gad.item_selected++;
				loadAnuncio(gadget, gad.item_selected);
				return false;
		}

		function updateItens(gadget){
				var xml_file = g_gadgets[gadget].xml_file + '-'+g_gadgets[gadget].page_selected+'-21-1.xml';
				g_gadgets[gadget].itens = importXML(xml_file).getElementsByTagName(gadget);
		}

		function loadAnuncio(gadget, id){
				gad = g_gadgets[gadget];
				if (gad==='undefined')
						return  loadAnuncio(gadget, id);
				gad.item_selected = id;
				if (document.getElementById('gadget_photo_'+gadget) == null)
						return false;
				
				if (!gad.itens)
						updateItens(gadget);

				var anuncio_url = 'http://www.queroonibus.com.br/';
				var anuncio_url = 'http://localhost/euquero/';
				var anuncio_image_url = 'images/animacao.gif';	
				var anuncio_price = 'quero ônibus!';
				var anuncio_carroceria = '';
				var anuncio_chassi = '';
				

				for (i = 0; i < gad.itens.length; i++){
						anuncio = gad.itens[i];
						anuncio_id = anuncio.attributes.getNamedItem("id").value;
						if (i == gad.itens.length - 1){
								if (anuncio_id > id){
										gad.page_selected++;
										updateItens(gadget);
										loadAnuncio(gadget, id);
										return true;
								}
						}
						
						if (!i)
								if (anuncio_id < id && gad.page_selected > 0){
										gad.page_selected--;
										updateItens(gadget);
										loadAnuncio(id);
										return true;
								}
						
						if (anuncio_id != id && id){
								continue;
						}

						if (id <= 0){
								gad.item_selected = anuncio_id;
								gad.page_selected = 0;
						}
						
						for (j = 0; j < anuncio.childNodes.length; j++){
								try{
										switch (anuncio.childNodes[j].nodeName){
												case "url":
														anuncio_url = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
												case "image_url":
														anuncio_image_url = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
												case "price":
														anuncio_price = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
												case "carroceria":
														anuncio_carroceria = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
												case "chassi":
														anuncio_chassi = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
										}
								}catch(err){
								}
						}
						break;
				}
				//if (!i)
				//		g_page_selected--;
				document.getElementById('gadget_photo_'+gadget).style.backgroundImage = 'url('+anuncio_image_url+')';
				document.getElementById('gadget_legend_'+gadget).innerHTML = anuncio_carroceria+'/'+anuncio_chassi+' por apenas '+anuncio_price;
				document.getElementById('gadget_link_'+gadget).href = anuncio_url;
				return true;
		}

		function loadADS(gadget, id){
				gad = g_gadgets[gadget];
				if (gad==='undefined')
						return  loadAnuncio(gadget, id);
				gad.item_selected = id;
				if (document.getElementById('gadget_photo_'+gadget) == null)
						return false;
				
				if (!gad.itens)
						updateItens(gadget);

				var anuncio_url = 'http://www.queroonibus.com.br/';
				var anuncio_url = 'http://localhost/euquero/';
				var anuncio_image_url = 'images/animacao.gif';	
				var anuncio_price = 'quero ônibus!';
				var anuncio_carroceria = '';
				var anuncio_chassi = '';
				

				for (i = 0; i < gad.itens.length; i++){
						anuncio = gad.itens[i];
						anuncio_id = anuncio.attributes.getNamedItem("id").value;
						if (i == gad.itens.length - 1){
								if (anuncio_id > id){
										gad.page_selected++;
										updateItens(gadget);
										loadAnuncio(gadget, id);
										return true;
								}
						}
						
						if (!i)
								if (anuncio_id < id && gad.page_selected > 0){
										gad.page_selected--;
										updateItens(gadget);
										loadAnuncio(id);
										return true;
								}
						
						if (anuncio_id != id && id){
								continue;
						}

						if (id <= 0){
								gad.item_selected = anuncio_id;
								gad.page_selected = 0;
						}
						
						for (j = 0; j < anuncio.childNodes.length; j++){
								try{
										switch (anuncio.childNodes[j].nodeName){
												case "url":
														anuncio_url = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
												case "image_url":
														anuncio_image_url = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
												case "price":
														anuncio_price = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
												case "carroceria":
														anuncio_carroceria = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
												case "chassi":
														anuncio_chassi = anuncio.childNodes[j].childNodes[0].nodeValue;
													break;
										}
								}catch(err){
								}
						}
						break;
				}
				//if (!i)
				//		g_page_selected--;
				document.getElementById('gadget_photo_'+gadget).style.backgroundImage = 'url('+anuncio_image_url+')';
				document.getElementById('gadget_legend_'+gadget).innerHTML = anuncio_carroceria+'/'+anuncio_chassi+' por apenas '+anuncio_price;
				document.getElementById('gadget_link_'+gadget).href = anuncio_url;
				return true;
		}

		function updaterHandler(){
				now = new Date();
				gad = g_gadgets['anuncio_onibus'];
				if (now.getTime() > g_updater_timer_update_interval + gad.last_op_time.getTime()){
						gad.item_selected = 0;
						gad.page_selected = 0;
						updateItens('anuncio_onibus');
						loadAnuncio('anuncio_onibus', 0);
				}
		}
		
		function walkerHandler(){
				now = new Date();
				gad = g_gadgets['anuncio_onibus'];
				if (now.getTime() > g_walker_timer_walk_interval + gad.last_op_time.getTime()){
						gad.item_selected--;
						loadAnuncio('anuncio_onibus', gad.item_selected);
				}
		}
	
		
//-->
