$.extend({ifm:{webapi:{uri:{scheme:"http://",host:"api1.interfirm.co.jp"},result:{},conf:{},url:function(){if(this.conf.table)this.conf.path=this.conf.id?"/"+this.conf.table+"/"+this.conf.id+".json":"/"+this.conf.table+".json";return this.uri.scheme+this.uri.host+this.conf.path},reset:function(a){var b=$("#"+a.id);b.setDisabled();switch(a.type){case "select":case "zip_pref":case "zip_city":case "zip_town":b.empty().append($("<option />").val("").append(a.text))}},find:function(a){this.conf=a;this.conf.target&&
($("#spinner_"+this.conf.target.id).show(),this.reset(this.conf.target));$.ajax({type:"GET",dataType:"jsonp",url:this.url(),data:this.conf.params,success:function(a){if($.ifm.webapi.conf.success)$.ifm.webapi.conf.success(a.ResultSet.Result);else if($.ifm.webapi.result=a.ResultSet.Result,$.ifm.webapi.conf.target){var c=$("#"+$.ifm.webapi.conf.target.id);switch($.ifm.webapi.conf.target.type){case "select":$.each($.ifm.webapi.result,function(a,b){c.append($("<option />").val(b.id).append(b.name))});
break;case "zip_pref":$.each($.ifm.webapi.result,function(a,b){c.append($("<option />").val(b.name).append(b.name))});break;case "zip_city":$.each($.ifm.webapi.result,function(a,b){c.append($("<option />").val(b.city).append(b.city))});break;case "zip_town":$.each($.ifm.webapi.result,function(a,b){c.append($("<option />").val(b.town).append(b.town))})}if($.ifm.webapi.conf.target.selected)switch($.ifm.webapi.conf.target.type){case "select":case "zip_pref":case "zip_city":case "zip_town":c.val($.ifm.webapi.conf.target.selected)}$("#spinner_"+
$.ifm.webapi.conf.target.id).fadeOut("slow");c.setEnabled()}},error:function(){$.ifm.webapi.conf.error&&$.ifm.webapi.conf.error()},complete:function(){$.ifm.webapi.conf.complete&&$.ifm.webapi.conf.complete()}})}},enquete:function(a){a.iwidth=a.iwidth||"260px";a.iheight=a.iheight||"140px";a.color=a.color||"transparent";a.width=a.width||"250px";a.height=a.height||"140px";a.cols=a.cols||"30";a.rows=a.rows||"10";$("#enquetes").append($("<iframe />").attr("src",this.webapi.uri.scheme+this.webapi.uri.host+
"/enquetes/new?url="+a.url+"&width="+a.width+"&height="+a.height+"&cols="+a.cols+"&rows="+a.rows).attr("frameborder","none").attr("scrolling","no").attr("allowtransparency","true").css({border:"none",width:a.iwidth,height:a.iheight,"background-color":a.color}))}},preloadImages:function(){for(var a=0;a<arguments.length;a++)$("<img />").attr("src",arguments[a])},externalLinks:function(a){a?$("a[rel="+a+"]").attr("target","_blank"):($('a[href^="http://"]').attr("target","_blank"),$('a[href^="https://"]').attr("target",
"_blank"))},appendScript:function(a){var b=document.createElement("script");b.type="text/javascript";b.charset="utf-8";b.src=a;b.async=!0;a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(b,a)},disableEnter2Submit:function(){$(":text").bind("keypress",function(a){a.keyCode==13&&a.preventDefault()})},numberFormat:function(a){return a.toString().replace(/([\d]+?)(?=(?:\d{3})+$)/g,function(a){return a+","})},sprintf:function(){var a={i:32785,d:32785,u:32801,o:33121,x:33377,X:37473,
f:146,c:10240,s:132},b=/%(?:(\d+)\$)?(#|0)?(\d+)?(?:\.(\d+))?(l)?([%iduoxXfcs])/g;window.sprintf=function(c){var e=1,f=0,k=arguments;return c.replace(b,function(b,c,g,i,j,d,h){if(h==="%")return"%";var b="",d=a[h],l;f=c?parseInt(c):e++;d&1024||(b=k[f]===void 0?"":k[f]);d&3&&(b=d&1?parseInt(b):parseFloat(b),b=isNaN(b)?"":b);d&4&&(b=((h==="s"?b:h)||"").toString());d&32&&(b=b>=0?b:b%4294967296+4294967296);d&768&&(b=b.toString(d&256?8:16));d&64&&g==="#"&&(b=(d&256?"0":"0x")+b);d&128&&j&&(b=d&2?b.toFixed(j):
b.slice(0,j));d&24576&&(l=typeof b!=="number"||b<0);d&8192&&(b=l?"":String.fromCharCode(b));d&32768&&(g=g==="0"?"":g);b=d&4096?b.toString().toUpperCase():b.toString();d&2048||i===void 0||b.length>=i||(c=Array(i-b.length+1).join(!g?" ":g==="#"?" ":g),b=d&16&&g==="0"&&!b.indexOf("-")?"-"+c+b.slice(1):c+b);return b})}},fascii2ascii:function(a){var b="["+String.fromCharCode(65281)+"-"+String.fromCharCode(65374)+"]";return a.replace(RegExp(b,"g"),function(a){return String.fromCharCode(a.charCodeAt(0)-
65248)})},mysqlTimeStampToDate:function(a){a=a.replace(/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/,"$1 $2 $3 $4 $5 $6").split(" ");return new Date(a[0],a[1]-1,a[2],a[3],a[4],a[5])},diffDate:function(a,b){var c="",e={d:"",h:"",m:"",s:""},f=new Date-a;e.d=parseInt(f/864E5);e.h=parseInt(f%864E5/36E5);e.m=parseInt(f%864E5%36E5/6E4);e.s=parseInt(f%864E5%36E5%6E4/1E3);if(e.d&&(c+=e.d+"\u65e5",!b))return c+="\u524d",c;e.h&&(c+=e.h+"\u6642\u9593");e.m&&(c+=e.m+"\u5206");
b&&e.s&&(c+=e.s+"\u79d2");c==""&&(c+="0\u5206");c+="\u524d";return c}});
(function(a){a.fn.extend({rollover:function(){a(this).hover(function(){a(this).attr("src",a(this).attr("src").replace(/^(.+)(\.[a-z]+)(\u00a5?.+)$/,"$1_on$2$3")).css("cursor","pointer")},function(){a(this).attr("src",a(this).attr("src").replace(/^(.+)_on(\.[a-z]+)(\u00a5?.+)$/,"$1$2$3")).css("cursor","default")}).each(function(){a("<img>").attr("src",a(this).attr("src").replace(/^(.+)(\.[a-z]+)(\u00a5?.+)$/,"$1_on$2$3"))});return this},goTop:function(){a(this).click(function(b){a("html,body").animate({scrollTop:0},
"slow");b.preventDefault()});return this},stripe:function(b){a(this).filter(":even").addClass("even").end().filter(":odd").addClass("odd");b&&a(this).filter(":even").css("background-color",b.even).end().filter(":odd").css("background-color",b.odd);return this},setDisabled:function(){a(this).attr("disabled","disabled");return this},setEnabled:function(){a(this).removeAttr("disabled");return this},socialBookmarks:function(b){a(this).css({overflow:"hidden",margin:0}).append(a("<ul />"));var c=a(this).find("ul"),
b={facebook:{tag:'<div id="fb-root"></div><fb:like href="" layout="button_count" width="110" show_faces="true" font="" style="width:110;overflow:hidden;"></fb:like>',script:"http://connect.facebook.net/ja_JP/all.js#xfbml=1"},twitter:{tag:a("<a />").attr({src:"http://twitter.com/share","data-count":"horizontal","data-lang":"ja"}).addClass("twitter-share-button").append("Tweet"),script:"http://platform.twitter.com/widgets.js"},hatena:{tag:a("<a />").attr({href:"http://b.hatena.ne.jp/entry/http://"+
location.host,title:"\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0","data-hatena-bookmark-layout":"standard"}).addClass("hatena-bookmark-button"),script:"http://b.st-hatena.com/js/bookmark_button.js"},plusone:{tag:'<g:plusone size="medium"></g:plusone>',script:"http://apis.google.com/js/plusone.js"},mixi:{tag:a("<a />").attr({href:"http://mixi.jp/share.pl","data-key":b.mixi.key,"data-button":"button-1"}).addClass("mixi-check-button").append("mixi\u30c1\u30a7\u30c3\u30af"),
script:"http://static.mixi.jp/js/share.js"},gree:{tag:'<iframe src="http://share.gree.jp/share?url='+location.host+'&type=0&height=20" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" style="border:none; overflow:hidden; width:80px; height:20px;" allowTransparency="true"></iframe>',script:""},tumblr:{tag:'<a href="http://www.tumblr.com/share" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:62px; height:20px; background:url(\'http://platform.tumblr.com/v1/share_2.png\') top left no-repeat transparent;">Share on Tumblr</a>',
script:"http://platform.tumblr.com/v1/share.js"}};a.support.opacity||delete b.facebook;a.each(b,function(){this.tag&&c.append(a("<li />").append(this.tag));this.script&&a.appendScript(this.script)});c.css({margin:"0px",padding:"0px"}).find("li").css({display:"inline","vertical-align":"middle",margin:"0px",padding:"0px","list-style":"none","line-height":"30px"});return this}})})(jQuery);

