// ===========================================================================
// SGAS.js: Codigo JS generico NEXUS
// ===========================================================================
var undefined;
var vSG_ws="http://"+location.hostname;
var vSG_htmls="http://ht.px.wke.es";
var vSG_cfmhtml="/sgas/SGchkses_html.cfm";
var vSG_vcgi="http://vt.px.wke.es/vcgi/search.cgi";
var vSG_htmlcgi="http://vt.px.wke.es/vcgi/search.cgi";
var vSG_navigatecgi="http://vt.px.wke.es/vcgi/navega_NEXUS_v2.cgi";
var vSG_template_dir="ctrib/ctrib_arti_12_N/";
var vSG_template_link_legis = "ctrib/ctrib_legis_12_L/plt_link_legis.hts";
var vSG_template_link_juris = "ctrib/ctrib_juris_12_J/plt_link_juris.hts";
var vSG_template_link_cons = "ctrib/ctrib_juris_12_J/plt_link_juris.hts";
var vSG_template_link_ex = "ctrib/ctrib_comen_12_E/plt_link_ex.hts";
var vSG_template_link_doct ="ctrib/ctrib_doct_12_D/plt_link_doct.hts";
//var vSG_traduce_codigos = "http://p12.vt.des.wke.es/vcgi/traduce_codigos.cgi";
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_traducir="1";
var vSG_traducir_masinfo="1";
var vSG_css="/o12/css/";
var vSG_getfhtml="/sgas/SGgetfhtml.cfm";
var vSG_tAUTH="&auth=nexus";
//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] = "Deciembre";

  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 );

}
