function abreVentana(theurl,winname,features) {
  window.open(theurl,winname,features);
}

function EsNumerico(cad)
{
	for(var i=0;i<cad.length;i++)
	{
		if ( !(cad.charAt(i)>='0' && cad.charAt(i)<='9') )
		{
			return false;
		}
	}
	return true;
}
	
function menuSelect()
{
	switch(document.formSelect.productes.value)
	{
		case '1':
			document.location.href="cat/productos_y_servicios/comptesidiposits.php";
			break;
		case '2':
			document.location.href="cat/productos_y_servicios/fonsdinversio.php";
			break;
		case '3':
			document.location.href="cat/productos_y_servicios/plansdepensions_i_ppa.php";
			break;
		case '4':
			document.location.href="cat/productos_y_servicios/productes_estructurats.php";
			break;
		case '5':
			document.location.href="cat/productos_y_servicios/borsa.php";
			break;
		case '6':
			document.location.href="cat/productos_y_servicios/prestecspersonals.php";
			break;
		case '7':
			document.location.href="cat/productos_y_servicios/hipoteques.php";
			break;
		case '8':
			document.location.href="cat/productos_y_servicios/targetes.php";
			break;
		case '9':
			document.location.href="cat/productos_y_servicios/telenginyers.php";
			break;
		case '10':
			document.location.href="cat/productos_y_servicios/economiafamiliarcat.php";
			break;
		case '11':
			document.location.href="cat/productos_y_servicios/assegurances.php";
			break;
		case '12':
			document.location.href="cat/productos_y_servicios/renting_cat.php";
			break;
		case '13':
			document.location.href="cat/productos_y_servicios/pies.php";
			break;
	}
}

function menuSelectCast()
{
	switch(document.formSelect.productes.value)
	{
		case '1':
			document.location.href="cast/productos_y_servicios/cuentasydepositos.php";
			break;
		case '2':
			document.location.href="cast/productos_y_servicios/fondosdeinversion.php";
			break;
		case '3':
			document.location.href="cast/productos_y_servicios/planesdepensiones_y_ppa.php";
			break;
		case '4':
			document.location.href="cast/productos_y_servicios/productos_estructurados.php";
			break;
		case '5':
			document.location.href="cast/productos_y_servicios/bolsa.php";
			break;
		case '6':
			document.location.href="cast/productos_y_servicios/prestamospersonales.php";
			break;
		case '7':
			document.location.href="cast/productos_y_servicios/hipotecas.php";
			break;
		case '8':
			document.location.href="cast/productos_y_servicios/tarjetas.php";
			break;
		case '9':
			document.location.href="cast/productos_y_servicios/teleingenieros.php";
			break;
		case '10':
			document.location.href="cast/productos_y_servicios/economiafamiliarcast.php";
			break;
		case '11':
			document.location.href="cast/productos_y_servicios/seguros.php";
			break;
		case '12':
			document.location.href="cast/productos_y_servicios/renting_cast.php";
			break;
		case '13':
			document.location.href="cast/productos_y_servicios/pias.php";
			break;
	}
}

function cambiaTitulo(titulo)
{
	//cambia el titulo de la web para ajustarlo al contenido
	document.title=titulo;
}

function seguridad(idioma)
{
	if(idioma == 1)
		window.document.location = "https://www.caja-ingenieros.es";
	else
		window.document.location = "https://www.caixa-enginyers.com";
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs, aux) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
	
  str += aux["alternativo"] + ' </object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs, ret.auxiliar);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs, ret.auxiliar);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  ret.auxiliar = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
	  case "alternativo":
		ret.auxiliar[args[i]] = args[i+1];
		break;
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
	  case "data":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function envia()
{
	document.telenginyers.submit();
	document.telenginyers.DOMINIO.value = "";
	document.telenginyers.PASSWORD.value = "";
}

// name - nombre de la cookie deseada
// devuelve un string conteniendo el valor de la cookie especificada o null si la cookie no existe
function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
	begin = dc.indexOf(cname);       
	if (begin != -1) {           
	  begin += cname.length;       
	  end = dc.indexOf(";", begin);
	  if (end == -1) end = dc.length;
		return unescape(dc.substring(begin, end));
	} 
  }
  return null;
}


// name - nombre de la cookie
// value - valor de la cookie
// [expires] - fecha de caducidad de la cookie (por defecto, el final de la sesión)
// [path] - camino para el cual la cookie es válida (por defecto, el camino del documento que hace la llamada)
// [domain] - dominio para el cual la cookie es válida (por defecto, el dominio del documento que hace la llamada)
// [secure] - valor booleano que indica si la trasnmisión de la cookie requiere una transmisión segura
// al especificar el valor null, el argumento tomará su valor por defecto
function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}


// name - nombre de la cookie
// [path] - camino de la cookie (debe ser el mismo camino que el especificado al crear la cookie)
// [domain] - dominio de la cookie (debe ser el mismo dominio que el especificado al crear la cookie)
// se considera el camino y dominio por defecto si se especifica null o no se proporcionan argumentos
function delCookie (name,path,domain) {
  if (getCookie(name)) {
	document.cookie = name + "=" +
	((path == null) ? "" : "; path=" + path) +
	((domain == null) ? "" : "; domain=" + domain) +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function aleatorio(inferior,superior)
{
	numPosibilidades = superior - inferior
	aleat = Math.random() * numPosibilidades
	aleat = Math.round(aleat)
	return parseInt(inferior) + aleat
} 

	