slider = new Array();
big = new Array();
big["width"] = 100;
big["height"] = 148;
big["height2"] = big["height"] + 0;
small = new Array();
small["width"] = 50;
small["height"] = 76;
small["height2"] = small["height"] + 0;
font = new Array();
font["big"] = 13;
font["small"] = 12;
timer = -1;
div_l = 0;
div_r = 0;

function equilibrate() {
	$('#slider ul li').each(function(i) {
		d = Math.abs(actual - i);
		var a = $(this);
		var img = a.children('a').children('img');
		var ttl = a.children('.imtitle');
		switch(d) {
			case 0:
				img.animate({width: big["width"], height: big["height"]});
				a.animate({width: big["width"], height: big["height2"], marginTop: '0', marginLeft: '8px', marginRight: '8px'}/*, function () { ttl.css({'font-size': font["big"]+'px'}); }*/);
				$('#nameTxt').html(ttl.attr('title'));
			break;
			case 1:
				if (slider[i] == 1) {
					slider[i] = 0;
					a.css({display: 'inline', width: '0px', height: '0px'});
					img.css({width: '0px', height: '0px'});
				}
				img.animate({width: small["width"], height: small["height"]}/*, function () { ttl.fadeTo(500, 1); }*/);
				a.animate({width: small["width"], height: small["height2"],  marginTop: '35px', marginLeft: '0', marginRight: '0'});
			break;
			default:
				slider[i] = 1;
				a.hide('fast');
			break;
		}
	});

}



		
function actual_change(diff) {
	if (actual + diff - 1 > 0 && actual + diff < max - 1) {
		actual = actual + diff;
		return true;
	}else if(actual + diff < 1){
		//$("#slider ul li:last-child").clone().prependTo("#slider ul");
		$("#slider ul").prepend($("#slider ul li:nth-child("+(actual + div_l)+")").css({width: '0px', height: '0px'}).clone());
		actual = actual + diff + 1;
		max++;
		return true;
	}else{
		$("#slider ul").append($("#slider ul li:nth-child("+(actual - div_r)+")").clone());
		//alert(actual);
		actual = actual + diff;
		max++;
		return true;
	}
	return false;
};
function directlink() {
	$('#directlink').attr('href', location.href.replace(location.search, '') + '?show=' + actual);
}
$(document).ready(function(){
	
	$('#slider ul').css('overflow', 'hidden');

	max = $('#slider ul li').size();
	max1 = max;
	actual = Math.round(max / 5) * 3;
	div_l = Math.round(max / 10) + 1;
	div_r = Math.round(max / 5) - div_l;
	
	$('#slider ul li').each( function(i) {
		d = Math.abs(actual - i);
		var a = $(this);
		var img = a.children('a').children('img');
		var ttl = a.children('.imtitle');
		switch(d) {
			case 0:
				/*ttl.css({'font-size': font["big"]+'px'});*/
				img.css({width: big["width"]+'px', height: big["height"]+'px'});
				if($.browser.msie && $.browser.version == '6.0'){
					a.css({height: big["height2"]+'px', margin: '0 8px'});
				}else{
					a.css({height: big["height2"]+'px', margin: '0 12px'});
				}
				a.show();
				$('#nameTxt').html(ttl.attr('title'));
				//showtext(a.attr('id').substr(5));
			break;
			case 1:
				img.css({width: small["width"]+'px', height: small["height"]+'px'});
				a.css({width: small["width"]+'px', height: small["height2"]+'px', margin: '35px 0 0 0'});
				a.show();
			break;
			default:
				a.css({display: 'none', width: '0px', height: '0px', margin: '35px 0 0 0'});
			break;
		}
	});
	$('#butleft').click( function () {
		if (actual_change(-1))
			equilibrate();
		return false;
	});
	$('#butright').click( function () {
		if (actual_change(+1))
			equilibrate();
		return false;
	});

	$('#slider ul li a').click( function () {
		//return false;
	});



});

function showtext(id) {
	$('#texts .text').each( function (i) {
		if ($(this).css('display') != 'none')
			//$(this).fadeOut('fast');
			$(this).hide();
	});
	$('#texts #text'+id).slideDown('slow');
}