// ===========================================================================
// SGAS.js: Codigo JS generico NEXUS
// ===========================================================================
var undefined;
var vSG_ws="http://"+location.hostname;
var vSG_cfmhtml="/sgas/SGchkses_html.cfm";
var vSG_vcgi="http://vt.px.wke.es/vcgi/search.cgi";
var vSG_htmlcgi="http://ht.px.wke.es/vcgi/search.cgi";
var vSG_navigatecgi="http://vt.px.wke.es/vcgi/navega_NEXUS_v2.cgi";
var vSG_htmls="http://ht.px.wke.es";
var vSG_template_dir="ecoiuris/eco_legis_13_L/";
var vSG_template_link_legis = "ecoiuris/eco_legis_13_L/plt_link_legis.hts";
var vSG_template_link_juris = "ecoiuris/eco_juris_13_J/plt_link_juris.hts";
var vSG_template_link_cons = "ecoiuris/eco_cons_13_S/plt_link_cons.hts";
var vSG_template_link_doct = "ecoiuris/eco_doct_13_D/plt_link_doct.hts";
var vSG_traduce_codigos = "http://vt.px.wke.es/vcgi/traduce_codigosPOST.cgi";
var vSG_cfmimg="/sgas/SGgetimg.cfm?img=http://imgs.wke.es/";
var vSG_tAUTH="&auth=ecoiuris";
//var vSG_tAUTH="";
// ===========================================================================
// fo_enlace_c: Enlace a paginas ecoiuris CERRADAS
// ===========================================================================
function fo_enlace_c(urld,idcomp,win_sgid,win_location)
{
 if (win_sgid === undefined) win_sgid=top;
 if (win_location === undefined) win_location=self;
 if (idcomp === undefined) idcomp= vSG_idcomp;
 var sgid= fSGAS_getsgid(win_sgid);
 urld= (isPath(urld)) ? vSG_cfmhtml + "urld=" + vSG_ws + urld :
                        vSG_cfmhtml + "urld=" + urld;
 fSGAS_sesion(urld,idcomp,win_sgid,win_location);
}

// ===========================================================================
// fSGAS_chkses_vaps_POST: Envio de formulario Verity tipo POST
// ===========================================================================
function fvsearch_POST(urld,win_sgid,bLibre,wProgreso)
{
 if (win_sgid === undefined) win_sgid=top;
 bLibre= (bLibre === undefined) ? "" : bLibre;
 wProgreso= (wProgreso === undefined) ? "" : "&vp=" + wProgreso;
 var sgid= fSGAS_getsgid(win_sgid);
 parent.oculto.document.enviopost.sgid.value = sgid;
 parent.oculto.document.enviopost.urld.value = urld;
 parent.oculto.document.enviopost.blibre.value = bLibre;
 //parent.oculto.enviopost.action = vSG_ws + "/sgas/SGchkses_vapsPOST.cfm";
 parent.oculto.document.enviopost.action = vSG_ws + "/sgas/SGchkses_vapspu.cfm";
 parent.oculto.document.enviopost.method = "POST";
 parent.oculto.document.enviopost.target = "TXT";
 parent.oculto.document.enviopost.submit();
}

//Funcion para la fecha
function fecha() {
  var this_month = new Array(12);
  this_month[0]  = "Enero";
  this_month[1]  = "Febrero";
  this_month[2]  = "Marzo";
  this_month[3]  = "Abril";
  this_month[4]  = "Mayo";
  this_month[5]  = "Junio";
  this_month[6]  = "Julio";
  this_month[7]  = "Agosto";
  this_month[8]  = "Septiembre";
  this_month[9]  = "Octubre";
  this_month[10] = "Noviembre";
  this_month[11] = "Diciembre";

  var this_day_e = new Array(7);
  this_day_e[0]  = "Domingo";
  this_day_e[1]  = "Lunes";
  this_day_e[2]  = "Martes";
  this_day_e[3]  = "Mi&eacute;rcoles";
  this_day_e[4]  = "Jueves";
  this_day_e[5]  = "Viernes";
  this_day_e[6]  = "S&aacute;bado";

  var today = new Date();
  var day   = today.getDate();
  var month = today.getMonth();
  var year  = today.getYear();
  var dia = today.getDay();
    if (year < 1000) {
       year += 1900; }
  document.write ( " " + this_day_e[dia] + ", " + day + " de " + this_month[month] + " de " + year);
}


// Si existe alguna palabra cortada/in al final de la cadena

function EliminaIncompleta ( cadena, max ) {
	
	if ( cadena.length == max ) {
		if ( cadena.charAt( cadena.lenght - 1 ) != " " ) {
		  cadena = cadena.substring(0,BuscaUltimoBlanco( cadena )) + " ...";
		}
	}
	return cadena;	
}

// Devuelve la posición del último espacio en blanco de la cadena pasada.
function BuscaUltimoBlanco ( cadena ) {
	
	var pos = cadena.length - 1;
	while ( pos > 0 && cadena.charAt(pos) != " ") {
		pos--;
	}
	
	return ( pos > 0 ? pos : cadena.length );

}

// ===========================================================================
// fo_enlace_c: Enlace a paginas ecoiuris CERRADAS
// ===========================================================================
function fo_enlace_c(urld,idcomp,win_sgid,win_location)
{
 // Cuando existan diferentes componentes hay que usar fSGAS_sesion + SGchkses_html + urld + idcomp
 urld= (isPath(urld)) ? vSG_ws + urld : urld;
 fSGAS_chkses_html(urld,win_sgid,win_location,"&js=n");

/*
 if (win_sgid === undefined) win_sgid=top;
 if (win_location === undefined) win_location=self;
 if (idcomp === undefined) idcomp= vSG_idcomp;
 var sgid= fSGAS_getsgid(win_sgid);
 win_location.location= vSG_ws + "/sgas/SGchkses_html.cfm?sgid=" + sgid + "&js=n" + "&urld=" + urld;
*/ 
}
// ===========================================================================
// fo_enlace_ex: Enlace a paginas web EXTERNAS
// ===========================================================================
function fo_enlace_ex(urld)
{
 furl_wopen_doc('/cfm/verdoc.cfm?web='+urld,'wexterna');
}
// ===========================================================================
// fo_enlace_LE: Enlace a LEGISLACION
// ===========================================================================
function fo_enlace_LE(urld,idcomp,win_sgid,win_location)
{
 window.location= urld;
// urld= (isPath(urld)) ? vSG_ws + urld : urld;
// fSGAS_chkses_html(urld,win_sgid,win_location,"&js=n");
}
// ===========================================================================
// fo_enlace_sgid: 
// ===========================================================================
function fo_enlace_sgid(urld,win_sgid,win_location)	
{
 // Para funcionar con formulario.cfm
 urld= (isPath(urld)) ? vSG_ws + urld : urld;
 if (win_sgid === undefined) win_sgid=top;
 if (win_location === undefined) win_location=self;
 var sgid= fSGAS_getsgid(win_sgid);
 win_location.location= (isQs(urld)) ? urld+"&sgid="+sgid : urld+"?sgid="+sgid;
}
// ===========================================================================
// fo_enlace_bin: Enlace a documentos PDF
// ===========================================================================
function fo_enlace_bin(urld,win_sgid,win_location)
{
 if (win_sgid === undefined) win_sgid=top;
 if (win_location === undefined) win_location=self;
 var sgid= fSGAS_getsgid(win_sgid);
 win_location.location= vSG_ws + "/sgas/SGgetfbin.cfm?sgid=" + sgid + "&fi=" + urld;

// ESTE CODIGO VALE PARA FICHEROS SIN ACL
/*
 urld= (isPath(urld)) ? vSG_ws + urld : urld;
 win_location.location= urld;
*/
}
// ===========================================================================
// fo_enlace_bin_nw: Enlace a documentos PDF abriendo en otra ventana
// ===========================================================================
function fo_enlace_bin_nw(urld)
{
 fSGAS_wopen_doc(urld,'wexterna');
}

function fo_enlace_bin_pdf_frame(urld,win_sgid,win_location)
{
 if (win_sgid === undefined) win_sgid=top;
 if (win_location === undefined) win_location=self;
 var sgid= fSGAS_getsgid(win_sgid);
 win_location.location= vSG_ws + "/sgas/SGgetfbin.cfm?sgid=" + sgid + "&fi=" + urld;
}

// ===========================================================================
// fl_enlacepass: Enlace a pagina de cambio de password
// ===========================================================================
function fl_enlacepass(urld)
{
 var sgid= fSGAS_getsgid(top);
  if (sgid == "") 
 {
  alert("Para modificar su contraseña debe iniciar la sesión en alguna de las secciones.");
 }  
 else
 { 
 var partes_sgid= sgid.split(".");
 urld= urld + "origen=" + vSG_ws;
 fSGAS_sesion(urld,partes_sgid[1],top,top);
 }
}
