var mailWin;
function openMail()
{
	
	var url = 'mail.asp';
	mailWin = window.open(url,'mailWin','toolbar=0,location=0,directories=0,resizable=yes,status=0,menubar=0,width=380,height=330,scrollbars=no,left=100,top=120');
	mailWin.focus();
}
function centrar() 
{ 
	mailWin.moveTo((screen.width-380)/2,(screen.height-60)/2) //centra la ventana. Eliminar si no se quiere centrar el popup 
} 


function showMenu(menuID) {
    document.getElementById(menuID).style.visibility = "visible";
}

function hideMenu(menuID) {
document.getElementById(menuID).style.visibility = "hidden";
}

function showCaja(menuID) {
document.getElementById(menuID).className = "visible";
}
function hideCaja(menuID) {
document.getElementById(menuID).className = "oculto";
}



var newwindow;
function poptastic(url){
 	newwindow=window.open(url,'name',  			'height=400,width=194,right=0,top=20,toolbar=no,menubar=no,directories=no,location=no,scrollbars=no,status=no,resizable=no,fullscreen=no')
if (window.focus) {newwindow.focus()}
}

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_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_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];}
}







//frameless

var windowW=500 // wide
var windowH=500 // high

// set the screen position where the popup should appear

//var windowX = 260 // from left
//var windowY = 100 // from top
var windowX = (screen.width/2)-(windowW/2);
var windowY = (screen.height/2)-(windowH/2);
// set the url of the page to show in the popup

var urlPop = "popIndex.html"

// set the title of the page

var title =  "ClubCerrito.com"

// set this to true if the popup should close
// upon leaving the launching page; else, false

var autoclose = true

// ============================
// do not edit below this line
// ============================

s = "width="+windowW+",height="+windowH;
var beIE = document.all?true:false

function openFrameless(){
  if (beIE){
    NFW = window.open("","popFrameless","fullscreen,"+s)     
    NFW.blur()
    window.focus()       
    NFW.resizeTo(windowW,windowH)
    NFW.moveTo(windowX,windowY)
    var frameString=""+
"<html>"+
"<head>"+
"<title>"+title+"</title>"+
"</head>"+
"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
"<frame name='top' src='"+urlPop+"' scrolling=auto>"+
"<frame name='bottom' src='about:blank' scrolling='no'>"+
"</frameset>"+
"</html>"
    NFW.document.open();
    NFW.document.write(frameString)
    NFW.document.close()
  } else {
    NFW=window.open(urlPop,"popFrameless","scrollbars,"+s)
    NFW.blur()
    window.focus() 
    NFW.resizeTo(windowW,windowH)
    NFW.moveTo(windowX,windowY)
  }   
  NFW.focus()   
  if (autoclose){
    window.onunload = function(){NFW.close()}
  }
}
var newwindow2;
function poptastic2(url){
 	newwindow2=window.open(url,'name','height=500,width=500,left=235,top=120,toolbar=no,menubar=no,directories=no,location=no,scrollbars=yes,status=no,resizable=no,fullscreen=no')
if (window.focus) {newwindow2.focus()}
}


var newwindow3;
function poptasticTarjeta(url){
 	newwindow3=window.open(url,'name','height=465,width=735,left=235,top=120,toolbar=no,menubar=no,directories=no,location=no,scrollbars=no,status=no,resizable=no,fullscreen=no')
if (window.focus) {newwindow3.focus()}
}


function getElementsByClassName(_clsName) {
	var matches = new Array(), els = document.getElementsByTagName('*');
	for(var i = 0; i < els.length; i++) {
		if(els.item(i).className == _clsName) matches.push(els.item(i));
	}
	return matches;
}

function toggleDivs(_clsName) { // Ad By E-S
		var divs = getElementsByClassName(_clsName);
		for(var i = 0; i < divs.length; i++) {
			if (navigator.appName.indexOf('Microsoft') == -1) {
				//divs[i].style.visibility = (divs[i].style.visibility != 'hidden') ? 'hidden': 'visible';
				divs[i].style.display = 'block';
				divs[i].style.width = divs[i].childNodes[0].offsetWidth;
				divs[i].style.height = divs[i].childNodes[0].offsetHeight;
			} else {
				objetoParent = divs[i].parentElement;
				objetoChild  = divs[i].childNodes[0];
				objetoDifAncho = objetoParent.offsetWidth-objetoChild.offsetWidth;
				if (objetoDifAncho < 4 )  { objetoParent.style.width = objetoChild.offsetWidth + 4 }
			}
		}
		return true;
}



// ----------------- Funciones para el menú ----------------- //

function swapTable(t)
{
	tab = buscarObjeto(t);
	if (tab.style)
		tab = tab.style;

	if (tab.display == 'block') {
			tab.display = 'none';
	} else {
		tab.display = 'block';
	}
}

function swapTableCerrar(t)
{
	tab = buscarObjeto(t);
	if (tab.style)
		tab = tab.style;

	if (tab.display == 'block') {
		tab.display = 'none';
	} 
}

function swapTableAbrir(t)
{
	tab = buscarObjeto(t);
	if (tab.style)
		tab = tab.style;

	if (tab.display == 'block') {
			
	} else {
		tab.display = 'block';
	}
	 
}


function buscarObjeto(nombre)
{
	if (document.layers) {
		obj = document.layers[nombre];
	} else if (document.all) {
		obj = document.all[nombre];
	} else if (document.getElementById) {
		obj = document.getElementById(nombre);
	}
	return obj;
}

function cambiaRenglon(elemento)
{
	document.getElementById(elemento).className = "renglon2";
}


function vuelveRenglon(elemento)
{
	document.getElementById(elemento).className = "renglon";
}

var renglon = "renglon";
var renglon2 = "renglon2";

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function objetoAjax(){
 var xmlhttp=false;
  try{
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
   try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }catch(E){
    xmlhttp = false;
   }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
   xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

function Pagina(nropagina, clave){
 //donde se mostrará los registros
 divContenido = document.getElementById('content');
 
 ajax=objetoAjax();
 //uso del medoto GET
 //indicamos el archivo que realizará el proceso de paginar
 //junto con un valor que representa el nro de pagina
 ajax.open("GET", "paginar.php?pag="+nropagina+"&clave="+clave);
 divContenido.innerHTML= '<img src="Images/indicator.gif" alt="" />';
 ajax.onreadystatechange=function() {
  if (ajax.readyState==4) {
   //mostrar resultados en esta capa
   divContenido.innerHTML = ajax.responseText
  }
 }
 //como hacemos uso del metodo GET
 //colocamos null ya que enviamos 
 //el valor por la url ?pag=nropagina
 ajax.send(null)
}

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+='Ingrese una dirección de correo válida.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' debe ser un número.\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 ser un número entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += 'El campo de '+nm+' no puede quedar vacío.\n'; }
  } if (errors) alert('Ocurrió un error:\n'+errors);
  document.MM_returnValue = (errors == '');
}
