$(document).ready(function() {
		
		jQuery( [ 'nav_about_us_on.png','nav_contact_on.png','nav_our_work_on.png','nav_news_on.png','our_work_bottom_panel.png','right_up.png','left_up.png','right_over.png','left_over.png' ] ).each( function(  )
	{
		var b = new Image();
		b.src = bloginfo_template_dir +"/img/"+this;
	} );

    /*$('.img_container').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});*/
	
		$('.project_image_container').cycle({
			fx : 'scrollLeft',
			timeout : 0,
			speed : 350,
			pager:  '.featured_thumbs', 
		    // callback fn that creates a thumbnail to use as pager anchor 
		    pagerAnchorBuilder: function(idx, slide) { 
		    	slide = $( slide )
		    	var src = slide.children('.hidden_thumb').attr('src');
		        return '<span class="thumb"><a href="#"><img src="' + src + '" width="105" height="105" /></a></span>'; 
		    } 
		})
	
		$('.img_container').cycle(
		{ 
			fx : 'scrollHorz',
			next: '#arrow_right a',
			prev:   '#arrow_left a',
    		timeout:  0 ,
    		speed : 350
			//easeIn:   'easeInBounce'
			//easeOut: 'backin'
		});
		
		$('#feature-box-container').cycle(
		{
			fx : 'fade',
			next: '#arrow_right a',
			prev:   '#arrow_left a',
    		timeout:  0 			
		});

		$('#featured_button').click(
			function(){
				$('#showreel_button div').removeClass('selected');
				$('#featured_button div').addClass('selected');
				$('#showreel').hide();
				$('#slideshow').show();
				$('#feature_description').show();
				return false;
			});

		$('#showreel_button').click(
			function(){
				$('#showreel_button div').addClass('selected');
				$('#featured_button div').removeClass('selected');
				$('#showreel').show();
				$('#slideshow').hide();
				$('#feature_description').hide();
				return false;
			});

		$('#showreel_button').click();
		$('#featured_button').click();

		/*$('.img_container').cycle(
		{ 
			fx : 'scrollLeft',
			timeout:  0 ,
    		easeIn:  'bounceout'
		});*/


		$("#twitter,#twitter_3").getTwitter({
					userName: "pluginmedia",
					numTweets: ( $('#twitter_3').length > 0 )?3:5,
					loaderText: "",
					slideIn: true,
					showHeading: true,
					headingText: "",
					showProfileLink: false,
					onCompleteCallback : function( tl )
					{
						$(tl).find('p').each( function(){
							var imageLink = $(this).find('a[href^="http://yfrog"]').first().detach().attr('href');
							if( imageLink )
							{
								$(this).prepend( '<a href="'+imageLink+'"><img style="display:block;margin:0 auto;" src="'+imageLink+'.th.jpg" /></a>' );
							}
						});
					}
					
				});
		$(".subnav_menu.ourwork a").hover(function(){
			$(this).siblings("span").css("color", "red");
			$(this).parent().prev("li").children("span:last").css("color", "red");
		}, function(){
			$(this).siblings("span").css("color", "#A5A5A5");
			$(this).parent().prev("li").children("span:last").css("color", "#A5A5A5");
		});
		
		$(".project_taxonomies a").hover(function(){
			$(this).parent().next("li").css("color", "red");
			$(this).parent().prev("li").css("color", "red");
		}, function(){
			$(this).parent().next("li").css("color", "#113B43");
			$(this).parent().prev("li").css("color", "#113B43");
		});
		
		$(".email").each(function(){
			var email = $(this).html();
			email = email.split("").reverse().join("");
			
			$(this).attr("href", "mailto:"+email);
			$(this).html(email);
		});
		$(".email_href_only").each(function(){
			var email = $(this).attr("href");
			email = email.split("").reverse().join("");
			
			$(this).attr("href", "mailto:"+email);
		});
		
		$(".portfolio_item").hover(function(){
			$(".portfolio_badge",this).fadeIn(100);
		},function(){
			$(".portfolio_badge",this).fadeOut(100);		
		});
		
		var arrowIn = function(){
			if( !$(this).data("in")) {
				var css = {
					'height': '95px',
					'width': '45px',
					'margin-top': '-4px',
					'margin-right': '-2px'
				};
				
				$(this).css(css);
				
				$(this).data("in", true);
				$(this).data("out", false);
			}
		};
		
		var arrowOut = function(){
			if( !$(this).data("out")) {
				var css = {
					'height': '87px',
					'width': '41px',
					'margin-top': '0px',
					'margin-right': '0px'
				};
				
				$(this).css(css);
				
				$(this).data("out", true);
				$(this).data("in", false);
			}
		}
		
		$("#arrow_left img").data("in", false);
		$("#arrow_left img").data("out", false);

		$("#arrow_left img").hover(arrowIn, arrowOut);
		
		$("#arrow_right img").data("in", false);
		$("#arrow_right img").data("out", false);

		$("#arrow_right img").hover(arrowIn, arrowOut);
		
		/*
		open external content in new window/tab
		*/
		$("a[href^='http:']").not("[href*="+bloginfo_url+"]")
        	.attr({ target: "_blank" });
		
		var flashvars = {
			linkUrl: bloginfo_url
		};
		
		var params = {
			wmode: 'transparent'
		};
		
		var attributes = {
		
		};
		
	    swfobject.embedSWF(bloginfo_template_dir+"/swf/animated_logo.swf", "animated_logo", "144", "137", "9.0.0", null, flashvars, params, attributes);
		

	/**/
});

