//var activar = new Object() ;
//
//function favOn(id, txt, path) {
//    favObj = document.getElementById("favorito"+id) ;
//    favObj.src = path+"web/i_favorito.gif" ;
//    favObj.title = txt ;
//
//    //también hemos de cambiar el texto
//    favTextObj = document.getElementById("favoritoText"+id) ;
//    favTextObj.innerHTML = txt ;
//    favTextObj.title = txt ;
//}
//
//function favOff(id, txt, path) {
//	favObj = document.getElementById("favorito"+id) ;
//    favObj.src = path+"web/i_favorito_off.gif" ;
//    favObj.title = txt ;
//    
//    //también hemos de cambiar el texto
//    favTextObj = document.getElementById("favoritoText"+id) ;
//    favTextObj.innerHTML = txt ;
//    favTextObj.title = txt ;
//}
//
//function changeFavIcon(id, txt_sub, txt_add, path) {
//    if (activar["key_"+id] == undefined) activar["key_"+id] = false ;
//    activar["key_"+id] = !activar["key_"+id] ;
//
//    if (activar["key_"+id]) {
//        favOn(id, txt_sub, path) ;
//        meteEnCookie(id) ;
//        //sumamos 1 al total
//        add2total() ;
//
//    } else {
//        favOff(id, txt_add, path) ;
//        sacaDeCookie(id) ;
//        //sumamos 1 al total
//        sub2total() ;
//    }
//}


window.onload = function() {
		
	
    strFav = readCookie("fav") ;
    if (strFav != null) 
    {
        aFav = strFav.split(",");
        for (var id in aFav)
	    {
        	if (id!=0){
        		if (document.getElementById("favorito"+aFav[id])) load_if_fav(aFav[id], '', '','') ;
        	}
        }
    }
    $("input#buscar_main").autocomplete("/services/suggest.php",{minChars:2,timeout:500,validSelection:false, 'inputDefault':$('#id_buscar').val().replace('.','~'),parameters:{'id_pais':sug_lang,'lang':$("#lang").val(),'texto_comunidad':txt3,'texto_provincia':txt1,'tipo_zona':$('#tipo_zona').val()}});
	 //obtener_respuesta_ajax()
	 
}


function favOn(id, txt, path,prefijo) {
	
	if ($("#favorito"+prefijo+id).length!=0){
		favObj = document.getElementById("favorito"+prefijo+id) ;
		favObj.src = path+"web/i_favorito.gif" ;
		favObj.title = txt ;
		favObj.className = 'compara_on';
		//add2total() ;
	}
	/*favTextObj = document.getElementById("favoritoText"+id) ;
	favTextObj.innerHTML = txt ;
	favTextObj.title = txt ;*/
}


function ver_detalle_listado(tipo, id, prefijo){
	/*
	if(tipo==1){
		$("#det_listado_"+id).css("display", "table");
		$("#det_listado_"+id+" .ver_mas_listado").hide();
		$("#det_listado_"+id+" .ver_menos").show();
	} else {
		$("#det_listado_"+id+" .ver_mas_listado").show();
		$("#det_listado_"+id+" .ver_menos").hide();
		$("#det_listado_"+id).css("display", "");
	}
	
	*/
	
	if (prefijo != 'r_') {
		prefijo = '';
	}
	
	if(tipo==1){
		if ($("#"+prefijo+"det_more_listado_"+id).html() == "") {
			$.ajax({
				  url: "/services/search/get_search_detail.php",
				  type: "POST",
				  data: {id : id, lang: $('#lang').val(), tipo_prefijo: prefijo},
				  dataType: "html",
				  success: function(html_data){
					$("#"+prefijo+"det_listado_"+id).hide();  
					$("#"+prefijo+"det_more_listado_"+id).html(html_data);
					$("#"+prefijo+"det_more_listado_"+id).css("display", "table");
				  }
				});
		} else {
			$("#"+prefijo+"det_listado_"+id).hide();  
			$("#"+prefijo+"det_more_listado_"+id).css("display", "table");
		}
	} else {
		$("#"+prefijo+"det_listado_"+id).show();  
		$("#"+prefijo+"det_more_listado_"+id).hide();
	}
	return false;
}
/*
function favOn(id) {
    favObj = document.getElementById("favorito"+id) ;
    favObj.src = "/images/web/i_favorito.gif" ;
    favObj.title = "Sacar de mi lista" ;
    
    //también hemos de cambiar el texto
    favTextObj = document.getElementById("favoritoText"+id) ;
    favTextObj.innerHTML = "Sacar de mi lista" ;
    favTextObj.title = "Sacar de mi lista" ;
}

function favOff(id) {
	favObj = document.getElementById("favorito"+id) ;
    favObj.src = "/images/web/i_favorito_off.gif" ;
    favObj.title = "Añadir a mi lista" ;
    
    //también hemos de cambiar el texto
    favTextObj = document.getElementById("favoritoText"+id) ;
    favTextObj.innerHTML = "Añadir a mi lista" ;
    favTextObj.title = "Añadir a mi lista" ;
}

function changeFavIcon(id) {
    if (activar["key_"+id] == undefined) activar["key_"+id] = false ;
    activar["key_"+id] = !activar["key_"+id] ;
    
    if (activar["key_"+id]) {
        favOn(id) ;
        meteEnCookie(id) ;
        
        //sumamos 1 al total
        add2total() ;
        
    } else {
        favOff(id) ;
        sacaDeCookie(id) ;
        
        //sumamos 1 al total
        sub2total() ;
    }
}
*/

/* FUNCIONES PARA COOKIE */
//function sacaDeCookie(id) {
//    //sacamos de la cookie
//    strFav = readCookie("fav");
//    finder = ","+id+"," ;
//    pos = strFav.indexOf(finder);
//    fav = strFav.substr(0, (pos+1)) + strFav.substr((pos+finder.length), strFav.length) ;
//    if (fav == ",") deleteCookie("fav") ;
//    else saveCookie("fav", fav, 365) ;
//}
//
//function meteEnCookie(id) {
//    //guardamos en la cookie
//    strFav = readCookie("fav");
//    if (strFav != null) strFav += id+"," ;
//    else strFav = ","+id+"," ;
//    saveCookie("fav", strFav, 365) ;
//}
///* FIN DE FUNCIONES PARA COOKIE */
//
//function add2total() {
//    total = document.getElementById("total_lista") ;
//    if (total) 
//    {
//        value = parseInt(total.innerHTML)+1 ;
//        total.innerHTML = value ;
//    }
//}
//
//function sub2total() {
//    total = document.getElementById("total_lista") ;
//    if (total) 
//    {
//        value = parseInt(total.innerHTML)-1 ;
//        total.innerHTML = value ;
//    }
//}
//
//function loadtotal(value) {
//    total = document.getElementById("total_lista") ;
//    if (total) 
//    {
//        total.innerHTML = value ;
//    }
//}
//
//function load_if_fav(id, texto_sub, path) {
//    strFav = readCookie("fav") ;
//    if(strFav){
//        if (strFav.indexOf(","+id+",") != -1)
//        {
//            activar["key_"+id] = true ;
//            favOn(id, texto_sub, path) ;
//        }
//    }
//}
//
//function vacia_mi_lista(formulario) {
//    if (formulario == "") 
//    {
//        deleteCookie("fav") ;
//    } else {
//        for (i = 0 ; i < formulario.elements.length ; i++)
//        {   
//		    if (formulario.elements[i].type == "checkbox") {
//                if (formulario.elements[i].checked && formulario.elements[i].value != -1) {
//                    sacaDeCookie(formulario.elements[i].value) ;
//                }
//            }
//	    }
//    }
//}

