function cambio(idCapa){
  if (document.layers) capa = eval("document." + idCapa);
  if (document.all) capa = eval(idCapa + ".style");
  if (document.getElementById) capa = eval('document.getElementById("' + idCapa + '").style');

if ((capa.visibility == "hidden") || (capa.visibility == "hide")){
capa.visibility = (document.layers) ? "show" : "visible" ;
}else{
capa.visibility = (document.layers) ? "hide" : "hidden" ;
}
}
/*Desactiva al hacer click el botón de envio del formulario*/
function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
{
tempobj.disabled = true;
tempobj.value = "Searching..."
}

}
return true;
}}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe ser una direccion de correo.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe contener un numero.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' debe contener un numero entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
  } if (errors) alert('Se han encontrado los siquientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);



function MM_setTextOfLayer(objName,x,newText) { //v3.0
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (navigator.appName=='Netscape') {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function mOvr(src,clrOver)
{
if (!src.contains(event.fromElement))
	{
	src.style.cursor = 'hand';
	src.bgColor = clrOver;
	 }
}

function mOut(src,clrIn)
{
if (!src.contains(event.toElement))
	{
	src.style.cursor = 'default';
	src.bgColor = clrIn;
	}
}

function mClk(src) {
 if(event.srcElement.tagName=='TD')
	 src.children.tags('A')[0].click();
 }


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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

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];}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

/*No muestra nada en la barra de estado*/
function hidestatus(){
window.status=''
return true
}
if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

document.onmouseover=hidestatus
document.onmouseout=hidestatus
/*
Limpia la una caja de texto al pasar x encima el ratoncito :)
onFocus="clearText(this)"
PortalUrbano.com 2002 :)
*/
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 

/*
Crea un iframe para previsualizar el link q se le pase
onclick=" previsualizar('http://')"
PortalUrbano.com 2002 :)
*/

function previsualizar(ob)
{
	var sHTML = "<br><iframe src='" + ob + "' width=600 height=300></iframe><br>"
	var obj = event.srcElement;
	var objP = obj.parentElement;
	if (objP.children.length == 2)
	{
		objP.insertAdjacentHTML("beforeEnd", sHTML);
		obj.innerText = "Cerrar Previsualizar";
	}
	else
	{
		objP.children.item(2).outerHTML = "";
		objP.children.item(2).outerHTML = "";
		obj.innerText = "Previsualizar";
	}
}

/*
<input id="link" name="ventananueva" type="checkbox" onClick="nueva(this.checked)">
<label for="link">Abrir enlaces en ventana nueva</label><
*/

function nueva(valor) {
if (valor) abreen = "_blank"; else abreen = "_self";
for (var i=0; i<document.links.length; i++) { document.links[i].target = abreen; }
}

// style="filter:alpha(opacity=70);-moz-opacity:0.7" onMouseover="makevisible(this,0);" onMouseout="makevisible(this,1);"
function makevisible(cur,which){
strength=(which==0)? 1 : 0.7
if (cur.style.MozOpacity)
cur.style.MozOpacity=strength
else if (cur.filters)
cur.filters.alpha.opacity=strength*100
}
function redirect(URLStr) { location = URLStr; }
function portada(theURL) { //v2.0
  window.open(theURL,PutasdelRap,scrollbars=yes );
}
/*navHover = function() {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);*/
//	Set up all accordions
function loadAccordions() {
			var topAccordion = new accordion('#top_container', {
				classNames : {
					toggle : 'horizontal_accordion_toggle',
					toggleActive : 'horizontal_accordion_toggle_active',
					content : 'horizontal_accordion_content'
				},
				defaultSize : {
					width : 525
				},
				direction : 'horizontal'
			});
			var bottomAccordion = new accordion('#bottom_container');
			
			// Open first one
			bottomAccordion.activate($$('#bottom_container .accordion_toggle')[0]);
			
			// Open second one
			//topAccordion.activate($$('#top_container .horizontal_accordion_toggle')[2]);
		}
		
function items(id){
      var obj = document.getElementById('item_' + id)
      if(obj.style.display == 'block') obj.style.display = 'none'
      else obj.style.display = 'block'
}
function ocultaItems(){
      listado = document.getElementById('listado')
      contenedores = listado.getElementsByTagName('div')
      numContenedores = contenedores.length
      for(m=0; m < numContenedores; m++){
         if(contenedores[m].id.indexOf('item_') == 0)
         contenedores[m].style.display = 'none'
      }
} 

// google analytics
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4652808-2']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
