	function muestradivMapa(divNameMain,divMapa,idSubSeccion)
{
	if(document.getElementById(divNameMain).style.display=='none')
		{
		document.getElementById(divNameMain).style.display='';
		showGoogleMapsPlanimetria(divMapa,idSubSeccion);	
		}
	else document.getElementById(divNameMain).style.display='none';
	
	

}



function saltosLinea(texto, conbr) {

 var nl=document.all?String.fromCharCode(13):"\n";
 if (conbr) { 	
 	while(texto.indexOf(nl)>=0){
	  texto = texto.replace(nl, "<br/>");
	  if(document.all)  texto = texto.replace("\n", "");
	}
 } else {
	while(texto.indexOf("<br/>")>=0){
	  texto = texto.replace("<br/>",nl);
	}
 }
 return texto;
}


function muestraDiv(divname)
{
	if(document.getElementById(divname).style.display=='none')document.getElementById(divname).style.display='';
	else document.getElementById(divname).style.display='none';

}



function vistaPrevia(formName,container, divOrigen,divDestino,divcontroles)
{



	var textContainer=document[formName][container].value;
	textContainer=saltosLinea(textContainer,true);
	
	document.getElementById(divDestino).innerHTML =textContainer;

	muestraDiv(divDestino);	
	muestraDiv(divcontroles);		
	muestraDiv(divOrigen);		
	
}




function showGoogleMapsPlanimetria(divDestino, idSubSeccion){
	latitud=41.126816;
	longitud=1.243459;
	zoom=16;





      if (GBrowserIsCompatible()) {

		var map = new GMap2(document.getElementById(divDestino));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());	
		map.setMapType(G_HYBRID_MAP);

		function addtag(point, address) 
			{        
			var marker = new GMarker(point);        
			GEvent.addListener(marker, "click", function() {	marker.openInfoWindowHtml(address); } );        
			return marker;        
			}
			
		var preferencias = new Array;
		var poliLinePoints = new Array;
		
		preferencias=llamadaAJAXPoints("cargaPuntos.asp?id="+idSubSeccion+"&tipo=prefs");
		poliLinePoints=llamadaAJAXPoints("cargaPuntos.asp?id="+idSubSeccion+"&tipo=puntos");

		
		var point2 = new GLatLng(preferencias[0],preferencias[1]);
		map.setCenter(point2,parseInt(preferencias[2]));

		var address = llamadaAJAXContenido("cargaMapa.asp?id="+idSubSeccion);
		var marker = addtag(point2, address);   	
		map.openInfoWindow(point2, address);
		map.addOverlay(marker);		



		
		if(poliLinePoints.length>1)
		{
			var Lineas= new Array
			for(i=0; i<(poliLinePoints.length/2); i++)Lineas.push(new GLatLng(poliLinePoints[i*2],poliLinePoints[(i*2)+1]));
			var polyline = new GPolyline(Lineas, preferencias[3],preferencias[4]);
			map.addOverlay(polyline);	
		}
		
		


}
	

	
}


function showGoogleMaps(latitud, longitud, zoom,  text){

	var newZoom=16
	 if(zoom!="")newZoom=zoom;


      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("dondeEstamos"));
        map.setCenter(new GLatLng(latitud, longitud), newZoom);
	
//		insertar una linea simple:
//		map.openInfoWindow(map.getCenter(),document.createTextNode(text));

//		insertar codigo HTML
		map.openInfoWindow(map.getCenter(),text);		

		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());		
		
		var point = new GLatLng(latitud, longitud);
		map.addOverlay(new GMarker(point));
	  }
}
	
	
	

function InsertaFlash(id,nombre,ancho,alto,alineado,bgcolor,aleatorio){

	var r;
	if(aleatorio==1) r=Math.round(Math.random() * 99999);
	else r=0;
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ancho+'" height="'+alto+'" id="'+id+'" align="'+alineado+'"') 
	document.write('<param name="allowScriptAccess" value="sameDomain"/>') 
	document.write('<param name="movie" value="'+nombre+'?r='+r+'"/>')
	document.write('<param name="quality" value="high">')
	document.write('<param name="scale" value="exactfit">')
	
if(bgcolor==-1) {
	document.write('<param name="wmode" value="transparent" />')
	document.write('<param name="bgcolor" value="#000000" />')
	}
else{
	document.write('<param name="bgcolor" value="'+bgcolor+'">')
	}
	
	document.write('<embed src="'+nombre+'?r='+r+'" quality="high" bgcolor="'+bgcolor+'" width="'+ancho+'" height="'+alto+'" name="'+id+'" align="'+alineado+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />') 	
	document.write('</object>') 

}



 var win=null;
function NewWindow(myphoto,myname,w,h,pos,infocus)
	{
	if(pos=="center")
		{
		myleft=(screen.width)?(screen.width-w)/2:100;
		mytop=(screen.height)?(screen.height-h)/2:100;
		}
	else if((pos!='center' && pos!="random") || pos==null)
		{
		myleft=0;mytop=20
		}
		
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";

	var features;
	features+="location=no,"
	features+="toolbar=no,"
	features+="directories=no,"
	features+="menubar=no,"
	features+="scrollbars=no,"
	features+="menubar=no,"
	features+="resizable=no,"
	features+="fullscreen=0,"
	features+="status=yes,"
	features+="channelmode=0,"
	features+="width="+w+","
	features+="height="+h+","
	features+="top="+mytop+","
	features+="left="+myleft+","
	features+="topmargin=0;"

	win=window.open("","",features);
	win.document.write("<html><head><title>"+myname+"</title></head>");
	win.document.write("<body topmargin=0 leftmargin=0>");
	win.document.write("<img src='" + myphoto + "'></html>");
	win.focus();

	}


	

var highlightbehavior="TD"
var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor)
	{
	source=ie? event.srcElement : e.target
	if (source.tagName=="TABLE")
	return
	while(source.tagName!=highlightbehavior && source.tagName!="HTML")
		source=ns6? source.parentNode : source.parentElement
	if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
		source.style.backgroundColor=highlightcolor
	}

function contains_ns6(master, slave) { 
	while (slave.parentNode)
	if ((slave = slave.parentNode) == master)
		return true;
	return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}
	
