function setOpacity(obj,opacity)
{
	document.getElementById(obj.id).style.filter = 'alpha(opacity='+opacity+')';
	document.getElementById(obj.id).style.opacity = opacity/100;	
}

function Popup(url,w,h,x,y,name,objwin)
{
  strWin1='width='+w+',height='+h+',top='+y+',left='+x;
  strWin2=',directories=0,location=0,status=0,scrollbars=1,toolbar=0,menubar=0,resizable=1';
  win=strWin1+strWin2;
  eval(objwin+"=open(\'" + url + "\',\'" + name + "\',\'" + win + "\')");
  winclosed = eval(objwin+'.closed');
  if (!winclosed)
     eval(objwin+'.focus()');
}

function CentrarPopup(url,w,h,name,objwin)
{
   if (!document.all && !document.layers)
   {
      x=20; y=20;
   }
   else
   {
      x=screen.width;
      y=screen.height;
      x=Math.floor((x-w)/2);
      y=Math.floor((y-h)/2)-20;
   }
   Popup(url,w,h,x,y,name,objwin);
}

function TotalPopup(url,name,objwin)
{
   if (!document.all && !document.layers)
   {
      w=70; h=550;
   }
   else
   {
      w=screen.width-10;
      h=screen.height-60;
   }
   Popup(url,w,h,0,0,name,objwin);
}

function FullPopup(url)
{
   win='fullscreen=1,directories=0,resizable=0,location=0,status=0,scrollbars=0,toolbar=0,menubar=0';
   window.open(url,'console',win);
}


/* Para ampliar fotos ****************************************
   Parametros:	
		rutaimg  = ruta de la imagen respecto a la raiz
		rutapoup = ruta popup respecto a la pagina html que lo abre
    	namewin  = nombre de la ventana
	Dependencias:
		root = raiz del sitio web (definida en js/framework/estructura)
	Testeo:
		Falta por testear cuando la imagen tiene rutas relativa hacia abajo
		es decir  ../xxx/xxx.gif	
***************************************************************/

function abrirFoto(rutaimg,rutapopup,namewin){
	foto1= new Image();
	foto1.src=(root+rutaimg);
	Control(rutaimg,rutapopup,namewin);
}

function Control(rutaimg,rutapopup,namewin){
	if((foto1.width!=0)&&(foto1.height!=0)){
		verFoto(rutaimg,rutapopup,namewin);
	}
	else{
		funcion="Control('"+rutaimg+"','"+rutapopup+"','"+namewin+"')";
		intervallo=setTimeout(funcion,20);
	}
}

function verFoto(rutaimg,rutapopup,namewin){
	ancho=foto1.width;
	alto=foto1.height+15;
	CentrarPopup(rutapopup+"?src="+root+rutaimg,ancho,alto,namewin,namewin);
}

/* Para mover ventana ***********************************************
   Variables generales (conveniente inicializar en la llamada)
   permiten la progresión en los desplazamientos
	  incrementoX=0; exponenteI=0;
*******************************************************************/
incrementoX=0;
exponenteI=0;
function moveWinT()
{
  	limiteH = window.screen.width; // ancho de la pantalla
   	a=1;r=900/860;                 // incrementos (progresion geometrica)
	//this.focus();
	if (incrementoX<limiteH)
	{
		exponenteI++;
  		t1=setTimeout('moveWinT2()',10);
     	incrementoX=a*Math.pow(r,exponenteI);
	}
	else
	   window.close(); //cerramos la ventana
}
function moveWinT2()
{  
  	clearTimeout(t1);
  	window.moveBy(incrementoX,0);
	moveWinT();
}

// batir ventana
function batir_xy(n) {
	if (self.moveBy) {
		for (i = 10; i > 0; i--) {
			for (j = n; j > 0; j--) {
				self.moveBy(0,i);
				self.moveBy(i,0);
				self.moveBy(0,-i);
				self.moveBy(-i,0);
			}
		}
	}
}

