/* -------------------------------------------------- *
 * Project scripts
 * -------------------------------------------------- *
 * Author: Morozov Igor
 * URL: http://www.morozoff.info/
 * Copyright: 2010 Morozov Igor
** -------------------------------------------------- */

$(document).ready(function() {
	if($('.plytex-tabs').length) {
		var plytab = $('.plytex-tabs');
		
		$('a',plytab).bind('mouseenter', function(){
			var idx = $('a',plytab).index(this);
			$('.pane','.b-main-profiles').hide().eq(idx).show();
		})
	}
	if($('.turn-night').length) {
		var tnight = $('#night-view');
		var daytex =$('.day');
		var nighttex =$('.night');
		nighttex.css('opacity','0');
		nighttex.css('display','block');
		$('.turn-night').click(function(){
			$(this).hide();
			tnight.css({opacity:0,top:0}).animate({
				opacity:1
			}, 1200, function(){
				tnight.css('filter','none')
			});
			daytex.css({opacity:1,top:0}).animate({
				opacity:0
			}, 1200, function(){
				daytex.css('filter','none')
			})
			nighttex.css({opacity:0,top:0}).animate({
				opacity:1
			}, 1200, function(){
				nighttex.css('filter','none')
			})
			return false;
		});
		
		$('.turn-day').click(function(){
			tnight.animate({
				opacity:0
			}, 1200, function(){
				tnight.css('top','-300px');
				$('.turn-night').show();
			})
			daytex.css({opacity:0,top:0}).animate({
				opacity:1
			}, 1200, function(){
				daytex.css('filter','none')
			})
			nighttex.css({opacity:1,top:0}).animate({
				opacity:0
			}, 1200, function(){
				nighttex.css('filter','none')
			})
			return false;
		});
	}
	if($('.link-cat').length) {
		var $linkcat = $('.link-cat');
		var $catcol = $linkcat.parent().parent();
		var $ppcat = $('#pp-cats');
		
		var hgh = ($ppcat.height() > $catcol.height()) ? 'auto' : $catcol.height() - 15 +'px';
		
		$ppcat.css('height',hgh);
		
		$linkcat.click(function(){
			$ppcat.show();
			return false;
		});
		
		$ppcat.bind('mouseleave', function(){
			$ppcat.hide();
		})
		
	}
	
	if($('div.b-uniscroller').length) {
		$("div.b-uniscroller").smoothDivScroll({
			scrollingSpeed: 7,
			mouseDownSpeedBooster: 2,
			autoScroll: "always",
			autoScrollDirection: "backandforth",
			scrollingHotSpotLeft:'.ar-l',
			scrollingHotSpotRight:'.ar-r',
			autoScrollSpeed: 1,
			pauseAutoScroll:"mouseover"
		});
		
		$("div.b-uniscroller .ar").click(function(){
			return false;
		})
	}
	
	
	
	$('.b-search .btn input').bind('mouseover mouseout', function(){
		$(this).toggleClass('input_hover')
	})
	
	$('.show-all-colors a').click(function(){
		$(this).parent().parent().addClass('active-colors');
		return false;
	})
	
	$('.b-colors-viewer .close').click(function(){
		$(this).parent().parent().removeClass('active-colors');
		return false;
	})
	
	$("#newarea").scrollable({circular:true}).autoscroll();
	$(".small-thumbs .g-scroll").scrollable({
		next: $('.ar-r',this),
		prev: $('.ar-l',this),
		onBeforeSeek: function(e, i) {
			$('.ar-r',$(this.getRoot()).parent()).css('display', i>=this.getSize()-3 ? 'none':'block');
			//alert($(this.getRoot()).attr('class'))
		}
	});
	$(".small-thumbs .ar").click(function(){
		return false;
	})
var region_disp='block';
	$('.chs-region .hd').click(function(){
		$('.chs-region ul').css('display',region_disp);
		if (region_disp=='block'){region_disp='none'} else{region_disp='block'}
		return false;
	})
$("a.sh_gal").click(function(){
var gal_rel=$(this).attr('name');
var anch=$("a[rel="+gal_rel+"]").eq(0);
if (anch){anch.click();}
return false;
});
});

