// ========== Smooth Scroll ===========

$(function(){
    $('a[href*=#]').click(function() {
    	if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 1000);   
                return false; 
            } 
        } 
    }); 
	
	// ie6 hover state
	var ie6 = ($.browser.msie && parseInt($.browser.version, 10) <= 6);
	if(ie6){
		$('.menu li').hover(
			function(){
				$(this).addClass('hoverstate');
			},
			function(){
				$(this).removeClass('hoverstate');						  
			}
		);
		$('.menu li ul li:first-child').addClass('first-child');
	}
	
});

// ========== Form Hovers ===========

$(function(){
	$('input, textarea').hover(function(){
		$(this).addClass('active');
	},
	function(){
		$(this).removeClass('active');
	});
});

// ======= Homepage Sidebar =========

$(function(){
	//
	$('#looking-for-development-tab-1').click(function(){
		if($('#looking-for-development-body').is(':visible')){
			return false;	
		}else{
			$('#looking-for-development').css('background-position','top left');
			$('#looking-for-development-tab-1').css('color','#000');
			$('#looking-for-development-tab-2').css('color','#ffe1a3');
			$('#looking-for-development-supporting').fadeOut(null,function(){
				$('#looking-for-development-body').fadeIn();
			});
		}
	});
	//
	$('#looking-for-development-tab-2').click(function(){
		if($('#looking-for-development-supporting').is(':visible')){
			return false;	
		}else{
			$('#looking-for-development').css('background-position','-319px 0px');
			$('#looking-for-development-tab-2').css('color','#000');
			$('#looking-for-development-tab-1').css('color','#ffe1a3');
			$('#looking-for-development-body').fadeOut(null,function(){
				$('#looking-for-development-supporting').fadeIn();
			});
		}
	});	   
});

// ======== Zoom =========

$(function(){
	$(".entry a img.zoom").parent().fancybox();
	$('.sites-by-region li:first-child').addClass('top');
	$('.sites-by-region h4 a:first-child').addClass('top');
});
