var URI = location.href.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?/i);
var DOMAIN = URI[1]+URI[3]+"/";
//var DOMAIN = "";//Local

window.addEvent('domready', function(){
	new wtnFontSize("header",{imgDir:DOMAIN+'images/fontsize/'});
	
	/* go to top */
	new GotoTop();

	/* IE6 No More! */
	//new IE6NoMoore();
	
	new wtnLinkIcons({excludeStr:["file:///","localhost","http://web-zero.jp",DOMAIN],iconDir:DOMAIN+"images/filetype/",QuickBox:true,open:"blank"});

});

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9643752-31']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

/**
 * wtnFontSize
 * @ver 1.0
 */
var wtnFontSize = new Class({
	
	Implements: [Options],

	options: {
		imgDir:"images/fontsize/",
		alt:{'small':'小','medium':'中','large':'大'},
		size:{
				'small':[11,"x-small"],
				'medium':[13,"small"],
				'large':[15,"medium"]
		}
	},
	initialize: function(container,options) {
		this.setOptions(options);
		this.container = $(container);
		if(!this.container) return;
		this.active = null;
		$this = this;
		var cookie = Cookie.read("wtnFontSize");
		if(cookie) this.set(this.options.size[cookie][0],this.options.size[cookie][1]);
		this.element = new Element("div",{'id':'fontsize','html':'<span class="label">文字サイズ</span>'});
		this.createButton(cookie);
		this.buttons.each(function(el,i){
			el.addEvents({
				"click":function(e){
					if($this.active) $this.active.tween(1);
					el.tween(0);
					$this.set($this.options.size[el.className][0],$this.options.size[el.className][1]);
					Cookie.write('wtnFontSize', el.className, { duration: 30});
					$this.active = el;
				},
				"mouseover":function(){
					if(el.style.visibility!="hidden") el.tween(0.5);
				},
				'mouseleave':function(){
					if(!$this.active || ($this.active.className != el.className)) el.tween(1);
				}
			});
			el.inject($this.element);
		});
		
		this.element.inject(this.container);
	},
	createButton:function(c){
		this.buttons = [];
		['small','medium','large'].each(function(n,i){
			var el = new Element("img",{'src':this.options.imgDir+n+'.png',"alt":this.options.alt[n], 'class':n, 'tween':{'property': 'opacity','link':'cancel'}});
			if(c==n){ el.fade('hide');this.active=el;}
			this.buttons.push(el);
		},this);
	},
	set:function(moz,ie){
		if(Browser.Engine.trident&&Browser.Engine.version<=5)
			document.body.style.fontSize = ie;
		else
			$(document.body).setStyle("font-size",moz);
	}
});

/**
 * GotoTop
 * @ver 1.1
 * ページのトップに戻るボタン
 */
var GotoTop=new Class({Implements:[Options],options:{id:"gototop",width:100},initialize:function(a){this.setOptions(a);this.width=this.options.width;this.gototop=$(this.options.id);var ss = new SmoothScroll({duration:500});window.store('SmoothScroll', ss);this.gototop&&this.start()},start:function(){var a=this;a.gototop.set("opacity","0").setStyle("display","block");window.addEvent("scroll",function(){Browser.Engine.trident4&&a.gototop.setStyles({position:"absolute",bottom:window.getPosition().y+10,width:this.width});a.gototop.fade(window.getScroll().y>
300?"in":"out")})}});

/**
 * IE6NoMoore
 * @ver 1.1.1
 * 
 * IE6への警告を表示する
 */
var IE6NoMoore=new Class({Implements:[Options],options:{css:true,image:"images/IE6NoMore/",topMargin:75},initialize:function(a){this.setOptions(a);this.imgurl=this.options.image;this.first=$$("body")[0].getFirst();$this=this;this.container=new Element("div",{id:"IE6NoMore"});this.wrap=new Element("div",{"class":"wrap"});this.closebtn=new Element("img",{"class":"close",src:this.imgurl+"ie6nomore-cornerx.jpg",alt:"\u9589\u3058\u308b",events:{click:function(){this.getParent().dispose();$(document.body).setStyle("padding-top", 0);Cookie.write("IE6NoMoore","true")}}});this.warning=new Element("img",{"class":"warning",src:this.imgurl+"ie6nomore-warning.jpg",alt:"Warning!"});this.message=new Element("div",{"class":"nomore-message",html:"\u3053\u306e\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u3092\u5feb\u9069\u306b\u95b2\u89a7\u3059\u308b\u306b\u306f\u30d6\u30e9\u30a6\u30b6\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u304f\u3060\u3055\u3044\u3002"});this.strongmes=new Element("strong",{html:"\u3042\u306a\u305f\u306f\u65e7\u5f0f\u30d6\u30e9\u30a6\u30b6\u3092\u3054\u5229\u7528\u4e2d\u3067\u3059"}); this.firefox=new Element("img",{src:this.imgurl+"ie6nomore-firefox.jpg",alt:"Get Firefox 3.5"});this.ie8=new Element("img",{src:this.imgurl+"ie6nomore-ie8.jpg",alt:"Get Internet Explorer 8"});this.safari=new Element("img",{src:this.imgurl+"ie6nomore-safari.jpg",alt:"Get Safari 4"});this.chrome=new Element("img",{src:this.imgurl+"ie6nomore-chrome.jpg",alt:"Get Google Chrome"});if(Browser.Engine.trident&&Browser.Engine.version<5&&!Cookie.read("IE6NoMoore")){this.first.grab(this.container,"before"); $(document.body).setStyle("padding-top",this.options.topMargin);$type(this.options.css)=="string"&&this.asset();this.start()}},start:function(){this.container.grab(this.wrap).grab(this.closebtn);this.warning.inject(this.wrap);this.message.grab(this.strongmes,"top").inject(this.wrap);(new Element("a",{href:"http://www.mozilla.jp",target:"_blank"})).grab(this.firefox).inject(this.wrap);(new Element("a",{href:"http://www.microsoft.com/downloads/details.aspx?FamilyID=341c2ad5-8c3d-4347-8c03-08cdecd8852b&DisplayLang=ja", target:"_blank"})).grab(this.ie8).inject(this.wrap);(new Element("a",{href:"http://www.apple.com/jp/safari/download/",target:"_blank"})).grab(this.safari).inject(this.wrap);(new Element("a",{href:"http://www.google.com/chrome?hl=ja",target:"_blank"})).grab(this.chrome).inject(this.wrap)},asset:function(){new Asset.css(this.options.css)}});

/**
 * wtnLinkIcons
 * @ver 1.4
 * 
 * 別窓を開くアイコンとhrefの拡張子に応じたアイコンや属性を追加
 */

var wtnLinkIcons=new Class({Implements:[Options],options:{areaID:"",ExternalLink:true,linkTitle:"\u30ea\u30f3\u30af\u3092\u65b0\u3057\u3044\u30a6\u30a4\u30f3\u30c9\u30a6\u3067\u958b\u304f",addExtIconClass:"exiAdd",open:"blank",excludeStr:[],FiletypeIcon:true,ImagetypeIcon:false,media:["pdf","doc","zip","xls","mov","mp3","psd","swf","txt","wmv",".ai","exe","ppt","mpg","flv"],iconType:"gif",iconDir:"images/filetype/",iconW:16,iconH:16,QuickBox:false},initialize:function(a){this.setOptions(a);this.exStr= this.options.excludeStr;this.addExI=this.options.addExtIconClass;this.media=this.options.media;this.iconD=this.options.iconDir;this.iconT=this.options.iconType;this.iconW=this.options.iconW;this.iconH=this.options.iconH;this.linkT=this.options.linkTitle;this.imgR=this.options.imgRel;this.FtI=this.options.FiletypeIcon;this.QuickBox=this.options.QuickBox;this.External=this.options.ExternalLink;this.gallery=false;this.gNum=0;this.area=this.options.areaID==""?$(document.body):$(this.options.areaID);this.area.getElements("a[href]").each(this.addIcon, this);return true},addExternal:function(a){if(this.External){var b=this.options.open=="js"?new Element("a",{href:"#",title:this.linkT,"class":"newWin",events:{click:function(){window.open(a.href);return false}}}):new Element("a",{href:a.href,title:this.linkT,target:"_blank","class":"newWin"});b.set("html",'<img src="'+this.iconD+"external."+this.iconT+'" width="'+this.iconW+'" height="'+this.iconH+'" alt="" class="icon" />');b.inject(a,"after")}},addArgs:function(a,b){if(a==1){a=b.getProperty("rel");a=a!=null? " "+a:"";b.setProperty("rel","quickbox"+a)}else if(this.External)this.options.open=="js"?b.addEvent("click",function(){window.open(this.href);return false}):b.setProperty("target","_blank")},createIcon:function(a,b){return new Element("img",{"class":"icon",src:this.iconD+a+"."+this.iconT,width:this.iconW,height:this.iconH,alt:b})},addIcon:function(a){var b=this,d=a.href,c=d.replace(d.slice(0,-3),"").toLowerCase(),e=a.get("text"),h=a.getChildren("img"),g=exiskip=expAdd=exiAdd=false,f=a.getProperties("target", "onclick","Class");this.options.ImagetypeIcon==true&&this.media.extend(["jpg","gif","png"]);if(a.hasClass("icoSkip")||a.hasClass("jbiwnjtorzbrnezsjqya"))g=true;if(a.hasClass("exiSkip")||f.target||f.onclick&&f.onclick.indexOf("window.open")!==-1||a.hasClass("jbiwnjtorzbrnezsjqya"))exiskip=true;if(a.hasClass("expAdd"))expAdd=true;if(a.hasClass(this.addExI))exiAdd=true;var i=this.exStr.some(function(j){if(d.indexOf(j)!==-1)return true})+$chk(d.match(/\.gif$|\.png$|\.jpg$|\.doc$|\.psd$|\.zip$|\.xls$|\.ai$|\.exe$|^mailto:|window\.print\(\)/)); if(c=="jpg"||c=="gif"||c=="png")if(this.QuickBox===true){g=true;b.addArgs(1,a)}else if(e==""&&this.QuickBox===false){g=true;b.addArgs(0,a)}else this.QuickBox===false&&b.addExternal(a);else if(!exiskip)if(!exiskip&&expAdd||expAdd)b.addArgs(2,a);else if(c=="txt"||c=="pdf"||c=="swf"||c=="mpg"||c=="mp3"||d!=""&&!i&&h.length==0||exiAdd)b.addExternal(a);else if(e!=""&&h.length!=0&&d!=""&&!i||e==""&&h.length!=0&&d!=""&&!i)b.addArgs(2,a);if(!g&&this.FtI==true){if(f.Class&&f.Class.indexOf("icoAdd")!==-1){e= f.Class.slice(7);b.createIcon(e.toLowerCase(),e.toUpperCase()+" File").inject(a,"before")}if(this.media.contains(c)){if(c.slice(0,1)==".")c=c.replace(".","");b.createIcon(c,c.toUpperCase()+" File").inject(a,"before")}else if(a.protocol=="mailto:")b.createIcon("email","Mail").inject(a,"before");else if(a.protocol==="https:")b.createIcon("https","SSL Page").inject(a,"before");else d=="javascript:window.print()"&&b.createIcon("print","Print").inject(a,"before")}}});

