/**                                           
 * raccoon.js
 * @author Tenderfeel
 * @ver 1.0
 * @HOME http://tenderfeel.xsrv.jp/
 * 
 * @Need:mootools 1.2
 *
 * ---MIT License--------------------------------------------
 * Copyright (c) 2008 Tenderfeel all rights reserved.
 * ----------------------------------------------------------
 */
 
var URI = location.href.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?/i);
var DOMAIN = URI[1]+URI[3]+"/";

//Google Ajax API KEY
var gAPIkey = 'ABQIAAAAwrzVu2iAWtCM12EpP4ZXHBSTHbMmSWwo84Xs4DGdfTaFbZ_W9BQ9Wrk9fOCKW0YOxXl77z9U3HKtnw';

//Google Analytics
var gANALYTICS_ID = 'UA-9643752-30';

window.addEvent('domready', function(){
									 
	new wtnRollover({area:"#main"});

	/* go to top */
	new GotoTop();
	
	if(Browser.Engine.trident && Browser.Engine.version <= 4 && $("teaser")){
		var size = window.getSize();
		$("teaser").setStyle("width",size.x);
	}
	
	if(Browser.Engine.trident4) {
		$("footer").setStyle("margin-top",-15);
	}
	
	/* IE6 No More! */
	new IE6NoMoore();
	
	new wtnLinkIcons({excludeStr:["file:///","http://web-zero.jp",DOMAIN],iconDir:"images/filetype/",QuickBox:true,open:"blank"});
	
	//Google Ajax API
	if(gAPIkey){
		new Element("script",{"src":'http://www.google.com/jsapi?callback=googleAPIloadings&key='+gAPIkey,"type":"text/javascript"}).inject($(document.body),"bottom");
	}
});


/** QuickBox Plugin */
var external_js = new Asset.javascript(DOMAIN+'js/QuickBox.js');
var myCSS = new Asset.css(DOMAIN+"css/quickbox.css",{ "media":"screen"});


/*****  Google Ajax API Config *****/
var gs,gm,gf;

/** Gmap */
var gmConfig = {
	"pageName":"shopinfo.html",//表示するページ
	"gmLat":35.34444,  //GLat
	"gmLng":137.1202356, //GLng
	"gmDivID":"gmap",    //地図を表示する要素のID
	"gmScope":18,        //拡大率
	"markerAdd":true,  //マーカーの表示
	"SMap_Controler":false, //小さいコントローラ
	"LMap_Controler":true, //大きいコントローラ
	"SmallZoomControl":false,//ズームコントローラ
	"NavLabelControl":true,//ナビゲーションレベルコントローラ
	"Type3_Controler":true, //地図タイプ切り替え（３種）
	"Type2_Controler":false, //地図タイプ切り替え（2種）
	"Scale_Controler":true, //スケール
	"OV_Controler":true, //右下の縮小地図
	"WheelZoom":false, //ホイールでのズーム操作
	"DClickZoom":true, //ダブルクリックでのズーム操作
	"WindowHTML":"<em>ベストカーテン</em><br />〒507-0015 岐阜県多治見市住吉町6-19-1"//情報ウィンドウのHTML
}

if(gmConfig&&location.href.indexOf(gmConfig.pageName)!==-1){gm=new Asset.javascript(DOMAIN+'js/gmap.js');}

function googleAPIloadings(){
	if(gm){google.load("maps", "2",{"callback" : "mapsLoaded","language" : "ja"});}
}

/**** Google Analytics ****/
if(gANALYTICS_ID!=""){
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', gANALYTICS_ID]);
	_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);
	})();
}

/**
 * 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)}});

/**
 * GotoTop
 * @ver 1.0
 * ページのトップに戻るボタン
 */
var GotoTop=new Class({Implements:[Options],options:{id:"gototop","class":"gotoTop",width:100},initialize:function(a){this.setOptions(a);this.width=this.options.width;if(this.gototop=$(this.options.id))this.start();else return false;new SmoothScroll({duration:500})},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")})}});


/**
 * wtnRollover
 * @ver 1.0
 * リンク下にある画像をロールオーバーor透過処理させる
 */

var wtnRollover=new Class({Implements:[Options],options:{area:"body",over:"_on",off:"_off",duration:300},initialize:function(b){this.setOptions(b);this.overTxt=this.options.over;this.offTxt=this.options.off;(this.imgs=$$(this.options.area+" a img"))&&this.Roll();return true},Roll:function(){var b=this;b.imgs.each(function(a){if($type(a)=="element"&&!a.hasClass("rollskip")){a.set("tween",{duration:b.options.duration});a.addEvents({mouseover:function(){if(a.src.indexOf(b.offTxt)===-1)a.tween("opacity", 0.5);else a.src=a.src.replace(b.offTxt,b.overTxt)},mouseleave:function(){if(a.src.indexOf(b.overTxt)===-1)a.tween("opacity",1);else a.src=a.src.replace(b.overTxt,b.offTxt)}})}})}});

/**
 * wtnLinkIcons
 * @ver 1.3
 * 
 * 別窓を開くアイコンと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="" />');b.inject(a,"after")}},addArgs:function(a,b){if(a==1){var c=b.getProperty("rel");b.setProperty("rel",
"quickbox"+(c!=null?" "+c:""))}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=a.href,c=b.replace(b.slice(0,-3),"").toLowerCase(),d=a.get("text"),g=a.getChildren("img"),f=exiskip=expAdd=exiAdd=false,e=a.getProperties("target","onclick",
"Class");this.options.ImagetypeIcon==true&&this.media.extend(["jpg","gif","png"]);if(a.hasClass("icoSkip")||a.hasClass("jbiwnjtorzbrnezsjqya"))f=true;if(a.hasClass("exiSkip")||e.target||e.onclick&&e.onclick.indexOf("window.open")!==-1||a.hasClass("jbiwnjtorzbrnezsjqya"))exiskip=true;if(a.hasClass("expAdd"))expAdd=true;if(a.hasClass(this.addExI))exiAdd=true;var h=this.exStr.some(function(i){if(b.indexOf(i)!==-1)return true})+$chk(b.match(/\.gif$|\.png$|\.jpg$|\.doc$|\.psd$|\.zip$|\.xls$|\.ai$|\.exe$|^mailto:|window\.print\(\)/));
if(c=="jpg"||c=="gif"||c=="png")if(this.QuickBox===true){f=true;this.addArgs(1,a)}else if(d==""&&this.QuickBox===false){f=true;this.addArgs(0,a)}else this.QuickBox===false&&this.addExternal(a);else if(!exiskip)if(!exiskip&&expAdd||expAdd)this.addArgs(2,a);else if(c=="txt"||c=="pdf"||c=="swf"||c=="mpg"||c=="mp3"||b!=""&&!h&&g.length==0||exiAdd)this.addExternal(a);else if(d!=""&&g.length!=0&&b!=""&&!h||d==""&&g.length!=0&&b!=""&&!h)this.addArgs(2,a);if(!f&&this.FtI==true){if(e.Class&&e.Class.indexOf("icoAdd")!==
-1){d=e.Class.slice(7);this.createIcon(d.toLowerCase(),d.toUpperCase()+" File").inject(a,"before")}if(this.media.contains(c)){if(c.slice(0,1)==".")c=c.replace(".","");this.createIcon(c,c.toUpperCase()+" File").inject(a,"before")}else if(a.protocol=="mailto:")this.createIcon("email","Mail").inject(a,"before");else if(a.protocol==="https:")this.createIcon("https","SSL Page").inject(a,"before");else b=="javascript:window.print()"&&this.createIcon("print","Print").inject(a,"before")}}});

