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 Paginador(pagina, div, nro, param){
 	//donde se mostrará los registros
	divContenido = document.getElementById(div);
  	ajax=objetoAjax();
	ajax.open("GET", pagina+"?pag="+nro+param);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divContenido.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

function Paginador(pagina, pag, div, nro, param){
 	//donde se mostrará los registros

	divContenido = document.getElementById(div);
  	ajax=objetoAjax();
	ajax.open("GET", pagina+"?"+pag+"="+nro+param);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divContenido.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

function deleteImage(url, id, div){
 	//donde se mostrará los registros
	divContenido = document.getElementById(div);
  	ajax=objetoAjax();
	ajax.open("GET", url+"?id="+id);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divContenido.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

function deleteImageGal(url, id, img, div){
 	//donde se mostrará los registros
	divContenido = document.getElementById(div);
  	ajax=objetoAjax();
	ajax.open("GET", url+"?id="+id+"&img="+img);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divContenido.innerHTML = ajax.responseText
		}
	}
	ajax.send(null)
}

function popup(url,name,width,height,resize,scroll) {
var dialogWin = new Object();
dialogWin.width = width;
dialogWin.height = height;
now = new Date();
var millis=now.getTime();
var mstr=""+millis;
if (navigator.appName == "Netscape") {
dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2);
dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
var attr = 'screenX=' + dialogWin.left + ',screenY=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
} else if (document.all) {
dialogWin.left = (screen.width - dialogWin.width) / 2;
dialogWin.top = (screen.height - dialogWin.height) / 2;
var attr = 'left=' + dialogWin.left + ',top=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
}
tienesp=false;
for (i=0; i<url.length; i++)
if (url.charAt(i)=='?')
tienesp=true;
if (tienesp)
nocach='&nocache='+mstr;
else
nocach='?nocache='+mstr;
window.open(url + nocach ,name,attr);
}

function validarExtension(input, ext){
	posPto = input.value.lastIndexOf(".", 0);
	//extArchivo = input.value.substring(posPto+1, input.value.length);
	extArchivo = input.value.substring(input.value.length-3, input.value.length);
	//alert(ext + "---" + extArchivo);
	if (extArchivo.toUpperCase() != ext.toUpperCase() ){
		alert("La extension del archivo debe ser: "+ext);
		input.value = "";
	}
}

function NewWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

var is_regexp = (window.RegExp) ? true : false;

function fetch_object(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}

function colexp(objid,action)
{
	obj = fetch_object(objid);
	cel = fetch_object(objid);
	img = fetch_object(objid);
	
	
	switch (action)
	{
		case 'expand':
			obj.style.display = '';
			break;
			
		case 'colapse':
			obj.style.display = 'none';
			break;
		
		case '':
			if (obj.style.display == 'none')
			{
				
				obj.style.display = '';
			}
			else
			{
				obj.style.display = 'none';
			}		
			break;
		
	}
	return false;
}