$(document).ready(function () {

menuAnims();

galleryAnims();

portfolioAnims();

shortcodeAnims();

postAnims();

contactForm();

singleAnims();

});

$(window).load(function () {

postImgAnims();

});

// MENU ANIMS

function menuAnims () {


$(' #menu ul li ').hover(function () {

	if($(this).find('ul')) {

		$(this).find('ul').css("display", "block");
		$(this).find('ul li ul').css("display", "none");

	}

},

function () {

	if($(this).find('ul')) {

		$(this).find('ul').css("display", "none");

	}

});


}

function galleryAnims () {

	$(" .gallery_four_post, .gallery_three_post, .gallery_two_post, .gallery_one_post ").find("img").hover(function () {
	
		$(this).stop().fadeTo("slow", 0.85);	
	
	}, function () {
	
		$(this).stop().fadeTo("slow", 1);			
	
	});


}

function portfolioAnims () {

	$(" .portfolio_four_post, .portfolio_three_post, .portfolio_two_post, .portfolio_one_post, .portfolio_post_large .portfolio_media ").find("img").hover(function () {
	
		$(this).stop().fadeTo("slow", 0.8);	
	
	}, function () {
	
		$(this).stop().fadeTo("slow", 1);			
	
	});


}

function shortcodeAnims () {

	$(" a.single_lightbox ").find("img").hover(function () {
	
		$(this).stop().fadeTo("slow", 0.8);	
	
	}, function () {
	
		$(this).stop().fadeTo("slow", 1);			
	
	});

}

function postAnims () {

	$(" div.blog_post_image ").find("img").hover(function () {
	
		$(this).stop().fadeTo("slow", 0.8);	
	
	}, function () {
	
		$(this).stop().fadeTo("slow", 1);			
	
	});

}


// CONTACT FORM AJAX REQUEST

function contactForm () {

	$(' #contact_form ').submit(function () {
		
	$(' #result_box ').html('');
	
	$(' #submit ').attr('value', '...');
	
	var _cfname = $(' #name ').val();
	var _cfemail = $(' #email ').val();
	var _cfphone = $(' #phone ').val();
	var _cfmessage = $(' #message ').val();
	var emailValResult = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
	var result = "";
	
	if (_cfname == name_val || _cfemail == email_val || _cfphone == phone_val || _cfmessage == message_val) {	
	
	result = ("<div class='error_box'>" + error_message_fields + '</div>').toString();
	
	$(' #result_box ').fadeTo(0,0).append(result).fadeTo("slow", 1);
	$(' #submit ').attr('value', submit_label);
	
	return false;
	
	} else if (!emailValResult.test(_cfemail)) {
	
	result = ("<div class='error_box'>" + error_message_email + '</div>').toString();
	
	$(' #result_box ').fadeTo(0,0).append(result).fadeTo("slow", 1);
	$(' #submit ').attr('value', submit_label);
	
	return false;
	
	}
	
	$.get(sendMail, {name:$(' #name ').val(), email:$(' #email ').val(), phone:$(' #phone ').val(), message: $(' #message ').val(), admin_email:admin_email, subject_email:subject_email, success_message:success_message},
	
	function(data){
	
	result = ("<div class='success_box'>" + data + '</div>').toString();
	
	$(' #submit ').attr('value', submit_label);
	$(' #result_box ').fadeTo(0,0).append(result).fadeTo("slow", 1);
	
	});	
	
	return false;
	
	});

}

function sliderNavAnims () {

$(' .nivo-directionNav a').hover(function() {

	$(this).stop().fadeTo("slow", 1);

}, function() {

	$(this).stop().fadeTo("slow", 0.2);	

}).delay(800).fadeTo("slow", 0.2);

}

function singleAnims () {

	$(" div.portfolio_post ").find("img").hover(function () {
	
		$(this).stop().fadeTo("slow", 0.8);	
	
	}, function () {
	
		$(this).stop().fadeTo("slow", 1);			
	
	});	

}

function postImgAnims () {

	$(" div.blog_post_image img ").fadeOut(0).fadeIn();
	$(" div.blog_post_image ").css("background", "none");
	
	$(" div.portfolio_image_post img ").fadeOut(0).fadeIn();
	$(" div.portfolio_image_post ").css("background", "none");	
	
	$(" div.portfolio_large_image img ").fadeOut(0).fadeIn(1000);
	$(" div.portfolio_large_image ").css("background", "none");	

	$(" div.portfolio_image img ").fadeOut(0).fadeIn(1000);
	$(" div.portfolio_image ").css("background", "none");	


}

