$(document).ready(function(){
  SexyLightbox.initialize({color:'white', dir: 'img/sexyimages'});
});

function showAlert(strUrl, iAncho, iAlto){
	if(iAncho==undefined) iAncho = 550;
	if(iAlto==undefined) iAlto = 400;
	if(!isNaN(strUrl)) strUrl = strUrl.toString();

	if(strUrl.indexOf('.php')==-1 || (strUrl.length > 50 && strUrl.indexOf('popup-imagen.php')==-1)){
		strUrl = "alertas.php?alerta=" + escape(strUrl);
	}

	if(strUrl.indexOf('?')==-1){
		strUrl += '?';
	}else{
		strUrl += '&';
	}
	
	strUrl += 'height=' + iAlto + '&width=' + iAncho;
	SexyLightbox.display(strUrl, '', true);
}


function descargarArchivo(path, file){
	var n = 'f' + Math.floor(Math.random() * 99999);
	var d = document.createElement('DIV');
	d.innerHTML = '<iframe style="display:none" src="download.php?path=' +path+ '&file=' + file + '" id="'+n+'" name="'+n+'"></iframe>';
	document.body.appendChild(d);
}

function DiferenciaFechas (CadenaFecha1, CadenaFecha2) {   
     
    //Obtiene dia, mes y aņo  
    var fecha1 = new fecha( CadenaFecha1 )     
    var fecha2 = new fecha( CadenaFecha2 )  
      
    //Obtiene objetos Date  
    var miFecha1 = new Date( fecha1.anio, fecha1.mes, fecha1.dia )  
    var miFecha2 = new Date( fecha2.anio, fecha2.mes, fecha2.dia )  
   
    //Resta fechas y redondea  
    var diferencia = miFecha1.getTime() - miFecha2.getTime()  
    var dias = Math.floor(diferencia / (1000 * 60 * 60 * 24))  
    //var segundos = Math.floor(diferencia / 1000)  
    //alert ('La diferencia es de ' + dias + ' dias,\no ' + segundos + ' segundos.')  
      
    return dias  
 }  
   
 function fecha( cadena ) {  
   
    //Separador para la introduccion de las fechas  
    var separador = "/"  
   
    //Separa por dia, mes y aņo  
    if ( cadena.indexOf( separador ) != -1 ) {  
         var posi1 = 0  
         var posi2 = cadena.indexOf( separador, posi1 + 1 )  
         var posi3 = cadena.indexOf( separador, posi2 + 1 )  
         this.dia = cadena.substring( posi1, posi2 )  
         this.mes = cadena.substring( posi2 + 1, posi3 )  
         this.anio = cadena.substring( posi3 + 1, cadena.length )  
    } else {  
         this.dia = 0  
         this.mes = 0  
         this.anio = 0     
    }  
 }  	
	

