
/***********************************************
**********  CUFON REPLACEMENTS  ****************
************************************************/

	$(document).ready(function(){
							   
		Cufon.replace('h1');
		Cufon.replace('h2');
		Cufon.replace('#navigation a',{hover:true});
		Cufon.replace('#socialNetworking .txt');
		Cufon.replace('#breadcrumbs a', {hover:true});
		Cufon.replace('.homeColumnRight .head');
		Cufon.replace('.contactBlockA span');
		Cufon.replace('.contactBlockB span');
		Cufon.replace('.caseStudies li a.title', {hover:true});
		Cufon.replace('.workGallery li a.title', {hover:true});
		Cufon.replace('#banner .wrapper p');
		Cufon.replace('#banner .wrapper a');
		Cufon.replace('#test');
		Cufon.replace('#test');
		
		
	});
	
/***********************************************
************  HOMEPAGE BANNER   ****************
************************************************/

$(document).ready(function() {
		$('.slider').DDSlider({
			trans: 'fading',
			waitTime: '5000',
			nextSlide: '.slider_arrow_right',
			prevSlide: '.slider_arrow_left'
		});
});

/***********************************************
*************** TWITTER FEEDS ******************
************************************************/  
  
$(function(){
      $("#twitterFeed").tweet({
        join_text: "auto",
        username: "TheSphereAgency",
        avatar_size: 24,
        count: 3,
        auto_join_text_default: "we said,",
        auto_join_text_ed: "we",
        auto_join_text_ing: "we were",
        auto_join_text_reply: "we replied",
        auto_join_text_url: "we were checking out",
        loading_text: "loading tweets..."
      });
});

/***********************************************
************ PRETTY PHOTO PLUGIN ***************
************************************************/ 

$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({
			theme: 'pp_default',
			ie6_fallback: true,
			deeplinking: false,
			social_tools: false
	});
});


/***********************************************
***  BUTTON ROLLOVER & PRELOAD  ****************
************************************************/

$(document).ready(function() {
	// button rollover
	if ($('.imgBtn') != null) {
		$('.imgBtn').hover(function(){
				if(!$(this).is('.disabled'))
					$(this).attr("src", $(this).attr("src").replace(/^(.*?)(?:-hover)?(\..*?)$/i,'$1-hover$2'));
			},
			function(){
					if(!$(this).is('.disabled'))
						$(this).attr("src", $(this).attr("src").replace(/^(.*)-hover(\..*?)$/i, '$1$2'));
				});
	}
	// preload image rollovers
	if ($("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']") != null) {
	    $("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']").each(function(){
			    $("<img>").attr("src", $(this).attr("src").replace(/(btn-.*)(\..*?)/i, '$1-hover$2'));
		    });
	}

/***********************************************
***  EXTERNAL LINKS  ***************************
************************************************/

	$("a[rel=external]").each(function() {
		$(this).addClass('external');
		$(this).attr({
			target: "_blank"
		});
	})
});

/***********************************************
********  ANIMATED SCROLLING   *****************
************************************************/

$(document).ready(function(){
		$('.GoTop').click(function(){
				var id = $(this).attr('href');
				if(id.length === 1) return;
				var ele = $(id);
				if(ele.length) {
					var destination = ele.offset().top;
					$('html:not(:animated), body:not(:animated)').animate({
							scrollTop: destination -20
						}, 700, 'easeOutQuint');
				}
			});
});

/***********************************************
***  COMPACT FORM (LABEL OVER INPUT)  **********
************************************************/

$(function(){
	$('form.compact input, form.compact select, form.compact textarea').focus(function(){
			$('label[for=' + $(this).attr('id') + ']').hide();
		});
	$('form.compact input, form.compact select, form.compact textarea').each(function(ele){
			if($(this).val().length > 0)
				$('label[for=' + $(this).attr('id') + ']').css({ display: "none" });
		});
	$('form.compact input, form.compact select, form.compact textarea').blur(function(){
			if($(this).val().length == 0)
				$('label[for=' + $(this).attr('id') + ']').show();
		});
	$('form.compact').removeClass('compact');
});



/***********************************************
******** SMALL ANIMATIONS AND EFFECTS **********
************************************************/  


$(document).ready(function() {

		// Logo Animation
		$('#header a.logo').hover(function(){
		$(this).find('span').stop().animate({
			opacity: 1
			}, 250, function(){});
	 	 },
	 	 function () {
			$(this).find('span').stop().animate({
			opacity: 0
			  }, 200, function(){});
	 		}
		);
		
		
		$('.caseStudies li' ).hover(function(){
		$(this).find('img').stop().animate({
			opacity: 1
			}, 250, function(){});
	 	 },
	 	 function () {
		$(this).find('img').stop().animate({
			opacity: 0.6
			}, 150, function(){});
	 		}
		);
		
		$('.workGallery li' ).hover(function(){
		$(this).find('img').stop().animate({
			opacity: 1
			}, 250, function(){});
	 	 },
	 	 function () {
		$(this).find('img').stop().animate({
			opacity: 0.5
			}, 150, function(){});
	 		}
		);
		
		$('.workDetailsGallery li' ).hover(function(){
		$(this).find('img').stop().animate({
			opacity: 1
			}, 250, function(){});
	 	 },
	 	 function () {
		$(this).find('img').stop().animate({
			opacity: 0.5
			}, 150, function(){});
	 		}
		);
		
		
			

		
})










/***********************************************
********* FINANCIAL CHART ANIMATION ************
************************************************/ 


$(function(){
		var delay = 6000;
		var fadeTime = 150;

		var curr = 1;
		var isFading = false;

		function intFunc(){
			var prev = curr;
			curr++;
			if ($('#framePagination li:nth-child(' + curr + ') a').length == 0){
				curr = 1;
			}
			$('#framePagination a.activeBtn').removeClass('activeBtn');
			$('#framePagination > li:nth-child(' + curr + ') a').addClass('activeBtn');

			isFading = true;
			$('#chartAnimation').addClass('anim');
			$('.chartGallery > li:nth-child(' + prev + ')').fadeOut(fadeTime, function(){
					$('.chartGallery > li:nth-child(' + curr + ')').fadeIn(fadeTime, function(){
							isFading = false;
							$('#chartAnimation').removeClass('anim');
						});
				});
		}
		var interval = window.setInterval(intFunc, delay);

		$('#framePagination li a').click(function(){
				if($(this).is('.activeBtn') || isFading)
					return false;
				clearInterval(interval);
				var ind = $('#framePagination li a').index(this) +1;
				$('#framePagination a.activeBtn').removeClass('activeBtn');
				$('#framePagination > li:nth-child(' + ind + ') a').addClass('activeBtn');

				isFading = true;
				$('#chartAnimation').addClass('anim');
				$('.chartGallery > li:nth-child(' + curr + ')').fadeOut(fadeTime, function(){
						$('.chartGallery > li:nth-child(' + ind + ')').fadeIn(fadeTime, function(){
								isFading = false;
								$('#chartAnimation').removeClass('anim');
							});
					});
				curr = ind;
				interval = window.setInterval(intFunc, delay)
				return false;
			});
	});




/***********************************************
************** BROWSER CONDITION ***************
************************************************/ 

/*$(document).ready(function() {
	jQuery.each(jQuery.browser, function(i) {
	   if($.browser.msie){
		
		
		
	   }else{
		
		
		
		
		
		
		
	   }
	 });
	 });
*/


