
//scroll smooser
jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

//equal height
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}

$(document).ready(function(){
  equalHeight($(".cbox1"));
  equalHeight($(".cbox2"));
  equalHeight($(".cbox3"));
  $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
          && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target
            || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
              var targetOffset = $target.offset().top;
              $('html,body')
              .animate({scrollTop: targetOffset}, 500,'quart');
             return false;
            }
    }
  });
});

//IE background
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}


$(document).ready( function () {
    $(".blank").append('&nbsp;<img src="/files/image/b_ext-link.png" height="12" width="12" alt="" />');
    $(".blank img").css("vertical-align","text-top");
    $(".blank").after('&nbsp;');
    $('.blank').click(function(){
        window.open(this.href, '_blank');
        return false;
    });
});



// check list highlight
var tableRowCheckboxCheckedClass='marked';

$(document).ready(function(){
	$("input[type='checkbox']").click(function(){
	var chk = $(this).attr('checked');
		if(chk == true){
		$(this).parent().addClass(tableRowCheckboxCheckedClass);
		}else{
		$(this).parent().removeClass(tableRowCheckboxCheckedClass);
		}
	return true;
	});
});

// checklist sum 
$(document).ready(function()
{	
	var total = 0;
	
	function calcTotal()
	{
		$("input:checked").each(function()
		{
			//This happens for each checked input field
			var value = $(this).attr("value");
			total += parseInt(value); 
		});
	}
	//This happens when the page loads
	calcTotal();
	$("#checkapp").after('<p class="check-result">該当項目数: <strong>' + total + '</strong></p>');
	$("input:checkbox, input:radio").click(function()
	{
		total = 0;
		calcTotal();
		$("p.check-result").html("該当項目数: <strong>" + total + "</strong>");
	});
});

/*
 * 	Easy Tooltip 1.0 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4380/easy-tooltip--jquery-plugin
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
 
(function($) {

	$.fn.easyTooltip = function(options){
	  
		// default configuration properties
		var defaults = {	
			xOffset: 10,		
			yOffset: 25,
			tooltipId: "easyTooltip",
			clickRemove: false,
			content: "",
			useElement: ""
		}; 
			
		var options = $.extend(defaults, options);  
		var content;
				
		this.each(function() {  				
			var title = $(this).attr("title");				
			$(this).hover(function(e){											 							   
				content = (options.content != "") ? options.content : title;
				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
				$(this).attr("title","");									  				
				if (content != "" && content != undefined){			
					$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");		
					$("#" + options.tooltipId)
						.css("position","absolute")
						.css("top",(e.pageY - options.yOffset) + "px")
						.css("left",(e.pageX + options.xOffset) + "px")						
						.css("display","none")
						.fadeIn("fast")
				}
			},
			function(){	
				$("#" + options.tooltipId).remove();
				$(this).attr("title",title);
			});	
			$(this).mousemove(function(e){
				$("#" + options.tooltipId)
					.css("top",(e.pageY - options.yOffset) + "px")
					.css("left",(e.pageX + options.xOffset) + "px")					
			});	
			if(options.clickRemove){
				$(this).mousedown(function(e){
					$("#" + options.tooltipId).remove();
					$(this).attr("title",title);
				});				
			}
		});
	  
	};

})(jQuery);

$(document).ready(function(){	
	$("span").easyTooltip();
});

