/* ****************************************************************** */
/* **** Funciones para validar la cookie de votacion del usuario **** */
/* **** 08/10/2002 - MCO ******************************************** */
/* ****************************************************************** */


// -----------------------------------------------------------------
function check_cookie(id) {
	var yavoto = getCookie(id); // cookie sesion
	
	if (yavoto == 'yavoto') {
	  return true;
	}
	else {
	  return false;
	};
}; // check_cookie.

// -----------------------------------------------------------------
function getCookie(name) {
// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}; // getCookie.

// -----------------------------------------------------------------
function graba_cookie(name, value, path, domain, secure) {
  var now = new Date();
  now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
  
  setCookie(name, value, now, path, domain, secure);
}; // graba_cookie.
  
// -----------------------------------------------------------------
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}; // setCookie;


var envio = 0;
// -----------------------------------------------------------------
function envia_encuesta() {
  if (document.layers) {
    if (! envio) {
      var opciones = window.document.encuesta.document.forms[0].Rad_ENCUESTA.length;
          
      var selecc = 0;
      for (var i = 0; opciones > i; i++) {
        if (window.document.encuesta.document.forms[0].Rad_ENCUESTA[i].checked) {
          selecc = 1;
          
          var enc_id = window.document.encuesta.document.forms[0].enc_id.value;
          var param = window.document.encuesta.document.forms[0].Rad_ENCUESTA[i].value;
          envio = 1;
          window.document.encuesta.src = "/cgi-bin/pli_encuesta_votar.cgi?enc_id=" + enc_id + "&Rad_ENCUESTA=" + param;
        };
      };
    };
  }
  else {
    var opciones = document.forms[0].Rad_ENCUESTA.length;
    var selecc = 0;
    for (var i = 0; opciones > i; i++) {
      if (document.forms[0].Rad_ENCUESTA[i].checked) {
        selecc = 1;
        document.forms[0].submit();
        break;
      };
    };
  };
  
  if (! selecc) {
    alert('Debe seleccionar alguna alternativa');
  };
}; // envia_encuesta.

var browserName = navigator.appName;
var browserVersion = parseInt(navigator.appVersion);

// -----------------------------------------------------------------
function resize_layer() {
  if ( (browserName == "Microsoft Internet Explorer") && (browserVersion >= 4) ) {
    parent.fila1.style.posHeight = document.all.fila0.offsetHeight;
    parent.alto_fila0 = document.all.fila0.offsetHeight;
  };
}; // resize_layer.
  