// ***************************************************************** //
// NOVEDADES
//
// - Controla la aparición aleatoria de las novedades en la página prinicpal
//
// - Marca la última novedad que se ha visualizado para mostrarl de nuevo, excepto si vuelves
//   a las novedades desdes la página de inicio, en cuyo caso se visualizará la novedad que
//   aparezca en esta
//
// variables globales para el control de la novedad a visualizar
var selNov = null;
var selNumberNov = null;
var totalNovs = 8;
// Procedimiento para determinar la novedad que debe mostrarse en la página de novedades
function GoToNovPage() {
	GotoNov(selNumberNov);
}
//
function GotoNovByaNumber(aValue){
	var aNumber;
	switch(aValue) {
		case 1:
			aNumber = "1";
			break;
		case 2:
			aNumber = "2";
			break;
		case 3:
			aNumber = "3";
			break;
		case 4:
			aNumber = "4";
			break;
		case 5:
			aNumber = "5";
			break;
		case 6:
			aNumber = "6";
			break;
		case 7:
			aNumber = "7";
			break;
		case 8:
			aNumber = "9";
			break;
		default:
			aNumber = "9";
	}
	aNumber = "nv" + aNumber;
	return aNumber;
}
//
function GotoNov(aValue){
	var VarToFlashDefined = eval(getCookieVarToFlashDefined());
	if (VarToFlashDefined) {
		selNov = getCookieVarToFlash();
	} else {
		if (selNov == null) {
			var aNumber = Math.random();
			aNumber = Math.round(aNumber*aValue);
			(aNumber < 1) ? aNumber = aValue : aNumber = aNumber ;
			selNov = GotoNovByaNumber(aNumber);
		};
	}
	if(aValue==null){
		location.href = "/novedades_07_CRVB.html";
	}
	else
	{
		location.href = "/novedades_01_01.html?" + selNov;
	}
}
//
function refreshNv() {
	var VarToFlashDefined = eval(getCookieVarToFlashDefined());
	if (VarToFlashDefined) {
		var varToFlashCookie = getCookieVarToFlash();
		if (document.all) {
			window.document.nv_en_id.SetVariable("_root.nvValueToRefresh", varToFlashCookie);
			window.document.nv_en_id.TGotoLabel("/", "refreshNv");
		} else {
			window.document.embeds[0].SetVariable("_root.nvValueToRefresh", varToFlashCookie);
			window.document.embeds[0].TGotoLabel("/", "refreshNv");
		}
	}
}
// Añade cookie
function setCookieVarToFlashDefined(varToFlashDefined) {
	var expdate = new Date();
	expdate.setDate(30);
	expdate.setMonth(11);
	expdate.setYear(2010);
	document.cookie = "varToFlashDefined=" + varToFlashDefined + ";expires=" + expdate.toGMTString(expdate.getTime()) + ";Path=/";
}
function setCookieVarToFlash(a_key, a_value) {
	var expdate = new Date();
	expdate.setDate(30);
	expdate.setMonth(11);
	expdate.setYear(2010);
	document.cookie = a_key + "=" + a_value + ";expires=" + expdate.toGMTString(expdate.getTime()) + ";Path=/";
}
// Este código se ejecuta antes de mostrar la página pasa saber dónde ir
function getCookieVarToFlashDefined() {
	var allcookies = document.cookie;
	var cookieFind = "varToFlashDefined="
	var pos = allcookies.indexOf(cookieFind);
	if(pos == -1){
		return false;
	} else {
		var start = pos + cookieFind.length;
		var stringToken = ";"
		var end;
		if (allcookies.indexOf(stringToken, start) > -1) {
		 	end = allcookies.indexOf(stringToken, start)
		} else {
			end = allcookies.lentgh
		}
		var value = allcookies.substring(start, end);
		return unescape(value);
	}
}
function getCookieVarToFlash() {
	var allcookies = document.cookie;
	var cookieFind = "varToFlash="
	var pos = allcookies.indexOf(cookieFind);
	if(pos == -1){
		return null;
	} else {
		var start = pos + cookieFind.length;
		var stringToken = ";"
		var end;
		if (allcookies.indexOf(stringToken, start) > -1) {
		 	end = allcookies.indexOf(stringToken, start)
		} else {
			end = allcookies.lentgh
		}
		var value = allcookies.substring(start, end);
		return unescape(value);
	}
}
// Flash talk to javascript
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
function nv_id_DoFSCommand(command, args)                {
  var myFlashObj = InternetExplorer ? nv_en_id : document.nv_en_id;
  varToFlash = args;
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('Sub nv_id_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call nv_id_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
}
//
// NOVEDADES //
// ***************************************************************** //

// ***************************************************************** //
// EVENTOS //
//
function GoToEvPage() {
	location.href = "/eventos_06_01.jsp";
}
//
// EVENTOS //
// ***************************************************************** //