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

function bannerslide1() {
	$('#banner ul#slidercircles li').removeClass('active');
	$('#banner ul#slidercircles li.circle1').addClass('active');
	$('#banner ul#slider li').fadeOut(1000);
	$('#banner ul#slider li.slide1').fadeIn(1000);
}

function bannerslide2() {
	$('#banner ul#slidercircles li').removeClass('active');
	$('#banner ul#slidercircles li.circle2').addClass('active');
	$('#banner ul#slider li').fadeOut(1000);
	$('#banner ul#slider li.slide2').fadeIn(1000);
}

function bannerslide3() {
	$('#banner ul#slidercircles li').removeClass('active');
	$('#banner ul#slidercircles li.circle3').addClass('active');
	$('#banner ul#slider li').fadeOut(1000);
	$('#banner ul#slider li.slide3').fadeIn(1000);
}

var x =2; // Featured Slide Number
var y =1; // Stop/Start Slider
var z = 0;

function changeBanner() {
if(y==1) {
	if(x=="1") {
		bannerslide1()
		x=2; 
	} else if(x=="2") { 
		bannerslide2()
		x=3; 
	} else if(x=="3") { 
		bannerslide3()
		x=1;  
	}
}
}


$(function() {

	setInterval("changeBanner()",5000);
	
	mainmenu();
	
	$('ul#nav li:last').css({"padding":"0","border":"none"});
	$('#footer ul li:last').css({"border":"none"});
	
	$('#banner li.circle1').click(function() { bannerslide1(); y = "0"; });
	$('#banner li.circle2').click(function() { bannerslide2(); y = "0"; });
	$('#banner li.circle3').click(function() { bannerslide3(); y = "0"; });
	
	
	// TABPOSTS //
	$('.postContainer li.dot1').addClass('active');
	$(' .postContainer .posts ul').hide();
	$(' .postContainer .posts ul.tab1').fadeIn();
	
	$('.postContainer .heading .dots li.dot a').click(function() {
		$('.postContainer .dots li.dot').removeClass('active');
		$(this).parent('li').addClass('active');
		return false;
	});
	
	$('.postContainer .heading .dots li.dot1 a').click(function() {
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab1').css({"left":"570px","display":"block","opacity":"0.0"});
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab1').animate({"left":"0px","opacity":"1.0"},500);
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab2').fadeOut();
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab3').fadeOut();
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab4').fadeOut();
	}); 
	
	$('.postContainer .heading .dots li.dot2 a').click(function() {
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab2').css({"left":"570px","display":"block","opacity":"0.0"});
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab2').animate({"left":"0px","opacity":"1.0"},500);
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab1').fadeOut();
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab3').fadeOut();
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab4').fadeOut();
	}); 
	
	$('.postContainer .heading .dots li.dot3 a').click(function() {
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab3').css({"left":"570px","display":"block","opacity":"0.0"});
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab3').animate({"left":"0px","opacity":"1.0"},500);
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab1').fadeOut();
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab2').fadeOut();
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab4').fadeOut();
	});
	
	
	$('.contactform #submit').remove();
    $('.contactform').append('<input type="button" name="submit" id="submit" value="Go" />');
    	
    $('.contactform #submit').click(function() {
        var name = $('.contactform input#name').val();
        var email = $('.contactform input#email').val();
        var message = $('.contactform input#message').val();

        $.ajax({
            type: 'post',
        	url: 'http://jcomcopy.com/wp-content/themes/jcom/scripts/sendMessage.php',
        	data: 'name=' + name + '&email=' + email + '&message=' + message,

            success: function(results) {
            $('.contactform ul.response').show();
            $('.contactform ul.response').html(results);
            }
        }); 
    });
    
    $('.contactform ul.response').click(function() {
    	$(this).fadeOut();
    	return false;
    });
    
    $('#name').focus(function() {
		if($(this).attr("value") == "your name") { $(this).attr("value",""); }
	});
	$('#name').blur(function() {
		if($(this).attr("value") == "") { $(this).attr("value","your name"); }
	});
    
    $('#email').focus(function() {
		if($(this).attr("value") == "email address") { $(this).attr("value",""); }
	});
	$('#email').blur(function() {
		if($(this).attr("value") == "") { $(this).attr("value","email address"); }
	});
    
    $('#message').focus(function() {
		if($(this).attr("value") == "and anything else you like") { $(this).attr("value",""); }
	});
	$('#message').blur(function() {
		if($(this).attr("value") == "") { $(this).attr("value","and anything else you like"); }
	});
    
    $('.searchform input#s').focus(function() {
		if($(this).attr("value") == "search") { $(this).attr("value",""); }
	});
	$('.searchform input#s').blur(function() {
		if($(this).attr("value") == "") { $(this).attr("value","search"); }
	});
	
	

	
});
