
$(document).ready(function() {	
	
	if(section != null) $("ul#mnav li#"+section).addClass("current");

	$("#slider").easySlider({
		continuous:true,
		numeric: true,
		numericId: 'controls',
		pause: 4000,
		auto: true
	});	
	
	$("#home-clients .imgContainer").fade({
		pause:	5000,
		speed: 1500
	});


	var theDiff;
	$('#competencies ul li').click(function(){
		$(this).addClass('current').siblings('li').removeClass("current");	;
		if($(this).index() == 0){
			theDiff = 90;
			moveX=10;
			$('#competencies .description p').html('').append($('p', this).html());
			$('#competencies ul').css({'backgroundPosition': '0 -218px'});
		}
		if($(this).index() == 1){
			theDiff = 132;
			moveX=140;
			$('#competencies .description p').html('').append($('p', this).html());
			$('#competencies ul').css({'backgroundPosition': '0 -436px'});
		}
		if($(this).index() == 2){
			theDiff = 250;
			moveX=200;
			$('#competencies .description p').html('').append($('p', this).html());
			$('#competencies ul').css({'backgroundPosition': '0 -654px'});
		}
		if($(this).index() == 3){
			theDiff = 323;
			moveX=300;
			$('#competencies .description p').html('').append($('p', this).html());
			$('#competencies ul').css({'backgroundPosition': '0 -872px'});
		}
		if($(this).index() == 4){
			theDiff = 422;
			moveX=380;
			$('#competencies .description p').html('').append($('p', this).html());
			$('#competencies ul').css({'backgroundPosition': '0 -1090px'});
		}		
		$('#competencies .description').fadeIn(function(){	
			$('#footer').animate({'margin-top':'100px'});
			$('#competencies .description span').animate({'left':theDiff+'px'},{duration:600,  easing:'easeInOutQuart' });
			$('#competencies .description').animate({'left':moveX+'px'},{duration:500, easing:'easeInOutQuart' });
		});
	});
	
	
	$('.btnClose').click(function(){
		$('#competencies .description').fadeOut(function(){
				$('#footer').animate({'margin-top':'0'});
			});						  
	});






	$('input#iName').val("Enter Your Name");
	$("input#iName").focus(function(){
		if(this.value == 'Enter Your Name'){
			this.value='';					
		}
	});
	$("input#iName").blur(function(){
		if(this.value==''){this.value='Enter Your Name';}
	});
	
	$('input#iEmail').val("Enter Your Email Address");
	$("input#iEmail").focus(function(){
		if(this.value == 'Enter Your Email Address'){
			this.value='';					
		}
	});
	$("input#iEmail").blur(function(){
		if(this.value==''){this.value='Enter Your Email Address';}
	});
	
	$('#iMessage').val("Enter Your Message");
	$("#iMessage").focus(function(){
		if(this.value == 'Enter Your Message'){
			this.value='';					
		}
	});
	$("#iMessage").blur(function(){
		if(this.value==''){this.value='Enter Your Message';}
	});


	//Back 2 Top
	$.easing.elasout = function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
		
	//this one is important, many browsers don't reset scroll on refreshes
	$('div.pane').scrollTo( 0 );//reset all scrollable panes to (0,0)
	$.scrollTo( 0 );//reset the screen to (0,0)			
	//TOC, shows how to scroll the whole window
	$('#snav li a').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( this.hash, 700, { easing:'elasout' });
		return false;
	});	
	
	
});



