jQuery(document).ready(function ($) {

	$(".ad_widget_125 li:nth-child(even), li.cat-item:nth-child(even), .mav_archives li:nth-child(even), .flickr_badge img:nth-child(3n+3), .post_style_wide li:nth-child(even)").css("margin-right", "0");
	$("#myslidemenu ul li ul li:last-child a, #catmenu ul li ul li:last-child a").css("border-bottom", "0");
	$("li.blogarticle:last-child").css("margin-bottom", "0");

	// Tabs
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});


	// Contact Form
	$('#send_message').click(function(e){
		e.preventDefault();
		var error = false;
		var name = $('#name').val();
		var email = $('#email').val();
		var subject = $('#subject').val();
		var message = $('#message').val();

		if(name.length == 0){
			error = true;
			$('#name_error').fadeIn(500);
		}else{
			$('#name_error').fadeOut(500);
		}
		if(email.length == 0 || email.indexOf('@') == '-1'){
			error = true;
			$('#email_error').fadeIn(500);
		}else{
			$('#email_error').fadeOut(500);
		}
		/* if(subject.length == 0){
			error = true;
			$('#subject_error').fadeIn(500);
		}else{
			$('#subject_error').fadeOut(500);
		} */
		if(message.length == 0){
			error = true;
			$('#message_error').fadeIn(500);
		}else{
			$('#message_error').fadeOut(500);
		}

		if(error == false){
			$('#send_message').attr({'disabled' : 'true', 'value' : 'Sending..' });

			var contactformurl = mysiteurl+"/js/send_email.php";
			$.post(contactformurl, $("#contact_form").serialize(),function(result){
				if(result == 'sent'){
					$('#cf_submit_p').remove();
					$('#mail_success').fadeIn(500);
				}else{
					$('#mail_fail').fadeIn(500);
					$('#send_message').removeAttr('disabled').attr('value', 'Send');
				}
			});
		}
	});


	// Toggle
	$(".toggle_container").hide(); 

	$(".toggle_trigger").click(function(){
		$(this).toggleClass("toggle_active").next().slideToggle("fast");
		return false;
	});
	
	
	// Image Effect
	$('.someclass').hover(function() {
		$(this).stop().animate({"opacity": 0.7}, 300);
	}, function () {
		$(this).stop().animate({"opacity": 1}, 300);
	});
	
	// Reverse Effect
	$('.social_facebook a, .social_twitter a, .social_linkedin a, .social_myspace a, .social_dribble a').hover(function() {
		$(this).stop().animate({"opacity": 1}, 300);
	}, function () {
		$(this).stop().animate({"opacity": 0.6}, 300);
	});
	
    // Post Thumbnails Hover
	$("a.post_image_thumb").hover(function(){
        $(this).children(".post_image_text").fadeIn(400);
    },function(){
        $(this).children(".post_image_text").fadeOut(200);
    });
});
