var contentHidden = false;

jQuery(document).ready(function () {
	jQuery(' #loading ').fadeIn(200);	
});

jQuery(window).load(function () {
	
	jQuery(' #loading ').fadeOut(200);	

	jQuery(' #show_hide_content_button ').click(function () {

		(contentHidden == true) ? contentHidden = false : contentHidden = true;
	
		if (contentHidden == true) {

		jQuery(' #standard_page, #menu ').animate({"right": "-=850px"}, 1000, "easeInOutExpo");
		jQuery(' #left_content_wrapper ').animate({"left": "-=600px"}, 1000, "easeInOutExpo");
		jQuery(' #footer ').fadeOut();
		
		} else {

		jQuery(' #standard_page ').animate({"right": "+=850px"}, 1000, "easeInOutExpo");
		jQuery(' #left_content_wrapper ').animate({"left": "+=600px"}, 1000, "easeInOutExpo");
		jQuery(' #footer ').fadeIn();
		
		}

	});
	
	contactForm();
	
	shortcodeAnims();
	
	menuAnims();
	
	jQuery(' .portfolio_post, .portfolio_post_two, .portfolio_post_three, .portfolio_post_one ').hover(function () {

	jQuery(this).find("a.portfolio_post_title, a.portfolio_post_title_three, a.portfolio_post_title_two, a.portfolio_post_title_one").stop().fadeTo("medium",1);
	jQuery(this).find("div.portfolio_post_image img").stop().fadeTo("slow", 0.9);

	}, function () {

	jQuery(this).find("a.portfolio_post_title, a.portfolio_post_title_three, a.portfolio_post_title_two, a.portfolio_post_title_one").stop().fadeTo("medium",0);
	jQuery(this).find("div.portfolio_post_image img").stop().fadeTo("slow", 1);

	}).find("a.portfolio_post_title, a.portfolio_post_title_three, a.portfolio_post_title_two, a.portfolio_post_title_one").fadeTo(0,0);

	
});

// CONTACT FORM AJAX REQUEST

function contactForm () {

jQuery(' #contact_form ').submit(function () {

jQuery(' #result_box ').html('');

jQuery(' #submit ').attr('value', '...');

var _cfname = jQuery(' #name ').val();
var _cfemail = jQuery(' #email ').val();
var _cfphone = jQuery(' #phone ').val();
var _cfmessage = jQuery(' #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();

jQuery(' #result_box ').fadeTo(0,0).append(result).fadeTo("slow", 1);
jQuery(' #submit ').attr('value', submit_label);

return false;

} else if (!emailValResult.test(_cfemail)) {

result = ("<div class='error_box'>" + error_message_email + '</div>').toString();

jQuery(' #result_box ').fadeTo(0,0).append(result).fadeTo("slow", 1);
jQuery(' #submit ').attr('value', submit_label);

return false;

}

jQuery.get(sendMail, {name:jQuery(' #name ').val(), email:jQuery(' #email ').val(), phone:jQuery(' #phone ').val(), message: jQuery(' #message ').val(), admin_email:admin_email, subject_email:subject_email, success_message:success_message},

function(data){

result = ("<div class='success_box'>" + data + '</div>').toString();

jQuery(' #submit ').attr('value', submit_label);
jQuery(' #result_box ').fadeTo(0,0).append(result).fadeTo("slow", 1);

});	

return false;

});

}

// SHORTCODE ANIMS

function shortcodeAnims () {

jQuery(' a.single_lightbox, a.button, #portfolio_page_image a ').hover(function () {

jQuery(this).stop().fadeTo(400, 0.7);

}, 

function () {

jQuery(this).stop().fadeTo(400, 1);

});

}

// MENU ANIMS

function menuAnims () {

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

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

		jQuery(this).find('ul').css("display", "block").fadeTo(0,0).fadeTo(500, 1);

	}

},

function () {

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

		jQuery(this).find('ul').fadeTo(500, 0).delay(500).css("display", "none");

	}

});


}
