function abreVentana(URL,nomVentana,opciones)
{
  window.open(URL,nomVentana,opciones);
}

function validaFormulari(strPantalla, strAccio)
{
	var bolValida;
	bolValida = true
	if (strPantalla == "modificaTarifa")
	{
		if (strAccio == "guarda")
		{
			bolValida = esFicheroPDF(document.getElementById('pdfRuta').value);
		}
	}
	
	return bolValida;	
}

function enviaFormulari(objEnvio, strPantalla, strAccio, idValor)
{	
	document.getElementById('pantalla').value = strPantalla;
	document.getElementById('accio').value = strAccio;
	document.getElementById('idValor').value = idValor;
	
	if (validaFormulari(strPantalla, strAccio) == true)
	{
		document.form1.submit();
	}
}


function esFicheroPDF(Cadena){   
  
  if (Cadena == '' )
  {
	  alert('Debes seleccionar un fichero pdf')
	  return false
  }
  
  if (Cadena.substring(Cadena.lastIndexOf("."),Cadena.length) != '.pdf')
  {
	  alert('El fichero seleccionado no es pdf')
	  return false
  }
  return true
}   

function posicionaTexto()
{
	var ancho;
	var distancia;
	var distanciaMenu;
	
	ancho = document.documentElement.clientWidth;
	distancia = ((ancho - 1024) / 2);
	
	if(distancia > 0)
	{
		distanciaMenu = distancia + 410;
		distancia = distancia + 440;
		distancia = distancia + 'px';
		distanciaMenu = distanciaMenu + 'px';
		document.getElementById('divTexto').style["left"] = distancia;
		document.getElementById('divMenu').style["left"] = distanciaMenu;
	}else
	{
		document.getElementById('divTexto').style["left"] = '440px';
		document.getElementById('divMenu').style["left"] = '410px';
	}
}

