
//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}, 1400,'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>");
	});
});
