String.prototype.width=function()
{var cArr=this.match(/[^\x00-\xff]/ig);return this.length+(cArr==null?0:cArr.length);};String.prototype.cutByWidth=function(len)
{for(var i=0;i<this.length;++i)
{var strCut=this.substring(0,i);if(strCut.width()>len)
return this.substring(0,i-1);else if(strCut.width()==len)
return strCut;}
return this;};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"").replace(/^[　]+|[　]+$/,"");};String.prototype.ltrim=function(){return this.replace(/^\s+/,"").replace(/^[　]+/,"");};String.prototype.rtrim=function(){return this.replace(/\s+$/,"").replace(/[　]+$/,"");};(function($){$.fn.extend({offsetParent:function()
{var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&$.css(offsetParent,'position')=='static'))
offsetParent=offsetParent.offsetParent;if(offsetParent&&offsetParent.tagName.toUpperCase()=='HTML')
offsetParent=document.body;return $(offsetParent);},txt:$.browser.msie?function(){return this.get(0).innerText;}:function(){return this.get(0).textContent;},enable:function()
{return this.attr('disabled','');},disable:function()
{return this.attr('disabled','disabled');},caretPosition:$.browser.msie?function(ps,len)
{var val=$(this).focus().val();if(typeof(ps)=='undefined')
{var sel=document.selection.createRange();var len=sel.text.length;sel.moveStart('character',-val.length);return{start:sel.text.length-len,end:sel.text.length};}
else
{var sel=$(this).get(0).createTextRange();sel.moveStart('character',-val.length);sel.moveEnd('character',-val.length);sel.moveStart('character',ps);if(typeof(len)=='undefined')
sel.moveEnd('character',0);else
sel.moveEnd('character',len);sel.select();}}:function(ps,len)
{var ta=$(this).focus().get(0);if(typeof(ps)=='undefined')
{if(ta.selectionStart||ta.selectionStart=='0')
return{start:ta.selectionStart,end:ta.selectionEnd};return{start:0,end:0};}
else
{ta.selectionStart=ps;if(typeof(len)=='undefined')
ta.selectionEnd=ps;else
ta.selectionEnd=ps+len;}},caretOffset:$.browser.msie?function()
{var os=document.selection.createRange();return{left:os.offsetLeft,top:os.offsetTop};}:function()
{var ta=$(this).get(0);var os=$(this).offset();var div=document.createElement('div');div.className=ta.className;var style=document.defaultView.getComputedStyle(ta,null);for(i in style)
{if(isNaN(parseInt(i)))
{try{var val=style[i];if(val.length)
div.style[i]=val;}catch(e){}}}
div.style.position='absolute';div.style.zIndex='-10px';div.textContent=ta.value;div.scrollLeft=ta.scrollLeft;div.scrollTop=ta.scrollTop;ta.parentNode.appendChild(div);var span=document.createElement('span');var r=document.createRange();var ret=null;if(div.firstChild)
{r.setStart(div.firstChild,ta.selectionStart);r.setEnd(div.firstChild,ta.selectionStart);r.surroundContents(span);span.textContent=' ';ret={left:span.offsetLeft-div.scrollLeft+parseInt(div.style.borderWidth),top:span.offsetTop-div.scrollTop+parseInt(div.style.borderWidth)};}
else
{span.textContent=' ';div.appendChild(span);ret={left:span.offsetLeft+parseInt(div.style.borderWidth),top:span.offsetTop+parseInt(div.style.borderWidth)};}
ta.parentNode.removeChild(div);return ret;},shine:function(opt)
{opt=$.extend({start:1,time:300,cb:null},opt);var jq=this;var dom=jq.get(0);if(opt.start)
{var c=0;function onShineTimer()
{if(null!=opt.cb)
{opt.cb(jq,++c);}}
if(typeof(jq.dom)=='undefined')
jq.shine({start:0});dom.shineTimer=setInterval(onShineTimer,opt.time);dom.shineCb=opt.cb;}
else
{if(dom.shineTimer)
{clearInterval(dom.shineTimer);if(null!=dom.shineCb)
dom.shineCb(jq,-1);}}},layerReset:function(opt)
{opt=$.extend({x:1,y:1,vr:$.viewRect(),w:this.width(),h:this.height()},opt);var dt=opt.vr.t;var l=parseInt(this.css('left'))|0;var t=parseInt(this.css('top'))|0;var ml=parseInt(this.css('marginLeft'))|0;var bl=$.toInt(this.css('borderLeft'))|0;var pl=parseInt(this.css('paddingLeft'))|0;if(isNaN(pl))pl=0;var vr=opt.vr;if(opt.y)
{if(vr.h>opt.h)
{this.css('top',dt+parseInt((vr.h-opt.h)/3)).trigger('move');}
else
{this.css('top',dt).trigger('move');}}
if(opt.x)
{if(vr.w>opt.w)
{this.css('left',parseInt((vr.w-opt.w)/2)-ml-bl-pl).trigger('move');}
else
{this.css('left',parseInt((vr.w-opt.w)/2)-ml-bl-pl).trigger('move');}}
return this;},layerAutoReset:function(opt)
{var div=this.get(0);opt=$.extend({auto:true,x:1,y:1},opt);if(opt.auto)
{$(window).bind('resize',onWinResize).bind('scroll',onWinScroll);}
else
{$(window).unbind('resize',onWinResize).unbind('scroll',onWinScroll);}
function onWinResize()
{if(div.style.display=='none')
return;$(div).layerReset({x:opt.x,y:opt.y});};function onWinScroll()
{if(div.style.display=='none')
return;var vr=$.viewRect();if(opt.y)
{var h=$(div).height();if(vr.h>h)
$(div).layerReset({x:opt.x,y:opt.y,'vr':vr,'h':h});}
else if(opt.x)
{var w=$(div).width();if(vr.w>w)
$(div).layerReset({x:opt.x,y:opt.y,'vr':vr,'w':w});}};return this;},layerShow:function(s)
{var o=$(this);if(typeof(s)=='undefined')return o.show().trigger('show');else return o.fadeIn(s,function(){o.trigger('show')});},layerHide:function(s)
{var o=$(this);if(typeof(s)=='undefined')return o.hide().trigger('hide');else return o.fadeOut(s,function(){o.trigger('hide')});},drag:function(opt)
{opt=$.extend({handle:this,bg:true,bound:true},opt);var dlg=this.get(0);var dt={};$(opt.handle).bind('mousedown',mousedown);function mousedown(event)
{var e=event;var z=$(dlg).css('zIndex');if(!z)z=0;var nz=z>1000?z:1000;$(dlg).css('zIndex',nz);$(dlg).trigger('zchange',[nz]);var x=e.clientX!=undefined?e.clientX:e.pageX;var y=e.clientY!=undefined?e.clientY:e.pageY;dt=$.extend(dt,{'x':x,'y':y,'z':z});var rect=$.viewRect();dt=$.extend(dt,{'viewRect':rect});if(e.preventDefault)e.preventDefault();$(document).bind('mousemove',mousemove).bind('mouseup',mouseup).bind('selectstart',selectstart);};function mouseup(event)
{var e=event;$(document).unbind('mousemove',mousemove).unbind('mouseup',mouseup).unbind('selectstart',selectstart);$(dlg).css('zIndex',dt.z);$(dlg).trigger('zchange',[dt.z]);};function mousemove(event)
{var e=event;var oldl=parseInt($(dlg).css('left'))|0;var oldt=parseInt($(dlg).css('top'))|0;var x=e.clientX!=undefined?e.clientX:e.pageX;var y=e.clientY!=undefined?e.clientY:e.pageY;var nl=oldl+x-dt.x,nt=oldt+y-dt.y;var rect=dt.viewRect;if(opt.bound)
{var canx=(nl>=rect.l)&&(nl+$(dlg).width()<rect.l+rect.w-25);var cany=(nt>=rect.t)&&(nt+$(dlg).height()<rect.t+rect.h-25);}
else
{var canx=1,cany=1;}
if(canx)
{if(cany)
{$(dlg).css('left',nl).css('top',nt);dt=$.extend(dt,{'x':x,'y':y});$(dlg).trigger('move');}
else
{$(dlg).css('left',nl);dt=$.extend(dt,{'x':x});$(dlg).trigger('move');}}
else
{if(cany)
{$(dlg).css('top',nt);dt=$.extend(dt,{'y':y});$(dlg).trigger('move');}}};function selectstart(){return false;};return this;},blurHide:function(opt)
{opt=$.extend({handle:null},opt);var div=this;var clickDiv=0,clickHandle=0;div.bind('click',function()
{clickDiv=1;});$(document).bind('click',function()
{if(!clickDiv&&!clickHandle)
div.layerHide();clickDiv=0;clickHandle=0;});if(opt.handle)
{opt.handle.bind('click',function()
{clickHandle=1;div.layerShow();});}
return this;},mouseOutHide:function(opt)
{opt=$.extend({handle:null},opt);var div=this;var all=div.add(opt.handle);var tm,out=1;all.bind('mouseover',function()
{if(tm)
clearTimeout(tm);out=0;div.layerShow();}).bind('mouseout',function()
{out=1;tm=setTimeout(function()
{if(out)
div.layerHide();},250);});},modal:function(opt)
{if($.browser.safari)
return this;opt=$.extend({alpha:0.7,color:'#111111'},opt);var div=this.get(0);if(div&&typeof(div.modalBg)=='undefined')
{var nz=parseInt($(div).css('zIndex'));if(isNaN(nz))nz=0;if(!$(div).css('zIndex')||$(div).css('zIndex')=='auto')
$(div).css('zIndex',nz);div.modalBg=$('<div></div>');div.modalBg.attr('unselectable','true').css('float','left').css('display',$(div).css('display')).css('position','absolute').css('left',0).css('top',0).css('zIndex',nz-1).css('backgroundColor',opt.color);if($.browser.msie)
div.modalBg.attr('unselectable','true').css('filter','progid:DXImageTransform.Microsoft.Alpha(style=0,opacity='+parseInt(opt.alpha*100)+')');else
div.modalBg.css('opacity',opt.alpha);$('body').append(div.modalBg);$(div).bind('zchange',divzchange).bind('show',divshow).bind('hide',divhide);$(window).bind('resize',winresize);$(document).bind('resize',winresize);if($.browser.msie&&$(document).height()>8000)
$(window).bind('scroll',winscroll);winresize();}
function divshow(event)
{div.modalBg.show();};function divhide(event)
{div.modalBg.hide();};function divzchange(event,z)
{div.modalBg.css('zIndex',z-2);};function winresize()
{var vr=$.viewRect();if($.browser.msie&&$(document).height()>8000)
{var h=vr.h;div.modalBg.height(h+4000);div.modalBg.width(vr.w);winscroll();}
else
{var maxH=Math.max(document.body.clientHeight,vr.h);div.modalBg.height(maxH);div.modalBg.width(vr.w);}};function winscroll()
{div.modalBg.css('top',$(document).scrollTop()-2000);};return this;},shadow:function(opt)
{opt=$.extend({alpha:0.55,color:'#000000'},opt);var div=this.get(0);var jdiv=$(div);if(div&&typeof(div.shadow)=='undefined')
{div.shadow=$('<div style="width:100%;height:100%;position:absolute;left:5px;top:5px;z-index:-1;background-color:black;opacity:'+opt.alpha+';filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity='+(opt.alpha*100)+')"></div>');jdiv.prepend(div.shadow);if($.browser.msie&&$.browser.version=='6.0')
{$(div).bind('resize',function()
{div.shadow.css('width',jdiv.width());div.shadow.css('height',jdiv.height());}).trigger('resize');}}
return this;},appendValues:function(data)
{var area=$(this);for(var item in data)
{area.append($('<textarea name="'+item+'"></textarea>').val(data[item]));}
return area;},removeValues:function(data)
{var area=$(this);for(var item in data)
{area.find('[name='+item+']').remove();}
return area;}});$.extend({toHTML:function(t){return $('<div></div>').text(t).html();},toText:function(h){return $('<div></div>').html(h).txt();},toInt:function(s)
{if(s==undefined)
return NaN;var i=s.search(/\d+/);return(-1==i)?NaN:parseInt(s.substring(i));},viewRect:function(wnd)
{var wnd=wnd||window;var doc=wnd.document;return{l:$(document).scrollLeft(),t:$(document).scrollTop(),w:doc.documentElement.clientWidth||doc.body.clientWidth||wnd.innerWidth||doc.width||0,h:doc.documentElement.clientHeight||doc.body.clientHeight||wnd.innerHeight||doc.height||0};},dbgWin:0,dbgInit:function(opt)
{if($.dbgDiv)return;opt=$.extend({w:350,h:500,l:0,t:0,z:10000,color:'white',bgColor:'black'},opt);$.dbgWin=$('<div><div></div><div></div></div>').css('fontSize','12px').css('left',opt.l).css('top',opt.t).css('zIndex',opt.z).css('position','absolute');$.dbgTit=$.dbgWin.find('div').eq(0);$.dbgCon=$.dbgWin.find('div').eq(1);$('body').append($.dbgWin);$.dbgTit.width(opt.w).height(16).css('cursor','move').css('backgroundColor','blue').css('color','white').text('-debug');$.dbgCon.css('width',opt.w).css('height',opt.h).css('color',opt.color).css('backgroundColor',opt.bgColor).css('overflow','auto');$.dbgWin.drag({handle:$.dbgTit,bg:false}).layerAutoReset({x:0}).layerReset({x:0});},dbg:function(s)
{if($.dbgWin==0)
$.dbgInit();if(undefined==s)s='undefined';if(null==s)s='null';if(!s.toString)
s='object'
$.dbgCon.append($.toHTML(s.toString()));$.dbgCon.get(0).scrollHeight;$.dbgCon.get(0).scrollTop=$.dbgCon.get(0).scrollHeight;},dbgln:function(s){$.dbg(s);$.dbgCon.append('<br>');},dbgObj:function(o)
{for(var n in o)
{$.dbgln(n+':'+o[n]);}},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;}},makeForm:function(opt)
{opt=$.extend({name:'form',action:'',method:'POST',target:'',data:{}},opt);var form=$('<form action="'+opt.action+'" method="'+opt.method+'" style="display:none"></form>');if(opt.name.length)form.attr('name',opt.name);if(opt.target.length)form.attr('target',opt.target);form.appendValues(opt.data);return form;},swf:function(opt)
{if(typeof(opt)!='object')
{if($.browser.msie)
return document.getElementById(opt);else
return document.getElementsByName(opt)[0];}
opt=$.extend({w:400,h:300,display:true,id:'swf',vars:'',wmode:'opaque',container:null,bgcolor:'#ffffff'},opt);var oh='',eh='';eh='<embed '+(opt.display?'':'style="display:none"')+' name="'+opt.id+'" width="'+opt.w+'" height="'+opt.h+'" align="middle" type="application/x-shockwave-flash" allownetworking="true" allowscriptaccess="always" allowfullscreen="false" menu="true" bgcolor="'+opt.bgcolor+'" devicefont="false" wmode="'+opt.wmode+'" scale="showall" '+(opt.vars.length?'FlashVars="'+opt.vars+'"':'')+' loop="true" play="true" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="'+opt.src+'" ></embed>';oh='<OBJECT '+(opt.display?'':'style="display:none"')+' id="'+opt.id+'" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" height="'+opt.h+'" width="'+opt.w+'" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ><PARAM value="'+opt.src+'" name="movie" />'+(opt.vars.length?'<PARAM name="FlashVars" value="'+opt.vars+'" />':'')+'<PARAM value="high" name="quality" /><PARAM value="true" name="play" /><PARAM value="true" name="loop" /><PARAM value="showall" name="scale" /><PARAM value="'+opt.wmode+'" name="wmode" /><PARAM value="false" name="devicefont" /><PARAM value="'+opt.bgcolor+'" name="bgcolor" /><PARAM value="true" name="menu" /><PARAM value="false" name="allowFullScreen" /><PARAM value="always" name="allowScriptAccess" /><PARAM value="true" name="allowNetworking" />'+eh+'</OBJECT>';if(opt.container==null)
return oh;try{opt.container.get(0).innerHTML=oh;}
catch(e){opt.container.innerHTML=oh;}
return oh;}});})(jQuery);