function open_windows_m(openfile,openwindow)
{
  window.open(openfile,openwindow,'directories=no,resizable=yes,scrollbars=no,width=430,height=230,hotkeys=yes,top=0,left=0');
}

function open_windows_mts(openfile,openwindow)
{
  fecha  = new Date();
  tstamp = fecha.getTime();
  window.open(openfile+'&ts='+tstamp,openwindow,'directories=no,resizable=yes,scrollbars=no,width=430,height=230,hotkeys=yes,top=0,left=0');
}

function open_windows_a(page)
{
  window.open(page,"","directories=no,resizable=no,scrollbars=yes,width=600,height=530,top=10,left=10");
}

function open_windows_mu(openfile,openwindow)
{
  window.open(openfile,openwindow,'menubar=yes,directories=no,resizable=yes,scrollbars=yes,width=695,height=500,hotkeys=yes,top=0,left=0');
}

function open_windows_mb(page)
{
  window.open(page,"","directories=no,resizable=no,scrollbars=yes,width=600,height=520,top=10,left=10");
}

function open_windows_mbs(page)
{
  window.open(page,"","directories=no,resizable=no,scrollbars=yes,status=yes,width=600,height=520,top=10,left=10");
}

function open_windows_cc(page)
{
  window.open(page,"","directories=no,resizable=no,scrollbars=no,width=600,height=310,top=10,left=10");
}

function open_windows_s(openfile)
{
  nombre=parseInt(Math.random()*1000)
  window.open(openfile,nombre);
}

function open_windows_avsizes(page)
{
  window.open(page,"","directories=no,resizable=no,scrollbars=no,width=370,height=235,top=10,left=10");
}

function open_windows_media(openfile,openwindow,ancho,alto)
{
  window.open(openfile,openwindow,'directories=no,resizable=yes,scrollbars=no,width='+ancho+',height='+alto+',hotkeys=yes,top=0,left=0');
}

function open_windows_price(openfile,openwindow)
{
  window.open(openfile,openwindow,"directories=no,status=yes,resizable=yes,scrollbars=yes,width=725,height=410,top=10,left=10");
}

function saltarURL()
{
	box = document.formsalto.navi;
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}

function open_windows_fac(openfile,openwindow)
{
window.open(openfile,openwindow,'menubar=yes,status=no,toolbar=no,location=no,directories=no,resizable=yes,scrollbars=yes,hotkeys=yes,width=780,height=475,top=0,left=0');
}

function open_windows_h(openfile,openwindow)
{
  window.open(openfile,openwindow,'directories=no,resizable=yes,scrollbars=no,width=505,height=527,hotkeys=yes,top=0,left=0');
}

function open_windows_v(openfile,openwindow)
{
  window.open(openfile,openwindow,'directories=no,resizable=yes,scrollbars=no,width=505,height=547,hotkeys=yes,top=0,left=0');
}

function open_windows_bah(openfile,openwindow)
{
  window.open(openfile,openwindow,'directories=no,resizable=yes,scrollbars=no,width=802,height=570,hotkeys=yes,top=0,left=0');
}

function open_windows_bav(openfile,openwindow)
{
  window.open(openfile,openwindow,'directories=no,resizable=yes,scrollbars=no,width=524,height=850,hotkeys=yes,top=0,left=0');
}

function goform(myurl)
{
  document.forms[0].action = myurl;
  document.forms[0].submit();
}

function selecc()
{
  window.open('selecc01b.asp','','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=700,height=500');
}

function open_windows_resizable(openfile, openwindow, width, height){
  window.open(openfile, openwindow, 'directories=no,resizable=yes,directories=0,status=0,menubar=0,scrollbars=1,width='+width+',height='+height)
}

/*
Envia el formulario.
  arguments[0]: numero del formulario
  arguments[1]: texto de confirm
*/
function enviarForm(){
  var numform   =  0;
  var tconfirm  = '';
  var enviar  = true; 

  if (!isNaN(arguments[0])) {numform  = arguments[0];} else {enviar=false;}
  if (arguments.length>1)   {tconfirm = arguments[1];}
  if (tconfirm!='')         {if (!confirm(tconfirm)){enviar=false;}}
  if (enviar)               {document.forms[numform].submit();}
}

// Swap de imagenes modo dreamweaver
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.0
  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 && document.getElementById) x=document.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];}
}

/*
Obtiene la distancia al borde superior de la pagina de un objeto imagen
imgElem : nombre de la capa
*/
function getTop(imgElem) {
  var yPos = 0;
	var imgMenu = document.images[imgElem];
	if(document.layers)	{yPos = imgMenu.y;}
	else if (imgMenu)	{
		if (document.getElementById) { //W3C DOM
			yPos = eval(imgMenu).offsetTop;
			tempEl = eval(imgMenu).offsetParent;
			while (tempEl != null) {
				yPos += tempEl.offsetTop;
				tempEl = tempEl.offsetParent;
			}
		}
		else { //navigator.appVersion.substr(0,3)=="4.0") //IE4 MAC
      yPos=0;
      obj=imgMenu;
      while (obj.tagName != 'HTML') {
        if (obj.parentNode) obj = obj.parentNode;
        else if (obj.parentElement) obj = obj.parentElement;
        if (obj.tagName.indexOf('T') == 0) {
          yPos += obj.offsetTop
        }
      }
      yPos=yPos+4;
	  }
  }
	return yPos;
}

/*
Obtiene la distancia al borde izquierdo de la pagina de un objeto imagen
imgElem : nombre de la capa
*/
function getLeft(imgElem) {
  var xPos = 0;
	var imgMenu = document.images[imgElem];
	if(document.layers)	{xPos = imgMenu.x;}
	else if (imgMenu)
  {
		if (document.getElementById) {//W3C DOM
			xPos = eval(imgMenu).offsetLeft;
			tempEl = eval(imgMenu).offsetParent;
			while (tempEl != null) {
				xPos += tempEl.offsetLeft;
				tempEl = tempEl.offsetParent;
			}
		}
		else { //navigator.appVersion.substr(0,3)=="4.0") //IE4 MAC
      xPos=0;
      obj=imgMenu;
      while (obj.tagName != 'HTML') {
        if (obj.parentNode) obj = obj.parentNode;
        else if (obj.parentElement) obj = obj.parentElement;
        if (obj.tagName.indexOf('T') == 0) {
          xPos += obj.offsetLeft
        }
      }
      //xPos=xPos+4;
	  }
  }
	return xPos;
}

/*
Ensenya una capa posicionantla relativa a una imatge que es passa, indicant distancia x i y
Si se li passa mes d'una capa, s'ha d'indicar totes les variables per cada una:
- nom de la capa 
- imatge respecte a la que es vol posicionar (r)
- distancia x (dx)
- distancia y (dy)
*/
function showLayerRelative(){
  var i,r,v,dx,dy,obj,args=showLayerRelative.arguments;
  for (i=0; i<(args.length-3); i+=4) {
    if ((obj=MM_findObj(args[i]))!=null) {       
      v='show';r=args[i+1];dx=args[i+2];dy=args[i+3];
      if (obj.style) { obj=obj.style; v='visible'; }
      obj.left=getLeft(r)+dx; obj.top=getTop(r)+dy;
      obj.visibility=v; 
    }
  }
}

/*
Amaga una o mes capes que se li passen per parametre
Si el primer parametre es -1, envia les capes a l'esquerra de la pagina per evitar scroll horitzontal
*/
function hideLayer(){
  var i,v,obj,moveLeft,starti,args=hideLayer.arguments;
  if (args[0]==-1){starti=1;moveLeft=true} else {starti=0;moveLeft=false;}
  for (i=starti; i<(args.length); i++) {
    if ((obj=MM_findObj(args[i]))!=null) {
      v='hide';
      if (obj.style) { obj=obj.style; v='hidden'; }
      obj.visibility=v; 
      if (moveLeft) { obj.left=0; }
    }
  }
}
