	var exist_win_encuesta_index = null;

	// checa si existe la ventana inicial de la encuesta para poderle dar foco y que siempre este en el primer plano
	function chk_exist_win_encuesta(){
		if (exist_win_encuesta_index){
			exist_win_encuesta_index.focus();
		}
		return true;
	}


	//establece una cookie que indica la versión de la página a la que accesaron.
	// se carga en home.htm
	function set_pag_version(){
   		var expdate = new Date ();
   		expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000* 1)); // 24 hrs from now * 1 dias
   		SetCookie ("pag_version", "flash", expdate,"/");
	}

	// inicializa la cookie de la encuesta, se llama en el homepage.htm
	function ini_cookie_enc(){
		encuesta= GetCookie('encuesta_cnpj');
		if (encuesta == null){
   			var expdate = new Date ();
   			expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000* 10000)); // 24 hrs from now * 10000 dias
   			SetCookie ("encuesta_cnpj", "sin_contestar", expdate,"/");
			var expdate3= new Date();
//			expdate3.setTime (expdate3.getTime() + (24 * 60 * 60 * 1000* 7)); // 24 hrs from now * 7 dias
 			expdate3.setTime (expdate3.getTime() + (1 * 1 * 60 * 1000* 1)); //1 minuto
			SetCookie ("recuerda_encuesta","si", expdate3, "/"); 
		}
	}


	function openNewWindow(URLtoOpen, windowName, windowFeatures){ 
		newWindow=window.open(URLtoOpen, windowName, windowFeatures);
	}
	
	// se carga en home.htm
	function chk_cookies_enc(){
		var encuesta= GetCookie('encuesta_cnpj');
		if (encuesta=="sin_contestar"){
			var recordar_encuesta=GetCookie('recuerda_encuesta');
			if (recordar_encuesta==null){
				new_win(); // abre la ventana que muestra la pregunta de si quiere participar
			}
		}
	}

	// abre una ventana que pregunta si quieres participar en la encuesta
	// se carga en home.htm
	function new_win(){
		var win_width=225;
		var win_height=200;
		var scr_width=screen.availWidth;
		var pos_x=parseInt((scr_width-win_width)/2);
		var scr_height=screen.availHeight;
		var pos_y=parseInt((scr_height-win_height)/2);
		var options="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width="+win_width+",height="+win_height+",left="+pos_x+",top="+pos_y;
		exist_win_encuesta_index = window.open('/encuesta1/index.htm','win_encuesta_index',options);
		return true;
	}

		function win_encuesta(b_close_win){
			var win_width=700;
			var win_height=500;
			var scr_width=screen.availWidth;
			var pos_x=parseInt(scr_width-win_width-10);
			var scr_height=screen.availHeight;
			var pos_y=parseInt((scr_height-win_height)/2);
			var options="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width="+win_width+",height="+win_height+",left="+pos_x+",top="+pos_y;
			window.open("/encuesta1/default.asp","win_encuesta",options);
			if (b_close_win == true){
			window.close(); 	
			}	
		}

		function set_recordar_encuesta(){
				var expdate3= new Date();
		   		expdate3.setTime (expdate3.getTime() + (24 * 60 * 60 * 1000* 7)); // 24 hrs from now * 7 dias
//		   		expdate3.setTime (expdate3.getTime() + (1 * 1 * 60 * 1000* 1)); // 1 minuto
				SetCookie ("recuerda_encuesta","si", expdate3, "/"); 
				window.close();
		}

		function set_no_encuesta(){
				cont_no_enc= GetCookie('cont_no_encuesta'); // contabiliza las veces que dicen no a la encuesta
				if ( cont_no_enc == null ){
					var expdate3= new Date();
		   			expdate3.setTime (expdate3.getTime() + (24 * 60 * 60 * 1000* 720)); // 24 hrs from now * 720 dias
					SetCookie ("cont_no_encuesta","1", expdate3, "/");
					var expdate3= new Date();
		   			expdate3.setTime (expdate3.getTime() + (24 * 60 * 60 * 1000* 60)); // 24 hrs from now * 60 dias, vuelve a recordar en 2 meses
//			   		expdate3.setTime (expdate3.getTime() + (1 * 1 * 60 * 1000* 1)); // 1 minuto
					SetCookie ("recuerda_encuesta","si", expdate3, "/"); 					
				} else {
					n_cont_no_enc = parseInt( cont_no_encuesta ); // convierte a numero el contador de respuesta de no a la encuesta
					n_cont_no_enc ++ ;
					if (n_cont_no_enc<4){
						var expdate3= new Date();
		   				expdate3.setTime (expdate3.getTime() + (24 * 60 * 60 * 1000* 720)); // 24 hrs from now * 720 dias
						SetCookie ("cont_no_encuesta",n_cont_no_enc, expdate3, "/");
						var expdate3= new Date();
		   				expdate3.setTime (expdate3.getTime() + (24 * 60 * 60 * 1000* 60)); // 24 hrs from now * 60 dias, vuelve a recordar en 2 meses
//				   		expdate3.setTime (expdate3.getTime() + (1 * 1 * 60 * 1000* 1)); // 1 minuto
						SetCookie ("recuerda_encuesta","si", expdate3, "/");
					} else {
						var expdate3= new Date();
		   				expdate3.setTime (expdate3.getTime() + (24 * 60 * 60 * 1000* 720)); // 24 hrs from now * 720 dias
						SetCookie ("cont_no_encuesta",n_cont_no_enc, expdate3, "/");
						var expdate3= new Date();
		   				expdate3.setTime (expdate3.getTime() + (24 * 60 * 60 * 1000* 2400 )); // 24 hrs from now * 2400 dias, no vuelve a recordar en aprox. 6 años
						SetCookie ("recuerda_encuesta","no", expdate3, "/");
					}
				}
				window.close();
		}

		// Se manda llamar en /encuesta1/default.asp
		function contesta(){
			var expdate3= new Date();
			expdate3.setTime (expdate3.getTime() + (24 * 60 * 60 * 1000* 2400 )); // 24 hrs from now * 2400 dias, no vuelve a recordar en aprox. 6 años
			SetCookie ("encuesta_cnpj","contestada3", expdate3, "/");
			return true;
		}
		function win_res_encuesta(){
			var win_width=480;
			var win_height=500;
			var scr_width=screen.availWidth;
			var pos_x=parseInt(scr_width-win_width-10);
			var scr_height=screen.availHeight;
			var pos_y=parseInt((scr_height-win_height)/2);
			var options="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width="+win_width+",height="+win_height+",left="+pos_x+",top="+pos_y;
			window.open("/encuesta1/resultados.htm","win_encuesta3",options);
		}