//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"});
    $('#featuredbanner .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;  }
    }
 }
 else {
    y--;
 }
}
function featured1() {
        $('.featuredDots li.dot1').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide1 blockquote').fadeIn();
        $('#featuredbanner .slide1').fadeIn(1000);
        $('#featuredbanner .slide1 .image').css({"left":"960px"});
        $('#featuredbanner .slide1 .image').animate({"left":"0px"},500);
} 
function featured2() {
        $('.featuredDots li.dot2').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide2 blockquote').fadeIn();
        $('#featuredbanner .slide2').fadeIn(1000);
        $('#featuredbanner .slide2 .image').css({"left":"960px"});
        $('#featuredbanner .slide2 .image').animate({"left":"0px"},500);
} 
function featured3() {
        $('.featuredDots li.dot3').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide3 blockquote').fadeIn();
        $('#featuredbanner .slide3').fadeIn(1000);
        $('#featuredbanner .slide3 .image').css({"left":"960px"});
        $('#featuredbanner .slide3 .image').animate({"left":"0px"},500);
} 
function featured4() {
        $('.featuredDots li.dot4').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide4 blockquote').fadeIn();
        $('#featuredbanner .slide4').fadeIn(1000);
        $('#featuredbanner .slide4 .image').css({"left":"960px"});
        $('#featuredbanner .slide4 .image').animate({"left":"0px"},500);
} 
function featured5() {
        $('.featuredDots li.dot5').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide5 blockquote').fadeIn();
        $('#featuredbanner .slide5').fadeIn(1000);
        $('#featuredbanner .slide5 .image').css({"left":"960px"});
        $('#featuredbanner .slide5 .image').animate({"left":"0px"},500);
}
function featured6() {
        $('.featuredDots li.dot6').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide6 blockquote').fadeIn();
        $('#featuredbanner .slide6').fadeIn(1000);
        $('#featuredbanner .slide6 .image').css({"left":"960px"});
        $('#featuredbanner .slide6 .image').animate({"left":"0px"},500);
}
function featured7() {
        $('.featuredDots li.dot7').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide7 blockquote').fadeIn();
        $('#featuredbanner .slide7').fadeIn(1000);
        $('#featuredbanner .slide7 .image').css({"left":"960px"});
        $('#featuredbanner .slide7 .image').animate({"left":"0px"},500);
}
function featured8() {
        $('.featuredDots li.dot8').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide8 blockquote').fadeIn();
        $('#featuredbanner .slide8').fadeIn(1000);
        $('#featuredbanner .slide8 .image').css({"left":"960px"});
        $('#featuredbanner .slide8 .image').animate({"left":"0px"},500);
}
function featured9() {
        $('.featuredDots li.dot9').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide9 blockquote').fadeIn();
        $('#featuredbanner .slide9').fadeIn(1000);
        $('#featuredbanner .slide9 .image').css({"left":"960px"});
        $('#featuredbanner .slide9 .image').animate({"left":"0px"},500);
}
function featured10() {
        $('.featuredDots li.dot10').animate({"opacity":"1.0"});
        $('#featuredbanner .slide blockquote').hide();
        $('#featuredbanner .slide10 blockquote').fadeIn();
        $('#featuredbanner .slide10').fadeIn(1000);
        $('#featuredbanner .slide10 .image').css({"left":"960px"});
        $('#featuredbanner .slide10 .image').animate({"left":"0px"},500);
}


$(function() {

    z = $('ul#featuredbanner 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"});
        $('#featuredbanner .slide').fadeOut(1000);
        y=8;
    });
    
    $('.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');
    });
    
    
    
    
    
    
});

