/*-----------------------------------------------------------------------------------*/
/*	IMAGE HOVER
/*-----------------------------------------------------------------------------------*/

$(function() {
	
	function mainmenu(){
		$(" #menu ul ul ").css({display: "none"}); // Opera Fix
		$(" #menu ul li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show(200);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
	});
	}

 	$(document).ready(function(){
		mainmenu();
	});
	
	$(document).ready(function(){
	    $("#menu-holder").sticky({topSpacing:0});
	});
	
	jQuery('.settings .openclose').click(function()
    {
        var target = jQuery(this).parent().parent('.settings');
        if(target.is('.display_switch'))
        {
            target.animate({top: "-78"}, function()
            {
                target.removeClass('display_switch').addClass('display_settings_false');
            });
        }
        else
        {
            target.animate({top: "0"}, function()
            {
                target.removeClass('display_settings_false').addClass('display_switch');
            });
        }
    });
	
	//When page loads...
	jQuery(".tab_content").hide(); //Hide all content
	jQuery("ul.tabs li:first").addClass("active").show(); //Activate first tab
	jQuery(".tab_content:first").show(); //Show first tab content

	//On Click Event
	jQuery("ul.tabs li").click(function() {

		jQuery("ul.tabs li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab

		return false;
	});
	
	//Toggle
	jQuery(".togglebox").hide();
	//slide up and down when click over heading 2
	
	jQuery("h4").click(function(){
	// slide toggle effect set to slow you can set it to fast too.
	jQuery(this).toggleClass("active").next(".togglebox").slideToggle("slow");
	
	return true;
	
	});
	
	$('.flexslider').flexslider();
	
	$('.widget blockquote').quovolver();
	
});

jQuery(function() {

	jQuery(".proj-three-preview a img, .proj-preview a img, .widget li img").css("opacity","1.0");
	jQuery(".proj-three-preview a img, .proj-preview a img, .widget li img").hover(function () {
	jQuery(this).stop().animate({ opacity: 0.3 }, "fast");  },
	function () {
	jQuery(this).stop().animate({ opacity: 1.0 }, "slow");  
	}); 

	jQuery("#social-footer img").css("opacity","1.0");
	jQuery("#social-footer img").hover(function () {
	jQuery(this).stop().animate({ opacity: 0 }, "fast");  },
	function () {
	jQuery(this).stop().animate({ opacity: 1.0 }, "fast");  
	});
	
	jQuery("#social-team img, .social-team img").css("opacity","1.0");
	jQuery("#social-team img, .social-team img").hover(function () {
	jQuery(this).stop().animate({ opacity: 0 }, "fast");  },
	function () {
	jQuery(this).stop().animate({ opacity: 1.0 }, "fast");  
	});
	
	jQuery(".aventador-sponsors img").css("opacity","0.5");
	jQuery(".aventador-sponsors img").hover(function () {
	jQuery(this).stop().animate({ opacity: 1.0 }, "fast");  },
	function () {
	jQuery(this).stop().animate({ opacity: 0.5 }, "fast");  
	});
	
	jQuery(".widget-menu li a").css("left","0px");
	jQuery(".widget-menu li a").hover(function () {
	jQuery(this).stop().animate({ left: "10px" }, "fast");  },
	function () {
	jQuery(this).stop().animate({ left: "0px" }, "fast");  
	});

});

/* ---------------------------------------------------- */
/*		Contact Form
/* ---------------------------------------------------- */

$(function(){

	$('#form-submit').after('<p class="hide" id="response">');
	
	//Do what we need to when form is submitted.
	$('#form-submit').click(function(e){
	
	//Setup any needed variables.
	var input_name = $('#form-name').val(),
		input_email = $('#form-email').val(),
		input_message = $('#form-message').val(),
		response_text = $('#response');
		//Hide any previous response text 
		response_text.hide();
		
		//Change response text to 'loading...'
		response_text.html('<img src="images/loader.gif" height="11" width="16" alt="Loading..." />').show();
		
		//Make AJAX request 
		$.post('php/contact-send.php', {name: input_name, email: input_email, message: input_message}, function(data){
			response_text.html(data);
		});
		
		//Cancel default action
		e.preventDefault();
	});

});
