/* Custom JavaScript - AnkaStudio */


/* Data rel prettyphoto jquery */
jQuery.noConflict()(function($){
$(document).ready(function() { 
	$('a.screenshot').each(function() {
        $(this).removeAttr('data-rel').attr('rel', 'prettyPhoto');
});
})
});

/* Small slider with content */
jQuery.noConflict()(function($){	
jQuery("#slider-small").slides({
		preload: true,
		effect: 'slide',
		slideSpeed: 500,
		fadeSpeed: 300,
		play: 3000
		
		});
	});

/* Slider nav fade out and fade in */
jQuery.noConflict()(function($){	
	$(document).ready(function() {
	if (jQuery().slides) {
		
		jQuery("#slides").hover( function() {
			jQuery('.slides-nav').fadeIn(400);
		}, function () {
			jQuery('.slides-nav').fadeOut(400);
		});
		
	}
	});	
	});	

/* Slides with caption */
jQuery.noConflict()(function($){	
	$(function(){
			$('#slides').slides({
				effect: 'fade',
				fadeSpeed: 750,
				play: 5000,
				pause: 2500,
				hoverPause: true,
				animationStart: function(current){
					$('.caption').animate({
						bottom:0
					},100);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationStart on slide: ', current);
					};
				},
				animationComplete: function(current){
					$('.caption').animate({
						bottom:0
					},200);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationComplete on slide: ', current);
					};
				},
				slidesLoaded: function() {
					$('.caption').animate({
						bottom:0
					},200);
				}
			});
		});
		});

/* Nivo Slider */
jQuery.noConflict()(function($){
$(document).ready(function() {
            $('#slider3').nivoSlider({
                pauseTime:5000,
                pauseOnHover:false
            });        
    });
});


/* Form validation */
jQuery.noConflict()(function($){
$(document).ready(function() {
	$('form#contact-form').submit(function() {
		$('form#contact-form .error').remove();
		var hasError = false;
		$('.requiredField').each(function() {
			if(jQuery.trim($(this).val()) == '') {
            	var labelText = $(this).prev('label').text();
            	$(this).parent().append('<div class="error">You forgot to enter your '+labelText+'</div>');
            	$(this).addClass('inputError');
            	hasError = true;
            } else if($(this).hasClass('email')) {
            	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
            	if(!emailReg.test(jQuery.trim($(this).val()))) {
            		var labelText = $(this).prev('label').text();
            		$(this).parent().append('<div class="error">You entered an invalid '+labelText+'</div>');
            		$(this).addClass('inputError');
            		hasError = true;
            	}
            }
		});
		if(!hasError) {
			$('form#contact-form input.submit').fadeOut('normal', function() {
				$(this).parent().append('');
			});
			var formInput = $(this).serialize();
			$.post($(this).attr('action'),formInput, function(data){
				$('form#contact-form').slideUp("fast", function() {
					$(this).before('<div class="simple-success">Your email was successfully sent. We will contact you as soon as possible.</div>');
				});
			});
		}

		return false;

	});
});
});


/* Screenshot image hover */
jQuery.noConflict()(function($){
$(document).ready(function() {  
            $('.screenshot-img').each(function() {
                $(this).hover(
                    function() {
                        $(this).stop().animate({ opacity: 0.7 }, 250);
                    },
                   function() {
                       $(this).stop().animate({ opacity: 1.0 }, 250);
                   })
                });
});
});
jQuery.noConflict()(function($){
$(document).ready(function() {  
            $('.screenshot-img-fancy').each(function() {
                $(this).hover(
                    function() {
                        $(this).stop().animate({ opacity: 0.7 }, 250);
                    },
                   function() {
                       $(this).stop().animate({ opacity: 1.0 }, 250);
                   })
                });
});
});

/* Twitter feeds */
jQuery.noConflict()(function($){
$(document).ready(function() { 
$(".tweet").tweet({
            username: "envato",/* change envato with your own username */
            join_text: null,
            avatar_size: null,/* avatar */
            count: 2,/* number of tweets */
            auto_join_text_default: "we said,", 
            auto_join_text_ed: "we",
            auto_join_text_ing: "we were",
            auto_join_text_reply: "we replied to",
            auto_join_text_url: "we were checking out",
            loading_text: "loading tweets..."
    });
	});
});


/* Prettyphoto */
jQuery.noConflict()(function($){
$(document).ready(function() {  

$("a[rel^='prettyPhoto']").prettyPhoto({opacity:0.80,default_width:500,default_height:344,theme:'light_rounded',hideflash:false,modal:false});

});
});



