function showDV(id){
	obj = document.getElementById(id)
	if(obj){
		if(obj.style.display ==""){
			obj.style.display ="none"
		}
		else{
			obj.style.display =""
		}
	}
}

var marcado
    
function showDVGrupo(id,grupo){
	marcado = id;
	MM_swapImage('10gestos','','img/botones/10g-nm.gif',1)
	MM_swapImage('hogar','','img/botones/hogar-nm.gif',1)
	MM_swapImage('jardin','','img/botones/jard-nm.gif',1)
	MM_swapImage('comunidad','','img/botones/vecn-nm.gif',1)
	
	var arrDvs = document.getElementsByTagName("DIV");
	for(i=0;i<arrDvs.length;i++){
		if (arrDvs[i].id.substring(0,grupo.length)==grupo){
			arrDvs[i].style.display="none";
		}
	}
	obj = document.getElementById(id)
	if(obj){
		if(obj.style.display ==""){
			obj.style.display ="none";
		}
		else{
			obj.style.display ="";
		}
	}
}
function showDVGrupoEmpresas(i,grupo){
	var i;
	var id = 'comp'+ i;
	var iant = i--;
	var isig = i++;
	
	var arrDvs = document.getElementsByTagName("DIV");
	document.getElementById('dvant').style.display="";
	document.getElementById('dvsig').style.display="";
	document.getElementById('dvsig').style.visibility="visible";
	document.getElementById('dvant').style.visibility="visible";
		
	if	(i==0) { 		
		document.getElementById('dvant').style.visibility="hidden";
	 }
	
	if (i==4) {
	
	document.getElementById('dvsig').style.visibility="hidden";
	 }
	
	for(i=0;i<arrDvs.length;i++){
		if (arrDvs[i].id.substring(0,grupo.length)==grupo){
			arrDvs[i].style.display="none";
		}
	}
	obj = document.getElementById(id)
	if(obj){
		if(obj.style.display ==""){
			obj.style.display ="none";
		}
		else{
			obj.style.display ="";
		}
	}
}

function showDVGrupoEmpresasABC(i,grupo){
	var i;
	var id = 'comp'+ i;
	
	var arrDvs = document.getElementsByTagName("DIV");
	
	for(i=0;i<arrDvs.length;i++){
		if (arrDvs[i].id.substring(0,grupo.length)==grupo){
			arrDvs[i].style.display="none";
		}
	}
	obj = document.getElementById(id)
	if(obj){
		if(obj.style.display ==""){
			obj.style.display ="none";
		}
		else{
			obj.style.display ="";
		}
	}
}

function showDVGrupo2(id,grupo){
	
	var arrDvs = document.getElementsByTagName("DIV");
	
	for(i=0;i<arrDvs.length;i++){
		if (arrDvs[i].id.substring(0,grupo.length)==grupo){
			arrDvs[i].style.display="none";
		}
	}
	obj = document.getElementById(id)
	if(obj){
		if(obj.style.display ==""){
			obj.style.display ="none";
		}
		else{
			obj.style.display ="";
		}
	}
}

var marcada
   
function showDVGrupo3(id,grupo){
	marcada = id;
	MM_swapImage('ecolaboradoras','','img/botones/ecolab-nm.gif',1)
	MM_swapImage('sumesuempresa','','img/botones/sume-nm.gif',1)
	MM_swapImage('consejosempresa','','img/botones/consemp-nm.gif',1)
	
	var arrDvs = document.getElementsByTagName("DIV");
	for(i=0;i<arrDvs.length;i++){
		if (arrDvs[i].id.substring(0,grupo.length)==grupo){
			arrDvs[i].style.display="none";
		}
	}
	obj = document.getElementById(id)
	if(obj){
		if(obj.style.display ==""){
			obj.style.display ="none";
		}
		else{
			obj.style.display ="";
		}
	}
}
var mark
function showDVGrupo5(id,grupo){
	mark = id;
	MM_swapImage('CorresponsalesdelAgua','','img/botones/coragua-nm.gif',1)
	MM_swapImage('Calendario','','img/botones/calendario-nm.gif',1)
	
	var arrDvs = document.getElementsByTagName("DIV");
	for(i=0;i<arrDvs.length;i++){
		if (arrDvs[i].id.substring(0,grupo.length)==grupo){
			arrDvs[i].style.display="none";
		}
	}
	obj = document.getElementById(id)
	if(obj){
		if(obj.style.display ==""){
			obj.style.display ="none";
		}
		else{
			obj.style.display ="";
		}
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var timer, timerAnim, alphaEntra, alphaSale, ultimo
function cargaAnimacion(){
	ultimo = 1
	alphaSale=100
	alphaEntra=0
	timer = setInterval("animacion()",10000)
}

function animacion(){
	var numero = parseInt(Math.random() * 4 + 1)
	while(numero==ultimo){
		numero = parseInt(Math.random() * 4 + 1)
	}

	objUltimo = document.getElementById("consejo" + ultimo)
	objActual = document.getElementById("consejo" + numero)
	if (objActual && objUltimo){
		objActual.style.cssText = "display:none;float:right;margin:53px 2px 0px 66px;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0)"
		timerAnim = setInterval("mostrar('consejo" + numero + "','consejo" + ultimo + "')",5)
		ultimo = numero
	}
}

function mostrar(idEntra, idSale){
	objEntra = document.getElementById(idEntra)
	objSale = document.getElementById(idSale)
	if (alphaSale>0){
		objSale.style.cssText = "float:right;margin:53px 2px 0px 66px;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=" + alphaSale + ")"
		alphaSale = alphaSale - 8
	}
	else if(alphaEntra<100){
		objSale.style.display = "none"
		objEntra.style.display = ""
		objEntra.style.cssText = "float:right;margin:53px 2px 0px 66px;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=" + alphaEntra + ")"
		alphaEntra = alphaEntra + 8
	}
	else{
		alphaSale=100
		alphaEntra=0
		clearInterval(timerAnim)
	}
}

var ventana,fichero;
var headHTML = '<html>\n<head>\n';
headHTML += '<title>Consejos del Canal de Isabel II</title>\n';
headHTML += '</head>\n<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">\n\n<div align="center">\n\n';
var footHTML = '</div>\n\n</body>\n</html>';


function popupWin(imgURL) {
	fichero = imgURL;

	tmpImg = new Image();
	tmpImg.src = fichero;

	x = ((screen.width / 2) - (100));
	y = ((screen.height / 2) - (25));
	
	var stbyHTML = '<p><b><i>Descargando Imagen... Por favor espere</i></b></p>';

	ventana = window.open('','ventana','width=100,height=100,toolbar=no,location=no,directories=no,status=no,menubar=no,resize=yes,scrollbars=yes,copyhistory=no');
	ventana.resizeTo(200,50);
	ventana.moveTo(x,y);
	ventana.focus();

	ventana.document.write(headHTML);
	ventana.document.write(stbyHTML);
	ventana.document.write(footHTML);
	ventana.document.close();

	if (tmpImg.complete) { showImg(); }
	else { tmpImg.onload = showImg;	}
}

function popupWinSWF(imgURL,an,al) {
	fichero = imgURL;

	tmpImg = new Image();
	tmpImg.src = fichero;
	x = ((screen.width / 2) - (an/2));
	y = ((screen.height / 2) - (al/2));
	
	var stbyHTML = '<p><b><i>Descargando Imagen... Por favor espere</i></b></p>';

	ventana = window.open('','ventana','width=100,height=100,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resize=yes,copyhistory=no');
	ventana.resizeTo(an,al);
	ventana.moveTo(x,y);
	ventana.focus();
	
	swf ="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"100%\" height=\"100%\" VIEWASTEXT>"
	swf = swf +  "<param name=\"movie\" value=\"" + imgURL + "\">"
	swf = swf +  "<param name=\"quality\" value=\"high\">"
	swf = swf +  "<embed src=\"" + imgURL + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"100%\" height=\"100%\"></embed>"
	swf = swf +  "</object>"
	ventana.document.write(headHTML + swf + footHTML);
}

function showImg() {

	if (ventana.closed) { return false; }

	w = tmpImg.width + 10;
	h = tmpImg.height + 29;
	w2 = w -10
	h2 = h -10
	if (w>740){w=740;w2=730}
	if (h>500){h=500;h2=470}
	x = ((screen.width / 2) - (w / 2));
	y = ((screen.height / 2) - (h / 2));

	var imgHTML = ' <a href="#" onclick="window.close();return false">\n';
	imgHTML += '   <img border="0" src="'+fichero+'"></a>\n\n';

	ventana.resizeTo(w,h);
	ventana.moveTo(x,y);
	ventana.focus();

	ventana.document.write(headHTML);
	ventana.document.write(imgHTML);
	ventana.document.write(footHTML);
	ventana.document.close();
}
