function MostrarDialogoModal(sUrl, sParam, nFunc, nAncho, nAlto)
{
	//return dialog(sUrl,"Imprimi Tus Fotos","",true,nAlto,nAncho);
	return dialog(sUrl,"Imprimi Tus Fotos",sParam,true,nFunc,nAlto,nAncho);
}

function dialog(url,name,feature,isModal,nFunc)
{
 if(url==null){return false;}
 url = url
 if(name==null){name=""}
 if(feature==null){feature=""};
 if(window.showModelessDialog)
 {
	var WindowFeature = new Object();
	WindowFeature["width"] = "";
	WindowFeature["height"]  = "";
	WindowFeature["left"]  = "";
	WindowFeature["top"]  =  "";
	WindowFeature["resizable"]  = "no";
	if(feature !=null && feature!="")
	{
	  feature = ( feature.toLowerCase()).split(",");
	  for(var i=0;i< feature.length;i++)
		{
		  /*if( feature[i].isArgument())
			{*/
			   var featureName = feature[i].split("=")[0];
			   var featureValue = feature[i].split("=")[1];
			   if(WindowFeature[featureName]!=null){WindowFeature[featureName] = featureValue; }
			//}
		}
	}
 
  if(WindowFeature["resizable"]==1 || WindowFeature["resizable"]=="1" || WindowFeature["resizable"].toString().toLowerCase()=="yes"){WindowFeature["resizable"] = "resizable:1;minimize:1;maximize:1;"}
  if(WindowFeature["left"]!=""){WindowFeature["left"] ="dialogLeft:" +  WindowFeature["left"] +"px;";}
  if(WindowFeature["top"]!=""){WindowFeature["top"] ="dialogTop:" +  WindowFeature["Top"] +"px;"; }
  if(window.ModelessDialog ==null){window.ModelessDialog = new Object() ; };
  if(name!="")
  {
   if(window.ModelessDialog[name]!=null && !window.ModelessDialog[name].closed )
   {
	 window.ModelessDialog[name].focus();
	 return window.ModelessDialog[name];
   }
  }
	//var F = WindowFeature["left"] +WindowFeature["top"] +  "dialogWidth:"+WindowFeature["width"] +" px;dialogHeight:"+WindowFeature["height"]+"px;center:1;help:0;" + WindowFeature["resizable"] +"status:0;unadorned:0;edge: raised; ;border:thick;center:true"
	var F = 'dialogHeight:'+WindowFeature["height"]+'px;dialogWidth:'+WindowFeature["width"]+'px;center:'+WindowFeature["center"]+';help:no;scroll:no;status:off;edge:raised';
	if(isModal)
	{
		return window.showModalDialog(url,self,F);
	}
	else
	{
		window.ModelessDialog[name] = window.showModelessDialog(url,self,F);
		return window.ModelessDialog[name];
	}	
 }
 else
 {
   if(document.getBoxObjectFor)
   {
   	//alert("holl");
	 if(isModal)
	 {		 
	 	//alert(nFunc);
		 var Modal = window.open(url,name,"modal=1," + feature);
		 var mostro = false;
		 var ModalFocus = function()
		 {
			//alert(Modal.closed);//true cuando se cierra
			if(!Modal.closed){
				Modal.focus();
			}else{
				var resultado = Modal.returnValue;
				Modal = null;
				ModalFocus = null;
				window.removeEventListener( "focus",ModalFocus, false );
				if(resultado){
					eval(nFunc);
				}
				return resultado;
			}
		 }
		 window.addEventListener( "focus",ModalFocus, false );
		 return false;
	 }
	 else
	 {
		return window.open(url,name,"modal=1," + feature);
	 }	 
   }
   else
   { 
	 return window.open(url,name,feature);
   }
 }
 return null;
}

function modal(url,feature)
{
	dialog(url,"",feature,true);
	return false;
}

function alerta(sMensaje, iTipo, iIcono, sTitulo){
	//alert(sMensaje);
	iHeight = sMensaje.length / 8 + 140;
	//retorno = window.showModalDialog("alerta.php?mensaje=" + sMensaje + "&tipo=" + iTipo+ "&icono=" + iIcono+ "&titulo=" + sTitulo, window, 'dialogHeight:' + iHeight + 'px;dialogWidth:250px;center:yes;help:no;scroll:no;status:off;edge:raised');
	//retorno = MostrarDialogoModal("alerta.php?mensaje=" + sMensaje + "&tipo=" + iTipo+ "&icono=" + iIcono+ "&titulo=" + sTitulo,'dialogHeight:' + iHeight + 'px;dialogWidth:250px;center:yes;help:no;scroll:no;status:off;edge:raised',450,iHeight);
	retorno = MostrarDialogoModal("alerta.php?mensaje=" + sMensaje + "&tipo=" + iTipo+ "&icono=" + iIcono+ "&titulo=" + sTitulo,'height=' + iHeight + ',width=250,center=yes,help=no,scroll=no,status=off,edge=raised,resizable=no');
}

function confirmar(sMensaje, iTipo, iIcono, nFunc, sTitulo){
	//alert(sMensaje);
	iHeight = sMensaje.length / 8 + 140;
	//retorno = window.showModalDialog("confirmar.php?mensaje=" + sMensaje + "&tipo=" + iTipo+ "&icono=" + iIcono+ "&titulo=" + sTitulo, window, 'dialogHeight:' + iHeight + 'px;dialogWidth:250px;center:yes;help:no;scroll:no;status:off;edge:raised');
	retorno = MostrarDialogoModal("confirmar.php?mensaje=" + sMensaje + "&tipo=" + iTipo+ "&icono=" + iIcono+ "&titulo=" + sTitulo,'height=' + iHeight + ',width=250,center=yes,help=no,scroll=no,status=off,edge=raised,resizable=no', nFunc);
	return retorno;
}

function redir(oDestination, sLocation){
	oDestination.location.href = sLocation;
}

function abrirVentana(pUrl, pProperties, pNombre)
{
	if (pNombre=="")
		pNombre = "popup";
		
	window.open(pUrl, pNombre, "status=0,toolbar=0,directories=0,menubar=0" + pProperties);
}


function abrirVentanaCentrada(pUrl,w,h){
	t = (screen.height - h)/2;
	l = (screen.width - w)/2;

	window.open(pUrl,"","resizable,status=0,toolbar=0,directories=0,scrollbars=1,menubar=0,top="+t+",left="+l+",width="+w+",height="+h);
}

function viewFotoSimple(idFoto){
	abrirVentana("viewfoto.php?idFoto=" + idFoto  , ",width=700,height=540,left=162,top=114", "viewfoto");
}

function viewFoto(idFoto,showCart,showSlide)
{
	abrirVentana("viewfoto.php?idFoto=" + idFoto + "&showCart=" + showCart + "&showSlide=" + showSlide , ",width=700,height=540,left=162,top=114", "viewfoto");
}

function viewFotoGrande(idFoto,showCart,showSlide)
{
	if(idFoto!='0' && idFoto.length > 0)
		abrirVentana("viewfotoGrande.php?idFoto=" + idFoto, ",width=700,height=540,left=162,top=114", "viewfoto");
}


function viewFotoSlide(idFoto,showCart, showSlide)
{
	document.location = "viewfoto.php?idFoto=" + idFoto + "&showCart=" + showCart + "&showSlide=" + showSlide;
}

function viewFotoCompartidoSlide(idFoto)
{
	document.location = "viewFotoCompartido.php?idFoto=" + idFoto;
}

function viewFotoCompartida(idFoto,clave)
{                           
	abrirVentana("viewFotoCompartido.php?idFoto=" + idFoto +"&clave="+ clave, ",width=700,height=540,left=162,top=114", "viewfoto");
}



function soloNumeros(event)
{
	
	if (navigator.appName == "Microsoft Internet Explorer")
		{
		if ((event.keyCode < 48) || (event.keyCode > 57))
		{
		event.keyCode = 0
		}
	} else {
		
		if((event.which != 8) && (event.which != 0)) {
			if( (event.which < 48) || (event.which > 57) )
			{
			alert("Solo numeros");
			return false;
			}
		}
	}
}

function soloDecimales()
{
	if (((event.keyCode < 48) || (event.keyCode > 57)) && event.keyCode != 46 )
	{
		event.keyCode = 0
	}	
}

function cambiaFotoChicaGrande(id,i)
{
	document.getElementById('idFotoGrande').value = id
	document.getElementById('muestraAutor').innerHTML = document.getElementById('autor'+i).value
    document.getElementById('muestraComentario').innerHTML = document.getElementById('comentario'+i).value
	document.getElementById("imagenGrande").src=document.getElementById("thumb"+i).src
}


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

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