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


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

function changeFeatured() {
if(y==1) {
	$('.featuredDots li').animate({"opacity":"0.2"});
	$('#featured .slide').fadeOut(1000);
	if(x>z) {
	featured1(); x=2;
	} else {
	if(x=="1") { featured1(); x=2; }
	else if(x=="2") { featured2(); x=3;  }
	else if(x=="3") { featured3(); x=4;  }
	else if(x=="4") { featured4(); x=5;  }
	else if(x=="5") { featured5(); x=6;  }
	else if(x=="6") { featured6(); x=7;  }
	else if(x=="7") { featured7(); x=8;  }
	else if(x=="8") { featured8(); x=9;  }
	else if(x=="9") { featured9(); x=10;  }
	else if(x=="10") { featured10(); x=1;  }
	}
}
}
function featured1() {
		$('.featuredDots li.dot1').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide1 blockquote').fadeIn();
		$('#featured .slide1').fadeIn(1000);
		$('#featured .slide1 .image').css({"left":"960px"});
		$('#featured .slide1 .image').animate({"left":"0px"},500);
} 
function featured2() {
		$('.featuredDots li.dot2').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide2 blockquote').fadeIn();
		$('#featured .slide2').fadeIn(1000);
		$('#featured .slide2 .image').css({"left":"960px"});
		$('#featured .slide2 .image').animate({"left":"0px"},500);
} 
function featured3() {
		$('.featuredDots li.dot3').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide3 blockquote').fadeIn();
		$('#featured .slide3').fadeIn(1000);
		$('#featured .slide3 .image').css({"left":"960px"});
		$('#featured .slide3 .image').animate({"left":"0px"},500);
} 
function featured4() {
		$('.featuredDots li.dot4').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide4 blockquote').fadeIn();
		$('#featured .slide4').fadeIn(1000);
		$('#featured .slide4 .image').css({"left":"960px"});
		$('#featured .slide4 .image').animate({"left":"0px"},500);
} 
function featured5() {
		$('.featuredDots li.dot5').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide5 blockquote').fadeIn();
		$('#featured .slide5').fadeIn(1000);
		$('#featured .slide5 .image').css({"left":"960px"});
		$('#featured .slide5 .image').animate({"left":"0px"},500);
}
function featured6() {
		$('.featuredDots li.dot6').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide6 blockquote').fadeIn();
		$('#featured .slide6').fadeIn(1000);
		$('#featured .slide6 .image').css({"left":"960px"});
		$('#featured .slide6 .image').animate({"left":"0px"},500);
}
function featured7() {
		$('.featuredDots li.dot7').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide7 blockquote').fadeIn();
		$('#featured .slide7').fadeIn(1000);
		$('#featured .slide7 .image').css({"left":"960px"});
		$('#featured .slide7 .image').animate({"left":"0px"},500);
}
function featured8() {
		$('.featuredDots li.dot8').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide8 blockquote').fadeIn();
		$('#featured .slide8').fadeIn(1000);
		$('#featured .slide8 .image').css({"left":"960px"});
		$('#featured .slide8 .image').animate({"left":"0px"},500);
}
function featured9() {
		$('.featuredDots li.dot9').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide9 blockquote').fadeIn();
		$('#featured .slide9').fadeIn(1000);
		$('#featured .slide9 .image').css({"left":"960px"});
		$('#featured .slide9 .image').animate({"left":"0px"},500);
}
function featured10() {
		$('.featuredDots li.dot10').animate({"opacity":"1.0"});
		$('#featured .slide blockquote').hide();
		$('#featured .slide10 blockquote').fadeIn();
		$('#featured .slide10').fadeIn(1000);
		$('#featured .slide10 .image').css({"left":"960px"});
		$('#featured .slide10 .image').animate({"left":"0px"},500);
}


$(function() {

	z = $('ul#featured li').size(); // Number of items on featured
	
	
	$('.postContainer .posts').css({"height":"310px"});
	$('.postContainer .posts ul').css({"position":"absolute"});
	$('ul.dots').css({"display":"block"});
	

	// MENU 
	mainmenu();
	
	$('#nav li a').css({"opacity":"0.7"});
		
	$('#nav li a').hover(function() {
		$(this).css({"opacity":"1.0"});
	}, function() {
		$(this).css({"opacity":"0.7"});	
	});
	
	
	// DOTS 
	$('ul.dots li.dot').css({"opacity":"0.2"});
	$('ul.dots li.dot1').css({"opacity":"1.0"});
	
	
	// FEATURED //
	$('.featuredDots li a').click(function() {
		$('.featuredDots li').animate({"opacity":"0.2"});
		$(this).parent('li').animate({"opacity":"1.0"});
		$('#featured .slide').fadeOut(1000);
		y=0;
	});
	
	$('.featuredDots li.dot1 a').click(function() { featured1(); });
	$('.featuredDots li.dot2 a').click(function() { featured2(); });
	$('.featuredDots li.dot3 a').click(function() { featured3(); });
	$('.featuredDots li.dot4 a').click(function() { featured4(); });
	$('.featuredDots li.dot5 a').click(function() { featured5(); });
	$('.featuredDots li.dot6 a').click(function() { featured6(); });
	$('.featuredDots li.dot7 a').click(function() { featured7(); });
	$('.featuredDots li.dot8 a').click(function() { featured8(); });
	$('.featuredDots li.dot9 a').click(function() { featured9(); });
	$('.featuredDots li.dot10 a').click(function() { featured10(); });
	
	
	
	// TABPOSTS //
	if($.browser.msie) { } else {
	$('#contentarea .postContainer .posts ul li p').css({"opacity":"0.8"});
	$('#contentarea .postContainer .posts ul li h3').css({"opacity":"0.8"});
	
	$('#contentarea .postContainer .posts ul li').hover(function() {
		$(this).find('p').css({"opacity":"1.0"});
		$(this).find('h3').css({"opacity":"1.0"});
	}, function() {
		$(this).find('p').css({"opacity":"0.8"});
		$(this).find('h3').css({"opacity":"0.8"});
	}); }
	
	$('#contentarea .postContainer .posts ul').hide();
	$('#contentarea .postContainer .posts ul.tab1').fadeIn();
	
	$('.postContainer .heading .dots li.dot a').click(function() {
		$(this).parent('li').parent('ul').find('li.dot').animate({"opacity":"0.2"});
		$(this).parent('li').animate({"opacity":"1.0"});
		return false;
	});
	
	$('.postContainer .heading .dots li.dot1 a').click(function() {
	if($.browser.msie) {
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab1').css({"left":"570px","display":"block"});
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab1').animate({"left":"0px"},500);
	} else {
		$(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();
	}); 
	
	$('.postContainer .heading .dots li.dot2 a').click(function() {
	if($.browser.msie) {
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab2').css({"left":"570px","display":"block"});
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab2').animate({"left":"0px"},500);
	} else {
		$(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();
	}); 
	
	$('.postContainer .heading .dots li.dot3 a').click(function() {
	if($.browser.msie) {
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab3').css({"left":"570px","display":"block"});
		$(this).parent('li').parent('ul').parent('.heading').parent('.postContainer').find('.posts').find('ul.tab3').animate({"left":"0px"},500);
	} else {
		$(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();
	}); 
	
	
	// SIDEBAR TABS
	$('#tabs .tabs ul li').click(function() {
		$('#tabs .panel').hide();
		$('#tabs .tabs ul li').removeClass('active');
	});
	$('#tabs .tabs ul li:eq(0)').click(function() {
		$('#tabs .panel1').fadeIn();
		$(this).addClass('active');	
	});
	$('#tabs .tabs ul li:eq(1)').click(function() {
		$('#tabs .panel2').fadeIn();
		$(this).addClass('active');
	});
	$('#tabs .tabs ul li:eq(2)').click(function() {
		$('#tabs .panel3').fadeIn();
		$(this).addClass('active');
	});
	
	
	// SOCIAL BOOKMARKING
	$('ul.socialIcons').hover(function() {
		$('.speechBubble').css({"display":"block","opacity":"0.0"});
		$('.speechBubble').animate({"opacity":"1.0"},500);
	}, function() {
		$('.speechBubble').hide();
		$('.speechBubble').stop();
	});
		
	$('ul.socialIcons li.a a').hover(function() {
		$('.speechBubble').css({"left":"-180px"});
		$('.speechBubble').html('Share this post with Delicious');
	});
	
	$('ul.socialIcons li.b a').hover(function() {
		$('.speechBubble').css({"left":"-140px"});
		$('.speechBubble').html('Share this post with Digg');
	});
	
	$('ul.socialIcons li.c a').hover(function() {
		$('.speechBubble').css({"left":"-100px"});
		$('.speechBubble').html('Share this post with Furl');
	});
	
	$('ul.socialIcons li.d a').hover(function() {
		$('.speechBubble').css({"left":"-60px"});
		$('.speechBubble').html('Share this post with Reddit');
	});
	
	$('ul.socialIcons li.e a').hover(function() {
		$('.speechBubble').css({"left":"-20px"});
		$('.speechBubble').html('Share this post with Stumble Upon');
	});
	
	$('ul.socialIcons li.f a').hover(function() {
		$('.speechBubble').css({"left":"20px"});
		$('.speechBubble').html('Share this post with Technorati');
	});
	
	$('ul.socialIcons li.g a').hover(function() {
		$('.speechBubble').css({"left":"60px"});
		$('.speechBubble').html('Share this post with Twitter');
	});
	
	
	
	
	
	
});