$(document).ready(function() {

$(function(){
	if ($("#sidebar").children(":first").attr('id') == 'be_args'){
		$('#be_args').css('margin-top', '10px');
	}
});


// Layout options feature
$('a#options').click(function (){
	if (($('.layout_options')).is(':hidden')) {
	$('#wrapper').fadeTo('fast', 0.33);
	$('.layout_options').fadeIn('normal');
	} else {
	$('#wrapper').fadeTo('fast', 1.0);
	$('.layout_options').fadeOut('normal');
	}
});

$('.cancel a').click(function() {
	$('#wrapper').fadeTo('fast', 1.0);
	$('.layout_options').fadeOut('normal');
});

$('a#reset').click(function() {
$('.cat-widget').each( function() {$.cookie($(this).attr('id'), null, { path: '/', expires: 100 }); $(this).show()});
$('.box_a').each( function() {$.cookie($(this).attr('id'), null, { path: '/', expires: 100 }); $(this).show()});
$('.widgets li').each (function() {$.cookie($(this).attr('id'), null, { path: '/', expires: 100 }); $(this).show()});
$('.layout_options').fadeOut('normal');
$('#wrapper').fadeTo('fast', 1.0);
});
// done.

// Drop Down Menu (multi level)
$("#menu ul li").hover(function(){
$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(300); 
},function(){
$(this).find('ul:first').css({visibility: "hidden"});
});
// End of Menu

/* various widget actions */
$('.minimize').click(function() {
	$(this).parent('h3').next('.container').toggle();
});

$('.Sminimize').click(function() {
	$(this).parent('h2').next().toggle();
});

$('.Wminimize').click(function() {
	$(this).parent('h2').next().toggle();
});
											
$('.close').click(function() {
	$(this).parent('h3').parent('.cat-widget').fadeOut('slow');
	$.cookie($(this).parent('h3').parent('.cat-widget').attr('id'), 'closed', { path: '/', expires: 100 });
	return false;
});

/* leaderboard actions */
$('.sticky-close').click(function() {
	$('.sticky-spacer').fadeOut('slow');
	$(this).parent('.sticky-footer-inner').parent('.sticky-widget').fadeOut('slow');
	$.cookie($(this).parent('.sticky-footer-inner').parent('.sticky-widget').attr('id'), 'closed', { path: '/', expires: 7 });
	return false;
});
/* end leaderboard actions */



$('.Sclose').click(function() {
	$(this).parent('h2').parent().fadeOut('slow');
	$.cookie($(this).parent('h2').parent('.box_a').attr('id'), 'closed', { path: '/', expires: 100 });
	return false;
});

$('.Wclose').click(function() {
	$(this).parent('h2').parent().fadeOut('slow');
	$.cookie($(this).parent('h2').parent('li').attr('id'), 'closed', { path: '/', expires: 100 });
	return false;
});

$('.cat-widget').each( function() {
	var cat_ID = $(this).attr('id');
	if ($.cookie(cat_ID) == 'closed') $(this).hide();
});

$('.sticky-widget').each( function() {
	var cat_ID = $(this).attr('id');
	if ($.cookie(cat_ID) == 'closed') $(this).hide();
});

$('.box_a').each( function() {
	var box_ID = $(this).attr('id');
	if ($.cookie(box_ID) == 'closed') $(this).hide();
});

$('.widgets li').each (function() {
	var sidebar_ID = $(this).attr('id');
	if ($.cookie(sidebar_ID) == 'closed') $(this).hide();
});

/* control visible stories */
$('ul.more_stories').each(function(index) {
$(this).children('li').slice(10).hide();
});

$('.minus').click(function() {
$(this).parent().next('ul').children('li:visible:last').hide();
});

$('.plus').click(function() {
$(this).parent().next('ul').children('li:hidden:first').show();
});

/* clear form */
clearInput('#feedemail');

$('.videothumb').bind('mouseenter', function() {$(this).children('.playit').children('a').show()});
$('.videothumb').bind('mouseleave', function() {$(this).children('.playit').children('a').hide()});

// do color animation

$(function() {
    $(".carousel-container").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev"
    });
});

$(function(){
		$('#post-lists .carousel-container a, a.home-again').click(function(){
		var i = $(this).attr('rel');
		$('.cover-additional-stories').css('display', 'none');
		$('.content-spacer #' + i).fadeIn();
		return false;
		});
		
		$('.content-spacer div:first').fadeIn();
});

$(function(){
		$('#post-convention-cal .carousel-container a').click(function(){
		var n = $(this).attr('rel');
		$('.in-this-issue-body').css('display', 'none');
		$('#mth-' + n).fadeIn();
		return false;
		});
		
		$('.in-this-issue-body.active').fadeIn();
});

$(function(){	
		$('.event-links a:first').addClass('active');
		$('.the-event-details div:first').addClass('nowvisible');
		$('.bottom-image-container div:first').fadeIn();
		$('.image-container-left div:first').addClass('nowvisible');
		$('.events-bottom .pad div:second').addClass('nowvisible');
		
		$('.event-links a').click(function(){
			$('.image-container-left div').removeClass('nowvisible');
			$('.the-event-details div').removeClass('nowvisible');
			$('.events-bottom .pad .the-photo').removeClass('nowvisible');
			$('.event-links a').removeClass('active');
			$(this).addClass('active');
			
			
			var clicked_link = $(this).attr('rel');
			
			
			$('.image-container-left').css('background', 'none');
			
			$('.image-container-left #'+clicked_link+'-image.event-image').addClass('nowvisible');
			$('.the-event-details #'+clicked_link+'-details.event-details').addClass('nowvisible');
			$('.the-photo#'+clicked_link+'-photo').addClass('nowvisible');
			return false;
		});
});

$(function(){
	
	if ($.cookie('slider') == 'true') {
		$('.slider-large-hero').hide();
		$('.slider-small-hero').fadeIn();		
	} else {
		$('.slider-small-hero').hide();
		$('.slider-large-hero').slideDown(1000);
	}
	
	$.cookie("slider", "true", { expires: 1 }); // Resets cookie every day
	
	$('#adcolumn a.expand-collapse').click(function(){
		var dis = $(this).parent().attr('class');
		
		if(dis == 'slider-large-hero'){
			//$(this).parent().animate({height: 50});
			//$(this).parent().css('display', 'none');
			$(this).parent().fadeOut(200);
			$('.slider-small-hero').fadeIn();
			return false;
		} else if(dis == 'slider-small-hero') {
			$(this).parent().fadeOut(200);
			$('.slider-large-hero').slideDown();
			return false;
		}
		
	});
	
/*	$('.box_a').each( function() {
		var box_ID = $(this).attr('id');
		if ($.cookie(box_ID) == 'closed') $(this).hide();
	});*/
	
});




$(function() {
    $(".carousel-container").css({'width': '535px','left': '45px'});
});


});

var axel = Math.random() + "";
var ord = axel * 1000000000000000000;


sfHover = function() {
	var sfEls = document.getElementById("nav_menu_list").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function preloader(){
document.getElementById("preloader").style.display = "none";
document.getElementById("container").style.display = "block";
}

$(document).ready(function() {
	if(options_loading) {
		window.onload = preloader;
	}
});






















function ticktock() {
	var m_names = new Array("January", "February", "March", 
	"April", "May", "June", "July", "August", "September", 
	"October", "November", "December");
	var d = new Date();
	var a_p = "";
	var curr_date = d.getDate();
	var curr_month = d.getMonth();
	var curr_year = d.getFullYear();
	var curr_hour = d.getHours();
	var curr_seconds = d.getSeconds();
	var curr_min = d.getMinutes();

	a_p = curr_hour > 12 ? "PM" : "AM";
	curr_hour = 1 + ((curr_hour-1) % 12);
	curr_min = "" + curr_min;

	if (curr_min.length < 2) curr_min = "0" + curr_min;
	if (curr_seconds.length < 2) curr_seconds = "0" + curr_seconds;

	$('#time_holder').html(
		m_names[curr_month] +
		" " + curr_date +
		", " + curr_year +
		" " + curr_hour +
		":" + curr_min +
//		":" + curr_seconds +
		" " + a_p);
}

$(document).ready(function() {
	ticktock();
	setInterval(ticktock, 60000);
});



function CreateBookmarkLink() {
title2 = "black enterprise";
url2 = "http://www.blackenteprise.com/";

if (navigator.userAgent.indexOf("Firefox")!=-1){
	
 window.sidebar.addPanel(title2, url2,"");
     
} else if(navigator.userAgent.indexOf("MSIE")!=-1) {
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage('http://www.blackenterprise.com');
} 
else if(window.opera && window.print) {
// Opera Hotlist
return true; 
} }
