$.noConflict();
jQuery(document).ready(function($) {

// 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;
});

$('.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();
});

$('.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(3).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
$('.animate').mouseover(function() {
$(this).css({'background-color' : '#297eb9', 'color' : '#ffffff'});
});

$('.animate').mouseout(function() {
$(this).css({'background-color' : '#ffffff', 'color' : '#297eb9'});
});

});
