function Animation(time, steps, delay) { 
this._time = time; 
this._steps = steps; 
this._delay = delay; 
this._animationFunctions = []; 
this._beginHandler = null; 
this._doneHandler = null; 
this._timer = null; 
}; 
Animation.prototype.addColorChange = function(el, attr, start, end) { 
var animationFunction = function(mix) { 
var colorArray = [0, 0, 0]; 
 
for (var i = 0; i < 3; ++i) { 
// simple linear interpolation 
colorArray[i] = (1.0 - mix) * start[i] + mix * end[i]; 
} 
 
el.style[attr] = arrayToColor(colorArray); 
}; 
this.addAnimationFunction(animationFunction); 
}; 
Animation.prototype.addMovement = function(el, attr, start, end) { 
var animationFunction = function(mix) { 
el.style[attr] = numToPixels((1.0 - mix) * start + mix * end); 
}; 
this.addAnimationFunction(animationFunction); 
}; 
Animation.prototype.addOpacity = function(el, desc) { 
var animationFunction = function(mix) { 
el.style.opacity = (desc)? (1.0 - mix) : mix; 
el.style.filter = 'alpha(opacity=' + ((desc)? (1.0 - mix) : mix)*100 + ')'; 
}; 
this.addAnimationFunction(animationFunction); 
}; 
Animation.prototype.addAnimationFunction = function(animationFunction) { 
this._animationFunctions[this._animationFunctions.length] = 
animationFunction; 
}; 
Animation.prototype.setBeginHandler = function(beginHandler) { 
this._beginHandler = beginHandler; 
}; 
Animation.prototype.setDoneHandler = function(doneHandler) { 
this._doneHandler = doneHandler; 
}; 
Animation.prototype._callAnimationFunctions = function(mix) { 
for(var i = 0; i < this._animationFunctions.length; ++i) { 
this._animationFunctions[i](mix); 
} 
}; 
Animation.prototype.start = function() { 
var obj = this; 
var nextStep = 0; 
var startTime = 0; 
var animationLoop = function() { 
var currentStep = nextStep; 
++nextStep; 
 
// where we are in the animation, between 0 and 1 
var currentMix = currentStep / obj._steps; 
var nextMix = nextStep / obj._steps; 
 
obj._callAnimationFunctions(currentMix); 
 
if (nextStep <= obj._steps) { 
// delay is calculated as the difference between the current 
// time and where we should be, as calculated by looking at when 
// we started and how long we should be taking 
var curTime = new Date().getTime(); 
var nextTime = startTime + Math.floor(obj._time * nextMix); 
var delay = Math.max(0, nextTime - curTime); 
obj._timer = window.setTimeout(animationLoop, delay); 
} else { 
obj._timer = null; 
if (obj._doneHandler) { 
obj._doneHandler(); 
} 
} 
}; 
var beginAnimation = function() { 
if (obj._beginHandler) { 
obj._beginHandler(); 
} 
startTime = new Date().getTime(); 
animationLoop(); 
}; 
this._timer = window.setTimeout(beginAnimation, this._delay); 
}; 
Animation.prototype.stop = function() { 
if (this._timer) { 
window.clearTimeout(this._timer); 
} 
}; 
function arrayToColor(arr) { 
return "rgb(" + Math.floor(arr[0]) + 
", " + Math.floor(arr[1]) + 
", " + Math.floor(arr[2]) + ")"; 
}; 
function numToPixels(num) { 
return Math.floor(num) + "px"; 
}; 
/** 
* @constructor 
*/ 
function LinkList() { 
this._listId = ""; 
// Colors are RGB 
// Time and delay are in milliseconds 
// Distances are in pixels 
this.BACKGROUND_COLOR = [255, 255, 255]; 
this.LINK_COLOR = [0, 0, 255]; 
this.OLD_LINK_COLOR = [255, 0, 255]; 
this.HIDE_TIME = 300; 
this.HIDE_STEPS = 10; 
this.HIDE_DELAY = 0; 
this.HIDE_DISTANCE = 0; 
this.SHOW_TIME = 300; 
this.SHOW_STEPS = 10; 
this.SHOW_DELAY = 0; 
this.SHOW_DISTANCE = 0; 
} 
LinkList.prototype.getList = function() { 
return document.getElementById(this._listId); 
}; 
LinkList.prototype.getItems = function() { 
var list = this.getList(); 
var retArray = []; 
for (var child = list.firstChild; child; child = child.nextSibling) { 
if (child.nodeType == 1 && child.nodeName == "LI") { 
retArray[retArray.length] = child; 
} 
} 
return retArray; 
}; 
LinkList.prototype.getLinks = function() { 
var retArray = []; 
var items = this.getItems(); 
for (var i in items) { 
var item = items[i]; 
for (var child = item.firstChild; child; child = child.nextSibling) { 
if (child.nodeType == 1 && child.nodeName == "A") { 
retArray[retArray.length] = child; 
break; 
} 
} 
} 
return retArray; 
}; 
LinkList.prototype._fixStyle = function(numItems) { 
var list = this.getList(); 
var items = this.getItems(); 
for (var i = 0; i < numItems && i < items.length; ++i) { 
items[i].style.display = "block"; 
} 
var needsClass = true; 
var classes = list.className.split(" "); 
for (var c in classes) { 
if (c == "yesscript") { 
needsClass = false; 
break; 
} 
} 
 
if (needsClass) { 
list.className += " yesscript"; 
} 
}; 
/** 
* @constructor 
*/ 
function ScrollList(listId) { 
/** 
* How many list items to keep fully visible (not including the one 
* that fades in) */ 
this.SHOW_COUNT = 1; 
this._listId = listId; 
this._replacementList = null; 
this._discardCount = 0; 
} 
ScrollList.prototype = new LinkList(); 
ScrollList.prototype.init = function() { 
// +1 is because initially the bottom item is shown as well. 
this._fixStyle(this.SHOW_COUNT + 1); 
this._hideCurrent(); 
}; 
ScrollList.prototype._showNext = function() { 
// If there is a list waiting to be inserted, do it here, when only 
// SHOW_COUNT elements are visible 
if (this._replacementList) { 
this._replaceList(); 
} 
var list = this.getList(); 
var items = this.getItems(); 
var links = this.getLinks(); 
if (items.length > this.SHOW_COUNT) { 
var currentItem = items[0]; 
var currentLink = links[0]; 
var nextItem = items[this.SHOW_COUNT]; 
var nextLink = links[this.SHOW_COUNT]; 
var animation = new Animation(this.SHOW_TIME, this.SHOW_STEPS, this.SHOW_DELAY); 
animation.addColorChange(currentLink, "color", this.LINK_COLOR, this.OLD_LINK_COLOR); 
animation.addColorChange(nextLink, "color", this.BACKGROUND_COLOR, this.LINK_COLOR); 
 
if (currentLink.getElementsByTagName("img").length) 
animation.addOpacity(currentLink.getElementsByTagName("img")[0],false); 
animation.setBeginHandler(function() { 
nextItem.style.display = "block"; 
}); 
var done = function() { 
arguments.callee.obj._hideCurrent(); 
}; 
done.obj = this; 
animation.setDoneHandler(done); 
 
animation.start(); 
} 
}; 
ScrollList.prototype._hideCurrent = function() { 
var list = this.getList(); 
var items = this.getItems(); 
var links = this.getLinks(); 
 
if (items.length > this.SHOW_COUNT) { 
var currentItem = items[0]; 
var currentLink = links[0]; 
var nextItem = items[1]; 
var nextLink = links[1]; 
var animation = new Animation(this.HIDE_TIME, this.HIDE_STEPS, this.HIDE_DELAY); 
 
animation.addColorChange(currentLink, "color", this.OLD_LINK_COLOR, this.BACKGROUND_COLOR); 
if (currentLink.getElementsByTagName("img").length) 
animation.addOpacity(currentLink.getElementsByTagName("img")[0],true); 
if (this.HIDE_DISTANCE != 0 || this.SHOW_DISTANCE != 0) { 
animation.addMovement(currentItem, "top", 0, this.HIDE_DISTANCE + this.SHOW_DISTANCE); 
animation.addMovement(list, "top", 0, -this.SHOW_DISTANCE); 
} 
var done = function() { 
var obj = arguments.callee.obj; 
 
currentItem.style.top = ""; 
currentItem.style.display = "none"; 
list.style.top = ""; 
 
// _keepTopItem is false if the list has just been replaced, in 
// which case we want to discard this old element rather than 
// move it to the bottom 
if (obj._discardCount > 0) { 
obj.getList().removeChild(currentItem); 
obj._discardCount--; 
} else { 
obj.getList().appendChild(currentItem); 
} 
 
obj._showNext(); 
}; 
done.obj = this; 
animation.setDoneHandler(done); 
animation.start(); 
} 
}; 
ScrollList.prototype.updateList = function(newList) { 
this._replacementList = newList; 
}; 
ScrollList.prototype._replaceList = function() { 
var list = this.getList(); 
var items = list.getElementsByTagName("li"); 
var newItems = this._replacementList.getElementsByTagName("li"); 
// SHOW_COUNT items are currently visible, so keep them for now 
while(items.length > this.SHOW_COUNT) { 
list.removeChild(items[this.SHOW_COUNT]); 
} 
 
while(newItems.length > 0) { 
list.appendChild(newItems[0]); 
} 
// Mark the top SHOW_COUNT items as old, so they'll be thrown out 
// instead of cycled to the bottom of the list 
this._discardCount = this.SHOW_COUNT; 
this._replacementList = null; 
}; 
function setupStartListStyle(linkList) { 
linkList.BACKGROUND_COLOR = [0, 113, 204]; // #0071CC 
linkList.LINK_COLOR = [255, 255, 255]; // #FFFFFF 
linkList.OLD_LINK_COLOR = [159, 214, 255]; // #9FD6FF 
} 
function setupShuffleList(linkList) { 
var list = linkList.getList(); 
var items = list.getElementsByTagName("li"); 
var newList = document.createElement("div"); 
while(items.length > 0) { 
var rn = Math.floor(Math.random()*items.length); 
newList.appendChild(items[rn]); 
} 
while(newList.childNodes.length > 0) { 
if(newList.childNodes[0].firstChild.getAttribute("src")) { 
var newImg = document.createElement("img"); 
newImg.src = newList.childNodes[0].firstChild.getAttribute("src"); 
newList.childNodes[0].firstChild.removeAttribute("src"); 
newList.childNodes[0].firstChild.insertBefore(newImg, newList.childNodes[0].firstChild.firstChild); 
} 
list.appendChild(newList.childNodes[0]); 
} 
} 
function setupRecentlyUpdated() { 
if(!window.searchW||!window.searchW.length||!document.getElementById("topsrch")) return; 
printStartList("topsrch_list"); 
window.updated = new ScrollList("topsrch_list"); 
setupStartListStyle(updated); 
setupShuffleList(updated); 
updated.SHOW_TIME = 300; 
updated.SHOW_STEPS = 5; 
updated.SHOW_DELAY = 0; 
updated.SHOW_DISTANCE = 0; 
updated.SHOW_COUNT = 0; 
updated.HIDE_TIME = 300; 
updated.HIDE_STEPS = 5; 
updated.HIDE_DISTANCE = 12; 
updated.HIDE_DELAY = 3000; 
updated.init(); 
} 
function printStartList(idList) { 
if(!document.getElementById("topsrch")) return; 
var prevList = document.createElement("ul"); 
prevList.id = idList; 
while(window.searchW.length>0) { 
var opts = window.searchW.shift(); 
if(!opts.txt || !opts.txt.length) opts.txt="En Recherche"; 
var prevItem = document.createElement("li"); 
if(opts.pais && opts.nombre) 
prevItem.innerHTML = '<a href="'+opts.href+'" target="_top" src="/share-imgs/paises/'+opts.pais+'.gif">'+opts.nombre+': '+opts.txt+' <b>'+opts.key+'</b>.</a>'; 
else 
prevItem.innerHTML = '<a href="'+opts.href+'" target="_top">'+opts.txt+' <b>'+opts.key+'</b>.</a>'; 
prevList.appendChild(prevItem); 
} 
document.getElementById("topsrch").appendChild(prevList); 
}