var Site = {
	
	/**
	 * PARAMETROS MENU HOME
	 */
	ruta:	null,
	timer		:0,
	sideblocks	:null,
	
	slidefxs	:[],
	colorfxs	:[],
	
	/**
	 * PARAMETROS BUSCADOR
	 */
	menufxs		:null,
	/**
	 * Se pone un 1 porque $IE no acepta que la capa tenga un 0
	 */
	minMenu		:1,
	/**
	 * Tengo que cambiar el 100 por un numero dinamica porque en $IE no se mantiene la relaci�n de distancias con Firefox
	 */
	maxMenu		:150,
	
	/**
	 * PARAMETROS DE LAS OFERTAS
	 */
	ofertesfxs		:null,
	delay			:0,
	ofertesPos		:0,
	sideblocksHotel	:null,
	slidefxsHotel	:[],
	lastHotelClick	:null,
	isOver			:false,
	ofertaActual	:0,
	/**
	 * PARAMETROS FOTOS HOTEL
	 */	
	sideblocksFotos	:null,
	slidefxsFotos	:[],
	countHotel		:0,
	/**
	 *PARAMETROS PARA EL BANNER 
	 */
	infxsBanner	:	null,
	infxsTitol	:	null,
	timerBanner	:	0,
	
	loaderImg		:	null,
	/**
	 * Recoge el paramatro name de la url de la pagina
	 * @param {Object} name
	 */
	gup:function( name ){
		var regexS = "[\?&]"+name+"=([^&#]*)";
		var regex = new RegExp ( regexS );
		var tmpURL = window.location.href;
		var results = regex.exec( tmpURL );
		if( results == null )
			return"";
		else
			return results[1];
	},
	start: function(){
		Site.appearText();
		Site.initCercador();
		if(Site.gup("opcion")==""){
			switch(Site.gup("option")){
				case 	"":
					Site.initOferta(this);
					//Site.initBanner();
				break;
				case	"com_inturco":
					switch(Site.gup("task")){
						case "":
							Site.initMenuHotel2();
						break;
						case "generales":
							Site.initFotosHotels();
						break;
						default:
						break;
					}
				break;
		}
		}
		//this.menuEffect();		
		//if ($('kwick')) Site.parseKwicks();
		
		//if ($('download')) Download.start();
	},
	/**
	 * FUNCIONES PARA EL BANNER CENTRAL
	 */
	/*
	cambiaNomImg:function(img){		
		var src	=	img.src.split("/");
		var aleat = Math.random() * 14;		
    	aleat = Math.floor(aleat);
		src[src.length-1]	=	"banner"+aleat+".jpg";
		return(src.join("/"));
	},
	initBanner:function(){
		var el				=	$("imgBanner");
		//this.timerBanner	=	0;
		//this.timer 			+= 400;
		this.infxsBanner	=	new Fx.Style(el, 'opacity', {
			duration: 800,
			transition: Fx.Transitions.expoIn,
			wait: false,
			onComplete: Site.finBanner.pass([el])
		});
		this.infxsBanner.start(1,0.1);
	},
	finBanner:function(el){
		//CAMBIAM LA IMATGE
		el.src				= 	this.cambiaNomImg(el);
		//alert(el.src);
		this.infxsBanner	=	new Fx.Style(el, 'opacity', {
			duration	: 800,
			transition	: Fx.Transitions.expoIn,
			wait		: false,
			onComplete	: Site.reBanner.pass([el])
		});
		this.infxsBanner.start(0.1,1);
	},
	reBanner:function(){
		setTimeout(Site.initBanner,5000);
	},
	initTitol:function(){
		// titulo
		var el				=	$("TitolBanner");
		this.infxsTitol	= new Fx.Style(el, 'width', 
			{ duration: 800, transition: Fx.Transitions.expoIn, wait: false, onComplete: Site.setajaxTitol.pass() });
		this.infxsTitol.start(395,0);
	},
	setajaxTitol:function(){
		new Ajax('/booking/components/com_inturco/titols.php',
			{	postBody:'lang=ES',
				onComplete: Site.fiTitol
			}
		).request();
	},
	fiTitol:function(req){
		var el				=	$("TitolBanner");
		el.innerHTML		=	req;
		this.infxsTitol		=	new Fx.Style(el, 'width', {
			duration: 800,
			transition: Fx.Transitions.expoIn,
			wait: false,
			onComplete: Site.reTitol.pass([el])
		});
		this.infxsTitol.start(0,395);
	},
	reTitol:function(){
		setTimeout(Site.initTitol,8000);
	},
	
	*/
	
	/**
	 * Iniciamos el proceso de cambiar la imagen y el título del banner
	 */
	initBanner : function() {
		// primero hacemos desaparecer la imagen
		var el				=	$("imgBanner");
		this.infxsBanner	=	new Fx.Style(el, 'opacity', {
			duration: 2000, transition: Fx.Transitions.expoIn, wait: false, onComplete: Site.setAjaxBanner});
		this.infxsBanner.start(1,0.1);
		
		// hacemos desparecer el titulo
		var el				=	$("TitolBanner");
		
		// si el titulo estaba desplegado
		if(el.style.width != "0px") {
			this.infxsTitol	= new Fx.Style(el, 'width', 
				{ duration : 2000, transition : Fx.Transitions.expoIn, wait : false, onComplete : null });
			this.infxsTitol.start(395,0);
		}
	},
	
	/**
	 * Escogemos una nueva imagen y un nuevo título para el banner
	 */
	setAjaxBanner : function() {
		new Ajax('/booking/components/com_inturco/titols.php', { postBody:'lang=ES', onComplete: Site.endBanner.pass()}).request();
	},
	
	/**
	 * Volvemos a mostrar la imagen del banner
	 */
	endBanner : function(req) {
		//alert(req);
		// cambiamos la imagen y el título del banner
		$("banner").innerHTML = req;
	
		var el				= $("imgBanner");
		this.infxsBanner	=	new Fx.Style(el, 'opacity', {
			duration : 2000, transition : Fx.Transitions.expoIn, wait : false, onComplete : Site.reBanner });
		this.infxsBanner.start(0.1,1);
		
		// cambiamos el titulo
		var el				=	$("TitolBanner");
		
		// si hay texto para mostrar en el banner, desplegamos el div
		// lo minimo que contiene el elemento será: <p></p>, de ahí el 7
		if (el.innerHTML.length > 7) {
			//el.innerHTML		=	req;
			this.infxsTitol		=	new Fx.Style(el, 'width', {
				duration : 2000, transition : Fx.Transitions.expoIn, wait : false, 
				onComplete : null
				// onComplete : setTimeout.pass([Site.initBanner,8000]) 
				});
			this.infxsTitol.start(0,395);
		}
	},

	/**
	 * Establecemos un lapso de tiempo antes de volver a iniciar el proceso de cambiar la imagen y el titulo del banner 
	 */	
	reBanner : function() {
		setTimeout(Site.initBanner,5000);
	},
	
	/**
	 * AJAX PARA LAS CONDICIONES LEGALES
	 */
 	// textos multitidioma
 	ver_condiciones_reserva		: null,
  
	ocultar_condiciones_reserva	: null,
 
	recuperaNotaLegal : function(ver, ocultar){
		Site.ver_condiciones_reserva		= Site.ver_condiciones_reserva		|| ver;
		Site.ocultar_condiciones_reserva	= Site.ocultar_condiciones_reserva	|| ocultar;
		
		/* ie compatibility */
		if (window.console) {
			console.debug('recuperaNotaLegal: ver =  ' + Site.ver_condiciones_reserva);
			console.debug('recuperaNotaLegal: ocultar =  ' + Site.ocultar_condiciones_reserva);
		}
		new Ajax('/booking/modules/mod_ofertas_legales.php',
			{	postBody:'',
				onComplete: Site.showLegal,
				update: 'notas'}
		).request();
		return false;
	},
 
	showLegal : function(req) {
		$("notas").style.height	=	"300px";
		var el 	=	$("ver");
		el.blur();
		el.innerHTML			=	Site.ocultar_condiciones_reserva;
		$("ver").onclick		=	Site.hideLegal;
		return false;
	},
 
	hideLegal : function() {
		$("notas").innerHTML	=	"";
		$("notas").style.height	=	"0px";
		var el 	=	$("ver");
		el.blur();
		el.innerHTML			=	Site.ver_condiciones_reserva;
		el.onclick				=	Site.recuperaNotaLegal;
		return false;
	},
	/**
	 * EFECTOS PARA LAS FOTOS DE LOS HOTELES
	 * 
	 */
	initFotosHotels:function(){
		this.timer = 0;
		this.sideblocksFotos = $$('.fotosUl a');
		this.slidefxsFotos = [];
		
		this.sideblocksFotos.each(function(el, i){
			el.setStyle('opacity', 0);
			this.timer += 400;
			this.slidefxsFotos[i] = new Fx.Style(el, 'opacity', {
				duration: 500,
				transition: Fx.Transitions.expoIn,
				wait: false,
				onComplete: this.createOverFoto.pass([el, i,this])
			});
			this.slidefxsFotos[i].start.delay(this.timer, this.slidefxsFotos[i], 1);
		}, this);
	},
	treuRuta:function(str){
		//var rutaPetita	=	str.substring(4,str.length-2);
		var separacio	=	str.split("/");
		var rutaPetita	=	separacio[separacio.length-1];
		var ruta		=	rutaPetita.substring(2,rutaPetita.length-2);
		separacio[separacio.length-1]	=	ruta+")";
		//var ruta	=	"";
		//var mitg	=	"";
		//var resta	=	0;		
		//alert(separacio[0].substring(separacio[0].length-3,separacio[0].length));
		/*
		if( (separacio[0].substring(separacio[0].length-3,separacio[0].length))=="thh" ){
			mitg	=	"h_";
			resta	=	3;
		}else{
			mitg	=	"bg_";
			resta	=	4;
		}
		var ruta 		=	separacio[0].substring(0,separacio[0].length-resta)+mitg+separacio[1];
		*/
		separacio	=	separacio.join("/");	
		return(separacio.substring(4,separacio.length-1));
	},
	createOverFoto:function(el,i,obj){
		/*el.addEvent('click', function(){
			//el.addClass("FotoActiva");
			var img	=	document.createElement("img");
			img.src	=	"/booking/templates/spanish_red/images/hotel/selected2.png";
			//img.injectInside(el);
			el.innerHTML	=	"";
			el.appendChild(img);
			var ruta	=	obj.treuRuta(el.style.background);
			$("fotoGran").src	=	ruta;		
		});*/
	},
	/**
	 * FUNCIONES PARA EL MENU DE HOTELES
	 * 
	 */
	initMenuHotel:function(){
		this.timer = 0;
		this.sideblocksHotel = $$('.Selector');
		
		this.slidefxsHotel = [];
		
		this.sideblocksHotel.each(function(el, i){
			//el.setStyle('margin-left', '-155px');
			//el.setStyle('opacity', '0');
			el.setStyle('width', '0');
			this.timer += 150;
			/*
			this.slidefxsHotel[i] = new Fx.Style(el, 'opacity', {
				duration: 400,
				transition: Fx.Transitions.expoIn,
				wait: false
				//onComplete: this.createOver.pass([el, i])
			});
			*/
			this.slidefxsHotel[i] = new Fx.Style(el, 'width', {
				duration: 400,
				transition: Fx.Transitions.expoIn,
				wait: false
				//onComplete: this.createOver.pass([el, i])
			});
			this.slidefxsHotel[i].start.delay(this.timer, this.slidefxsHotel[i], 200);
			//alert(this.slidefxs[i].start);
			//this.slidefxs[i].start();

		}, this);
	},
	
	/**
	 * Inicializa el menú de hoteles en la seccion de "Nuestros hoteles"
	 */
	initMenuHotel2:function(){
		this.timer = 0;
		
		// Recogemos los elementos que tienen class="Selector" para añadirles los efectos en el mouseover y mouseout y la llamada en el onclick
		// (son los h2)
		this.sideblocksHotel = $$('.Selector');
		
		// Array de efectos para el cambio de color
		this.slidefxsHotel = [];

		// Contador de elementos en el menu de hoteles
		this.countHotel = this.sideblocksHotel.length;
		
		// Para cada elemento
		this.sideblocksHotel.each(function(el, i){
			
			//el.setStyle('margin-left', '-155px');
			//el.setStyle('opacity', '0');
			el.setStyle('backgroundColor', '#B8CD44');
			this.timer += 150;
			
			/*
			this.slidefxsHotel[i] = new Fx.Style(el, 'opacity', {
				duration: 400,
				transition: Fx.Transitions.expoIn,
				wait: false
				//onComplete: this.createOver.pass([el, i])
			});
			*/
			this.slidefxsHotel[i] = new Fx.Style(el, 'backgroundColor', {
				duration: 400,
				transition: Fx.Transitions.expoIn,
				wait: false,
				onComplete: this.createOverHotel.pass([el, i,this])
			});
			this.slidefxsHotel[i].start.delay(this.timer, this.slidefxsHotel[i], '77ADE9');
			//alert(this.slidefxs[i].start);
			//this.slidefxs[i].start();

		}, this);
	},
	
	/**
	 * Crea el efecto al pasar el ratón por encima de la lista de hoteles en el menú de "Nuestros hoteles" 
	 * @param {Object} el	elemento al que añadir el efecto
	 * @param {Object} i	contador
	 * @param {Object} obj	el objeto site para poder referenciarlo
	 */
	createOverHotel: function(el, i,obj){
		var first = el;
		//if (!first || first.getTag() != 'a') return;
		var overfxs = new Fx.Styles(first, {'duration': 200, 'wait': false});
		/*if (first.hasClass('big')){
			var tocolor = '333';
			var fromcolor = 'fff';
		} else {
			var tocolor = 'CD0066';
			var fromcolor = '666';
		}*/
		el.addEvent('mouseover', function(){
			overfxs.start({
				//'color': tocolor,
				'width': 155
			});
		});
		el.addEvent('mouseout', function(){
			overfxs.start({
				//'color': fromcolor,
				'width': 140
			});
		});
		el.addEvent('click', obj.carregaHotel.pass([el,el.id,obj]));
		
		// decrementamos el contador
		if("x_" + obj.gup("catid") == el.id)
			obj.carregaHotel(el,el.id,obj);
	},
	
	/**
	 * Cargamos los hoteles de la zona seleccionada
	 * @param {Object} el	elemento que contiene la zona ( en el que se ha clicado)
	 * @param {Object} id	identificador del elementos que contiene la zona
	 * @param {Object} obj	el objeto site para poder referenciarlo
	 */
	carregaHotel:function(el,id,obj){
		id	=	id.split("_")[1];
		el.blur();		
		if( obj.lastHotelClick	!=	id ){
			var overfxs = new Fx.Styles(el, {'duration': 500, 'wait': false});			
			overfxs.start({
					'backgroundColor': 'B8CD44'
			});
			if(obj.lastHotelClick){
				var overfxs = new Fx.Styles($(obj.lastHotelClick), {'duration': 500, 'wait': false});			
				overfxs.start({
					'backgroundColor': '77ADE9'
				});
			}
			obj.lastHotelClick	=	el.id;
		}
		new Ajax('/booking/components/com_inturco/listado_hotels.php', {postBody:"idSection="+id,onComplete: obj.imprimirHotel}).request();
	},
	
	/**
	 * Recoge el resultado de la llamada ajax e inserta la informacion de los hoteles de esa zona en la capa 
	 * @param {Object} req
	 */
	imprimirHotel:function(req){
		$("Hotels").innerHTML	=	req;
	},	
	/**
	 * FUNCIONES PARA LOS EFECTOS DE OFERTA
	 * @param {Object} obj
	 */
	initOferta:function(obj){
		//var ofertes	=	$$(".Portada");
		var oferta		=	$("portadaOfertesCambiants");
		$('nav-ant').addEvent('click', this.cambiaOfertaNext.pass([obj]));
		$('nav-sig').addEvent('click', this.cambiaOfertaPrev.pass([obj]));
		/*ofertes.each(function(el){
			el.onmouseover	=	obj.overOferta.pass([obj]);
			el.onmouseout	=	obj.outOferta.pass([obj]);
		});*/
		/*
		oferta.onmouseover	=	obj.overOferta.pass([obj]);
		oferta.onmouseout	=	obj.outOferta.pass([obj]);
		obj.cambiaOferta(obj);
		*/
		
	},
	/**
	 *
	 * @param {Object} obj
	 */
	cambiaOfertaPrev:function(obj){
		$('nav-ant').blur();
		ofertes	=	$("portadaOfertesCambiants");	
			obj.delay += 400;
			obj.ofertesfxs = new Fx.Style(ofertes, 'opacity', {
				duration: 1000,
				wait: false,
				onComplete: obj.posaLoading.pass([ofertes,obj])
			});
		obj.ofertesfxs.start(1,0.2);
		this.ofertaActual-=2;
	},
	cambiaOfertaNext:function(obj){
		$('nav-sig').blur();
		ofertes	=	$("portadaOfertesCambiants");	
			obj.delay += 400;
			obj.ofertesfxs = new Fx.Style(ofertes, 'opacity', {
				duration: 1000,
				wait: false,
				onComplete: obj.posaLoading.pass([ofertes,obj])
			});
		obj.ofertesfxs.start(1,0.2);
		this.ofertaActual+=2;
	},
	posaLoading:function(el,obj){
		//POSAM EL LOADING
			new Ajax('/booking/modules/mod_ofertas_rec.php', {postBody:"lang=ES&max_ofertas=2&max_habitaciones=2",onComplete: obj.retornaOfertes.bind(obj)}).request();
	},
	retornaOfertes:function(req){
		$("portadaOfertesCambiants").innerHTML	=	req;
		this.tornaOferta();
	},
	tornaOferta:function(){
		ofertes	=	$("portadaOfertesCambiants");	
			this.delay += 400;
			this.ofertesfxs = new Fx.Style(ofertes, 'opacity', {
				duration: 1000,
				wait: false,
				onComplete: this.comensaOfertes.pass([this])
			});
		this.ofertesfxs.start(0.2,1);
	},
	comensaOfertes:function(obj){
		//setTimeout(obj.cambiaOferta.pass([obj]),5000);
	},
	/**
	 * FUNCIONES PARA REPLEGAR/DESPLEGAR BUSCADOR
	 */
	initCercador:function(){
		var boto	=	$("button1");
		var form	=	$("Formulario");
		this.menufxs = new Fx.Style(form, 'height', {
				duration: 1000,
				//transition: Fx.Transitions.circIn,
				transition: Fx.Transitions.bounceOut,	
				wait: false
			});
	    //this.replega (this);
		boto.addEvent('click', this.replega.pass([this]));
	},
	replega:function(obj){
		$("button1").blur();		
		obj.menufxs.start(obj.minMenu,obj.maxMenu);
		var tmp	=	obj.minMenu;
		obj.minMenu	=	obj.maxMenu;
		obj.maxMenu	=	tmp;
	},
	replegaInit:function(){
		var form	=	$("Formulario");
		var menufxs = new Fx.Style(form, 'height', {
				duration: 1000,
				//transition: Fx.Transitions.circIn,
				transition: Fx.Transitions.bounceOut,	
				wait: false
			});
		menufxs.start(100,1);
	},
	/**
	 * FUNCIONES PARA EL MENU
	 */
	parseKwicks: function(){
		var kwicks = $$('#kwick .kwick');
		var fx = new Fx.Elements(kwicks, {wait: false, duration: 200, transition: Fx.Transitions.quadOut});
		kwicks.each(function(kwick, i){
			kwick.addEvent('mouseover', function(e){
				e = new Event(e).stop();
				var obj = {};
				obj[i] = {
					'width': [kwick.getStyle('width').toInt(), 185]
				};
				kwicks.each(function(other, j){
					if (other != kwick){
						var w = other.getStyle('width').toInt();
						if (w != 105) obj[j] = {'width': [w, 105]};
					}
				});
				fx.start(obj);
			});
		});
		
		document.addEvent('mouseover', function(e){
			e = new Event(e);
			var rel = e.relatedTarget;
			if (!rel) return;
			if (rel.hasClass && (rel.hasClass('kwicks') || rel.hasClass('kwick') || rel.id == 'kwick')){
				var obj = {};
				kwicks.each(function(other, j){
					obj[j] = {'width': [other.getStyle('width').toInt(), 125]};
				});
				fx.start(obj);
			};
		});
	},
	menuEffect:function(){
		this.sideblocks = $$('#textMenu li');
		this.sideblocks.each(function(el, i){
			this.overMenu(el, i);
		},this);
	},
	appearText: function(){
		this.timer = 0;
		this.sideblocks = $$('.menuO');
		
		//this.slidefxs = [];
		//this.colorfxs = [];
		
		this.sideblocks.each(function(el, i){
			/*el.setStyle('opacity', '0');*/
			el.setStyle('backgroundColor', '#ffffff');
			this.timer += 150;
			/*this.slidefxs[i] = new Fx.Style(el, 'opacity', {
				duration: 400,
				transition: Fx.Transitions.expoIn,
				wait: false,
				onComplete: this.createOver.pass([el, i])
			});*/
			this.slidefxs[i] = new Fx.Style(el, 'backgroundColor', {
				duration: 400,
				transition: Fx.Transitions.expoIn,
				wait: false,
				onComplete: this.createOver.pass([el, i])
			});
			this.slidefxs[i].start.delay(this.timer, this.slidefxs[i], 'a4cefc');
		}, this);
	},
	overMenu:function(el,i){
		var first = el.getFirst();		
		//var first = el;
		//if (!first || first.getTag() != 'a') return;
		var overfxs = new Fx.Styles(first, {'duration': 200, 'wait': false,transition: Fx.Transitions.elasticIn});
		if (first.hasClass('big')){
			var tocolor = '333';
			var fromcolor = 'fff';
		} else {
			var tocolor = 'CD0066';
			var fromcolor = '666';
		}
		el.addEvent('mouseover', function(){
			overfxs.custom({
				//'color': [tocolor,fromcolor],
				//'margin-left': [10,0]
				'backgroundColor':['F1F1F1','77ADE9']
			});
		});
		el.addEvent('mouseout', function(){
			overfxs.custom({
				'color': [fromcolor,tocolor],
				'margin-left': [0,10]
			});
		});
	},
	createOver: function(el, i){
		//var first = el.getFirst().parentNode;
		var first = el.getFirst();
		if (!first || first.getTag() != 'a') return;
		var overfxs = new Fx.Styles(first, {'duration': 800, 'wait': false});
		if (first.hasClass('big')){
			var tocolor = '333';
			var fromcolor = 'fff';
		} else {
			var tocolor = 'FFF';
			var fromcolor = '666';
		}
		el.addEvent('mouseover', function(){
			overfxs.start({
				'color': tocolor,
				//'margin-left': 10
				'backgroundColor':['a4cefc','77ADE9']
			});
		});
		el.addEvent('mouseout', function(){
			overfxs.start({
				'color': fromcolor,
				//'margin-left': 0
				'backgroundColor':['77ADE9','a4cefc']
			});
		});
	}
	
};

var Download = {

	start: function(){
		Download.checkAll = $('checkall');
		Download.checkNone = $('checknone');
		Download.checkAll.addEvent('click', function(event){
			new Event(event).stop();
			Download.all();
		});
		Download.checkNone.addEvent('click', function(event){
			new Event(event).stop();
			Download.none();
		});
		Download.trs = $$('tr.option');
		Download.chks = $$('#download div.check');
		Download.radios = $$('#options div.check');
		Download.fx = [];
		Download.parse();
		
		Download.select(Download.chks[0]);
		
		Download.chks.each(function(chk){
			if (chk.getElement('input').checked) Download.select(chk);
		});
		
		Download.select(Download.radios[0]);
		
		[].extend(Download.chks).extend(Download.radios).each(function(chk){
			chk.getElement('input').setStyle('display', 'none');
		});
	},

	select: function(chk){
		chk.getElement('input').checked = 'checked';
		Download.fx[chk.index].start({
			'background-color': '#191919',
			'color': '#FFF'
		});
		chk.addClass('selected');
		
		if (chk.deps){
			chk.deps.each(function(id){
				if (!$(id).hasClass('selected')) Download.select($(id));
			});
		} else {
			Download.radios.each(function(other){
				if (other == chk) return;
				Download.deselect(other);
			});
		}
	},
	
	all: function(){
		Download.chks.each(function(chk){
			Download.select(chk);
		});
	},
	
	none: function(){
		Download.chks.each(function(chk){
			Download.deselect(chk);
		});
	},

	deselect: function(chk){
		chk.getElement('input').checked = false;
		Download.fx[chk.index].start({
			'background-color': '#202020',
			'color': '#555'
		});
		chk.removeClass('selected');
		
		if (chk.deps){
			Download.chks.each(function(other){
				if (other == chk) return;
				if (other.deps.test(chk.id) && other.hasClass('selected')) Download.deselect(other);
			});
		}
	},

	parse: function(){
		Download.trs.each(function(tr, i){
			Download.fx[i] = new Fx.Styles(tr, {wait: false, duration: 300});

			var chk = tr.getElement('div.check');

			chk.index = i;
			var dp = chk.getProperty('deps');
			if (dp) chk.deps = dp.split(',');

			tr.onclick = function(){
				if (!chk.hasClass('selected')) Download.select(chk);
				else if (tr.hasClass('file')) Download.deselect(chk);
			};

			tr.onmouseover = function(){
				if (!chk.hasClass('selected')){
					Download.fx[i].start({
						'background-color': '#1c1c1c',
						'color': '#bbb'
					});
				}
			}

			tr.onmouseout = function(){
				if (!chk.hasClass('selected')){
					Download.fx[i].start({
						'background-color': '#202020',
						'color': '#666'
					});
				}
			}

		});
	}

};

//window.addEvent('domready', Site.start);
