//------------------------------------FUNCIONES COOKIES----------------------------------------------------------------
function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function pintaFotos_secuencial(maximo,inicio)
{
	valor = getCookie('id');
	var tope=maximo;
	tope=parseInt(tope);

	if (valor == null)
	{
		imagen1.src = img1[inicio];	
		imagen2.src = img2[inicio];
		imagen1.alt = alt1[inicio];
		imagen2.alt = alt2[inicio];

		inicio=inicio+1;
		setCookie('id',inicio);
	}
	else
	{
		valor=parseInt(valor);
		if(valor>tope)
		{
			valor=0;	
		}
		imagen1.src = img1[valor];
		imagen1.alt = alt1[valor];
		enlace1.href =  link1[valor];
		imagen2.src = img2[valor];
		imagen2.alt = alt2[valor];
		enlace2.href =  link2[valor];

		valor=valor+1;
		setCookie('id', valor);
	}
	
}

function pintaFotos_aleatorio(maximo)
{
	var valor = getCookie('id');
	var tope=maximo;
	tope=parseInt(tope);
	var muestra_aleatorio;

	valor=parseInt(valor);
	do
	{
		muestra_aleatorio=Math.round(Math.random()*tope);
	}
	while (valor==muestra_aleatorio);
	
	imagen1.src = img1[muestra_aleatorio];
	imagen1.alt = alt1[muestra_aleatorio];
	enlace1.href =  link1[muestra_aleatorio];
	imagen2.src = img2[muestra_aleatorio];
	imagen2.alt = alt2[muestra_aleatorio];
	enlace2.href =  link2[muestra_aleatorio];
		
	setCookie('id', muestra_aleatorio);
}


/*
//crear cookie
setCookie('fechaentrada', 14/05/2004);
//leer cookie
getCookie('fechaentrada');
//borrar cookie
delCookie('fechaentrada');
*/

