function habilitar_masinfos(nodo,cuantos,estilo){
	
	for (i=1; i<=cuantos; i++){
	
		if (document.getElementById("destinos_mas_info_"+i)){
			
			if (nodo==i){
				document.getElementById("destinos_mas_info_"+i).style.display = 'inline';
			}else {
				document.getElementById("destinos_mas_info_"+i).style.display = 'none';
			
			}
			
		}
	}
	
	for (i=1; i<=cuantos; i++){
	
		if (document.getElementById("destinos_mas_title_"+i)){
			
			if (nodo==i){
				
				document.getElementById("destinos_mas_title_"+i).className=estilo;
			}else {
				document.getElementById("destinos_mas_title_"+i).className='';
			
			}
			
		}
	}

}

function imagenes(titulo,copete,autor,src){
	this.titulo=titulo;
	this.copete=copete;
	this.autor=autor;
	this.src=src;	
}

function videos(titulo,copete,autor,video,preview){
	this.titulo=titulo;
	this.copete=copete;
	this.autor=autor;
	this.video=video;	
	this.preview=preview;	
}

function agregarImagenes(titulo,copete,autor,src){
	V_Imagenes[V_Imagenes.length]=new imagenes(titulo,copete,autor,src);

}

function agregarVideos(titulo,copete,autor,video,preview){
	V_Videos[V_Videos.length]=new videos(titulo,copete,autor,video,preview);

}

function verImagenCaja(modo){

	if (modo == "+"){
		index_imagenes = index_imagenes +1;
		if (index_imagenes>V_Imagenes.length - 1){
			index_imagenes = 0;
		}
	}else if (modo=='-'){
		index_imagenes = index_imagenes -1;
		if (index_imagenes<0){
			index_imagenes = V_Imagenes.length - 1;
		}
	} 
	
	document.getElementById("src_imagenes_caja").src= V_Imagenes[index_imagenes].src;
	
	if (V_Imagenes[index_imagenes].titulo != "" || V_Imagenes[index_imagenes].copete !="" || V_Imagenes[index_imagenes].autor !="" ){
		document.getElementById("copete_imagenes_caja").innerHTML= '<p class="fc_c1_11">'+V_Imagenes[index_imagenes].titulo+'</p><p><span>'+V_Imagenes[index_imagenes].copete+'</span> '+(V_Imagenes[index_imagenes].autor!=""?'| <span>'+V_Imagenes[index_imagenes].autor+'</span>':'')+'</p>'
	}
	
	SetEfectos('src_imagenes_caja');
		
}

function verVideoCaja(modo){

	if (modo == "+"){
		index_videos = index_videos +1;
		if (index_videos>V_Videos.length - 1){
			index_videos = 0;
		}
	}else if (modo=='-'){
		index_videos = index_videos -1;
		if (index_videos<0){
			index_videos = V_Videos.length - 1;
		}
	}
		
	document.getElementById("video_caja").innerHTML='<object width="400" height="250" data="http://www.destinationargentina.com/includes/flvplayer/flvplayer.swf" type="application/x-shockwave-flash"><param value="http://www.destinationargentina.com/includes/flvplayer/flvplayer.swf" name="movie"></param><param value="transparent" name="wmode"></param><param value="#FFFFFF" name="bgcolor"></param><param value="file='+V_Videos[index_videos].video+'&showdigits=true&image='+V_Videos[index_videos].preview+'&showicons=true&volume=100" name="flashvars"></param></object>';
	
	if (V_Videos[index_videos].titulo != "" || V_Videos[index_videos].copete !="" || V_Videos[index_videos].autor !=""){
		document.getElementById("copete_videos_caja").innerHTML = '<p class="fc_c1_11">'+V_Videos[index_videos].titulo+'</p><p><span>'+V_Videos[index_videos].copete+'</span> '+(V_Videos[index_videos].autor!=""?'| <span>'+V_Videos[index_videos].autor+'</span>':'')+'</p>';
	}
	

}

function habilitarCaja(caja, totales){
	
	for (i=1; i<=totales; i++){
		if (document.getElementById("caja_solapa_"+i)){
		document.getElementById("caja_solapa_"+i).className="";
		}
	}
	
	document.getElementById("caja_solapa_"+caja).className="tab_navigator_on";
	
	if (caja == 1){
		
		if (document.getElementById("tab_maps")){
			document.getElementById("tab_maps").style.display='none';
		}
		
		if (document.getElementById("tab_videos")){
			document.getElementById("tab_videos").style.display='none';
			document.getElementById("video_caja").innerHTML = "";
		}
		
		if (document.getElementById("tab_fotos")){
			document.getElementById("tab_fotos").style.display='block';
			SetEfectos('tab_fotos');
		}
		
		verImagenCaja('i');		
	}
	
	if (caja==2){
		
		if (document.getElementById("tab_maps")){
			document.getElementById("tab_maps").style.display='none';
		}
		
		if (document.getElementById("tab_videos")){
			document.getElementById("tab_videos").style.display='block';
			SetEfectos('tab_videos');
		}
		
		if (document.getElementById("tab_fotos")){
			document.getElementById("tab_fotos").style.display='none';
		}
		verVideoCaja('i');
	}
	
	if (caja==3){
		
		if (document.getElementById("tab_maps")){
			document.getElementById("tab_maps").style.display='block';
			
		}
		
		if (document.getElementById("tab_videos")){
			document.getElementById("tab_videos").style.display='none';
			document.getElementById("video_caja").innerHTML = "";
		}
		
		if (document.getElementById("tab_fotos")){
			document.getElementById("tab_fotos").style.display='none';
		}
		initializeCajaMapa(varLat,varLong,varZoom,varTipo);
		SetEfectos('tab_maps');
	}
	
}

/*mapa*/
function initializeCajaMapa(latVal,longVal,zoom,tipo) {

	if (GBrowserIsCompatible()) {

		map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(parseFloat(longVal),parseFloat(latVal)), zoom);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setMapType(tipo);
		geocoder = new GClientGeocoder();

		//icono inicial
		var point = new GLatLng(parseFloat(longVal),parseFloat(latVal));
		marker = createMarker(point,'','');
		map.addOverlay(marker);

	}

}

function createMarker(point,name,html) {

	var marker = new GMarker(point);

	/*GEvent.addListener(marker, "click", function() {
	marker.openInfoWindowHtml(html);
	});

	gmarkers[i] = marker;
	htmls[i] = html;

	i++;*/
	return marker;

}

function createMarker_(point,name,html) {
	var marker = new GMarker(point);

	GEvent.addListener(marker, "click", function() {
		
		/*document.getElementById("google_map").style.width = 710+"px";
		document.getElementById("direcciones").style.width = 220+"px";
		document.getElementById("direcciones").style.display = 'block';
		
		var routerOptions = { "locale": "es_ES", "preserveViewport": true, "getPolyline": true, "getSteps": true };
		gdir = new GDirections(map, document.getElementById("direcciones"),routerOptions);  
    	gdir.clear();
		GEvent.addListener(gdir, "error", handleErrors); 
    	GEvent.addListener(gdir, "load", onGDirectionsLoad);

    	gdir.load("from: -34.60965209737086,-58.39090168476105 to: @" + point,{"preserveViewport":"true"}); 
    	*/
    	marker.openInfoWindowHtml(html);
	});

	gmarkers[i] = marker;
	htmls[i] = html;
	i++;
	return marker;
}

function createMarker_home(point,name,html) {

	var marker = new GMarker(point);

	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});

	gmarkers[i] = marker;
	htmls[i] = html;
	i++;
	return marker;
}

function myclick(i) {
	gmarkers[i].openInfoWindowHtml(htmls[i]);
}
    
 
function handleErrors(){  
          /*if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)  
            alert("Direccion desconocida");  
          else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)  
            alert("Error de Servidor");  
          else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)  
            alert("Falta la direccion inicial");  
          else if (gdir.getStatus().code == G_GEO_BAD_KEY)  
            alert("Clave de Google Maps incorrecta");  
          else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)  
            alert("No se ha encontrado la direccion de llegada");  
         else alert("Error desconocido");*/
         
         document.getElementById("direcciones").innerHTML = "";  
 } 
       
function onGDirectionsLoad()
{ 
	  	/*document.getElementById("direcciones").innerHTML = gdir.getSummaryHtml(); */
	  	
} 
/*fin mapa*/

function popupDiv(width,height,url){
	//id= es el id galeria
		
	var anchoPantalla=screen.width;
	var altoPantalla=screen.height;
	var x=(anchoPantalla - parseFloat(width))/2;
	var y=(altoPantalla - parseFloat(height))/2;
	
	window.open(url,'','width='+width+',height='+height+',top='+y+',left='+x+',toolbar=no,directories=no,resizable=no,location=no,status=no,menubar=no,border=no');
	
	
}

function SetEfectos(objeto) {
	
	var shaker = $(objeto);
	
	if (shaker){
		
		shaker.setStyles({
			opacity: 0.1
		});
		shaker.fade('in');
	}
	
}

function habilitar_copete_agenda(modo,orden,totales){

	if (document.getElementById("lista_agenda_"+orden).style.display == 'none'){
		document.getElementById("lista_agenda_"+orden).style.display = 'block';
		document.getElementById("sw_lista_agenda_cerrar_"+orden).style.display = 'block';
		document.getElementById("sw_lista_agenda_ampliar_"+orden).style.display = 'none';
	}else {
		document.getElementById("lista_agenda_"+orden).style.display = 'none';
		document.getElementById("sw_lista_agenda_ampliar_"+orden).style.display = 'block';
		document.getElementById("sw_lista_agenda_cerrar_"+orden).style.display = 'none';
	}
	
	/*for (i=0; i<totales; i++){
		document.getElementById("lista_agenda_"+i).style.display = 'none';
		document.getElementById("sw_lista_agenda_ampliar_"+i).style.display = 'block';
		document.getElementById("sw_lista_agenda_cerrar_"+i).style.display = 'none';
	}*/

}

function SacarPopup(){
	document.getElementById("principal").style.display = 'none';
	document.getElementById("caja").style.display = 'none';
	document.getElementById("caja_galeria_src").innerHTML = "";
	
} 

function HabilitarPopup(ww,hh){
	var width=ww;
	var height=hh;
	
	var anchoPantalla=screen.width;
	var altoPantalla=screen.height;
	var x=(anchoPantalla - parseFloat(width))/2;
	var y=(altoPantalla - parseFloat(height))/2;
	
	document.getElementById("principal").style.display = 'inline';
	
	//cambiar esto en firefox se ve mal
	if (ieversion){		
		document.getElementById("principal").style.height  = document.body.offsetHeight+"px";	
	}else {
		//alert ("funcion HabilitarPopup() ->"+document.body.scrollHeight+"--->"+(hh+200));
		if (document.body.scrollHeight>(hh+220)){
			document.getElementById("principal").style.height  = document.body.scrollHeight+"px";
		}
	}
	
	
	document.getElementById("caja").style.display = 'inline';
	document.getElementById("caja").style.top = y-250+'px';
	document.getElementById("caja").style.left = x+'px';
	
	SetEfectos('caja');
	
}

function CambiarSrc(id,titulo,autor,v_src, objeto){
	
	document.getElementById(objeto+"_src").innerHTML = '<img src="'+v_src+'" alt="" title="" />';
	document.getElementById(objeto+"_bajada").innerHTML = titulo+". ("+autor+")";
	document.getElementById(objeto+"_descarga").innerHTML = '<a href="/download.php?fileId='+id+'" class="fc_c1_18" style=" font-weight:bold;">Download</a>';
	
	if (!ieversion){
		document.getElementById("caja").style.width='840';
		document.getElementById(objeto+"_descarga").style.width='840';		
	}else {
		
		if (ieversion == 6){		
			document.getElementById("caja").style.width='795px';
			document.getElementById(objeto+"_descarga").style.width='795px';
		}
		if (ieversion == 7){		
			document.getElementById("caja").style.width='863px';
			document.getElementById(objeto+"_descarga").style.width='863px';
		}
	}
	
	HabilitarPopup(820,428);

}

function PopupVideoPropio(v_src, objeto){
	
	document.getElementById(objeto+"_src").innerHTML = '<iframe src="'+v_src+'" frameborder="0" width="480" height="302" marginheight="0" marginwidth="0" scrolling="no" ></iframe>';
	document.getElementById(objeto+"_bajada").innerHTML="";
	document.getElementById(objeto+"_descarga").innerHTML="";
	document.getElementById(objeto+"_descarga").className = "descarga_1 fc_c1_18";
	
	if (!ieversion){
		document.getElementById("caja").style.width='480';
	}else {	
		if (ieversion >= 6){		
			document.getElementById("caja").style.width='523px';
		}
		
	}
	
	HabilitarPopup(480,302);
	
}

function validarBusquedaSimple(valorBusqueda){
	if (valorBusqueda.length < 3){
	return false;
	}else {
	return true;
	}
}


function verReloj(hhh,mmm,sss){
	
    alert (mmm);
	document.getElementById("reloj_header") = hhh + " : " + mmm + " : " + sss;
    
} 

function cambiarMapaHome(){
	myclick(document.getElementById("id_mapa_socio").value);
	map.setZoom(15);
}

function cambiar_socio_rightbar(){
	
	var socio = document.getElementById("selector_socios_rightbar").value;
	document.location.href = document.getElementById("selector_socios_rightbar").value;

}

function addDestinosPlanifique(){
	
	var comboBox = document.getElementById('destinos');
	var text = document.getElementById('destinos_selector').options[document.getElementById('destinos_selector').options.selectedIndex].text
	text = text.replace("--","");
	var newOption = new Option(text,text);
	comboBox.options[comboBox.options.length] = newOption;
	
	document.getElementById('destinos_selector').options[document.getElementById('destinos_selector').options.selectedIndex] = null;
}

function delDestinosPlanifique(){
	
	document.getElementById('destinos').options[document.getElementById('destinos').options.selectedIndex] = null;
}
