(function($) {
  $("a").bind("focus",function(){if(this.blur)this.blur();});
 

  $("#right_col ul > li:last-child").css({marginBottom:"0"});

  $("#comment_area ol > li:even").addClass("even_comment");
  $("#comment_area ol > li:odd").addClass("odd_comment");
  $(".even_comment > .children > li").addClass("even_comment_children");
  $(".odd_comment > .children > li").addClass("odd_comment_children");
  $(".even_comment_children > .children > li").addClass("odd_comment_children");
  $(".odd_comment_children > .children > li").addClass("even_comment_children");
  $(".even_comment_children > .children > li").addClass("odd_comment_children");
  $(".odd_comment_children > .children > li").addClass("even_comment_children");

  $("#guest_info input,#comment_textarea textarea")
    .focus( function () { $(this).css({borderColor:"#33a8e5"}) } )
    .blur( function () { $(this).css({borderColor:"#ccc"}) } );

  $(".search_tag").toggle(function(){
    $(".search_tag").addClass("active_search_tag");
    $("#tag_list ul").animate({ opacity: 'show', height:"show" }, {duration:1000 ,easing:"easeOutBack"});
    return false;
  },function(){
    $("#tag_list ul").fadeTo("slow", 0).slideUp("slow").fadeTo("fast", 1);
    $(".search_tag").removeClass("active_search_tag")
    return false;
  });

  $("#trackback_switch").click(function(){
    $("#comment_switch").removeClass("comment_switch_active");
    $(this).addClass("comment_switch_active");
    $("#comment_area").animate({opacity: 'hide'}, 0);
    $("#trackback_area").animate({opacity: 'show'}, 1000);
    return false;
  });

  $("#comment_switch").click(function(){
    $("#trackback_switch").removeClass("comment_switch_active");
    $(this).addClass("comment_switch_active");
    $("#trackback_area").animate({opacity: 'hide'}, 0);
    $("#comment_area").animate({opacity: 'show'}, 1000);
    return false;
  });

  $("#guest_info input,#comment_textarea textarea")
    .focus( function () { $(this).css({borderColor:"#33a8e5"}) } )
    .blur( function () { $(this).css({borderColor:"#ccc"}) } );

  $("blockquote").append('<div class="quote_bottom"></div>');

  $(".side_box:first").addClass("first_side_box");

});


function changefc(color){
  document.getElementById("search_input").style.color=color;
}


/*
dropdowm menu
*/

jQuery.fn.droppy = function(options) {
    
  options = jQuery.extend({speed: 250}, options || {});
  
  this.each(function() {
    
    var root = this, zIndex = 1000;
    
    function getSubnav(ele) {
      if (ele.nodeName.toLowerCase() == 'li') {
        var subnav = jQuery('> ul', ele);
        return subnav.length ? subnav[0] : null;
      } else {
        return ele;
      }
    }
    
    function getActuator(ele) {
      if (ele.nodeName.toLowerCase() == 'ul') {
        return jQuery(ele).parents('li')[0];
      } else {
        return ele;
      }
    }
    
    function hide() {
      var subnav = getSubnav(this);
      if (!subnav) return;
      jQuery.data(subnav, 'cancelHide', false);
      setTimeout(function() {
        if (!jQuery.data(subnav, 'cancelHide')) {
          jQuery(subnav).slideUp(options.speed);
        }
      }, 500);
    }
  
    function show() {
      var subnav = getSubnav(this);
      if (!subnav) return;
      jQuery.data(subnav, 'cancelHide', true);
      jQuery(subnav).css({zIndex: zIndex++}).slideDown(options.speed);
      if (this.nodeName.toLowerCase() == 'ul') {
        var li = getActuator(this);
        jQuery(li).addClass('hover');
        jQuery('> a', li).addClass('hover');
      }
    }
    
    jQuery('ul, li', this).hover(show, hide);
    jQuery('li', this).hover(
      function() { jQuery(this).addClass('hover'); jQuery('> a', this).addClass('hover'); },
      function() { jQuery(this).removeClass('hover'); jQuery('> a', this).removeClass('hover'); }
    );
    
  });
  
};

jQuery(function() {
    jQuery("#nav").droppy();

	jQuery('#contact_wrapper h4').click(function() {
		jQuery(this).next().toggle('slow');
		return false;
	}).next().hide();
  });
