//Programming by Yezhoff Oleg yezhoff@ya.ru

/*==============================================================================
ready
==============================================================================*/
$(document).ready(function()
	{
var w_width=$(window).width();
//$('#scroll_container').css({'width':w_width});


enableCrawLine ();

		$('.show_map').click(function()
			{
  				$("#black").css('opacity', 0.6).show();
						var top = ($(window).height()-$('#map').height())/2+$(document).scrollTop();
						var left = ($(window).width()-$('#map').width())/2;
						$('#map').css({'top': top+'px'});
						$('#map').css({'left': left+'px'});
						$('#map').css({'visibility':'visible'});
				return false;
			}
		);



   $('.close a').click(function(){
     $('#map').css({'visibility':'hidden'});
     $("#black").hide();
     return false;
   });

$('.show').click(function(){
  $(this).addClass('active');
  $('.hidden').show();
})

	  //	$("#splash").draggable();
/*==============================================================================
tooltip
==============================================================================*/
		$(".tooltip a").mousemove(function(event)
			{
				var ttw = $('#tooltip').width();
				var tth = $('#tooltip').height();
                var X=event.pageX;
                var Y=event.pageY;

				if ((X+ttw)>($(document).width()-80)) {var x_coord = X-ttw-30;}
                else {var x_coord = X+20;}

				if ((Y+tth-$(document).scrollTop())>($(window).height()-80)) {var y_coord = Y-tth-20;}
                else {var y_coord = Y+20;}

				$('#tooltip').css({'left': x_coord, 'top': y_coord});
			});
        //show
		$(".tooltip a").mouseover(function()
			{
//				var info = $(this).next(".tooltip_txt").attr("innerHTML");
				var info = $(this).attr("name");
                if (info){$('#tooltip').attr("innerHTML", info).css('opacity', 0.9).show(); }

			});
        //hide
		$(".tooltip a").mouseout(function(){$('#tooltip').hide()});



$('.photos')
	.mousewheel(function(event, delta) {
		if (delta > 0)
			$('.scroll').animate({'left': '+=92.5px'},0);
		else if (delta < 0)
		     $('.scroll').animate({'left': '-=92.5px'},0);
		return false; // prevent default
	});



$('.to_left').click(function(){
  $('.scroll').animate({'left': '+=185px'},1000);
});

$('.to_right').click(function(){
  $('.scroll').animate({'left': '-=185px'},1000);
});
		/*==============================================================================
  ********************************************************************************
  ==============================================================================*/
		//end of ready
	}
);



var craw_line_offset;

function enableCrawLine () {
craw_line_offset = 0;

var craw_line_width = document.getElementById('scroll_text').offsetWidth;

if (craw_line_width < 145) {
return;
}


moveCrawLine (craw_line_width);
}

function moveCrawLine (w) {
var lefttime;
var container_width = document.getElementById('scroll_container').offsetWidth;
step = 1;

w = parseInt(w);
if (craw_line_offset<(w+container_width)) {
craw_line_offset = craw_line_offset + step;
} else {
craw_line_offset = 0;
}

document.getElementById('scroll_text').style.left = parseInt(container_width-craw_line_offset)+'px';

setTimeout('moveCrawLine ('+w+');', 10);
}

