function changeImages(id,imagenes,sufijo,next){
	var img = Array();
	img = imagenes.split(",");
	if(next>=img.length){
		next =1;
	}
	if(next>0){
		$(id).src = '/images/media/' + img[next] + sufijo + '.jpg';
	}
	next = parseInt(next) +1;
	if(img.length>1){
		setTimeout("changeImages('" + id + "','" + imagenes + "','" + sufijo + "','" + next + "');", 5000);
	}
}

function frasesRnd(){
	frases = Array(
				   '... A dios enfrentando y con el diablo dando',
				   'Porque en Venezuela hay más de un filósofo...',
				   'Equilibrio en la información, ...(pero sin Ruperti)',
				   'Devuélvanle la maleta a Mr Bean',
				   '¿Pitiyanki, Pitiruso o Pitipua\'?',
				   'McCain y la Hilton vs Chávez y la Morillo',
				   'Todo 11 tiene su 13 ...(sí, ...a mí también me crece)',
				   '"I see dead people" - Fidel',
				   '¿Es Kirchner o es Kosher?',
				   'Cristo viene y viene arrecho (24, 25 y 26 en el Poliedro)',
				   'No le pidas peras al horno, pídele una maleta',
				   'VEA, Tal cual... si se acaba el Mundo compre el Universal',
				   '¡Conspiratox, las deja bien muertas!',
				   '"Todo está excesivamente anormal"',
				   'Cambio laptop de Reyes por maleta de Antonnini',
				   'Compro cupos - La Kirchner',
				   'A Popy le intervinieron el telefonito',
				   'Aló presidente, Aló ciudadano, ¿Aló?, ¿Aló?, ¿Aló?...',
				   'Las cejas de Julio Borges vs la pollina de Vanessa Davies',
				   '¿Carmona es tanga o es hilo?',
				   'Celdas solares y cuatro soles, se acabaron los apagones',
				   'Iriiisss apaga el secador de pelo que se volvió a ir la luz',
				   'Yo quisiera que los políticos, fueran fueran paralíticos',
				   'Paquetazo: pa-que-te tengo, pa-que-te agarro, pa-que-te cojo',
				   'No hay mar que por por bien no venga - Evo',
				   'Carreño es el hombre de la etiqueta',
				   '¿Quién dijo que La Guaira es lejos? - El Viaducto'
				   );
	var numero = Math.round(Math.random() * frases.length);

	$('lafrase').innerHTML = frases[numero];
}

function tratarError(){ 
   return true; 
} 
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
function loadCrystalFrame(url,params){
	window.scroll(0,0);
	$('lightbox').innerHTML="<div align=\"center\"><img src=\"/images/admin/loading-h.gif\" border=\"0\"></div>";
	var arrayPageSize = getPageSize();
	$('overlay').style.display='';
	Element.setHeight('overlay', arrayPageSize[1]);
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);
	Element.setTop('lightbox', lightboxTop);
	$('lightbox').style.display='none';
	
    var myAjax = new Ajax.Updater('lightbox', url, { method: 'post', evalScripts: true, parameters: params, onComplete: function(){Effect.Appear('lightbox',{duration:0.5});} });
}


function closeCrystal(){
	$('overlay').style.display='none';
	Effect.Shrink('lightbox');	
	$('lightbox').innerHTML="";
}
window.onerror = tratarError;
