$(document).ready(function () {
	
	//Show hide login bar
	$('#test-bar').hide();
	$('#torqe-test-bar').click(function(){
		if ($('#test-bar:visible').length==0){
			$('#test-bar').slideDown(300);
			$(this).addClass("selected");
		}
		else {
			$('#test-bar').slideUp(300);
			$(this).removeClass("selected");
		}
	});
	
	//highlight image
	//$('.mask').hide();
	$('.img-wrapper a img').mouseover(function(){
		$(this)
			.parents('#col-2')
				//.find('.mask')
				//	.not($(this).parent('a').siblings('.mask')).stop()
				//		.show().stop().fadeTo(500,0.7);
		
		
			//.parents('#col-2')
				.find('.img-wrapper a img')
					.not(this)						
						.stop().fadeTo(300, 0.60);
						//.animate({opacity:0.7},200);		
	}).mouseout(function(){
		$(this)
			.parents('#col-2')
				//.find('.mask')
				//	.not($(this).parent('a').siblings('.mask'))
				//	.stop().fadeTo(500,0).hide();
				.find('.img-wrapper a img')				
					.not(this)
						.stop().fadeTo(250, 1);
					//	.animate({opacity:1},10);
		
		});

	//Scroll to Top
	$('.BTT').click(function(){
		$.scrollTo($('#wrapper'),400,{easing:'swing'});
	});
	
	
	//Navbar Highlight
	function selectNav() {		
	  $(this)
	    .parents('ul')
	      .find('a')
	        .removeClass('actived')
	      .end()
	    .end()
	    .addClass('actived');
	}

	$('#second-nav').find('a').click(selectNav);
	
	//Side Panel Scroll
	function trigger(data) {
		var el = $('#second-nav').find('a[href$="' + data.id + '"]').get(0);
		selectNav.call(el);   
	}

	if (window.location.hash) {
		trigger({ id : window.location.hash.substr(1) });
	} else {
		$('#second-nav a:first').click();
	}
	
	var $panels = $('.scrollPanel > div');
	var $container = $('.scrollPanel');
	var $scroll = $('#wrap-full-width').css('overflow', 'hidden');
	$('.scrollPanel').css('width',680 * $(this).find('.panel').length);

	var offset = 0;
	var scrollOptions = {
		target: $scroll, 
		items: $panels,  
		queue: true,
		offset: offset,
		navigation: '#second-nav a', 
		axis: 'xy',	   
		duration: 1000
	}
	$.localScroll(scrollOptions);
	scrollOptions.duration = 1;
	$.localScroll.hash(scrollOptions);
	
	//Clear textbox default value when focus	
	$("#search-box input[type=text]")
		.css('color','gray')
		.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
				$(this).css('color','#000');
			}
		})
		.blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
				$(this).css('color','gray');
			}
		});

	
});