//<--
/*

	@author: SWAT (Rostovtsev Ruslan)
	@url: http://www.jsysteam.ru
	@version: 0.1.0 Alpha

*/

var site = {};


/***** Config ******/



site.config = {};

// Сделать таблицы полосатыми
site.config.msTable = true;	



/***** End Config *****/



/******** Archive ********/

site.archive = {};
site.archive.cur = null;
site.archive.pos = 0;
site.archive.data = new Array();

site.archive.find = function(year) {
	try {
		for(var i = 0; i < this.data.length; i++) {
			if(this.data[i].year == year) return this.data[i];
		}
	} catch(E) {
		alert(E);
	}
}


site.archive.show_number = function() {
	$('arch_num_img').src = this.cur.nums[this.pos].img;
	$('arch_num_img').alt = this.cur.nums[this.pos].txt;
	$('arch_num_txt').innerHTML = this.cur.nums[this.pos].txt;
	$('arch_num_url').href = this.cur.nums[this.pos].url;
	$('arch_num_url').title = this.cur.nums[this.pos].txt;
}


site.archive.show = function(year) {
	try {
		
		var y = this.find(year);

		if(Browser.Engine.trident) {
		
			$('arch_year_' + this.cur.year).setStyle('color', '#FFFFFF'); 
			$('arch_year_' + y.year).setStyle('color', '#cb9e37'); 
		
		} else {
			
			$('arch_year_' + this.cur.year).removeClass('active');
			$('arch_year_' + y.year).addClass('active');	
		}
		
		this.cur = y;
		this.pos = 0;
		
		/*var cover = $('arch_num_img');
		cover.set('slide', {duration: 'long', transition: 'bounce:out'});
		cover.slide();
		site.archive.show_number.delay(1000);
		cover.slide.delay(1000);
		*/
		
		this.show_number();
		
	} catch(E) {
		alert(E);
	}
}

site.archive.left = function() {
	
	if(this.pos < 1) {
		this.pos = this.cur.nums.length-2;
	} else {
		this.pos--;	
	}
	
	this.show_number();
}

site.archive.right = function() {
	
	if(this.pos >= this.cur.nums.length-2) {
		this.pos = 0;
	} else {
		this.pos++;	
	}
	
	this.show_number();
}

/************ End Archive ************/


/************ Persons **************/

site.persons = {};
site.persons.pos = 0;
site.persons.prev = 0;
site.persons.data = new Array();


site.persons.show = function(num) {
	
	try {
		
		if(num < this.data.length) {
		
			if(this.pos != num) {
				this.prev = this.pos;
				this.pos = num;
			}
			
			
			if (!Browser.Engine.trident) {
				
				$('pers_num_' + (this.prev + 1)).removeClass('active_' + (this.prev + 1)).addClass('num_' + (this.prev + 1));
				$('pers_num_' + (this.pos + 1)).removeClass('num_' + (this.pos + 1)).addClass('active_' + (this.pos + 1));
				
			} else {
				
				var prev_left = this.prev ? ('-' + (this.prev*22)) : 0;
				var pos_left = this.pos ? ('-' + (this.pos*22)) : 0;
				$('pers_num_' + (this.prev + 1)).setStyle('background-position', prev_left + 'px top');
				$('pers_num_' + (this.pos + 1)).setStyle('background-position', pos_left + 'px -22px');
				
			}

			$('pers_img').src = this.data[this.pos].img;
			$('pers_url').href = this.data[this.pos].url;
		
		} else {
			alert('Нет персоны.');	
		}
		
	} catch(E) {
		alert(E);
	}
}


site.persons.left = function() {
	
	this.prev = this.pos;
	
	if(this.pos < 1) {
		this.pos = this.data.length-1;
	} else {
		this.pos--;	
	}
	
	this.show(this.pos);
}


site.persons.right = function() {

	this.prev = this.pos;
	
	if(this.pos >= this.data.length-1) {
		this.pos = 0;
	} else {
		this.pos++;	
	}
	
	this.show(this.pos);
}


/************ End Persons **************/


function makeStripedTable() {
   var tabs = document.getElementsByTagName("table");
   for (var e = 0; e < tabs.length; e++) {
         var rows = tabs[e].getElementsByTagName("tr");
         for (var i = 0; i < rows.length; i++) 
            rows[i].className += ((i % 2) == 0 ? " oddrows" : " evenrows");
   }
}




window.addEvent('domready', function() {   
    
    try {
	 
	 if(!Browser.Engine.presto && !Browser.Engine.webkit && site.config.msTable) makeStripedTable();
	 
	 if($chk('top50')) {
		 //var scroller = new UvumiScrollbar("top50");
		 var top_scroll = new Scroller('top50', {area: 190, velocity: 1});
		 $('top50').addEvent('mouseover', top_scroll.start.bind(top_scroll));
		 $('top50').addEvent('mouseout', top_scroll.stop.bind(top_scroll));
		 $('top50').addEvent('click', top_scroll.stop.bind(top_scroll));
	 }	
	 

	} catch(E) {
		//alert(E);
	}
}); 




//-->