window.addEventListener?window.addEventListener("load",noCache,false):window.attachEvent("onload",noCache);
window.addEventListener?window.addEventListener("load",analytics,false):window.attachEvent("onload",analytics);
window.addEventListener?window.addEventListener("load",highlyMenuItem,false):window.attachEvent("onload",highlyMenuItem);

/* Deshabilitar la caché en el navegador */
function noCache() {
	if ('Navigator' == navigator.appName) {
		document.forms[0].reset(); 
	}
}

/* Activar las estadísticas en Google Analytics */
function analytics() {
	_uacct = "UA-73145-1";
//	urchinTracker();
}

/* Remarcar el menú seleccionado */
function highlyMenuItem() {
	var pathName = window.location.pathname;
	var pageName = pathName.substring(pathName.lastIndexOf('/') + 1, pathName.lastIndexOf('.'))

	// Elminamos la parte del final en el programaDia1, programaDia2, programaDia3, programaDia4
	if (pageName.indexOf("Dia") != -1)
	{
		pageName = pageName.substring(0, pageName.lastIndexOf("Dia"));
	}

	// Añadimos el nombre del menú.
	var fullPageName = pageName + 'Mnu';
	document.getElementById(fullPageName).style.color = 'yellow';
}

/*
   Name: getFeed(uri, id).
   Desc: This function retrieves a JSON feed.
	 Params:
		 - uri: Json feed.
		 - id:  Id for the script which retrieves the JSON feed.
*/
function getFeed(uri, id)
{
  // Retrieve the JSON feed.
  var script = document.getElementById(id);
  var head = document.getElementsByTagName("head")[0];
	
  if (script && head)
  {
    head.removeChild(script);
  }

  script = document.createElement('script');
  script.setAttribute('src', uri);
  script.setAttribute('id', id);
  script.setAttribute('type', 'text/javascript'); 

  head.appendChild(script);
}

function changeAlbum(uri)
{
  // Check if the first option is selected.
	if (uri == "")
	{
		return;
	}
	
	uri = "http://picasaweb.google.com/data/feed/api/user/simposalsa/albumid/" + uri + "&kind=photo&thumbsize=144&callback=feedAlbum";
	getAlbum(uri);
}
