// JavaScript Document

//side banner////////////////////
$(function(){
	$('#side img').hover(function(){
        $(this).attr('src', $(this).attr('src').replace('_off', '_on'));
		}, function(){
        	if (!$(this).hasClass('currentPage')) {
        	$(this).attr('src', $(this).attr('src').replace('_on', '_off'));
        }
   });
});


//header menu////////////////////
$(function() {
	var $menu = $('#menu');
	var $menu_items	= $menu.children('li');
	var $over = $('#over');
	var $object = $('.object');
	var $main = $('#main,#under');
	
	$over.addClass('visibility');
	
	$menu_items.bind('mouseenter',
		function(){
		var $this = $(this);
		$this.addClass('slided selected');
		$this.children('div').css('z-index','9999').stop(true,true).slideDown(500,
			function(){
			$menu_items.not('.slided').children('div').hide();
			$this.removeClass('slided');
			});
		}).
	bind('mouseleave',
		function(){
		var $this = $(this);
		$this.removeClass('selected').children('div').css('z-index','1');
		}
	);
		
	$menu.bind('mouseenter',
		function(){
		var $this = $(this);
		$object.addClass('visibility');
		$over.removeClass('visibility');
		$main.css('z-index','-2');
		$over.stop(true,true).fadeTo(500, 0.7);
		$this.addClass('hovered');
	}).
	bind('mouseleave',
		function(){
		var $this = $(this);
		$this.removeClass('hovered');
		$over.stop(true,true).fadeTo(500, 0);
		$main.css('z-index','0');
		$object.removeClass('visibility');
		$over.addClass('visibility');
		$menu_items.children('div').hide();
	})
});


//Fade////////////////////
$(function(){
	//images hide
	$('#main p img').hide();
});

//Initialization
var i = 0;
//IE
var int=0;

$(window).bind("load", function() {
	//load
	//0.1second intervals fade
	var int=setInterval("doThis(i)",100);
});

function doThis() {
	//Number of images
	var imgs = $('#main p img').length;
	if (i >= imgs) {
		//Clear timers
		clearInterval(int);
	}
	//Show images fade was concealing 0.5second intervals
	$('#main p img:hidden').eq(0).fadeIn(500);
	i++;
}

$(function(){
	$("#main p a img").hover(function(){
		$(this).stop(true, false).fadeTo(300,0.3);},
		function(){
			$(this).stop(true, false).fadeTo(300,1.0);
		});
});


//Animate Top////////////////////
$(function(){
     $("#toTop a").click(function(){
     $('html,body').animate({ scrollTop: $($(this).attr("href")).offset().top }, 'slow','swing');
     return false;
     })
});

