$(document).ready(function(){var selected=new Array();var check=function(val){var cb=$("#comboList input[value='"+val+"']");var c=cb.attr("checked");cb.parent().toggleClass("checked");var p=cb.parents("tr:first");var at=function(a,f){var d=Number($("#at"+a).text());var g="#ct";if(a<=4)g+=1;else if(a<=7)g+=2;else if(a<=14)g+=3;else g+=4;var gc=Number($(g).text());var tc=Number($("#totalCd").text());if(f){$("#at"+a).text(d+1);$(g).text(gc+1);$("#totalCd").text(tc+1);}else{$("#at"+a).text(d-1);$(g).text(gc-1);$("#totalCd").text(tc-1);}}
var sum=0;$("span",p).each(function(){var id=$("a",this).attr("class");var disc=$(this).attr("class").substr(4);var point=Number($(this).get(0).lastChild.nodeValue.slice(1,-1));if(c){if(!selected[id]){selected[id]=1;at(disc,true);sum+=point;}else{selected[id]+=1;}}else{if(selected[id]==1){delete selected[id];at(disc,false);sum-=point;}else{selected[id]-=1;}}});var tp=Number($("#totalPt").text());$("#totalPt").text(tp+sum);$("#mydeck strong").text($("#comboList input:checked").length);if($("#mydeck input#save").attr("checked"))save(val);};var mydeck=function(f){$("#comboList input:checked").each(function(){if(f){var p=$(this).parents("tr:first");var btn="<button id='b"+this.value+"'>削除</button>";var e=$(this).parents("div:first").children("h2").attr("title");if($(".detail",p).length)e+="("+$(".detail",p).text()+")";var cn=$(".cn",p).text();var pt=$(".pt",p).text();var card=new Array();var i=1;$("span",p).each(function(){var c=$(this).parent().attr("class");card[i]="<td class='"+c+"'>"+$(this).parent().clone().html()+"</td>";i++;});if(!card[3])card[3]="<td>&nbsp;</td>";$("#mydeck table").append("<tr><td class='effect'>"+e+"</td><td>"+cn+"</td><td class='pt'>"+pt+"</td>"+card[1]+card[2]+card[3]+"<td>"+btn+"</td></tr>");$("#mydeck a").cluetip();}else{$("#mydeck tr:gt(0)").remove();}});};var cb=($.cookie('deck1'))?$.cookie('deck1').split(","):new Array();var save=function(n){if(n){if($("#comboList input[value='"+n+"']").attr("checked")){cb.push(n);}else{(function(v){for(var i=0;i<this.length;i++)if(this[i]==v)this.splice(i--,1);}).call(cb,n);}}else{cb=new Array();$("#comboList input:checked").each(function(){cb.push($(this).val());});}
$.cookie('deck1',cb);};$("#comboList div").hide();$("#comboList a").cluetip();$(function(){$("#comboList input:checked").attr("checked",false);if(cb.length){for(var i in cb){$("#comboList input[value='"+cb[i]+"']").attr("checked",true);}
$("#mydeck input#save").attr("checked",true).parent().addClass("selected");cb=new Array();}else{$("#mydeck input:cheked").attr("checked",false);}
$("#comboList input:checked").each(function(){check(this.value);});var c="selected";var startTab=($("#comboList input:checked").length)?"mydeck":"toggle";$("#tab li#tab_"+startTab).addClass(c);if(startTab=="mydeck")mydeck(true);$("#panel li:not(#"+startTab+")").hide();$("#tab li").click(function(){$("#tab li").removeClass(c);$(this).addClass(c);$("#panel li").hide();$("#panel li:eq("+$("#tab li").index(this)+")").show();if($(this).is("#tab_mydeck")){mydeck(true);$("#comboList").hide();}
else{mydeck(false);$("#comboList").show();}});});$(window).scroll(function(){var outer=$("#contents").offset();var scrollTop=document.body.scrollTop||document.documentElement.scrollTop;var move=(outer.top<scrollTop)?scrollTop-outer.top:0;$("#ptTbl").css("margin-top",move+"px");});$("#comboList input:checkbox").click(function(){check(this.value);}).parent().mouseover(function(){$(this).addClass("hover");}).mouseout(function(){$(this).removeClass("hover");});$("#mydeck button").live("click",function(){var val=this.id.slice(1);$("#comboList input[value='"+val+"']").attr("checked",false);check(val);$(this).parents("tr:first").remove();});$("#toggle button").mouseover(function(){$(this).addClass("hover");}).mouseout(function(){$(this).removeClass("hover");}).click(function(){$(this).blur();$("#comboList div").hide();var c="selected";var p=$(this.parentNode);var pp=$(this.parentNode.parentNode);if(p.get(0).tagName=="DT"){var y=pp.find("button");($(this).hasClass(c))?y.removeClass(c):y.addClass(c);}else{$(this).toggleClass(c);var e=pp.find("button:first");(pp.find("button[id^=t-]").length==pp.find("dd button.selected").length)?e.addClass(c):e.removeClass(c);}
var lv3=$("dt.lv3 button");var lv2=$("dt.lv2 button");(lv3.length==lv3.filter("."+c).length)?lv2.filter(":first").addClass(c):lv2.filter(":first").removeClass(c);(lv2.length==lv2.filter("."+c).length)?$("#all").addClass(c):$("#all").removeClass(c);$("button[id^=t-].selected").each(function(){$("#c-"+this.id.substring(2)).show();});});$("#mydeck input#save").click(function(){$(this).parent().toggleClass("selected");(this.checked)?save():$.cookie('deck1',null);});});jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};(function($){var $cluetip,$cluetipInner,$cluetipOuter,$cluetipTitle,$cluetipArrows,imgCount;$.fn.cluetip=function(js,options){if(typeof js=='object'){options=js;js=null;}
return this.each(function(index){var $this=$(this);var opts=$.extend(true,{},$.fn.cluetip.defaults,options||{},$.metadata?$this.metadata():$.meta?$this.data():{});var cluetipContents=false;var cluezIndex=parseInt(opts.cluezIndex,10)-1;var isActive=false,closeOnDelay=0;if(!$('#cluetip').length){$cluetipInner=$('<div id="cluetip-inner"></div>');$cluetipTitle=$('<h3 id="cluetip-title"></h3>');$cluetipOuter=$('<div id="cluetip-outer"></div>').append($cluetipInner).prepend($cluetipTitle);$cluetip=$('<div id="cluetip"></div>').css({zIndex:opts.cluezIndex}).append($cluetipOuter).append('<div id="cluetip-extra"></div>')[insertionType](insertionElement).hide();$('<div id="cluetip-waitimage"></div>').css({position:'absolute',zIndex:cluezIndex-1}).insertBefore('#cluetip').hide();$cluetip.css({position:'absolute',zIndex:cluezIndex});$cluetipOuter.css({position:'relative',zIndex:cluezIndex+1});$cluetipArrows=$('<div id="cluetip-arrows" class="cluetip-arrows"></div>').css({zIndex:cluezIndex+1}).appendTo('#cluetip');}
var tipAttribute=$this.attr(opts.attribute),ctClass=opts.cluetipClass;if(!tipAttribute&&!opts.splitTitle&&!js)return true;if(opts.local&&opts.localPrefix){tipAttribute=opts.localPrefix+tipAttribute;}
if(opts.local&&opts.hideLocal){$(tipAttribute+':first').hide();}
var tOffset=parseInt(opts.topOffset,10),lOffset=parseInt(opts.leftOffset,10);var tipHeight,wHeight;var defHeight=isNaN(parseInt(opts.height,10))?'auto':(/\D/g).test(opts.height)?opts.height:opts.height+'px';var sTop,linkTop,posY,tipY,mouseY,baseline;var tipInnerWidth=isNaN(parseInt(opts.width,10))?'auto':parseInt(opts.width,10);var tipWidth=tipInnerWidth+(parseInt($cluetip.css('paddingLeft'),10)||0)+(parseInt($cluetip.css('paddingRight'),10)||0);var linkWidth=this.offsetWidth;var linkLeft,posX,tipX,mouseX,winWidth;var tipParts;var tipTitle=$this.text();var localContent;var activate=function(event){if(!opts.onActivate($this)){return false;}
isActive=true;$cluetip.removeClass().css({width:tipInnerWidth});$this.attr('title','');if(opts.hoverClass){$this.addClass(opts.hoverClass);}
linkTop=posY=$this.offset().top;linkLeft=$this.offset().left;mouseX=event.pageX;mouseY=event.pageY;if($this[0].tagName.toLowerCase()!='area'){sTop=$(document).scrollTop();winWidth=$(window).width();}
if(opts.positionBy=='fixed'){posX=linkWidth+linkLeft+lOffset;$cluetip.css({left:posX});}else{posX=(linkWidth>linkLeft&&linkLeft>tipWidth)||linkLeft+linkWidth+tipWidth+lOffset>winWidth?linkLeft-tipWidth-lOffset:linkWidth+linkLeft+lOffset;if($this[0].tagName.toLowerCase()=='area'||opts.positionBy=='mouse'||linkWidth+tipWidth>winWidth){if(mouseX+20+tipWidth>winWidth){$cluetip.addClass(' cluetip-'+ctClass);posX=(mouseX-tipWidth-lOffset)>=0?mouseX-tipWidth-lOffset-parseInt($cluetip.css('marginLeft'),10)+parseInt($cluetipInner.css('marginRight'),10):mouseX-(tipWidth/2);}else{posX=mouseX+lOffset;}}
var pY=posX<0?event.pageY+tOffset:event.pageY;$cluetip.css({left:(posX>0&&opts.positionBy!='bottomTop')?posX:(mouseX+(tipWidth/2)>winWidth)?winWidth/2-tipWidth/2:Math.max(mouseX-(tipWidth/2),0)});}
wHeight=$(window).height();if(js){if(typeof js=='function'){js=js($this[0]);}
$cluetipInner.html(js);cluetipShow(pY);}
else if(tipParts){var tpl=tipParts.length;$cluetipInner.empty();for(var i=0;i<tpl;i++){if(i==0){$cluetipInner.html(tipParts[i]);}else{$cluetipInner.append('<div class="split-body">'+tipParts[i]+'</div>');}};cluetipShow(pY);}
else if(!opts.local&&tipAttribute.indexOf('#')!=0){if(/\.(jpe?g|tiff?|gif|png)$/i.test(tipAttribute)){$cluetipInner.html('<img src="'+tipAttribute+'" alt="'+tipTitle+'" />');cluetipShow(pY);}else if(cluetipContents&&opts.ajaxCache){$cluetipInner.html(cluetipContents);cluetipShow(pY);}else{var ajaxSettings=opts.ajaxSettings;ajaxSettings.cache=false;ajaxSettings.url=tipAttribute;ajaxSettings.beforeSend=function(){$cluetipOuter.children().empty();if(opts.waitImage){$('#cluetip-waitimage').css({top:mouseY+20,left:mouseX+20}).show();}};ajaxSettings.error=function(){if(isActive){$cluetipInner.html('情報を取得できませんでした。');}};ajaxSettings.success=function(data){cluetipContents=opts.ajaxProcess(data);if(isActive){$cluetipInner.html(cluetipContents);}};ajaxSettings.complete=function(){imgCount=$('#cluetip-inner img').length;if(imgCount&&!$.browser.opera){$('#cluetip-inner img').load(function(){imgCount--;if(imgCount<1){$('#cluetip-waitimage').hide();if(isActive)cluetipShow(pY);}});}else{$('#cluetip-waitimage').hide();if(isActive)cluetipShow(pY);}};$.ajax(ajaxSettings);}}else if(opts.local){var $localContent=$(tipAttribute+(/#\w+$/.test(tipAttribute)?'':':eq('+index+')')).clone(true).show();$cluetipInner.html($localContent);cluetipShow(pY);}};var cluetipShow=function(bpY){$cluetip.addClass('cluetip-'+ctClass);if(opts.truncate){var $truncloaded=$cluetipInner.text().slice(0,opts.truncate)+'...';$cluetipInner.html($truncloaded);}
function doNothing(){};tipTitle?$cluetipTitle.show().html(tipTitle):(opts.showTitle)?$cluetipTitle.show().html('&nbsp;'):$cluetipTitle.hide();if(opts.sticky){var $closeLink=$('<div id="cluetip-close"><a href="#">'+opts.closeText+'</a></div>');(opts.closePosition=='bottom')?$closeLink.appendTo($cluetipInner):(opts.closePosition=='title')?$closeLink.prependTo($cluetipTitle):$closeLink.prependTo($cluetipInner);$closeLink.click(function(){cluetipClose();return false;});if(opts.mouseOutClose){if($.fn.hoverIntent&&opts.hoverIntent){$cluetip.hoverIntent({over:doNothing,timeout:opts.hoverIntent.timeout,out:function(){$closeLink.trigger('click');}});}else{$cluetip.hover(doNothing,function(){$closeLink.trigger('click');});}}else{$cluetip.unbind('mouseout');}}
var direction='';$cluetipOuter.css({overflow:defHeight=='auto'?'visible':'auto',height:defHeight});tipHeight=defHeight=='auto'?Math.max($cluetip.outerHeight(),$cluetip.height()):parseInt(defHeight,10);tipY=posY;baseline=sTop+wHeight;if(opts.positionBy=='fixed'){tipY=posY+tOffset;}else if((posX<mouseX&&Math.max(posX,0)+tipWidth>mouseX)||opts.positionBy=='bottomTop'){if(posY+tipHeight+tOffset>baseline&&mouseY-sTop>tipHeight+tOffset){tipY=mouseY-tipHeight-tOffset;direction='top';}else{tipY=mouseY+tOffset;direction='bottom';}}else if(posY+tipHeight+tOffset>baseline){tipY=(tipHeight>=wHeight)?sTop:baseline-tipHeight-tOffset;}else if($this.css('display')=='block'||$this[0].tagName.toLowerCase()=='area'||opts.positionBy=="mouse"){tipY=bpY-tOffset;}else{tipY=posY;}
if(direction==''){posX<linkLeft?direction='left':direction='right';}
$cluetip.css({top:tipY+'px'}).removeClass().addClass('clue-'+direction+'-'+ctClass).addClass(' cluetip-'+ctClass);if(opts.arrows){var bgY=(posY-tipY);$cluetipArrows.css({top:(/(left|right)/.test(direction)&&posX>=0&&bgY>0)?bgY+'px':/(left|right)/.test(direction)?0:''}).show();}else{$cluetipArrows.hide();}
$cluetip.hide()[opts.fx.open](opts.fx.open!='show'&&opts.fx.openSpeed);if($.fn.bgiframe){$cluetip.bgiframe();}
if(opts.delayedClose>0){closeOnDelay=setTimeout(cluetipClose,opts.delayedClose);}
opts.onShow($cluetip,$cluetipInner);};var inactivate=function(event){isActive=false;$('#cluetip-waitimage').hide();if(!opts.sticky||(/click|toggle/).test(opts.activation)){cluetipClose();clearTimeout(closeOnDelay);};if(opts.hoverClass){$this.removeClass(opts.hoverClass);}};var cluetipClose=function(){$cluetipOuter.parent().hide().removeClass();opts.onHide($cluetip,$cluetipInner);$this.removeClass('cluetip-clicked');if(tipTitle){$this.attr(opts.titleAttribute,tipTitle);}
if(opts.arrows)$cluetipArrows.css({top:''});};if((/click|toggle/).test(opts.activation)){$this.click(function(event){if($cluetip.is(':hidden')||!$this.is('.cluetip-clicked')){activate(event);$('.cluetip-clicked').removeClass('cluetip-clicked');$this.addClass('cluetip-clicked');}else{inactivate(event);}
this.blur();return false;});}else if(opts.activation=='focus'){$this.focus(function(event){activate(event);});$this.blur(function(event){inactivate(event);});}else{$this.click(function(){if($this.attr('href')&&$this.attr('href')==tipAttribute&&!opts.clickThrough){return false;}});var mouseTracks=function(evt){if(opts.tracking==true){var trackX=posX-evt.pageX;var trackY=tipY?tipY-evt.pageY:posY-evt.pageY;$this.mousemove(function(evt){$cluetip.css({left:evt.pageX+trackX,top:evt.pageY+trackY});});}};if($.fn.hoverIntent&&opts.hoverIntent){$this.mouseover(function(){$this.attr('title','');}).hoverIntent({sensitivity:opts.hoverIntent.sensitivity,interval:opts.hoverIntent.interval,over:function(event){activate(event);mouseTracks(event);},timeout:opts.hoverIntent.timeout,out:function(event){inactivate(event);$this.unbind('mousemove');}});}else{$this.hover(function(event){activate(event);mouseTracks(event);},function(event){inactivate(event);$this.unbind('mousemove');});}}});};$.fn.cluetip.defaults={width:'auto',height:'auto',cluezIndex:97,positionBy:'mouse',topOffset:15,leftOffset:15,local:false,localPrefix:null,hideLocal:true,attribute:'href',titleAttribute:'title',splitTitle:'',escapeTitle:false,showTitle:true,cluetipClass:'default',hoverClass:'',waitImage:true,arrows:true,sticky:true,mouseOutClose:false,activation:'click',clickThrough:false,tracking:false,delayedClose:0,closePosition:'bottom',closeText:'<img src="images/close.gif" />',truncate:0,fx:{open:'show',openSpeed:''},hoverIntent:{sensitivity:3,interval:50,timeout:0},onActivate:function(e){return true;},onShow:function(ct,c){},onHide:function(ct,c){},ajaxCache:true,ajaxProcess:function(data){data=data.replace(/<s(cript|tyle)(.|\s)*?\/s(cript|tyle)>/g,'').replace(/<(link|title)(.|\s)*?\/(link|title)>/g,'');return data;},ajaxSettings:{dataType:'html'},debug:false};var insertionType='appendTo',insertionElement='body';$.cluetip={};$.cluetip.setup=function(options){if(options&&options.insertionType&&(options.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)){insertionType=options.insertionType;}
if(options&&options.insertionElement){insertionElement=options.insertionElement;}};})(jQuery);