// No conflict with JS libraries
jQuery.noConflict();
jQuery(document).ready(function() {

    // Drop Down Menu (2 Levels)
    jQuery('#menu ul').hide(0.000000000000000000000000000000000000001);
    jQuery('#menu li a').addClass('nav_parent');
    jQuery('#menu ul a').removeClass('nav_parent');
    jQuery('#menu ul a').addClass('nav_child');

    jQuery('.nav_parent').bind('mouseenter', function() {
	if ((jQuery(this).next().is('ul')) && (jQuery(this).next().is(':visible'))) {
	return false;
	} else if ((jQuery(this).next().is('ul')) && (jQuery(this).next().is(':hidden'))) {
	jQuery(this).addClass('selected');
	jQuery(this).append('<div class="arrow"></div>');
	jQuery(this).next().show();
	return false;
	}
    });

    jQuery('.nav_parent').parent().bind('mouseleave', function() {
	jQuery('#menu li a').removeClass('selected');
	jQuery('.arrow').remove();
	jQuery('#menu ul:visible').hide();
    });

    jQuery('#menu ul a').bind('mouseenter', function() {
	if ((jQuery(this).next().is('ul')) && (jQuery(this).next().is(':visible'))) {
	return false;
	} else if ((jQuery(this).next().is('ul')) && (jQuery(this).next().is(':hidden'))) {
	jQuery(this).next().show();
	return false;
	}
    });
    jQuery('#menu ul a').bind('mouseleave', function() {
	jQuery(this).next().hide();
    });
    jQuery('#menu ul ul').bind('mouseenter', function() {
	jQuery(this).show();
	jQuery(this).event.stopPropagation();
    });
    jQuery('#menu ul ul').bind('mouseleave', function() {
	jQuery(this).hide();
    });
    // End of Menu

    // CSS Work
    jQuery('#pagenav li:last').css('border', 'none');
    jQuery('#pagenav li:last').css('padding', '0 0 0 4px');
    jQuery('#sidebar_l li:first').css('margin-top', '0');
    jQuery('#sidebar_r li:first').css('margin-top', '0');
    jQuery('#sidebar_m li:first').css('margin-top', '0');
    jQuery('#sidebar_m li:first').css('margin-bottom', '15px');

    // Photo Gallery from Flickr
    jQuery('#gallery img').fadeTo(1, 0.75);
    jQuery('#gallery img').bind('mouseenter', function() { jQuery(this).fadeTo(200, 1.0); });
    jQuery('#gallery img').bind('mouseleave', function() { jQuery(this).fadeTo(200, 0.75); });

    // Post Gallery - Carousel
    jQuery('#carousel ul li a img').fadeTo(1, 0.70);
    jQuery('#carousel ul li a img').bind('mouseenter', function() { jQuery(this).fadeTo(200, 1.0); });
    jQuery('#carousel ul li a img').bind('mouseleave', function() { jQuery(this).fadeTo(200, 0.70); });

    // Social Bookmarking
    jQuery('#social').hide();
    jQuery('#share').click(function() {
	if ( jQuery('#social').is(':hidden') ) {
	jQuery('#social').slideDown('normal');
	} else {
	jQuery('#social').slideUp('normal');
	}
    });
    jQuery('ul.postinfoB').bind('mouseleave', function() {
	jQuery('#social').slideUp('normal');
    });

    jQuery('.post h1').click(function() { jQuery('#subheaderi').slideToggle("slow"); });
    jQuery('#top input.searchfield').mouseenter(function() { 
	jQuery('#top input.searchfield').height('25px');
	jQuery('#top input.searchfield').width('250px');
    });

    jQuery('#top input.searchfield').mouseout(function() {
	jQuery('#top input.searchfield').height('17px');
        jQuery('#top input.searchfield').width('150px');
     });

    // Expand Panel    
    jQuery("#open").click(function(){
                jQuery("div#panel").slideDown("slow");
    });

    // Collapse Panel
    jQuery("#close").click(function(){
                jQuery("div#panel").slideUp("slow");
    });

    // Switch buttons from "Log In | Register" to "Close Panel" on click
    jQuery("#toggle a").click(function () {
                jQuery("#toggle a").toggle();
    });

});

//DD_roundies.addRule('#footeri', '8px');
//DD_roundies.addRule('#subheader .column', '8px');
//jQuery(document).ready(function() { jQuery('.post h1').click(function() { jQuery('#subheaderi').slideToggle("slow"); }); });
//jQuery(document).ready(function() { jQuery('.post h1').click(function() { jQuery('#subheaderi').slideToggle("slow"); }); });
	

