	/**
 * @author soptec
 */
//var tabla='<table width="100%"><tr><td id="fmenu" height="36"></td></tr><tr><td id="fcont"  ></td></tr></table>';
var tabla = '<div width="100%" id="fmenu" height="36"></div><br><div id="fcont" height="630" width="100%"> </div>';
var video = '<noscript> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="480" height="270" id="FLVPlayer"> <param name="movie" value="FLVPlayer_Progressive.swf" /><param name="salign" value="lt" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="scale" value="noscale" />    <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Corona_Skin_3&streamName=recursos/agua-viernes_11Mbps_001&autoPlay=true&autoRewind=false" /><embed wmode="transparent" src="FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=Corona_Skin_3&streamName=recursos/agua-viernes_11Mbps_001&autoPlay=true&autoRewind=false" quality="high" scale="noscale" width="480" height="270" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" /></object></noscript>';
var menusacm = '<embed wmode="transparent" height="41px" width="670px" src="swf/categorias_secundarias/secundaria_seccion1.swf"/>';
var menusau = '<embed  wmode="transparent" height="41px" width="670px" src="swf/categorias_secundarias/secundaria_seccion2.swf"/>';
var menucultura = '<embed  wmode="transparent" height="41px" width="670px" src="swf/categorias_secundarias/secundaria_seccion31.swf"/>';
var menumarco = '<embed  wmode="transparent" height="41px" width="670px" src="swf/categorias_secundarias/secundaria_seccion4.swf"/>';
var menucompras = '<embed wmode="transparent"  height="41px" width="670px" src="swf/categorias_secundarias/secundaria_seccion5.swf"/>';
var menupublicacion = '<embed wmode="transparent"  height="41px" width="670px" src="swf/categorias_secundarias/secundaria_seccion6.swf"/>';
var menutransparencia = '<embed  wmode="transparent" height="41px" width="670px" src="swf/categorias_secundarias/secundaria_seccion7.swf"/>';
var menutarjeta = '<embed  wmode="transparent" height="41px" width="670px" src="swf/categorias_secundarias/secundaria_seccion8.swf"/>';
var arbol=false;
var cp2006="";
/****************************************************/
//Funciones trim
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

/*********************************************************/
function totalGraf(url, tip, tcol1, tcol2, tit) {
    doPostGraf(url, "", "fcont", tip, tcol1, tcol2, tit);
}
function doPostGraf(url, vars, div, tip, tcol1, tcol2, tit) {
    var ajax = null;

	alt=$("#"+div).css("height");
	if(alt=="auto") alt="730px";
    $("#"+div).html("<center><img src='img/ajax-loader-min.gif' align='center'></center>");	

	$("#"+div).animate({ height:"96px"}, "normal", function(){
		try {
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(exception) {
			ajax = new XMLHttpRequest();
		}
		ajax.open('POST', url, true);
		ajax.onreadystatechange = function () {
			if (ajax.readyState == 4) {	
				if (ajax.status == 200) {					
					$("#"+div).html(ajax.responseText);					
					$("#"+div).animate({ height: alt}, "normal", function(){						
						if(div=="dinamico"){
							$("#"+div).removeAttr("style");
						}						
					});
					if(tip=="pie"){
						var algo=$("#valor").html();					
						data="html/publicaciones/calidad/2010/total/data_tot.php?valor="+algo;
						dataurl="swf/open-flash-chart.swf";
						widthgraf="480";
						heightgraf="250";								
					}else if(tip=="line"){
						var algo=$("#valor").html();
						var fila=document.getElementById("data");
						fila=fila.getElementsByTagName("tr");
						
						titx="data=";
						col1="";
						col2="";
						j=0;
						for(i=2; i<fila.length; i++){
							tdl=fila[i].getElementsByTagName("td");
							titx+=tdl[0].innerHTML.trim()+"@";
							col1+=tdl[1].innerHTML.trim()+"@";
							col2+=tdl[2].innerHTML.trim()+"@";
							
							j++;
						}						
						data="html/publicaciones/calidad/2010/total/data_point.php?"+titx+col1+col2+tcol1+"@"+tcol2+"@"+tit;						
						
						dataurl="swf/open-flash-chart.swf";
						widthgraf="480";
						heightgraf="250";
					}else if(tip=="line_grand"){
						var algo=$("#valor").html();
						var fila=document.getElementById("data");
						fila=fila.getElementsByTagName("tr");
						
						titx="data=";
						col1="";
						col2="";
						j=0;
						for(i=2; i<fila.length; i++){
							tdl=fila[i].getElementsByTagName("td");
							titx+=tdl[0].innerHTML.trim()+"@";
							col1+=tdl[1].innerHTML.trim()+"@";
							col2+=tdl[2].innerHTML.trim()+"@";
							
							j++;
						}						
						data="html/publicaciones/calidad/2010/total/data_point_grand.php?"+titx+col1+col2+tcol1+"@"+tcol2+"@"+tit;						
						
						dataurl="swf/open-flash-chart.swf";
						widthgraf="550";
						heightgraf="250";
					}
					else if(tip=="line_med"){
						var algo=$("#valor").html();
						var fila=document.getElementById("data");
						fila=fila.getElementsByTagName("tr");
						
						titx="data=";
						col1="";
						col2="";
						j=0;
						for(i=2; i<fila.length; i++){
							tdl=fila[i].getElementsByTagName("td");
							titx+=tdl[0].innerHTML.trim()+"@";
							col1+=tdl[1].innerHTML.trim()+"@";
							col2+=tdl[2].innerHTML.trim()+"@";
							
							j++;
						}						
						data="html/publicaciones/calidad/2010/total/data_point_med.php?"+titx+col1+col2+tcol1+"@"+tcol2+"@"+tit;						
						
						dataurl="swf/open-flash-chart.swf";
						widthgraf="550";
						heightgraf="250";
					}
					swfobject.embedSWF(dataurl, "holder", widthgraf, heightgraf, "9.0.0", "expressInstall.swf", {"data-file":data} );					
				}
				else if (ajax.status == 404) {
					return "La direccion no existe";
				}
			}
		}
		ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		ajax.send(vars);											
															
	});
    
}
function borrarSWF(val){
    $("#"+val).unbind();
	$("#"+val).remove();
}
function timedCount()
{

$("#poptarjeta").slideUp("slow", function(){
	$("#divswf").show("slow");								   
});
if($("#poptarjeta").css("display")=="none"){
	 clearTimeout(t);
	 
}

}

function stopCount()
{
clearTimeout(t);
}
$(document).ready(function () {
    $("#poptarjeta").slideDown("slow", function(){
		$("#divswf").hide("fast");							   
	});
	var top = "50px";
	t=setTimeout("timedCount()",5000);
    var left = (document.getElementById("ref").offsetLeft - 7) + "px";
    document.getElementById("sombratormenta").style.left = left;
    document.getElementById("sombrainteres").style.left = left;
    document.getElementById("sombracarcamo").style.left = left;
    document.getElementById("sombratormenta").style.top = top;
    document.getElementById("sombracarcamo").style.top = top;
    document.getElementById("sombrainteres").style.top = top;
    document.getElementById("sombratormenta").style.width = (document.getElementById("poptormenta").offsetWidth + 5) + "px";
    document.getElementById("sombrainteres").style.width = (document.getElementById("popinteres").offsetWidth + 5) + "px";
    document.getElementById("sombracarcamo").style.width = (document.getElementById("popcarcamo").offsetWidth + 5) + "px";
    document.getElementById("sombratormenta").style.height = (document.getElementById("poptormenta").offsetHeight + 5) + "px";
    document.getElementById("sombrainteres").style.height = (440 + 5) + "px";
    document.getElementById("sombracarcamo").style.height = (document.getElementById("popcarcamo").offsetHeight + 5) + "px";
    $("#sombrainteres").fadeOut("fast");
    $("#sombracarcamo").slideUp("fast");
    $("#sombratormenta").hide("fast");
    var top = (document.getElementById("ref").offsetTop + 8) + "px";
    $("#sombratormenta").corner("14px");
    $("#poptormenta").corner("15px");
    $("#sombrainteres").corner("14px");
    $("#popinteres").corner("15px");
    $("#sombracarcamo").corner("14px");
    //$("#shadowcarcamo").corner("14px");
    $("#popcarcamo").corner("15px");
    document.getElementById("poptormenta").style.top = "2px";
    document.getElementById("poptormenta").style.left = "2px";
    document.getElementById("popinteres").style.top = "2px";
    document.getElementById("popinteres").style.left = "2px";
    document.getElementById("popcarcamo").style.top = "2px";
    document.getElementById("popcarcamo").style.left = "2px";
    $("#ltormenta").click(function () {
        $("#sombratormenta").show("fast");
    });
    $("#ctormenta").click(function () {
        $("#sombratormenta").hide("fast");
    });

    $("#linteres").click(function () {
        $("#sombrainteres").fadeIn("fast");

    });
    $("#cinteres").click(function () {
        $("#sombrainteres").fadeOut("fast");
    });

    $("#lcarcamo").click(function () {
        $("#sombracarcamo").slideDown("fast", function () {
		});
    });
    $("#ccarcamo").click(function () {
        $("#sombracarcamo").slideUp("fast", function () {
            //document.getElementById("shadowcarcamo").style.visibility="hidden";
        });
    });

});

function cargarHTML(url) {
    doPost(url, "", "fcont");
}


function cargarArt14() {
	url="html/transparencia/articulos/art14.php";
	vars="";
	div="fcont";
    var ajax = null;

	//alert(height);
	alt=$("#"+div).css("height");
	if(alt=="auto") alt="730px";
    $("#"+div).html("<center><img src='img/cargando.gif' align='center'></center>");
	
//	$("#"+div).fadeOut("slow");
	$("#"+div).animate({ height:"96px"}, "normal", function(){
		try {
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(exception) {
			ajax = new XMLHttpRequest();
		}
		ajax.open('POST', url, true);
		ajax.onreadystatechange = function () {
			if (ajax.readyState == 4) {
	
				if (ajax.status == 200) {
					
					//$("#dinamico").animate({ height: alt}, { queue:false, duration:5000 });
					
					//$("#"+div).fadeIn("slow", function(){
					$("#"+div).html(ajax.responseText);
					
					$("#"+div).animate({ height: alt}, "normal", function(){
						
						if(div=="dinamico"){
							$("#"+div).removeAttr("style");
						}
					});
					
						$(".arbol").treeview({
							animated: "fast",
							collapsed: true,
							unique: true												
						});
						arbol=true;
						cp2006=document.getElementById("cp2006").innerHTML;
					
					
				}
				else if (ajax.status == 404) {
					return "La direccion no existe";
				}
			}
		}
		ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		ajax.send(vars);											
															
	});
    
}
function cargarHome() {
	$.cookie("idModulo", "20");
	$.cookie("tipo", false);
    doPost("html/home.php", "", "dinamico");
}
function cargarclc() {
	$.cookie("idModulo", "20");
	$.cookie("tipo", false);
    doPost("html/licitaciones/clc.php", "", "dinamico");
}
function verCultura(mod) {
    var url = "",
    dims = "";

    if (mod == 1) {
        url = "html/cultura/camino.html";
        dims = "width=700,height=575";
    }
    else if (mod == 2) {
        url = "html/cultura/libros.html";
        if (detectarNavegador()) dims = "width=820,height=665,location=YES";
        else dims = "width=820,height=665,toolbar=YES";
    }
    else if (mod == 3) {
        url = "html/cultura/futuro.html";
        dims = "width=700,height=665";
    }
    else if (mod == 4) {
        url = "html/cultura/limpieza.html";
        dims = "width=700,height=575";
    }
    else if (mod == 5) {
        url = "html/cultura/tips.html";
        dims = "width=700,height=650";
    }

    var ventana = window.open(url, "popup", dims);
}
function detectarNavegador() {
    if (navigator.appName.indexOf("Explorer") != -1) {
        return true;
    }
    else {
        return false;
    }
}
function doGet(url, vars) {
    var xml = null;
    try {
        xml = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(exception) {
        xml = new XMLHttpRequest();
    }
    xml.open("GET", url + "?" + vars, false);
    xml.send(null);
    if (xml.status == 404) return "Url no valida";
    else return xml.responseText;
}

function verLibro(nombre) {
    window.open('../../swf/libros/' + nombre + '.html', 'popup', 'width=820,height=610');

}
function matarCookies(){
	$.cookie("idModulo", null);
	$.cookie("tipo", null);
	$.cookie("fnc", null);
}
function recargar(){
	
	tipo=$.cookie('tipo');
	idModulo=$.cookie("idModulo");
	
	fnc=$.cookie("fnc");
	
	if(tipo!="" && idModulo!="" && fnc!=""){
		idModulo=parseInt(idModulo);
		fnc=parseInt(fnc);
		if(isNaN(idModulo)){
			idModulo=20;
			tipo=false;
			fnc=0;
		}
		
		if(fnc==0)
		actualizarTD(idModulo, tipo);
		else
		dirigirBanners(idModulo, tipo);
		
		
		
		
	}
}
function doPost(url, vars, div) {
    var ajax = null;

	//alert(height);
	
	
	alt=$("#"+div).css("height");

	if(alt=="auto") alt="730px";
    $("#"+div).html("<center><img src='img/ajax-loader-min.gif' align='center'></center>");
	
//	$("#"+div).fadeOut("slow");
	$("#"+div).animate({ height:"96px"}, "normal", function(){
		try {
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(exception) {
			ajax = new XMLHttpRequest();
		}
		ajax.open('POST', url, true);
		ajax.onreadystatechange = function () {
			if (ajax.readyState == 4) {
	
				if (ajax.status == 200) {
					
					
					$("#"+div).html(ajax.responseText);
					
					$("#"+div).animate({ height: alt}, "normal", function(){
						
						if(div=="dinamico"){
							$("#"+div).removeAttr("style");
						}
					});
					
					
					
				}
				else if (ajax.status == 404) {
					return "La direccion no existe";
				}
			}
		}
		ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		ajax.send(vars);											
															
	});
    
}


//Emergente
function quejas(URL, TITULO) {
    window.open(URL, TITULO, "width=680,height=550,scrollbars=no,menubar=no");
}

function regresarMapa() {
    document.getElementById("fcont").innerHTML = "<br><embed src='swf/mapas/mapas.swf' width='667' height='635'/>";
}
function verDelegacion(delegacion) {

    document.getElementById("fcont").innerHTML = "<br><embed src='swf/mapas/" + delegacion + ".swf' width='667' height='635'/>";
}
function volverDirectorio() {

    doPost("html/directorio/index.php", "", "fcont");
}
function verDireccion(idMod) {
    doPost("html/directorio/index.php", "id_tipo=" + idMod, "fcont");
}
function actualizarTD(idModulo, tipo) {
	
	$.cookie("idModulo", idModulo);
	$.cookie("tipo", tipo);
	$.cookie("fnc", "0");
	
	
    if (tipo) $("#dinamico").html(tabla);
    if (((idModulo > 0 && idModulo <= 5) || idModulo == 14) && tipo)$("#fmenu").html(menusacm);
    else if ((idModulo >= 6 && idModulo <= 10) && tipo) {
        $("#fmenu").html(menusau);
    }
    else if ((idModulo >= 11 && idModulo <= 13) && tipo) {
       $("#fmenu").html(menucultura);
    }
    else if ((idModulo >= 15 && idModulo <= 18) && tipo) $("#fmenu").html(menumarco);
    else if (idModulo == 19 && tipo) {
        $("#fmenu").html(menutarjeta);
    }
	
	
    switch (idModulo) {
    case 1:
        urlajax = "html/sacm.php";
        break;
    case 2:
        urlajax = "html/sacm.php";
        break;
    case 3:
        urlajax = "html/funciones.php";
        break;
    case 4:
        alert("PENDIENTE");
        break;
    case 5:
        urlajax = "html/directorio/index.php";
        break;
    case 6:
        urlajax = "html/pagos.php";

        break;
    case 7:
        urlajax = "html/pagos.php";
        break;
    case 8:
        $("#fcont").html("<embed  wmode='transparent'  src='swf/mapas/mapas.swf' width='667' height='635'/>");
        return;
        break;
    case 9:
        urlajax = "html/tarifas.php";
        break;
    case 10:
        urlajax = "html/tramitesindex.php";
        break;
    case 11:
        urlajax = "html/tips.php";
        break;
    case 12:
        urlajax = "html/tips.php";
        break;
    case 13:
        $("#fcont").html("<embed wmode='transparent' src='swf/cultura.swf' width='667' height='635'/>");
		//$("#dinamico").show("slow");
        return;
        break;
    case 14:
        urlajax = "html/contacto.php";
        break;
    case 15:
        urlajax = "html/transparencia/leyes.php";
        break;
    case 16:
        urlajax = "html/transparencia/leyes.php";
        break;
    case 17:
        urlajax = "html/transparencia/reglamentos.php";
        break;
    case 18:
        urlajax = "html/transparencia/circulares.php";
        break;
    case 19:
        urlajax = "html/tarjeta.php";
        break;
    case 21:
        urlajax = "html/licitaciones/clc.php";
        break;
	case 20:
		cargarHome();
		return;
	break;
		
	break;
    }
	
    doPost(urlajax, "", "fcont");
	
}
function verTransparencia() {
    document.getElementById("dinamico").innerHTML = tabla;
    document.getElementById("fmenu").innerHTML = menutransparencia;
    doPost("html/transparencia/index.php", "", "fcont");
    document.location = "#";
}
function dirigirBanners(idModulo, tipo) {
	$.cookie("idModulo", idModulo);
	$.cookie("tipo", tipo);
	$.cookie("fnc", "1");

    if (tipo) document.getElementById("dinamico").innerHTML = tabla;
    if ((idModulo == 1 || idModulo == 2 || idModulo == 6 ) && tipo) document.getElementById("fmenu").innerHTML = menucompras;
    else if ((idModulo >= 3 && idModulo <= 5) && tipo) document.getElementById("fmenu").innerHTML = menupublicacion;
    var urlajax = "";
    switch (idModulo) {
    case 1:
        urlajax = "html/licitaciones/compras2008.php";
        break;
    case 2:
        urlajax = "html/licitaciones/prebases.php"; //Listo
        break;

    case 3:
        urlajax = "html/publicaciones/compromisos2008.php"; //Listo
        break;
    case 4:
        urlajax = "html/publicaciones/calidadagua.php"; //Pendiente
        break;
    case 5:
        urlajax = "html/publicaciones/apazu2008.php"; //Listo
        break;
	case 6:
        urlajax = "html/licitaciones/clc.php"; //Listo
        break;
    }
	
    
    doPost(urlajax, "", "fcont");
}
function dirigir(url) {

    doPost(url, "", "fcont");
}
function verDiv(nombre, vis, tam) {

	$("div#fcont ul li>div").css("visibility", "hidden");
	$("div#fcont ul li>div").css("display", "none");
	$("#"+nombre).css("visibility", vis);
	if (vis == "visible") $("#"+nombre).css("display", "block");
}

function verPopup(id) {
    document.getElementById("popup").innerHTML="";
	document.getElementById("swfpop").style.visibility="hidden";
	document.getElementById("popup").style.display="block";
	doPost("html/tramites.php", "id="+id, "popup");
}

function cerrarPopup() {
    document.getElementById("swfpop").style.visibility = "visible";
    document.getElementById("popup").style.display = "none";
}
function onOver(elem) {
    elem.src = "img/close_over.png";
}
function onOut(elem) {
    elem.src = "img/close_out.png";
}
function onOverFlecha(elem) {
    elem.src = "img/icono_up_over.jpg";
}
function onOutFlecha(elem) {
    elem.src = "img/icono_up_out.jpg";
}

function mostrarPop(){
		
		tamano=tamanoVentana();
		height=tamano[1];
		width=tamano[0];
		var newdiv = document.createElement('div');
   		newdiv.setAttribute('id', "fondo_negro");
		
		document.body.appendChild(newdiv);
		
		

		html='<div  id="titulo" class="titulo_caja_gris_1_mod">'+
        '<img src="img/base/pleca_vineta.jpg" width="22" height="26px" align="absmiddle" />'+
        '<span class="titulo_blanco"> Acciones para el Ahorro de Agua</span>'+
      '</div>'+
      '<div   id="sep_menu" class="titulo_caja_gris_2_mod">'+
        '&nbsp;'+
      '</div>'+
      '<div id="barra_menu" class="titulo_caja_gris_3_mod">'+
        '<div id="close" ><a href="javascript:;" onclick="cerrarVideo()" id="kill"><img align="right" src="img/close_out.png"/>	</a>	</div>'+
      '</div><div id="cont_mod" ><center>'+
	  '<img src="img/acciones.jpg" alt="Ahorro en Casa"/></center>'+
	  '</div>';
	 //27
	 	var newdiv = document.createElement('div');
   		newdiv.setAttribute('id', "module");
		
		aux=705*100/width;
		
		left=(100-aux)/2;
		izq=""+Math.round(left);		
		aux=538*100/height;
		alto=0;
		alto=(100-aux)/2.5;		
		alto=Math.round(alto);
		alto=""+alto;
		
		alto=Math.round(height*alto/100);
		newdiv.innerHTML=html;
		document.body.appendChild(newdiv);
		if (BrowserDetect.browser=="Explorer" && BrowserDetect.version=="6"  )
		{
			document.getElementById("fondo_negro").style.height=height+"px";
			document.getElementById("fondo_negro").style.width=width+"px";
		}
		//document.getElementById("module").style.left=izq;
		
		$('#module').scrollFollow(
					{
						speed: 500,
						offset: alto,
						relativeTo: 'top',
						killSwitch: 'kill',
						onText: 'Cerrar'
					}
				);
		
		$( '#fondo_negro' ).scrollFollow(
					{
						speed: 500,
						offset: 0,
						relativeTo: 'top',
						killSwitch: 'kill',
						onText: 'Cerrar'
					}
				);
		
	
	
}
function tamanoVentana() {
  var Tamanyo = [0, 0];
  if (typeof window.innerWidth != 'undefined')
  {
    Tamanyo = [
        window.innerWidth,
        window.innerHeight
    ];
  }
  else if (typeof document.documentElement != 'undefined'
      && typeof document.documentElement.clientWidth !=
      'undefined' && document.documentElement.clientWidth != 0)
  {
 Tamanyo = [
        document.documentElement.clientWidth,
        document.documentElement.clientHeight
    ];
  }
  else   {
    Tamanyo = [
        document.getElementsByTagName('body')[0].clientWidth,
        document.getElementsByTagName('body')[0].clientHeight
    ];
  }
  return Tamanyo;
}
function cerrarVideo(){
	document.body.removeChild(document.getElementById("module"));
	document.body.removeChild(document.getElementById("fondo_negro"));
}
function abrirVentana (pagina) {
var opciones= "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=780, height=780, top=85, left=140";
window.open(pagina,"",opciones);
}