
;(function($){
	$(function(){

	/************* CODE FOR INPUT EFFECTS  ********/
		$('input:text').focus(function(){
			if(this.value==this.defaultValue){this.value=''}
		})
		$('input:text').blur(function(){
			if(!this.value){this.value=this.defaultValue;}
		})
		$('input:password').focus(function(){
			if(this.value==this.defaultValue){this.value=''}
		})
		$('input:password').blur(function(){
			if(!this.value){this.value=this.defaultValue;}
		})
		$('textarea').focus(function(){
			if(this.value==this.defaultValue){this.value=''}
		})
		$('textarea').blur(function(){
			if(!this.value){this.value=this.defaultValue;}
		})
		/************* END CODE FOR INPUT EFFECTS  ********/
		
		/************* CODE FOR ROLLOVER  ********/
		$('div.work-page-col').mouseenter(function(){
			$(this).addClass('black')
		})
		$('div.work-page-col').mouseleave(function(){
			$(this).removeClass('black')
		})
		if($('#slider')){
			iindevSlideShowinIt()
		}
		// END CODE FOR ROLLOVER

		/* BEGIN TABS LIST ITEM CLICKING FUNCTION. */
		$('#love-container > div.love-contents').html($('#tabs > li.active').find('div.love-contents').html())	
		$('#tabs > li').each(function(i){
			$(this).click(function(){
				if( $(this).hasClass('active')) return false
				else{
					$('#tabs > li.active').removeClass('active')
					$(this).addClass('active')
					$('#love-container > div.love-contents').html($('#tabs > li.active').find('div.love-contents').html())
				}// End else
			})// End click()
		})// End each()
		
		$('#tabs > li > a').click(function(e){
			e.preventDefault()
		})
		/* END TABS LIST ITEM CLICKING FUNCTION. */
		
		/************* CODE FOR OVERLAY ANIMATION  ********/
		var animationSpeed		= 400
		
		$('div.work-page-overlay').animate({ 'height':'hide' }, 0 )

		if( $('div.work-page-col-box-wrap') ){
			$('div.work-page-col-box-wrap').mouseenter(function(){			
				$(this).find('div.work-page-overlay').animate({'height':'show'}, animationSpeed , 'easeOutCirc' )
			})
			$('div.work-page-col-box-wrap').mouseleave(function(){
				$(this).find('div.work-page-overlay').animate({ 'height' : 'hide' }, animationSpeed-100 ,'easeInCirc')
			})
		}// END IF()
		/*********** END CODE FOR OVERLAY ANIMATION  *****/
		
		// START BUTTONS CLICKING FUNCTIONS
		var	currentlyShowingPannel		= 0
		var	sliderAnimationSpeed		= 600
		var sliderContainerWidth		= 960 * $('div.profile-slider-container').length
		
		$('#team-sliding-panel').width( sliderContainerWidth + 100 )
		
		$('#profile-slider-left').click(function(){							 
			if(currentlyShowingPannel==0) return false
			else{
				currentlyShowingPannel-=1
				var runToAnimated=(960*currentlyShowingPannel)
				$('#team-sliding-panel').animate( { 'left' : -runToAnimated }, sliderAnimationSpeed )
			}
		})// END LEFT BUTTON CLICK FUNCTIONING 
		$('#profile-slider-right').click(function(){						 
			if(currentlyShowingPannel==$('div.profile-slider-container').length-1) return false
			else{
				currentlyShowingPannel+=1
				var runToAnimated=(960*currentlyShowingPannel)
				$('#team-sliding-panel').animate( { 'left' : -runToAnimated }, sliderAnimationSpeed )
			}
		})// END RIGHT BUTTON CLICK FUNCTIONING 
		
		/* Start full project page sliding and clicking function */
		var	currentlyShowingImagePannel		= 0
		var	imageSliderAnimationSpeed		= 500
		var showingFadingSpeed				= 300
		var imageSliderContainerWidth		= 527 * $('div.sliding-image-container').length

		$('#full-img-overlay').css({'opacity':0})
		$('#image-slider-left').css({'opacity':0})
		$('#image-slider-right').css({'opacity':0})
		
		$('#image-sliding-panel').width( imageSliderContainerWidth + 100 )
		
		$('#image-slider-left').click(function(){							 
			if(currentlyShowingImagePannel==0) return false
			else{
				currentlyShowingImagePannel-=1
				var runToAnimated=(527*currentlyShowingImagePannel)
				$('#image-sliding-panel').animate( { 'left' : -runToAnimated }, sliderAnimationSpeed )
				$('#image-slider-left').animate({'opacity':1},showingFadingSpeed)
				
				if( (currentlyShowingImagePannel>0)&&(currentlyShowingImagePannel<$('div.sliding-image-container').length-1 ) ){
					$('#image-slider-left').animate({'opacity':1},showingFadingSpeed)
					$('#image-slider-right').animate({'opacity':1}, showingFadingSpeed)
				}
				else if(currentlyShowingImagePannel==0){
					$('#image-slider-left').animate({'opacity':0}, showingFadingSpeed-100)
				}
			}
		})// END LEFT BUTTON CLICK FUNCTIONING 
		$('#image-slider-right').click(function(){						 
			if(currentlyShowingImagePannel==$('div.sliding-image-container').length-1) return false
			else{
				currentlyShowingImagePannel+=1
				var runToAnimated=(527*currentlyShowingImagePannel)
				$('#image-sliding-panel').animate( { 'left' : -runToAnimated }, sliderAnimationSpeed )
				if( (currentlyShowingImagePannel>0)&&(currentlyShowingImagePannel<$('div.sliding-image-container').length-1 ) ){
					$('#image-slider-left').animate({'opacity':1},showingFadingSpeed)
					$('#image-slider-right').animate({'opacity':1}, showingFadingSpeed)
				}
				else if(currentlyShowingImagePannel==$('div.sliding-image-container').length-1){
					$('#image-slider-right').animate({'opacity':0}, showingFadingSpeed-100)
				}
			}
		})// END RIGHT BUTTON CLICK FUNCTIONING
		
		$('#full-img-container').mouseenter(function(){
			$('#full-img-overlay').animate({'opacity':0.4}, showingFadingSpeed )
			if(currentlyShowingImagePannel==0) 
			{	
				$('#image-slider-left').animate({'opacity':0},showingFadingSpeed-100)
				$('#image-slider-right').animate({'opacity':1}, showingFadingSpeed )
			}
			else if( (currentlyShowingImagePannel>0)&&(currentlyShowingImagePannel<$('div.sliding-image-container').length-1 ) ){
				$('#image-slider-left').animate({'opacity':1},showingFadingSpeed)
				$('#image-slider-right').animate({'opacity':1}, showingFadingSpeed )
			}
			else if( currentlyShowingImagePannel==$('div.sliding-image-container').length-1 )
			{
				$('#image-slider-right').animate({'opacity':0}, showingFadingSpeed )
				$('#image-slider-left').animate({'opacity':1},showingFadingSpeed)
			}
		})// END MOUSEENTER
		
		$('#full-img-container').mouseleave(function(){
			$('#full-img-overlay').animate({'opacity':0}, showingFadingSpeed-100 )
			$('#image-slider-left').animate({'opacity':0},showingFadingSpeed-100)
			$('#image-slider-right').animate({'opacity':0}, showingFadingSpeed-100 )
		})// END MOUSELEAVE
		
		/*End full project page sliding and clicking function */		
		
	})// END OF DOCUMENT READY FUNCTION
})(jQuery)


/************* CODE FOR SLIDING ITEM  CHANGES   ********/
var currentlyRunning	= false
var autoSlidingPointer	= false
var totalItemCount		= 0
var $slider				= false
var $slider_item_cont	= false
var $sliderArrow_Li		= false
var imageShowingSpeed	= 500
var imageSlidingInterval= 3500
var presentlyShown		= 0
var nextItemToShow		= 0

function iindevSlideShowinIt(){
	
	// Count the item numbers and setup the bullets..
	totalItemCount	= jQuery('#slider div.home-slider-contents').length
	jQuery('#pagination').append('<ul></ul>')
	
	
	jQuery('#pagination > ul').html('<li class="active"></li>')
	for(var i=1; i<totalItemCount; i++){
		jQuery('#pagination > ul').append('<li></li>')
	}
	
	$slider_item_cont	= jQuery('#slider div.home-slider-contents')
	$sliderArrow_Li		= jQuery('#pagination > ul > li')

	// Show the first image
	//$slider_item_cont.fadeOut(1)
	$slider_item_cont.hide()
	$slider_item_cont.eq(0).fadeIn(imageShowingSpeed)
	
	autoSlidingPointer = setInterval( 'autoRunTheSlider()', imageSlidingInterval )
	
	$sliderArrow_Li.each(function(i){
		$(this).click(function(){
			if(currentlyRunning || (presentlyShown == i)) return false
			
			clearInterval(autoSlidingPointer)
			
			nextItemToShow	= i
	
			currentlyRunning = true
			
			$sliderArrow_Li.eq(presentlyShown).removeClass('active')
			$sliderArrow_Li.eq(nextItemToShow).addClass('active')
						
			$slider_item_cont.eq(presentlyShown).fadeOut(imageShowingSpeed, function(){
					$slider_item_cont.eq(nextItemToShow).fadeIn(imageShowingSpeed, function(){
					presentlyShown = nextItemToShow
					currentlyRunning = false
					autoSlidingPointer = setInterval( 'autoRunTheSlider()', imageSlidingInterval )
				})
			})
		})
	})

}

function autoRunTheSlider(){
	
	nextItemToShow	= ( presentlyShown == (totalItemCount-1) ) ? 0 : presentlyShown+1
	
	currentlyRunning = true
	
	$sliderArrow_Li.eq(presentlyShown).removeClass('active')
	$sliderArrow_Li.eq(nextItemToShow).addClass('active')
		
	$slider_item_cont.eq(presentlyShown).fadeOut(imageShowingSpeed, function(){
			$slider_item_cont.eq(nextItemToShow).fadeIn(imageShowingSpeed, function(){
			presentlyShown = nextItemToShow
			currentlyRunning = false
		})

	})
}
/*********** END CODE FOR SLIDING ITEM  CHANGES ********/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: 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;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

