
$(document).ready(function(){
	// ------------------------------------------------------------------------
	// carousel 
	// ------------------------------------------------------------------------
	var slide = $('div.box-slid-banner');
	var clear = basedir+'img/clear.gif';
	
	if ($.browser.msie && $.browser.version < 7) {
		$('#menu > ul > li,div.box-slid-banner > div > div.box-1').hover( function(){ $(this).stop().addClass('over') } , function(){ $(this).removeClass('over'); } );
		
		$.each($('img',slide),function(){
			src = $(this).attr('src');
			width = $(this).width()+'px';
			height = $(this).height()+'px';
			background = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+src+'",sizingMethod="scale")';
			$(this).attr('src',clear).css('filter',background).css('width',width).css('height',height);
		});
	}
	
	if($('> div > div',slide).length > 3){
		var countSlide = $('> div > div',slide).length;
		var currentSlide = 1;
		$(slide).prepend('<a href="#prev" class="prev"><img src="'+basedir+'img/prev-1.gif" alt="prev" title="" /></a><a href="#next" class="next"><img src="'+basedir+'img/next-1.gif" alt="next" title="" /></a>')
			.hover(function(){
					$('> a',slide).stop().css('display','block').animate({'opacity':0.25},300);
				},function(){
					$('> a',slide).stop().animate({'opacity':0},300,function(){ $(this).css('display','none'); });
				});
		$('>div.slide',slide).append($('>div.slide',slide).html());
		$('> a',slide).css('display','none').css('opacity',0)
			.hover(function(){
					$(this).stop().animate({'opacity':0.5},300);
				},function(){
					$(this).animate({'opacity':0.25},300);
				})
			.click(function(){
				move = ($(this).attr('class') == 'next')?currentSlide++:--currentSlide - 1;
				
				if(move < 0){
					move = countSlide - 1;
					currentSlide = countSlide;
					$('>div.slide',slide).animate({'left':(0-(countSlide*290))+'px'},0);
				}else if(move > countSlide){
					$('>div.slide',slide).animate({'left':0},0);
					currentSlide = 2;
					move=1;
				}
				
				$('~div.slide',this).stop().animate({'left':(0-(move*290))+'px'},500);
				return(false);
			});
		$('> div.slide',slide).css('width','99999px');
	}
	
	var slideHeader = $('h3',slide);
	
	$.each(slideHeader,function(){
		var href = $('a',this).attr('href');
		var html = $('a',this).html();
		$(this).html(html);
		$(this).parent().parent().click(function(){

			//window.open(href,'_blank');
			
			location.replace(href);
		});
	});

	// ------------------------------------------------------------------------
	// login form
	// ------------------------------------------------------------------------
	$('#reveal_login_form').click(function(){

		$('#login_form_container').css({
			'left':(Math.floor($(window).width()/2-$('#login_form_container').width()/2)),
			'top':(Math.floor($(window).height()/2-$('#login_form_container').height()/2)-100)
		});


		$('#overlay').css({'display':'block'});
		$('#login_form_container').css({'display':'block'});
	});

	$('#login_form_close').click(function(){
		$('#overlay').css({'display':'none'});
		$('#login_form_container').css({'display':'none'});		
	});

});

