
$(document).ready(function() {

	/*
	$('input[name="your-name"]').bind("focus blur",function(){
		if ($(this).attr("value") == 'Name')
		{
			$(this).attr("value","");
		}
		else if ($(this).attr("value") == '')
		{
			$(this).attr("value","Name");
		}
	});

	$('input[name="your-email"]').bind("focus blur",function(){
		if ($(this).attr("value") == 'Email')
		{
			$(this).attr("value","");
		}
		else if ($(this).attr("value") == '')
		{
			$(this).attr("value","Email");
		}
	});
	$('textarea[name="your-message"]').bind("focus blur",function(){
		if ($(this).attr("name") == 'your-message')
		{
			if ($(this).val() == 'Comments')
			{
				$(this).val('');
			}
			else if ($(this).val() == '')
			{
				$(this).val('Comments');
			}
		}
	});
	*/


	/* HOME MOUSE OVER FOR BLOGS */
	/*
	$("#blog_holder .each_post span a").hover(function() {

		if(!$(this).parent().parent().hasClass('active')) {
			$("#blog_holder .each_post span a").stop().animate({fontSize: "14px",padding:"5px 10px"}, 500);
			$("#blog_holder .each_post span a").parent().stop().css({backgroundColor: "black"});
		}
		
		$("#blog_holder .each_post").removeClass('active');
		$(this).parent().parent().addClass('active');		
		$(this).stop().animate({fontSize: "24px",height: '35'}, 500);
		$(this).parent().stop().animate({backgroundColor:"#a41910",opacity: 1}, 500);	
	});
	*/

/* MENU */

$('#search_box').hover(
	function(){
		$('#s').show();
		$('#s').stop().animate({'width':'243'},500);

	},
	function(){
	
		$('#s').stop().animate({'width':'1'},500, function(){
		$('#s').hide();
		});
	
	}
);

$('#Nav ul.menu > li').each(function(index) {
	var $spans = $('ul');
   $(this).find($spans).parent().addClass('has_sub');
  });


/* LIST VIEW BLOGS */
	var speed = 1000;  // animation speed
	$container = $('#content').find('.inLoop');

	$container.imagesLoaded(function(){
		$container.masonry({
			itemSelector: '.post',
			animationOptions: {
				duration: speed,
				queue: false
			}
		});
	});


/*fading of the each of the posts */
	//(function( $ ){
		$.fn.showdelay = (function() {
			var delay = 0;
			$(this).hide();
			
			return this.each(function() {
				$(this).delay(delay).fadeIn(200);
				delay += 300;
			});
		});
	
		$(".post").showdelay();
	
	//})(jQuery);


	$container.infinitescroll({
		navSelector  : 'div.nav-previous',    // selector for the paged navigation 
		nextSelector : 'div.nav-previous a',  // selector for the NEXT link (to page 2)
		itemSelector : '.post',     // selector for all items you'll retrieve
		finished : false,
		animate : false,
		extraScrollPx : 0,
		bufferPx : 10,
		localMode : true,
		loading: {
			finishedMsg: 'No more pages to load.',
			img: 'http://i.imgur.com/6RMhx.gif'
		},
		errorCallback: function() { 
			// fade out the error message after 2 seconds
			$('#infscr-loading').animate({opacity: .8},4000).fadeOut('normal');   
		}
	},
	// trigger Masonry as a callback
	function( newElements ) {
		// hide new items while they are loading
		var $newElems = $( newElements ).css({ opacity: 0 });
		// ensure that images load before adding to masonry layout
		$newElems.imagesLoaded(function(){
			// show elems now they're ready
			$newElems.animate({ opacity: 1 });
			$container.masonry( 'appended', $newElems.showdelay(), true ); 
			
			$('.image_holder a').bind({
				mouseenter:function(){
				$('.image_holder a span').hide();
				$(this).children('span').fadeIn(150);
			},mouseleave:function(){
				$(this).children('span').fadeOut(150);
			}
		});

		});
	}
	);

$('.image_holder a span').hide();
$('.image_holder a').hover(function(){
	$('.image_holder a span').hide();
	$(this).children('span').fadeIn(150);
},function(){
	
	$(this).children('span').fadeOut(150);
});


$('.more_work .holder a span').hide();
$('.more_work .holder a').hover(function(){
	$('.more_work .holder a span').hide();
	$(this).children('span').fadeIn(150);
},function(){
	
	$(this).children('span').fadeOut(150);
});

$('.Nav_PreNext_Image a span').hide();
$('.Nav_PreNext_Image a').hover(function(){
	$('.Nav_PreNext_Image a span').hide();
	$(this).children('span').fadeIn(150);
},function(){
	
	$(this).children('span').fadeOut(150);
});


		function formatText(index, panel) {
			  return index + "";
		  };



		$(function() {

			$( "#accordion" ).accordion({
			autoHeight: false
			});

		});


			$('#slider1').anythingSlider({
				resizeContents      : false, // If true, solitary images/objects in the panel will expand to fit the viewport
				navigationSize      : 3,     // Set this to the maximum number of visible navigation tabs; false to disable
				vertical            : false,
				playRtl				: false,
					navigationFormatter : function(index, panel){ // Format navigation labels with text
					return index + "";
				},
				 buildNavigation     : false,      // If true, builds a list of anchor links to link to each panel
				 buildStartStop      : false,      // If true, builds the start/stop button
				onSlideComplete: function(slider) {
					// keep the current navigation tab in view
					slider.navWindow( slider.currentPage );
				}
			});

//CLEAR SEARCH BOX

/*
	$('input[name=s]').bind("focus blur",function(){
		if ($(this).attr("value") == 'SEARCH')
		{
			$(this).attr("value","");
		}
		else if ($(this).attr("value") == '')
		{
			$(this).attr("value","SEARCH");
		}
	});

  */ 

	//CV form functions

//$('form.wpcf7-form textarea[name="cv_comments"]').attr("value") = 'Comments';

    $("form.wpcf7-form input, form.wpcf7-form textarea").focus(function(){
        var newValue = '';
        
        if ($(this).attr("name") == 'cv_name' && $(this).attr("value") == 'Name') {
                $(this).attr("value",newValue);
        }
        
        if ($(this).attr("name") == 'cv_email' && $(this).attr("value") == 'Email') {
                $(this).attr("value",newValue);
        }

        
        if ($(this).attr("name") == 'cv_subject' && $(this).attr("value") == 'Subject') {
                $(this).attr("value",newValue);
        }
        
        if ($(this).attr("name") == 'cv_comments' && $(this).text() == 'Comments') {
                $(this).text(newValue);
        }
        
    });

    $("form.wpcf7-form input, form.wpcf7-form textarea").blur(function(){
        if ($(this).attr("name") == 'cv_name' && $(this).attr("value") == '') {
                $(this).attr("value","Name");
        }

        if ($(this).attr("name") == 'cv_email' && $(this).attr("value") == '') {
                $(this).attr("value","Email");
        }
        if ($(this).attr("name") == 'cv_subject' && $(this).attr("value") == '') {
                $(this).attr("value","Subject");
        }
        if ($(this).attr("name") == 'cv_comments' && $(this).text() == '') {
                
				$(this).text("Comments");
        }
    });


/* CLIENT */

$(".holder .over_state").hover(
function() {
$(this).stop().animate({"opacity": "0"}, 1000);
},
function() {
$(this).stop().animate({"opacity": "1"}, 1000);
});
 
/* SELECTED WORK */

$(".over_caption a").hover(
function() {
$(this).children(".caption").stop(true, true).slideToggle('slow');
},
function() {
	$(this).children(".caption").stop(true, true).slideToggle('slow');
});


 $('.backtotop a').click(function(){
	 $.scrollTo( '#header',1000 ); 
 });

})//END




