jQuery(document).ready(function($) {
	rollover();
	addCss();
});

/* !rollover ---------------------------------------------------------------- */
var rollover = function(){
	var suffix = { normal : '_no.', over   : '_on.'}
	$('a.over, img.over, input.over').each(function(){
		var a = null;
		var img = null;

		var elem = $(this).get(0);
		if( elem.nodeName.toLowerCase() == 'a' ){
			a = $(this);
			img = $('img',this);
		}else if( elem.nodeName.toLowerCase() == 'img' || elem.nodeName.toLowerCase() == 'input' ){
			img = $(this);
		}

		var src_no = img.attr('src');
		var src_on = src_no.replace(suffix.normal, suffix.over);

		if( elem.nodeName.toLowerCase() == 'a' ){
			a.bind("mouseover focus",function(){ img.attr('src',src_on); })
			 .bind("mouseout blur",  function(){ img.attr('src',src_no); });
		}else if( elem.nodeName.toLowerCase() == 'img' ){
			img.bind("mouseover",function(){ img.attr('src',src_on); })
			   .bind("mouseout", function(){ img.attr('src',src_no); });
		}else if( elem.nodeName.toLowerCase() == 'input' ){
			img.bind("mouseover focus",function(){ img.attr('src',src_on); })
			   .bind("mouseout blur",  function(){ img.attr('src',src_no); });
		}

		var cacheimg = document.createElement('img');
		cacheimg.src = src_on;
	});
};
/* !Addition Fitst & Last --------------------------------------------------- */
var addCss = (function(){
	$('li:last-child').addClass('last');
	$('li:first-child').addClass('first');	
});
/* !OpacityHover ------------------------------------------------------------ */
$(function(){
	$(".opHover").fadeTo(1,1);
	$(".opHover").hover(function (){
		$(this).stop().fadeTo(1, 0.75);
	},function (){
		$(this).stop().fadeTo(1, 1);
	});
});

/* !Block Hover ------------------------------------------------------------- */
$(function(){
	$("ul.item_bd,div.list_tag").click(function(){
		window.location=$(this).find("a").attr("href");
		return false;
	});
	$("ul.item_bd,div.list_tag").hover(function() {
		$(this).addClass('hover');
		$(this).children().find('img').stop().fadeTo(1, 0.75);
	},function() {
		$(this).removeClass('hover');
		$(this).children().find('img').stop().fadeTo(1, 1);
	});
});


/* SmoothScroll ------------------------------------------------------ */
$(function(){
   $('#return_top a[href^=#]').click(function() {
      var speed = 800;
      var href= $(this).attr("href");
      var target = $(href == "#" || href == "" ? 'html' : href);
      var position = target.offset().top;
      $($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
      return false;
   });
});

