/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 * 
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
 * 
 * Version: 1.3.4 (11/11/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

;(function(b){var m,t,u,f,D,j,E,n,z,A,q=0,e={},o=[],p=0,d={},l=[],G=null,v=new Image,J=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,W=/[^\.]\.(swf)\s*$/i,K,L=1,y=0,s="",r,i,h=false,B=b.extend(b("<div/>")[0],{prop:0}),M=b.browser.msie&&b.browser.version<7&&!window.XMLHttpRequest,N=function(){t.hide();v.onerror=v.onload=null;G&&G.abort();m.empty()},O=function(){if(false===e.onError(o,q,e)){t.hide();h=false}else{e.titleShow=false;e.width="auto";e.height="auto";m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
F()}},I=function(){var a=o[q],c,g,k,C,P,w;N();e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));w=e.onStart(o,q,e);if(w===false)h=false;else{if(typeof w=="object")e=b.extend(e,w);k=e.title||(a.nodeName?b(a).attr("title"):a.title)||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(k===""&&e.orig&&e.titleFromAlt)k=e.orig.attr("alt");c=e.href||(a.nodeName?b(a).attr("href"):a.href)||null;if(/^(?:javascript)/i.test(c)||
c=="#")c=null;if(e.type){g=e.type;if(!c)c=e.content}else if(e.content)g="html";else if(c)g=c.match(J)?"image":c.match(W)?"swf":b(a).hasClass("iframe")?"iframe":c.indexOf("#")===0?"inline":"ajax";if(g){if(g=="inline"){a=c.substr(c.indexOf("#"));g=b(a).length>0?"inline":"ajax"}e.type=g;e.href=c;e.title=k;if(e.autoDimensions)if(e.type=="html"||e.type=="inline"||e.type=="ajax"){e.width="auto";e.height="auto"}else e.autoDimensions=false;if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=
false;e.enableEscapeButton=false;e.showCloseButton=false}e.padding=parseInt(e.padding,10);e.margin=parseInt(e.margin,10);m.css("padding",e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(j.children())});switch(g){case "html":m.html(e.content);F();break;case "inline":if(b(a).parent().is("#fancybox-content")===true){h=false;break}b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(j.children())}).bind("fancybox-cancel",
function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();v=new Image;v.onerror=function(){O()};v.onload=function(){h=true;v.onerror=v.onload=null;e.width=v.width;e.height=v.height;b("<img />").attr({id:"fancybox-img",src:v.src,alt:e.title}).appendTo(m);Q()};v.src=c;break;case "swf":e.scrolling="no";C='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+c+
'"></param>';P="";b.each(e.swf,function(x,H){C+='<param name="'+x+'" value="'+H+'"></param>';P+=" "+x+'="'+H+'"'});C+='<embed src="'+c+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+P+"></embed></object>";m.html(C);F();break;case "ajax":h=false;b.fancybox.showActivity();e.ajax.win=e.ajax.success;G=b.ajax(b.extend({},e.ajax,{url:c,data:e.ajax.data||{},error:function(x){x.status>0&&O()},success:function(x,H,R){if((typeof R=="object"?R:G).status==200){if(typeof e.ajax.win==
"function"){w=e.ajax.win(c,x,H,R);if(w===false){t.hide();return}else if(typeof w=="string"||typeof w=="object")x=w}m.html(x);F()}}}));break;case "iframe":Q()}}else O()}},F=function(){var a=e.width,c=e.height;a=a.toString().indexOf("%")>-1?parseInt((b(window).width()-e.margin*2)*parseFloat(a)/100,10)+"px":a=="auto"?"auto":a+"px";c=c.toString().indexOf("%")>-1?parseInt((b(window).height()-e.margin*2)*parseFloat(c)/100,10)+"px":c=="auto"?"auto":c+"px";m.wrapInner('<div style="width:'+a+";height:"+c+
";overflow: "+(e.scrolling=="auto"?"auto":e.scrolling=="yes"?"scroll":"hidden")+';position:relative;"></div>');e.width=m.width();e.height=m.height();Q()},Q=function(){var a,c;t.hide();if(f.is(":visible")&&false===d.onCleanup(l,p,d)){b.event.trigger("fancybox-cancel");h=false}else{h=true;b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");f.is(":visible")&&d.titlePosition!=="outside"&&f.css("height",f.height());l=o;p=q;d=e;if(d.overlayShow){u.css({"background-color":d.overlayColor,
opacity:d.overlayOpacity,cursor:d.hideOnOverlayClick?"pointer":"auto",height:b(document).height()});if(!u.is(":visible")){M&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});u.show()}}else u.hide();i=X();s=d.title||"";y=0;n.empty().removeAttr("style").removeClass();if(d.titleShow!==false){if(b.isFunction(d.titleFormat))a=d.titleFormat(s,l,p,d);else a=s&&s.length?
d.titlePosition=="float"?'<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+s+'</td><td id="fancybox-title-float-right"></td></tr></table>':'<div id="fancybox-title-'+d.titlePosition+'">'+s+"</div>":false;s=a;if(!(!s||s==="")){n.addClass("fancybox-title-"+d.titlePosition).html(s).appendTo("body").show();switch(d.titlePosition){case "inside":n.css({width:i.width-d.padding*2,marginLeft:d.padding,marginRight:d.padding});
y=n.outerHeight(true);n.appendTo(D);i.height+=y;break;case "over":n.css({marginLeft:d.padding,width:i.width-d.padding*2,bottom:d.padding}).appendTo(D);break;case "float":n.css("left",parseInt((n.width()-i.width-40)/2,10)*-1).appendTo(f);break;default:n.css({width:i.width-d.padding*2,paddingLeft:d.padding,paddingRight:d.padding}).appendTo(f)}}}n.hide();if(f.is(":visible")){b(E.add(z).add(A)).hide();a=f.position();r={top:a.top,left:a.left,width:f.width(),height:f.height()};c=r.width==i.width&&r.height==
i.height;j.fadeTo(d.changeFade,0.3,function(){var g=function(){j.html(m.contents()).fadeTo(d.changeFade,1,S)};b.event.trigger("fancybox-change");j.empty().removeAttr("filter").css({"border-width":d.padding,width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2});if(c)g();else{B.prop=0;b(B).animate({prop:1},{duration:d.changeSpeed,easing:d.easingChange,step:T,complete:g})}})}else{f.removeAttr("style");j.css("border-width",d.padding);if(d.transitionIn=="elastic"){r=V();j.html(m.contents());
f.show();if(d.opacity)i.opacity=0;B.prop=0;b(B).animate({prop:1},{duration:d.speedIn,easing:d.easingIn,step:T,complete:S})}else{d.titlePosition=="inside"&&y>0&&n.show();j.css({width:i.width-d.padding*2,height:e.autoDimensions?"auto":i.height-y-d.padding*2}).html(m.contents());f.css(i).fadeIn(d.transitionIn=="none"?0:d.speedIn,S)}}}},Y=function(){if(d.enableEscapeButton||d.enableKeyboardNav)b(document).bind("keydown.fb",function(a){if(a.keyCode==27&&d.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if((a.keyCode==
37||a.keyCode==39)&&d.enableKeyboardNav&&a.target.tagName!=="INPUT"&&a.target.tagName!=="TEXTAREA"&&a.target.tagName!=="SELECT"){a.preventDefault();b.fancybox[a.keyCode==37?"prev":"next"]()}});if(d.showNavArrows){if(d.cyclic&&l.length>1||p!==0)z.show();if(d.cyclic&&l.length>1||p!=l.length-1)A.show()}else{z.hide();A.hide()}},S=function(){if(!b.support.opacity){j.get(0).style.removeAttribute("filter");f.get(0).style.removeAttribute("filter")}e.autoDimensions&&j.css("height","auto");f.css("height","auto");
s&&s.length&&n.show();d.showCloseButton&&E.show();Y();d.hideOnContentClick&&j.bind("click",b.fancybox.close);d.hideOnOverlayClick&&u.bind("click",b.fancybox.close);b(window).bind("resize.fb",b.fancybox.resize);d.centerOnScroll&&b(window).bind("scroll.fb",b.fancybox.center);if(d.type=="iframe")b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" '+(b.browser.msie?'allowtransparency="true""':"")+' scrolling="'+e.scrolling+'" src="'+d.href+'"></iframe>').appendTo(j);
f.show();h=false;b.fancybox.center();d.onComplete(l,p,d);var a,c;if(l.length-1>p){a=l[p+1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}if(p>0){a=l[p-1].href;if(typeof a!=="undefined"&&a.match(J)){c=new Image;c.src=a}}},T=function(a){var c={width:parseInt(r.width+(i.width-r.width)*a,10),height:parseInt(r.height+(i.height-r.height)*a,10),top:parseInt(r.top+(i.top-r.top)*a,10),left:parseInt(r.left+(i.left-r.left)*a,10)};if(typeof i.opacity!=="undefined")c.opacity=a<0.5?0.5:a;f.css(c);
j.css({width:c.width-d.padding*2,height:c.height-y*a-d.padding*2})},U=function(){return[b(window).width()-d.margin*2,b(window).height()-d.margin*2,b(document).scrollLeft()+d.margin,b(document).scrollTop()+d.margin]},X=function(){var a=U(),c={},g=d.autoScale,k=d.padding*2;c.width=d.width.toString().indexOf("%")>-1?parseInt(a[0]*parseFloat(d.width)/100,10):d.width+k;c.height=d.height.toString().indexOf("%")>-1?parseInt(a[1]*parseFloat(d.height)/100,10):d.height+k;if(g&&(c.width>a[0]||c.height>a[1]))if(e.type==
"image"||e.type=="swf"){g=d.width/d.height;if(c.width>a[0]){c.width=a[0];c.height=parseInt((c.width-k)/g+k,10)}if(c.height>a[1]){c.height=a[1];c.width=parseInt((c.height-k)*g+k,10)}}else{c.width=Math.min(c.width,a[0]);c.height=Math.min(c.height,a[1])}c.top=parseInt(Math.max(a[3]-20,a[3]+(a[1]-c.height-40)*0.5),10);c.left=parseInt(Math.max(a[2]-20,a[2]+(a[0]-c.width-40)*0.5),10);return c},V=function(){var a=e.orig?b(e.orig):false,c={};if(a&&a.length){c=a.offset();c.top+=parseInt(a.css("paddingTop"),
10)||0;c.left+=parseInt(a.css("paddingLeft"),10)||0;c.top+=parseInt(a.css("border-top-width"),10)||0;c.left+=parseInt(a.css("border-left-width"),10)||0;c.width=a.width();c.height=a.height();c={width:c.width+d.padding*2,height:c.height+d.padding*2,top:c.top-d.padding-20,left:c.left-d.padding-20}}else{a=U();c={width:d.padding*2,height:d.padding*2,top:parseInt(a[3]+a[1]*0.5,10),left:parseInt(a[2]+a[0]*0.5,10)}}return c},Z=function(){if(t.is(":visible")){b("div",t).css("top",L*-40+"px");L=(L+1)%12}else clearInterval(K)};
b.fn.fancybox=function(a){if(!b(this).length)return this;b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(c){c.preventDefault();if(!h){h=true;b(this).blur();o=[];q=0;c=b(this).attr("rel")||"";if(!c||c==""||c==="nofollow")o.push(this);else{o=b("a[rel="+c+"], area[rel="+c+"]");q=o.index(this)}I()}});return this};b.fancybox=function(a,c){var g;if(!h){h=true;g=typeof c!=="undefined"?c:{};o=[];q=parseInt(g.index,10)||0;if(b.isArray(a)){for(var k=
0,C=a.length;k<C;k++)if(typeof a[k]=="object")b(a[k]).data("fancybox",b.extend({},g,a[k]));else a[k]=b({}).data("fancybox",b.extend({content:a[k]},g));o=jQuery.merge(o,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},g,a));else a=b({}).data("fancybox",b.extend({content:a},g));o.push(a)}if(q>o.length||q<0)q=0;I()}};b.fancybox.showActivity=function(){clearInterval(K);t.show();K=setInterval(Z,66)};b.fancybox.hideActivity=function(){t.hide()};b.fancybox.next=function(){return b.fancybox.pos(p+
1)};b.fancybox.prev=function(){return b.fancybox.pos(p-1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a);o=l;if(a>-1&&a<l.length){q=a;I()}else if(d.cyclic&&l.length>1){q=a>=l.length?0:l.length-1;I()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");N();e.onCancel(o,q,e);h=false}};b.fancybox.close=function(){function a(){u.fadeOut("fast");n.empty().hide();f.hide();b.event.trigger("fancybox-cleanup");j.empty();d.onClosed(l,p,d);l=e=[];p=q=0;d=e={};h=false}if(!(h||f.is(":hidden"))){h=
true;if(d&&false===d.onCleanup(l,p,d))h=false;else{N();b(E.add(z).add(A)).hide();b(j.add(u)).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");j.find("iframe").attr("src",M&&/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank");d.titlePosition!=="inside"&&n.empty();f.stop();if(d.transitionOut=="elastic"){r=V();var c=f.position();i={top:c.top,left:c.left,width:f.width(),height:f.height()};if(d.opacity)i.opacity=1;n.empty().hide();B.prop=1;
b(B).animate({prop:0},{duration:d.speedOut,easing:d.easingOut,step:T,complete:a})}else f.fadeOut(d.transitionOut=="none"?0:d.speedOut,a)}}};b.fancybox.resize=function(){u.is(":visible")&&u.css("height",b(document).height());b.fancybox.center(true)};b.fancybox.center=function(a){var c,g;if(!h){g=a===true?1:0;c=U();!g&&(f.width()>c[0]||f.height()>c[1])||f.stop().animate({top:parseInt(Math.max(c[3]-20,c[3]+(c[1]-j.height()-40)*0.5-d.padding)),left:parseInt(Math.max(c[2]-20,c[2]+(c[0]-j.width()-40)*0.5-
d.padding))},typeof a=="number"?a:200)}};b.fancybox.init=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),t=b('<div id="fancybox-loading"><div></div></div>'),u=b('<div id="fancybox-overlay"></div>'),f=b('<div id="fancybox-wrap"></div>'));D=b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
D.append(j=b('<div id="fancybox-content"></div>'),E=b('<a id="fancybox-close"></a>'),n=b('<div id="fancybox-title"></div>'),z=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),A=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));E.click(b.fancybox.close);t.click(b.fancybox.cancel);z.click(function(a){a.preventDefault();b.fancybox.prev()});A.click(function(a){a.preventDefault();b.fancybox.next()});
b.fn.mousewheel&&f.bind("mousewheel.fb",function(a,c){if(h)a.preventDefault();else if(b(a.target).get(0).clientHeight==0||b(a.target).get(0).scrollHeight===b(a.target).get(0).clientHeight){a.preventDefault();b.fancybox[c>0?"prev":"next"]()}});b.support.opacity||f.addClass("fancybox-ie");if(M){t.addClass("fancybox-ie6");f.addClass("fancybox-ie6");b('<iframe id="fancybox-hide-sel-frame" src="'+(/^https/i.test(window.location.href||"")?"javascript:void(false)":"about:blank")+'" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D)}}};
b.fn.fancybox.defaults={padding:10,margin:40,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.7,overlayColor:"#fff",titleShow:true,titlePosition:"float",titleFormat:null,titleFromAlt:false,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",easingIn:"swing",
easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,enableKeyboardNav:true,onStart:function(){},onCancel:function(){},onComplete:function(){},onCleanup:function(){},onClosed:function(){},onError:function(){}};b(document).ready(function(){b.fancybox.init()})})(jQuery);

/*--------------------------------------------------------------------------*
 *  
 *  heightLine JavaScript Library beta4
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata 
 *  http://www.webcreativepark.net
 *  
 *--------------------------------------------------------------------------*/
new function(){
	
	function heightLine(){
	
		this.className="heightLine";
		this.parentClassName="heightLineParent"
		reg = new RegExp(this.className+"-([a-zA-Z0-9-_]+)", "i");
		objCN =new Array();
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		for(var i = 0; i < objAll.length; i++) {
			var eltClass = objAll[i].className.split(/\s+/);
			for(var j = 0; j < eltClass.length; j++) {
				if(eltClass[j] == this.className) {
					if(!objCN["main CN"]) objCN["main CN"] = new Array();
					objCN["main CN"].push(objAll[i]);
					break;
				}else if(eltClass[j] == this.parentClassName){
					if(!objCN["parent CN"]) objCN["parent CN"] = new Array();
					objCN["parent CN"].push(objAll[i]);
					break;
				}else if(eltClass[j].match(reg)){
					var OCN = eltClass[j].match(reg)
					if(!objCN[OCN]) objCN[OCN]=new Array();
					objCN[OCN].push(objAll[i]);
					break;
				}
			}
		}
		
		//check font size
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.body.appendChild(e);
		var defHeight = e.offsetHeight;
		
		changeBoxSize = function(){
			for(var key in objCN){
				if (objCN.hasOwnProperty(key)) {
					//parent type
					if(key == "parent CN"){
						for(var i=0 ; i<objCN[key].length ; i++){
							var max_height=0;
							var CCN = objCN[key][i].childNodes;
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j] && CCN[j].nodeType == 1){
									CCN[j].style.height="auto";
									max_height = max_height>CCN[j].offsetHeight?max_height:CCN[j].offsetHeight;
								}
							}
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j].style){
									var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight -= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight -= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","");
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									CCN[j].style.height =newheight+"px";
								}
							}
						}
					}else{
						var max_height=0;
						for(var i=0 ; i<objCN[key].length ; i++){
							objCN[key][i].style.height="auto";
							max_height = max_height>objCN[key][i].offsetHeight?max_height:objCN[key][i].offsetHeight;
						}
						for(var i=0 ; i<objCN[key].length ; i++){
							if(objCN[key][i].style){
								var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight-= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight-= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","")
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									objCN[key][i].style.height =newheight+"px";
							}
						}
					}
				}
			}
		}
		
		checkBoxSize = function(){
			if(defHeight != e.offsetHeight){
				changeBoxSize();
				defHeight= e.offsetHeight;
			}
		}
		changeBoxSize();
		setInterval(checkBoxSize,1000)
		window.onresize=changeBoxSize;
	}
	
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}
	addEvent(window,"load",heightLine);
}

/**
 * exValidation
 *
 * @version   : 1.2.2
 * @author    : nori (norimania@gmail.com)
 * @copyright : 5509 (http://5509.me/)
 * @license   : The MIT License
 * @link      : http://5509.me/log/exvalidation
 * @modified  : 2011-04-24 22:14
 */
;(function($) {
	$.exValidationRules = $.exValidationRules || {};
	var exValidation = function(form, conf) {
		if ( form.length > 1 ) {
			alert("You cannot select any forms");
			return false;
		}

		this.form = form;
		// for browse
		var _this = this,
			b = $("body"),
			conf = this.conf = $.extend({
				errInsertPos       : "body", // "body" or after(before)
				err                : null,
				ok                 : null,
				errFocus           : false,
				errHoverHide       : false,
				stepValidation     : false,
				scrollToErr        : true,
				scrollDuration     : 500,
				scrollAdjust       : -10,
				customScrollAdjust : false,
				errPosition        : "absolute", // fixed
				errOpacity         : undefined,
				errTipPos          : "right", // left
				errTipCloseBtn     : true,
				errTipCloseLabel   : "×",
				errZIndex          : 500,
				errMsgPrefix       : "\* ",
				customAddError     : null, // function(){}
				customClearError   : null, // function(){}
				customSubmit       : null, // function(){}
				customListener     : "blur keyup change focus",
				customBind         : null,
				/* Using this conf, you can bind validation func to any element
					{
						object: $(button),
						listener: "blur keyup change focus",
						callback: function() {}
					}
				*/
				customGetErrHeight  : null,
				firstValidate       : false,
				// default checking targets
				inputs              : "input:text,input:password,input:hidden,textarea,select,[class*=group],[class*=radio],[class*=checkbox]",
				// default checking targets in groups
				groupInputs         : "input:text,input:password,input:checkbox,input:radio,select,textarea"
			}, conf || {});

		this.errFocus = function(id) {
			if ( !conf.errFocus ) return false;
			errFocus(id, conf.errZIndex);
		}
		this.errFocusClear = function() {
			if ( !conf.errFocus ) return false;
			errFocusClear(conf.errZIndex);
		}

		if ( fnConfirmation(conf.customSubmit) ) {
			form.submit(function() {
				return false;
			});
		}
		$("input:checkbox,input:radio,input:button,input:submit,input:reset").click(function() {
			_this.errFocusClear();
		});

		// addClasses for each inputs by validation rules
		for ( var c in conf.rules ) {
			$("#" + c).addClass(conf.rules[c]);
		}

		// If this form doesn"t have ID, formID for error tips is to be decided by random integer
		var formID = form.attr("id")
			? "form_" + form.attr("id")
			: "form_" + randomInt()*randomInt();

		var inputs = $(conf.inputs, form)
			.filter(function() { return !$(this).parents().hasClass("chkgroup"); }),
			classReg = returnReg(),
			bindValidateFuncs = function(target, group) {
				var self = group ? group : target;
				target.bind(conf.customListener, function() {
					_this.basicValidate(group ? group : this, conf.err, conf.ok);
					_this.errFocus("#err_" + self.attr("id"));
				}).blur(function() {
					_this.errFocusClear();
				});
			}

		inputs.each(function() {
			var self = $(this),
				cl = this.className,
				id = this.id;

			if ( conf.errTipPos === "right" ) {
				self.addClass("errPosRight");
			}

			// if target has one of classRegulations
			//console.log(cl)
			if ( cl.match(classReg) ) {
				if ( conf.errInsertPos === "body" ) {
					b.append(_this.generateErr(id, formID));
				} else {
					self[conf.errInsertPos](_this.generateErr(id, formID));
					self.addClass(conf.errInsertPos);
				}

				if ( conf.errHoverHide ) {
					$("#err_"+id).mouseenter(function() {
						$(this).fadeOut();
					});
				}
				if ( conf.errTipCloseBtn ) {
					$("#err_"+id).append(
						$("<span></span>")
							.addClass("formErrorClose")
							.text(conf.errTipCloseLabel)
							.click(function() {
								$(this).parent().fadeOut();
							})
					);
				}
				if ( conf.errOpacity !== undefined ) {
					$("#err_"+id).children().css("opacity", conf.errOpacity);
				}
				if ( conf.errPosition === "absolute" ) {
					if ( fnConfirmation(conf.customGetErrHeight) ) {
						_this.customGetErrHeight(id);
					} else {
						_this.getErrHeight(id, conf.errZIndex);
					}

					// Reget the position
					$(window).resize(function() {
						if ( fnConfirmation(conf.customGetErrHeight) ) {
							_this.customGetErrHeight(id);
						} else {
							_this.getErrHeight(id, conf.errZIndex);
						}
					});
				}
				$("#err_"+id).hide();
			}
		});

		if ( conf.firstValidate ) {
			inputs.each(function() {
				var _self = $(this);
				if ( _self.hasClass("chkgroup") ) {
					bindValidateFuncs($(conf.groupInputs, _self), _self);
				} else {
					bindValidateFuncs(_self);
				}
			});
		}

		// You call this func everytime you like after init
		this.laterCall = function(t) {
			_this.basicValidate(t, conf.err, conf.ok);
		}

		function _exeValidation(customBindCallback) {
			if ( conf.firstValidation ) {
				inputs.unbind("blur keyup change click");
				conf.firstValidate = false;
			}
			inputs.each(function() {
				var self = $(this);
				_this.basicValidate(this, conf.err, conf.ok, true);

				if ( self.hasClass("chkgroup") ) {
					bindValidateFuncs($(conf.groupInputs, self), self);
				} else {
					bindValidateFuncs(self);
				}
			});

			var err = $(".formError:visible[class*='"+formID+"']");
			// if errs are displayed
			if ( err.length > 0 ) {
				if ( fnConfirmation(conf.customAddError) ) {
					conf.customAddError();
				}
				if ( conf.scrollToErr ) {
					var reverseOffsetTop,
						infoErr, errTop,
						scrollTarget = $.support.boxModel
							? navigator.appName.indexOf("Opera") !== -1 ?
								"html" : "html,body"
							: "body";
					if ( !conf.customScrollAdjust ) {
						reverseOffsetTop = $(err[0]).offset().top;
						errTop = $(err[0]);

						for ( var i=0, l=err.length; i<l; i++ ) {
							infoErr = $(err[i]);
							reverseOffsetTop = infoErr.offset().top < reverseOffsetTop
								? infoErr.offset().top : reverseOffsetTop;
							errTop = infoErr.offset().top < reverseOffsetTop
								? infoErr : errTop;
						}

						if ( conf.errPosition === "fixed" ) {
							reverseOffsetTop -= $("#"+errTop.attr("id").replace("err_", ""))
                                                    .get(0).offsetHeight;
						}
					} else {
						reverseOffsetTop = fnConfirmation(conf.customScrollAdjust)
							? parseFloat(conf.customScrollAdjust()) : parseFloat(conf.customScrollAdjust);
					}

					$(scrollTarget).animate({
						scrollTop: reverseOffsetTop + conf.scrollAdjust
					}, {
						easing: $.easing.easeInOutCirc ? "easeInOutCirc" : "swing",
						duration: conf.scrollDuration
					});
				}
				return false;

			// if no err is displayed
			} else {
				if ( fnConfirmation(conf.customClearError) ) {
					// falseが返ってきた場合はキャンセルする
					var result = conf.customClearError();
					if ( !result ) return false;
					// if ( result == false ) return false;
				}
				// CustomBindCallBack
				if ( fnConfirmation(customBindCallback) ) {
					customBindCallback();
					return false;
				} else {
					// customSubmit
					if ( fnConfirmation(conf.customSubmit) ) {
						conf.customSubmit();
						return false;
					// Default Postback
					} else {
						// OK
					}
				}
			}
		}

		// When the form is submited
		form.submit(_exeValidation);

		// Add the Validation
		if ( conf.customBind ) {
			conf.customBind.object.bind(conf.customBind.listener, function() {
				_exeValidation(conf.customBind.callback);
				return false;
			});
		}

		// Return the instance
		return this;
	}
	
	// Common prototype functions
	exValidation.prototype = {
		// Errtip content
		// this HTML source code from "A jQuery inline form validation, because validation is a mess"
		// thanks to http://bit.ly/onlNv (http://www.position-relative.net/)
		generateErr: function(id, formID) {
			return [
				'<div id="err_'+id+'" class="formError userformError'+' '+formID+' '+this.conf.errPosition+'">',
					'<div class="formErrorMsg formErrorContent"></div>',
					'<div class="formErrorArrow">',
						'<div class="line10"></div>',
						'<div class="line9"></div>',
						'<div class="line8"></div>',
						'<div class="line7"></div>',
						'<div class="line6"></div>',
						'<div class="line5"></div>',
						'<div class="line4"></div>',
						'<div class="line3"></div>',
						'<div class="line2"></div>',
						'<div class="line1"></div>',
					'</div>',
				'</div>'
			].join("");
		},
		// Insert error message
		insertErrMsg: function(t, id, c, errMsg) {
			var msgs = $(".errMsg", "#err_"+id),
				returnFlg = true;
			if ( msgs.length > 0 ) {
				$.each(msgs, function() {
					if ( $(this).hasClass(c) ) {
						returnFlg = false;
					}
				});
			}
			if ( !returnFlg ) return false;
			$(".formErrorMsg", "#err_"+id).append(
				$("<span></span>")
					.addClass("errMsg")
					.addClass(c)
					.text(errMsg)
				);
			this.getErrHeight(id);
		},
		// Basic get error height
		getErrHeight: function(id, zIndex) {
			if ( this.conf.errPosition !== "absolute" ) return false;
			var input = $("#"+id),
				err = $("#err_"+id),
				target = input.is(":hidden") ? input.next() : input,
				pos = target.offset();
			
			if ( !!pos ) {
				var left = target.hasClass("errPosRight")
						? pos.left + target.get(0).offsetWidth - 40
						: pos.left - 20;
						
				err.css({
					position: "absolute",
					top: pos.top - err.get(0).offsetHeight,
					left: left
				});
			}
			
			if ( zIndex ) {
				err.css("zIndex", zIndex);
			}
		},
		// Basic validation
		basicValidate: function(t, err, ok) {
			var _t = $(t),
				CL = _t.attr("class"),
				chk = $.exValidationRules,
				id = _t.attr("id"),
				txt = "",
				_this = this;
			
			if ( _t.hasClass("chkgroup") ) {
				var groupInputs = $(_this.conf.groupInputs, t);
				groupInputs.each(function(i) {
					var self = $(this);
					txt += self.val();
					if( CL.indexOf("chkemail") !== -1 && i==0 && self.val().length > 0 )
						txt += "@";
				});
			} else {
				txt = _t.val();
			}
			
			var check = {
				isError: false,
				failed: function(t, c) {
					var msg = chk[c][0];
					if ( c.match(/chkmin/i) && CL.match(/chkmin(\d+)/i) ) {
						msg = RegExp.$1 + msg;
					} else
					if ( c.match(/chkmax/i) && CL.match(/chkmax(\d+)/i) ) {
						msg = RegExp.$1 + msg;
					}
					
					if( fnConfirmation(err) ) {
						err(t, id, _this.conf.errMsgPrefix + msg);
					} else {
						_t.addClass("err");
						$("."+c, "#err_"+id).show();
						$("#err_"+id).fadeIn();
						_this.insertErrMsg(t, id, c, _this.conf.errMsgPrefix + msg);
						_this.getErrHeight(id);
					}
					this.isError = true;
				}
			}

			var c;
			for ( c in chk ) {
				if ( _t.hasClass(c)
				|| (c === "chkmin" && CL.match(/(?:\s+|^)chkmin\d+(?:\s+|$)/) )
				|| (c === "chkmax" && CL.match(/(?:\s+|^)chkmax\d+(?:\s+|$)/) )
				|| ( CL.indexOf(c) !== -1 && CL.indexOf("chkretype") !== -1 ) ) {
					if ( typeof(chk[c][1]) !== "function" ) {
						if ( !txt.match(chk[c][1]) ) {
							check.failed(t, c);
						} else
						if ( _this.conf.stepValidation ) {
							if ( $(".errMsg:visible", "#err_"+id).length > 1 ) {
								$("."+c, "#err_"+id).hide();
								_this.getErrHeight(id);
							}
						}
					} else {
						if ( !chk[c][1](txt, t) ) {
							check.failed(t, c);
						} else
						if ( _this.conf.stepValidation ) {
							if ( $(".errMsg:visible", "#err_"+id).length > 1 ) {
								$("."+c, "#err_"+id).hide();
								_this.getErrHeight(id);
							}
						}
					}
				}
			}
			
			if ( !check.isError ) {
				if ( fnConfirmation(ok) ) {
					ok(t, id);
				} else {
					_t.removeClass("err");
					$("#err_"+id).fadeOut();
				}
			}
		}
	}
	
	// Common functions
	function returnReg() {
		var validationClasses = "";
		for( var c in $.exValidationRules ) {
			validationClasses += "(?:\\s+|^)"+c+"(?:\\s+|$)|";
		}
		validationClasses += "(?:\\s+|^)chkmin\\d+(?:\\s+|$)|";
		validationClasses += "(?:\\s+|^)chkmax\\d+(?:\\s+|$)|";
		validationClasses = validationClasses.replace(/\|$/,"");
		return new RegExp(validationClasses);
	}
	function errFocusClear(errZIndex) {
		$(".formError")
			.removeClass("fadeOut")
			.css("zIndex", errZIndex)
	}
	function errFocus(id, errZIndex) {
		var formError = $(".formError");
		formError.removeClass("fadeOut").css("zIndex", errZIndex);
		formError.not(id).addClass("fadeOut");
		$(id).css({
			zIndex: errZIndex + 100
		});
	}
	function fnConfirmation(fn) {
		return fn && typeof fn === "function";
	}
	function randomInt() {
		return Math.floor(Math.random()*10)+1;
	}
	
	// Extense the namespace of jQuery as method
	// This function returns instance
	$.fn.exValidation = function(options) {
		return new exValidation(this, options);
	}
	if ( !$.fn.validation ) {
		$.fn.validation = $.fn.exValidation;
	}
})(jQuery);

/**
 * exValidation
 *
 * @version   : 1.2.2
 * @author    : nori (norimania@gmail.com)
 * @copyright : 5509 (http://5509.me/)
 * @license   : The MIT License
 * @link      : http://5509.me/log/exvalidation
 * @modified  : 2011-04-24 22:14
 */
;(function($) {
	// Extend validation rules
	$.exValidationRules = $.extend($.exValidationRules, {
		chkrequired: [
			"入力してください",
			function(txt, t) {
				if ( $(t).hasClass("chkgroup") ) {
					var flag = 0;
					$("input,select",t).each(function() {
						if ( $(this).val().length > 0 ) flag++;
					});
					if ( txt && flag === $("input,select", t).length ) {
						if ( /^[ 　\r\n\t]+$/.test(txt) ) {
							return false;
						} else {
							return true;
						}
					}
				} else {
					if ( txt && txt.length>0 ) {
						if ( /^[ 　\r\n\t]+$/.test(txt) ) {
							return false;
						} else {
							return true;
						}
					}
				}
			}
		],
		chkselect: [
			"選択してください",
			function(txt, t) {
				if ( txt && txt.length>0 ) {
					if ( /^[ 　\r\n\t]+$/.test(txt) ) {
						return false;
					} else {
						return true;
					}
				}
			}
		],
		chkretype: [
			"入力内容が異なります",
			function(txt, t) {
				var elm = $("#" + $(t).attr("class").split("retype\-")[1].split(/\b/)[0]);
				if ( elm.hasClass("chkgroup") ) {
					var chktxt = $("input", elm), txt = $("input", t);
					for ( var i = 0, flag = false; i < chktxt.length; i++ ) {
						if ( chktxt[i].value === txt[i].value ) flag = true;
						else flag = false;
					}
					if ( flag ) return true;
				} else {
					return elm.val() == txt;
				}
			}
		],
		chkemail: [
			"正しいメールアドレスの形式を入力してください",
			/^(?:[^\@]+?@[A-Za-z0-9_\.\-]+\.+[A-Za-z\.\-\_]+)*$/
		],
		chkhankaku: [
			"全角文字は使用できません",
			/^(?:[a-zA-Z0-9@\;\:\[\]\{\}\|\^\=\/\!\*\`\"\#\$\+\%\&\'\(\)\,\.\-\_\?\\\s]*)*$/
		], //"
		chkzenkaku: [
			"全角文字で入力してください",
			/^(?:[^a-zA-Z0-9@\;\:\[\]\{\}\|\^\=\/\!\*\"\#\$\+\%\&\'\(\)\,\.\-\_\?\\\s]+)*$/
		], //"
		chkhiragana: [
			"ひらがなで入力してください",
			/^(?:[あ-んー～]+)*$/
		],
		chkkatakana: [
			"カタカナで入力してください",
			/^(?:[ア-ンー～]+)*$/
		],
		chkfurigana: [
			"ふりがなはひらがな、全角数字と〜、ー、（）が利用できます",
			/^(?:[あ-ん０-９ー～（）\(\)\d 　]+)*$/
		],
		chknochar: [
			"英数字で入力してください",
			/^(?:[a-zA-Z0-9]+)*$/
		],
		chknocaps: [
			"英数字(小文字のみ)で入力してください",
			/^(?:[a-z0-9]+)*$/
		],
		chknumonly: [
			"半角数字のみで入力してください",
			/^(?:[0-9]+)*$/
		],
		chkmin: [
			"文字以上で入力してください",
			function(txt, t) {
				if ( txt.length === 0 ) return true;
			 	var length = $(t).attr("class").match(/min(\d+)/) ? RegExp.$1 : null;
				return txt.length >= length;
			}
		],
		chkmax: [
			"文字以内で入力してください",
			function(txt, t) {
				var length = $(t).attr("class").match(/max(\d+)/) ? RegExp.$1 : null;
				return txt.length <= length;
			}
		],
		chkradio: [
			"選択してください",
			function(txt, t) {
				return $("input:checked",t).length>0;
			}
		],
		chkcheckbox: [
			"選択してください",
			function(txt, t) {
				return $("input:checked",t).length>0;
			}
		],
		chkurl: [
			"正しいURLの形式を入力してください",
			/^(?:http(s)?\:\/\/[^\/]*)*$/
		],
		chktel: [
			"正しい電話番号を入力してください",
			/^(?:\(?\d+\)?\-?\d+\-?\d+)*$/
		],
		chkfax: [
			"正しいファックス番号を入力してください",
			/^(?:\(?\d+\)?\-?\d+\-?\d+)*$/
		]
	});
})(jQuery);

/**
 * jQselectable
 *
 * @author     : nori (norimania@gmail.com)
 * @copyright  : 5509 (http://5509.me/)
 * @license    : The MIT License
 * @link       : http://5509.me/log/jqueryselectable
 * @repository : https://github.com/5509/jQselectable
 * @modified   : 2010-04-21 11:40
 * @since      : 2008-09-14 02:34
 */
;(function($) {
	
	// jQuery.jQselectable
	// Make selectbox so usuful and accesible
	// @ 2010-01-09
	var jQselectable = function(select, options, temp) {
		this.conf = {
			style: 'selectable', // or 'simple'
			set: 'show', // 'show', 'slideDown' or 'fadeIn'
			out: 'hide', // 'hide', 'slideUp' or 'fadeOut'
			setDuration: 'normal', // 'slow', 'normal', 'fast' or int(millisecond)
			outDuration: 'normal',
			opacity: 1, // pulldown opacity
			top: 0,
			left: 0,
			callback: null
		}
		this.temp = {
			selectable: '<div class="sctble_cont"></div>',
			simpleBox: '<div class="simple_cont"></div>'
		}
		
		// Extend confs and temps by user options
		$.extend(this.conf, options || {});
		$.extend(this.temp, temp || {});
		
		this.target = $(select);
		this.matHeight = 0;
		this.attrs = {
			id: this.target.attr('id'),
			cl: this.target.attr('class')
		}
		this.generatedFlg = false;
		
		// Init start
		this.init();
	}
	
	jQselectable.prototype = {
		// Init selectable
		// @ 10-01-09 21:00
		init: function() {
			// Build selectable
			this.build();
			// Event apply
			this.bind_events();
			// Switch flag true
			this.generatedFlg = true;
		},
		// API : disabled, enabled
		disabled: function() {
			if ( !this.clickBlocker ) {
				// Generate the clickBlocker
				var _this = this,
					_m = this.m_input,
					_mPos = _m.offset();
				this.clickBlocker = $('<div></div>')
					.css({
						width: _m.attr('offsetWidth'),
						height: _m.attr('offsetHeight'),
						position: 'absolute',
						top: _mPos.top,
						left: _mPos.left,
						background: '#fff',
						opacity: 0
					});
				$(window).resize(function() {
					_mPos = _m.offset();
					_this.clickBlocker
						.css({
							top: _mPos.top,
							left: _mPos.left
						});
				});
				$('body').append(this.clickBlocker);
				
				// Unbind events
				this.m_input.addClass('disabled').unbind();
				this.mat.unbind();
				$('a',this.mat).unbind();
				$('label[for="'+this.attrs.id+'"]').unbind();
			}
		},
		enabled: function() {
			if ( this.clickBlocker ) {
				// Remove the clickBlocker
				this.clickBlocker.remove();
				this.clickBlocker = null;
				// Bind events
				this.m_input.removeClass('disabled');
				this.bind_events();
			}
		},
		// Rebuild selectable
		// @ 09-09-18 17:28
		rebuild: function() {
			// unbind events from elements related selectable
			this.m_input.unbind();
			this.mat.unbind();
			$('a',this.mat).unbind();
			$('label[for="'+this.attrs.id+'"]').unbind();
			
			// Build selectable
			this.build();
			
			// Event apply
			this.bind_events();
		},
		
		// Building selectable from original select element
		// @ 2010-01-09 21:00
		build: function() {
			
			// Declare flag
			var has_optgroup = $('optgroup', this.target).length > 0;
			
			var _this = this;
			var generate_anchors = function(obj, parent) {
				// options:disabled - added at 11-04-21 11:41
				var _option;
				if ( obj.attr("disabled") ) {
					_option = $('<span class="disabled"></span>');
				} else {
					_option = $('<a></a>');
				}
				$(parent).append(_option);
				
				_option.text(obj.text()).attr({
					href: '#'+encodeURI(obj.text()),
					name: obj.val()
				});
				
				if ( obj.is(':selected') ) {
					_this.m_text.text(obj.text());
					_option.addClass('selected');
				}
				if ( obj.hasClass('br') ) {
					_option.after('<br/>');
				}
			}
			
			if ( !this.m_input ) {
				this.m_input = $('<a></a>');
				this.m_text = $('<span></span>');
				var _style = this.conf.style.match(/simple/) ? 'sBox' : 'sctble';
				
				this.m_input.append(this.m_text).attr({
					id: this.attrs.id+'_dammy',
					href: 'javascript:void(0)'
				}).addClass('sctble_display').addClass(_style).addClass(this.attrs.cl).insertAfter(this.target);
				this.target.hide();
				this.mat = $('<div></div>');
				
				// Customized
				if ( _style == 'simple' ) {
					this.mat.append(this.temp.selectable);
				} else {
					this.mat.append(this.temp.simpleBox);
				}
				// Customized end
				this.mat.attr({
					id: this.attrs.id+'_mat'
				}).addClass(_style).addClass(this.attrs.cl);
			}
			
			// For rebuilding
			if ( this.generatedFlg) {
				this.mat.empty();
				
				if ( _style == 'simple' ) {
					this.mat.append(this.temp.selectable);
				} else {
					this.mat.append(this.temp.simpleBox);
				}
			}
			
			this._div = $('<div class="body"></div>');
			if ( has_optgroup ) {
				this.mat.addClass('otpgroup');
				var _optgroup = $('optgroup', this.target);
				var _option = [];
				
				for ( var i=0; i<_optgroup.length; i++ ) {
					_option[i] = $('option', _optgroup[i]);
				}
				
				var _dl = $('<dl></dl>');
				
				for ( var i=0; i<_optgroup.length; i++ ) {
					var _dt = $('<dt></dt>');
					_dt.text($(_optgroup[i]).attr('label'));
					var _dd = $('<dd></dd>');
					for ( var j=0; j<_option[i].length; j++ ) {
						generate_anchors($(_option[i][j]), _dd);
					}
					_dl.append(_dt).append(_dd);
				}
				this._div.append(_dl).addClass('optg');
				$('div', this.mat).append(this._div);
				
			} else {
				this.mat.addClass('nooptgroup');
				var _option = $('option', this.target);
				for ( var i=0; i<_option.length; i++ ) {
					generate_anchors($(_option[i]), this._div);
				}
				$('div', this.mat).append(this._div.addClass('nooptg'));
			}
			
			// For rebuilding
			if ( !this.generatedFlg ) {
				$('body').append(this.mat);
				this.mat.addClass('sctble_mat').css({
					position: 'absolute',
					zIndex: 1000,
					display: 'none'
				});
				$('*:first-child',this.mat).addClass('first-child');
				$('*:last-child',this.mat).addClass('last-child');
			}
			
			// This is for IE6 that doesn't have "max-height" properties
			if ( document.all && typeof document.body.style.maxHeight == 'undefined' ) {
				if ( this.conf.height < this.mat.height() ) {
					$(this._div).css('height', this.conf.height);
				}
			// Other browsers
			} else {
				$(this._div).css('maxHeight', this.conf.height);
			}
			
			// get height of the mat
			this.mat.show();
			this.matHeight = this.mat.attr('offsetHeight');
			this.mat.hide();
		},
		
		// Bind events
		// @ 09-09-17 22:59
		bind_events: function() {
			var _this = this;
			// Flag checking where the events was called
			var is_called = true;
			
			var set_pos = function() {
				var topPos,
					scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
					clientHeight = document.documentElement.clientHeight || document.body.clientHeight,
					_pos = _this.m_input.offset();
					
				if ( clientHeight/2 < (_pos.top - scrollTop) ) {
					topPos = _pos.top - _this.matHeight + _this.conf.top - 5;
				} else {
					topPos = _pos.top + _this.m_input.height()*1.3 + _this.conf.top;
				}
				_this.mat.css({
					top: topPos,
					left: _pos.left + _this.conf.left
				});
			}
			$(window).resize(function() {
				set_pos();
			});
			
			// Hide all mats are displayed
			var mat_hide = function() {
				var _mat = $('.sctble_mat');
				
				switch( _this.conf.out ) {
					case 'slideUp':
						_mat.slideUp(_this.conf.outDuration);
						break;
					case 'fadeOut':
						_mat.fadeOut(_this.conf.outDuration);
						break;
					default:
						_mat.hide();
						break;
				}
			}
			
			// Show the mat
			var mat_show = function() {
				mat_hide();
				
				if ( _this.conf.set == 'slideDown' ) {
					var scrollTop = document.documentElement.scrollTop || document.body.scrollTop,
						clientHeight = document.documentElement.clientHeight || document.body.clientHeight,
						_pos = _this.m_input.offset(),
						balance = clientHeight/2 < (_pos.top - scrollTop);
						
					if ( balance ) {
						_this.mat.css('top', _pos.top + _this.conf.top - 5);
					}
				}
				
				if ( _this.conf.set == 'slideDown' ) {
					if ( balance ) {
						_this.mat
							.animate({
								height: 'toggle',
								top: parseInt(_this.mat.css('top')) -  _this.matHeight
							}, {
								easing: 'swing',
								duration: _this.conf.setDuration
							})
							.css('opacity', _this.conf.opacity);
					} else {
						_this.mat.slideDown(_this.conf.setDuration).css('opacity', _this.conf.opacity);
					}
				} else
				if ( _this.conf.set == 'fadeIn' ) {
					_this.mat.css({
						display: 'block',
						opacity: 0
					}).fadeTo(_this.conf.setDuration, _this.conf.opacity);
				} else {
					_this.mat.show().css('opacity', _this.conf.opacity);
				}
				
				var _interval = isNaN(_this.conf.setDuration) ? null : _this.conf.setDuration+10;
				if( _interval == null ) {
					if ( _this.conf.setDuration.match(/slow/) ) {
						interval = 610;
					} else if ( _this.conf.setDuration.match(/normal/) ) {
						interval = 410;
					} else {
						interval = 210;
					}
				}
				
				var _chk = setInterval(function() {
					$('a.selected', _this.mat).focus();
					clearInterval(_chk);
				}, _interval);
			}
			
			// Call selectable
			this.m_input.click(function(event) {
				if ( _this.mat.is(':visible') ) return false;
				set_pos();
				$(this).addClass('sctble_focus');
				$('a.sctble_display').not(this).removeClass('sctble_focus');
				
				mat_show();
				event.stopPropagation();
				return false;
			}).keyup(function(event) {
				if( is_called ){
					set_pos();
					mat_show();
					event.stopPropagation();
				} else {
					is_called = true;
				}
			});
			
			// Stop event propagation
			this.mat.click(function(event) {
				event.stopPropagation();
			});
			
			// Hide the mat
			$('body, a').not('a.sctble_display').click(function(event) {
				$('a.sctble_display').removeClass('sctble_focus');
				mat_hide();
			}).not('a').keyup(function(event) {
				if ( event.keyCode=='27' ) {
					$('a.sctble_focus').removeClass('sctble_focus');
					is_called = false;
					_this.m_input.blur();
					mat_hide();
				}
			});
			
			// Click value append to both dummy and change original select value
			$('a', this.mat).click(function() {
				var self = $(this);
				_this.m_text.text(decodeURI(self.attr('href').split('#')[1]));
				$('option[value="'+self.attr('name')+'"]', _this.target).attr('selected', 'selected');
				$('.selected', _this.mat).removeClass('selected');
				self.addClass('selected');
				_this.m_input.removeClass('sctble_focus');
				is_called = false;
				mat_hide();
				
				if ( _this.conf.callback && typeof _this.conf.callback=='function' ) {
					_this.conf.callback.call(_this.target);
				}
				
				_this.m_input.focus();
				return false;
			});
			
			// Be able to click original select label
			$('label[for="'+this.attrs.id+'"]').click(function(event) {
				set_pos();
				_this.m_input.addClass('sctble_focus');
				$('a.sctble_focus').not(_this.m_input).removeClass('sctble_focus');
				mat_show();
				event.stopPropagation();
				return false;
			});
		}
	}
	
	// Extense the namespace of jQuery as method
	// This function returns (the) instance(s)
	$.fn.jQselectable = function(options, temp) {
		if ( $(this).length>1 ) {
			var _instances = [];
			$(this).each(function(i) {
				_instances[i] = new jQselectable(this, options, temp);
			});
			return _instances;
		} else {
			return new jQselectable(this, options, temp);
		}
	}
	
	// If namespace of jQuery.fn has 'selectable', this is 'jQselectable'
	// To prevent the interference of namespace
	// You can call 'selectable' method by both 'jQuery.fn.selectable' and 'jQuery.fn.jQselectable' you like
	if ( !jQuery.fn.selectable ) {
		$.fn.selectable = $.fn.jQselectable;
	}
	
})(jQuery);

/*
 * jQuery.zip2addr
 *
 * Copyright 2010, Kotaro Kokubo a.k.a kotarok kotaro@nodot.jp
 * Dual licensed under the MIT or GPL Version 2 licenses.
 *
 * https://github.com/kotarok/jQuery.zip2addr
 *
 * Depends:
 *	jQuery 1.4 or above
 */

$.fn.zip2addr = function(target){
    var c = {
		api: location.protocol + '//www.google.com/transliterate?langpair=ja-Hira|ja&jsonp=?',
		prefectureToken: '(東京都|道|府|県)',
		zipDelimiter: '-'
    }

	var cache = $.fn.zip2addr.cache;

    var getAddr = function(zip,callback){
        $.getJSON(c.api,{'text':zip},
			function(json){
				if(RegExp(c.prefectureToken).test(json[0][1][0])){
					callback(json[0][1][0].replace(RegExp('(.*?'+c.prefectureToken+')(.+)'),function(a,b,c,d){return [b,d]}))
				}
			}
		)
	}
	
	var fillAddr = (function(){
		if(typeof target == 'object' && target.pref){
			return function(addr){
				var addrs = addr.split(',');
				if(addrs){
					if(!RegExp(addrs[1]).test($(target.addr).val())){
						$(target.pref).val(addrs[0]);
						$(target.addr).val(addrs[1]);
					}
				}else if(!RegExp(addrs[1]).test($(target.addr).val())){
					$(target.pref).add(target.addr).val('');
				}
			}
		}else{
			return function(addr){
				var addrStr = addr.replace(',','');
				var addrField = target.addr || target;
				if(addrStr){
					if(!RegExp(addrStr).test($(addrField).val())){
						$(addrField).val(addrStr);
					}
				}else if(!RegExp(addrStr).test($(addrField).val())){
					$(addrField).val('');
				}
			}
		}
	})()

	//From http://liosk.blog103.fc2.com/blog-entry-72.html
	var fascii2ascii = (function() {
		var pattern = /[\uFF01-\uFF5E]/g, replace = function(m) {
			return String.fromCharCode(m.charCodeAt() - 0xFEE0);
		};
		return function(s){return s.replace(pattern, replace);};
	})();

	var check = function(_val){
		var val = fascii2ascii(_val).replace(/\D/g,'');
		if(val.length == 7){
			if(cache[val] == undefined){
				getAddr(val.replace(/(\d\d\d)(\d\d\d\d)/,'$1-$2'),function(json){
					cache[val] = json;
					fillAddr(json);
				})
			}else{
				fillAddr(cache[val]);
			}
		}
	}

    this.each(function(){
        var elem = $(this);
		if(typeof target == 'object' && target.zip2){
			elem.add($(target.zip2))
				.bind('keyup.zip2addr change.zip2addr',function(){
					check(elem.val()+''+$(target.zip2).val())
				})
				.bind('blur.zip2addr',function(){
					$(this).val(function(){
						return fascii2ascii($(this).val())
					})
				})
		}else{
			elem
				.bind('keyup.zip2addr change.zip2addr',function(){
					check(elem.val())
				})
				.bind('blur.zip2addr',function(){
					$(this).val(function(){
						return fascii2ascii($(this).val()).replace(/\D/g,'').replace(/(\d\d\d)(\d\d\d\d)/,'$1'+c.zipDelimiter+'$2')
					})
				})
		}
    });

    return this;
};

$.fn.zip2addr.cache = {};

/*====================================================================================================
//////////////////////////////////////////////////////////////////////////////////////////////////////

 author : http://www.yomotsu.net
 thanks : http://css-happylife.com
 created: 2008/02/23
 update : 2009/01/06
 
 public domain
 
 入力されたテキストを自動で指定の形式(半角,全角,ひらがな,全角カタカナ)に変換する JavaScript。
 自動で指定の形式に変換したい input 要素、または textarea 要素の class 属性に
 この JS 内の conf で設定した内容を指定すると動作します。

//////////////////////////////////////////////////////////////////////////////////////////////////////
====================================================================================================*/

var valueConvertor = {
	
	conf : {
		asciiClass        : "ascii",
		multibyteClass    : "multibyte",
		hiraganaClass     : "hiragana",
		katakanaClass     : "katakana",
		fullwidthKanaClass: "fullwidth-kana",
		halfwidthKanaClass: "halfwidth-kana"
	},
	

	main : function (){
		var i;
		var input    = document.getElementsByTagName("input");
		var textarea = document.getElementsByTagName("textarea");
		
		for ( i in valueConvertor.conf ){
			valueConvertor.conf[i] = new RegExp("\\b"+valueConvertor.conf[i]+"\\b");
		}
		
		for(i=0;i<input.length;i++)	{
			try {
				input[i].addEventListener('blur', valueConvertor.convert, false);
			} catch (e) {
				input[i].attachEvent('onblur', (function(el){return function(){valueConvertor.convert.call(el);};})(input[i])); 
			}
		}
		for(i=0;i<textarea.length;i++){
			try {	
				textarea[i].addEventListener('blur', valueConvertor.convert, false);
			} catch (e) {
				textarea[i].attachEvent('onblur', (function(el){return function(){valueConvertor.convert.call(el);};})(textarea[i])); 
			}
		}
	},

	convert : function(){
		
		if (this.className.match(valueConvertor.conf.asciiClass))
			this.value = valueConvertor.toAsciiCase(this.value);
		else if (this.className.match(valueConvertor.conf.multibyteClass))
			this.value = valueConvertor.toMultibyteCase(this.value);
			
		if (this.className.match(valueConvertor.conf.hiraganaClass)){
			this.value = valueConvertor.toZenkanaCase(this.value);
			this.value = valueConvertor.toHiraganaCase(this.value);
			this.value = valueConvertor.toPaddingCase(this.value);
		}
		else if (this.className.match(valueConvertor.conf.katakanaClass)){
			this.value = valueConvertor.toZenkanaCase(this.value);
			this.value = valueConvertor.toKatakanaCase(this.value);
			this.value = valueConvertor.toPaddingCase(this.value);
		}
		
		if(this.className.match(valueConvertor.conf.fullwidthKanaClass)){
			this.value = valueConvertor.toZenkanaCase(this.value);
			this.value = valueConvertor.toPaddingCase(this.value);
		}
		else if(this.className.match(valueConvertor.conf.halfwidthKanaClass)){
			this.value = valueConvertor.toHankanaCase(this.value);
		}
	},
	
	toAsciiCase : function(text){
		var i, charCode, charArray = [];
		for(i=text.length-1;0<=i;i--) {
			charCode = charArray[i] = text.charCodeAt(i);
			switch(true) {
				case (charCode <= 0xff5e && 0xff01 <= charCode):
					charArray[i] -= 0xfee0;
					break;
				case (charCode == 0x3000):
					charArray[i] = 0x0020;
					break;
				case (charCode == 0x30FC):
					charArray[i] = 0x002D;
					break;
			}
		}
		return String.fromCharCode.apply(null, charArray);
	},
	
	toMultibyteCase : function(text){
		var i, charCode, charArray = [];
		for(i=text.length-1;0<=i;i--)
		{
			charCode = charArray[i] = text.charCodeAt(i);
			switch(true) {
				case (charCode <= 0x007E && 0x0021 <= charCode):
					charArray[i] += 0xFEE0;
					break;
				case (charCode == 0x0020):
					charArray[i] = 0x3000;
					break;
			}
		}
		return String.fromCharCode.apply(null, charArray);	
	},
	
	toZenkanaCase : function(text){
		var i, charCode, m, charArray = [];
		m =
		{
			0xFF66:0x30F2, 0xFF67:0x30A1, 0xFF68:0x30A3, 0xFF69:0x30A5, 0xFF6A:0x30A7,
			0xFF6B:0x30A9, 0xff6c:0x30e3, 0xff6d:0x30e5, 0xff6e:0x30e7, 0xff6f:0x30c3,
			0xFF70:0x30FC, 0xFF71:0x30A2, 0xFF72:0x30A4, 0xFF73:0x30A6, 0xFF74:0x30A8,
			0xFF75:0x30AA, 0xFF76:0x30AB, 0xFF77:0x30AD, 0xFF78:0x30AF, 0xFF79:0x30B1,
			0xFF7A:0x30B3, 0xFF7B:0x30B5, 0xFF7C:0x30B7, 0xFF7D:0x30B9, 0xFF7E:0x30BB,
			0xFF7F:0x30BD, 0xFF80:0x30BF, 0xFF81:0x30C1, 0xFF82:0x30C4, 0xFF83:0x30C6,
			0xFF84:0x30C8, 0xFF85:0x30CA, 0xFF86:0x30CB, 0xFF87:0x30CC, 0xFF88:0x30CD,
			0xFF89:0x30CE, 0xFF8A:0x30CF, 0xFF8B:0x30D2, 0xFF8C:0x30D5, 0xFF8D:0x30D8,
			0xFF8E:0x30DB, 0xFF8F:0x30DE, 0xFF90:0x30DF, 0xFF91:0x30E0, 0xFF92:0x30E1,
			0xFF93:0x30E2, 0xFF94:0x30E4, 0xFF95:0x30E6, 0xFF96:0x30E8, 0xFF97:0x30E9,
			0xFF98:0x30EA, 0xFF99:0x30EB, 0xFF9A:0x30EC, 0xFF9B:0x30ED, 0xFF9C:0x30EF,
			0xFF9D:0x30F3, 0xFF9E:0x309B, 0xFF9F:0x309C
		};
		
		for(i=text.length-1;0<=i;i--){
			charCode = text.charCodeAt(i);
			if (m[charCode]){
				charArray[i] = m[charCode];
			}
			else{
				charArray[i] = charCode;
			}
		}
		
		return String.fromCharCode.apply(null, charArray);
	},
	
	toHankanaCase : function(text){
		var i, charCode, m, charArray = [];
		m =
		{
			0x30A1:0xFF67, 0x30A3:0xFF68, 0x30A5:0xFF69, 0x30A7:0xFF6A, 0x30A9:0xFF6B,
			0x30e3:0xff6c, 0x30e5:0xff6d, 0x30e7:0xff6e, 0x30c3:0xff6f, 0x30FC:0xFF70,
			0x30A2:0xFF71, 0x30A4:0xFF72, 0x30A6:0xFF73, 0x30A8:0xFF74, 0x30AA:0xFF75,
			0x30AB:0xFF76, 0x30AD:0xFF77, 0x30AF:0xFF78, 0x30B1:0xFF79, 0x30B3:0xFF7A,
			0x30B5:0xFF7B, 0x30B7:0xFF7C, 0x30B9:0xFF7D, 0x30BB:0xFF7E, 0x30BD:0xFF7F,
			0x30BF:0xFF80, 0x30C1:0xFF81, 0x30C4:0xFF82, 0x30C6:0xFF83, 0x30C8:0xFF84,
			0x30CA:0xFF85, 0x30CB:0xFF86, 0x30CC:0xFF87, 0x30CD:0xFF88, 0x30CE:0xFF89,
			0x30CF:0xFF8A, 0x30D2:0xFF8B, 0x30D5:0xFF8C, 0x30D8:0xFF8D, 0x30DB:0xFF8E,
			0x30DE:0xFF8F, 0x30DF:0xFF90, 0x30E0:0xFF91, 0x30E1:0xFF92, 0x30E2:0xFF93,
			0x30E4:0xFF94, 0x30E6:0xFF95, 0x30E8:0xFF96, 0x30E9:0xFF97, 0x30EA:0xFF98,
			0x30EB:0xFF99, 0x30EC:0xFF9A, 0x30ED:0xFF9B, 0x30EF:0xFF9C, 0x30F3:0xFF9D,
			0x309B:0xFF9E, 0x309C:0xFF9F, 0x30F2:0xFF66
		};
		for(i=0;i<text.length;i++) {
			charCode = text.charCodeAt(i);
			switch(true) {
				case (charCode in m):
					charArray.push(m[charCode]);
					break;
				case (0x30AB <= charCode && charCode <= 0x30C9):
					charArray.push(m[charCode-1], 0xFF9E);
					break;
				case (0x30CF <= charCode && charCode <= 0x30DD):
					charArray.push(m[charCode-charCode%3], [0xFF9E,0xFF9F][charCode%3-1]);
					break;
				case (0x30f4 == charCode):
					charArray.push(0xff73, 0xFF9E);
					break;
				default:
					charArray.push(charCode);
					break;
			}
		}
		return String.fromCharCode.apply(null, charArray);
	},
	
	toHiraganaCase : function(text){
		var i, charCode, charArray = [];
		for(i=text.length-1;0<=i;i--){
			charCode = text.charCodeAt(i);
			charArray[i] = (0x30A1 <= charCode && charCode <= 0x30F6) ? charCode - 0x0060 : charCode;
		}
		return String.fromCharCode.apply(null, charArray);
	},
	
	toKatakanaCase : function(text){
		var i, charCode, m, charArray = [];
		for(i=text.length-1;0<=i;i--){
			charCode = text.charCodeAt(i);
			if(0x3041 <= charCode && charCode <= 0x3096){
				charArray[i] = charCode + 0x0060 ;
			}
			else{
				charArray[i] = charCode;
			}
		}
		return String.fromCharCode.apply(null, charArray);
	},
		
	//半角の濁点、半角の半濁点の処理
	toPaddingCase : function(text){
		var i, charCode, charArray = [];
		for(i=0;i<text.length;i++)
		{
			charCode = text.charCodeAt(i);
			switch(true)
			{
				case (0x304B <= charCode && charCode <= 0x3062 && (charCode % 2 == 1)):
				case (0x30AB <= charCode && charCode <= 0x30C2 && (charCode % 2 == 1)):
				case (0x3064 <= charCode && charCode <= 0x3069 && (charCode % 2 == 0)):
				case (0x30C4 <= charCode && charCode <= 0x30C9 && (charCode % 2 == 0)):
					charArray.push(charCode + ({0x309B:1}[text.charCodeAt(i+1)] || 0));
					if(charArray[charArray.length-1] != charCode){ i++; };
					break;
				case (0x306F <= charCode && charCode <= 0x307F && (charCode % 3 == 0)):
				case (0x30CF <= charCode && charCode <= 0x30DD && (charCode % 3 == 0)):
					charArray.push(charCode + ({0x309B:1,0x309C:2}[text.charCodeAt(i+1)] || 0));
					if(charArray[charArray.length-1] != charCode){ i++; };
					break;
				case (0x3046 == charCode || 0x30a6 == charCode):
					charArray.push(charCode + ({0x309B:78}[text.charCodeAt(i+1)] || 0));
					if(charArray[charArray.length-1] != charCode){ i++; };
					break;
				default:
					charArray.push(charCode);
					break;
				}
		}
		return String.fromCharCode.apply(null, charArray);
	},
	
	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
	
}

valueConvertor.addEvent();

/*
 * smartRollover
 */
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

/*
 * Animated Scrolling
 */
$(document).ready(function(){
  $('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}, 400);
       return false;
      }
    }
  });
});

/* User Agent Snippet */
var _ua = (function(){
 return {
  ltIE6:typeof window.addEventListener == "undefined" && typeof document.documentElement.style.maxHeight == "undefined",
  ltIE7:typeof window.addEventListener == "undefined" && typeof document.querySelectorAll == "undefined",
  ltIE8:typeof window.addEventListener == "undefined" && typeof document.getElementsByClassName == "undefined",
  mobile:/android|iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase())
 }
})();
