(function($, window){
	// データ読み込み
	// 初期ロード時グローバル変数
	Array.prototype.shuffle=function(){
		var list = this;
		var i = list.length;
		while (--i) {
		var j = Math.floor(Math.random() * (i + 1));
		if (i == j) continue;
		var k = list[i];
			list[i] = list[j];
			list[j] = k;
		}
		return list;
	}
	window.jQIKData = $.jQIKData = {
		selector : {
			jQIKLoader : "#jQIKTopHeadLoader"
		},
		image : {
			loader : "/images/loader.gif"
		},
		script:{
			xmlPath : "/scripts/php/xml.php",
			kmlPath : "/scripts/php/kml.php"
		}
	};
	var s = $.jQIKData.selector,i = $.jQIKData.image;
	// MT XMLデータ初期ロード
	$.ajax({url : jQIKData.script.xmlPath, data:{type:"index"},dataType : "json",
			beforeSend : function(){
				$(function(){$(document.body).append('<img src="'+i.loader+'" id="' + s.jQIKLoader.replace("#","") + '" style="position:absolute;top:'+($("#header").height()/2)+'px;left:50%;">');});
			},
			success : function(json){
			window.jQIKData.AreaIndex = json;
			// console.log(location.host);
			var host = location.host;
			jQIKEncodeData[host] = base64decode(jQIKEncodeData[host]);
			// console.log(json.node,jQIKEncodeData[host]);
			window.jQIKData.JsonArray = [];
			// すべての地域を取得
			var node = json.node;
			var basicAuth = jQIKEncodeData;
			
			for(var i=0;i<node.length;i++){
				var href = json.node[i].link["@attributes"].href;
				href = href.split('http://');
				var url401 = "http://" + basicAuth[host] +href[1];
				$.ajax({url : jQIKData.script.xmlPath, data:{type:"archive", url:url401}, dataType : "json", success : function(jsonArchive){window.jQIKData.JsonArray.push(jsonArchive);}});
			}
			
		}
	});
	// Google MyMap KMLデータ初期ロード
	$.ajax({url : jQIKData.script.kmlPath,dataType : "json",success : function(json){window.jQIKData.KML = json;}});
	$.ajax({url : jQIKData.script.kmlPath,data:{type:"place"}, dataType : "json",success : function(json){window.jQIKData.Placemark = json;}});
	// データ読み込み
	// データ読み込み完了処理
})(jQuery, window);
(function($, window){
	var setting = {
		size : {
			map:{width:270, height:215},
			width :270,// GoogleMap - width
			height :215,// GoogleMap - height
			image:{
				animal :{
					large : {width:370,height:250},
					thumbs :{width:90,height:90}
				},
				label :{width:100,height:100}
			}
		}, 
		selector : {
			jQIKStamp : "#jQIKStamp",// Root Element
			jQIKStampHeader : "#jQIKStampHeader",
			jQIKMaps : "#vcmap",
			jQIKVCInfo : "#vcinfo",
			jQIKSymbolAnimalPhoto : "#vcphoto",//生き物写真(Large)
			jQIKStampLabel : "#vcstamp",//シンボル画像
			jQIKSealLabel: "#vcseal",//シール画像
			jQIKSlider : "#vclist"
		},
		groupID:[],
		api:{
			Google:{
				source : {
					map : "",
					ajax : ""
				},
				map : {
					"localhost" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BTlx4nDiNho73p6zHngF8Vo8nSqvBRHNBcHgatd5r4U8_C8DpKGotfiTQ",
					"ikimono-meguri.go.jp" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BSgrgGBjXI9C4WX6fOe2-bupz-bzRRNJjaNZf6xbHVFAtmw44pvMSuuFw",
					"www.ikimono-meguri.go.jp" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BQU6hAKkwpkR5pnlyVGsQUoVMZG1BSBZzBXwQJpMHF8fgyEH2nlXy7pMA",
					"www.ikimono-meguri.go.jp" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BQWWzsaVbCbH8PW-y9iEzZDQ3d7FRQDG_3O_Ex-4iodEmDVcrRlY-W5xA",
					"www.ikimono-meguri.go.jp" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BQOX335fSTvarQFaMpiDlRYTH2WvRRrNktoOXk4gf_Yw0XwCAv8B3FhMA"
				},
				ajax : {
					"localhost" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTgbsjIkP76TTbD-2DdDskRVIL4RQ",
					"ikimono-meguri.go.jp" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BSgrgGBjXI9C4WX6fOe2-bupz-bzRRNJjaNZf6xbHVFAtmw44pvMSuuFw",
					"www.ikimono-meguri.go.jp" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BQU6hAKkwpkR5pnlyVGsQUoVMZG1BSBZzBXwQJpMHF8fgyEH2nlXy7pMA",
					"www.ikimono-meguri.go.jp" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BQWWzsaVbCbH8PW-y9iEzZDQ3d7FRQDG_3O_Ex-4iodEmDVcrRlY-W5xA",
					"www.ikimono-meguri.go.jp" : "ABQIAAAAMQVvSZKtoV97HNFZLyeh4BQOX335fSTvarQFaMpiDlRYTH2WvRRrNktoOXk4gf_Yw0XwCAv8B3FhMA",
					"ikimono-staging.ball-inc.co.jp":""
				},
				key : function(api_service){/* Return API KEY - Location.HOST */var host = location.host;return this.api.Google[api_service][host];}
			}
		},
		element :function(){
			var s = setting.selector,str = '<div id="'+s.jQIKStamp.replace("#","")+'">'+
			'<div id="'+s.jQIKSymbolAnimalPhoto.replace("#","")+'"></div>'+
			'<div id="'+s.jQIKStampLabel.replace("#","")+'"></div>'+
			'<div id="'+s.jQIKSealLabel.replace("#","")+'"></div>'+
			'<div id="'+s.jQIKMaps.replace("#","")+'"></div>'+
			'<div id="'+s.jQIKVCInfo.replace("#","")+'"></div>'+
			'<ul id="'+s.jQIKSlider.replace("#","")+'"></ul>'+
			'</div>';
			return str;
		}
	},
	jQIKStamp = window.jQIKStamp = $.jQIKStamp = function(vars){
		return jQIKStamp.prototype.init(vars);
	}
	jQIKStamp.prototype = {
		element : setting.element,
		size : setting.size,
		selector : function(){
			return setting.selector;
		},
		image : {},
		vars : {},
		map : {},
		init : function(vars){
			var html = this.element,
			v = vars,
			$this = this;
			$(function(){
				if(typeof v.selector == "undefined") v.selector = document.body;
				if(typeof v.width == "undefined") v.width = $(document).width();
				if(typeof v.height == "undefined") v.height = $(document).height();
				var s = $this.selector();
				$(v.selector).append(html);
				// マップ作成前に一意に設定されたシンボル
				// スライダーの設定
				var maxnum=6,entrys ={entry : $this.animalGroupMerge(maxnum)};
				// console.log(entrys.entry.length, entrys.entry.length/maxnum);
				$this.stampSlider($this,entrys,{min:0, max:maxnum}); /* length/6からlength/7へ書換え */
				// スタンプ - ローディング
				// console.log(jQIKData.Xml.entry);
				var num = 0;
				var entry = entrys.entry[num];
				$this.kmlMap(v, $this);
				var animalImageSize = {width:$this.size.image.animal.large.width,height:$this.size.image.animal.large.height},
				labelImageSize = {width:$this.size.image.label.width,height:$this.size.image.label.height};
				$this.addImages(s.jQIKSymbolAnimalPhoto,'', entry.symbol.image[1]["@attributes"].src, {size:animalImageSize});
				$this.addImages(s.jQIKStampLabel,'', entry.stamp.image["@attributes"].src, {
					size: labelImageSize
				});
				$this.addImages(s.jQIKSealLabel,'', entry.seal.image["@attributes"].src, {
					size: labelImageSize
				});
				
				var groups;
				for(var k=0;k<jQGlobalGroups.length;k++){
					if(Number(jQGlobalGroups[k].gID) == entry.vcGID) groups = jQGlobalGroups[k];
				}
				if(typeof groups.group=="undefined") groups.group=""
				$this.infoView( s.jQIKVCInfo, entry.title, entry.link["@attributes"].href, entry.contents, entry.address, entry.symbolAnimal, groups.group );
				
				window.jQIKSliderStart = false;
				/* 自動再生 */
				var slShow = setInterval(function(){
					num++;
					window.jQIKSliderStart = true;
					if(window.jQIKSliderClick){
						clearInterval(slShow);
						return;
					}
					if(num > entrys.entry.length) num=0;
					var entry = entrys.entry[num];
					if (typeof entry == "undefined") {
						return;
					}
					var animalImageSize = {width:$this.size.image.animal.large.width,height:$this.size.image.animal.large.height},
					labelImageSize = {width:$this.size.image.label.width,height:$this.size.image.label.height};
					$this.addImages(s.jQIKSymbolAnimalPhoto,'', entry.symbol.image[1]["@attributes"].src, {size:animalImageSize});
					$this.addImages(s.jQIKStampLabel,'', entry.stamp.image["@attributes"].src, {size: labelImageSize});
					$this.addImages(s.jQIKSealLabel,'', entry.seal.image["@attributes"].src, {size: labelImageSize});
					var groups;
					for(var k=0;k<jQGlobalGroups.length;k++){
						if(Number(jQGlobalGroups[k].gID) == entry.vcGID) groups = jQGlobalGroups[k];
					}
					if(typeof groups=="undefined") groups.group="";
						$this.infoView( s.jQIKVCInfo, entry.title, entry.link["@attributes"].href, entry.contents, entry.address, entry.symbolAnimal, groups.group );
					
					var coord = entry.Placemark.Point.coordinates.split(",");
					if(typeof window.oldinfowindow != "undefined"){
						window.oldinfowindow.close();
					}
					var latlng = new google.maps.LatLng(coord[1], coord[0]);
					var contentString = "<div class='gmapVcInfo'>"+
					'<h3><a href="'+entry.link["@attributes"].href+'">' + entry.title + '</a></h3>'+
					"</div>";
					var infowindow = new google.maps.InfoWindow({content: contentString});
					var marker = new google.maps.Marker({position: latlng, map: $this.map, visible:false});
					$this.map.panTo(latlng);
					// $this.infoView( s.jQIKVCInfo, entry.title, entry.link["@attributes"].href, entry.contents, entry.address, entry.symbolAnimal, groups.group );
					infowindow.open($this.map, marker);
					window.oldinfowindow = infowindow;
					$(".gmapVcInfo").css({"font-size":"10pt"});
				count++;
				}, 10000);
				
			});
			return this;
		},
		animalGroupMerge:function(num){
			/* スライダー向けグルーピング あまりを出して先頭から埋め合わせ */
			// var num = 8;
			// 全データから生き物グループ抽出
			var animalGroup = [];
			for(var i=0;i<window.jQIKData.JsonArray.length;i++){
				var ja = jQIKData.JsonArray[i];
				for(var k=0;k<ja.entry.length;k++){
					if(ja.entry[k].symbol.image[1]["@attributes"].src.indexOf("no.")==-1){
						animalGroup.push(ja.entry[k]);
					}
				}
			}
			var amari = animalGroup.length % num;
			// console.log(animalGroup.length, amari);
			Array.prototype.clone = function(){
				 return Array.apply(null,this)
			}
			if(amari != 0){
				amari = num - amari;
				animalGroupCopy = animalGroup.clone();
				for(var i=0;i<amari;i++){
					var a = animalGroupCopy[i];//先頭から抽出
					animalGroup.push(a);
				}
			}
			// Shuffle Object
			var firstArray = animalGroup[0];
			animalGroup.shift();
			animalGroup = animalGroup.shuffle();
			animalGroup.unshift(firstArray);
			return window.jQIKData.animalGroup = animalGroup;
			/* スライダー向けグルーピング */
		},
		stampSlider:function(){// Stamp Slider - 
			var $this = arguments[0],s=$this.selector(),jQIKSlider = s.jQIKSlider,jQIKSliderUL = jQIKSlider + " ul",x = arguments[1],c=arguments[2];
			s.jQIKSliderPrev = "#jQIKSliderPrev",
			s.jQIKSliderPrevA = s.jQIKSliderPrev + " a",
			s.jQIKSliderNext = "#jQIKSliderNext",
			s.jQIKSliderNextA = s.jQIKSliderNext + " a";
			var images = [],entry;
			$(jQIKSlider).html("");
			// console.log(jQIKData.Placemark);
			// console.log(x.entry.length,jQIKData.Placemark.Document.Placemark.length);
			for(var i=0;i<x.entry.length;i++){
				var num = Number(x.entry[i].vcID);
				var place = jQIKData.Placemark.Document.Placemark;
				for(var k=0;k<place.length;k++){
					var placeName = place[k].name.split("."),placeNum = placeName[0];
					if(placeNum == num){
						// console.log(placeNum, num , jQIKData.Placemark.Document.Placemark[k].name, x.entry[i].title);
						x.entry[i].Placemark = jQIKData.Placemark.Document.Placemark[k];
						continue;
					}
				}
				
			}
			// console.log(x.entry);
			var liCount = 0;
			// c.max = Math.floor(c.max);
			for (var i = c.min; i < c.max; i++) {
				entry = x.entry[i];
				$(jQIKSlider).append('<li></li>');
				jQIKSliderLI = jQIKSlider + " li:eq(" + liCount + ")";
				jQIKSliderLIA = jQIKSliderLI + " a";
				$this.addImages(jQIKSliderLI, '', entry.symbol.image[0]["@attributes"].src, {size:{width:90, height:90}, type:"click"});
				var header = '<h3><a href="' + entry.link['@attributes'].href+'">',
				// text = header + entry.title+'</a></h3>' + entry.address;
				text = header + entry.title+'</a></h3>',
				text = text.split("<").join("&lt;"),
				text = text.split(">").join("&gt;");
				var groups;
				for(var k=0;k<jQGlobalGroups.length;k++){
					// console.log(jQGlobalGroups[k].gID, entry.vcGID, jQGlobalGroups[k].group);
					if (Number(jQGlobalGroups[k].gID) == entry.vcGID){
						groups = jQGlobalGroups[k];
					}
				}
				$(jQIKSliderLIA).attr({
					"data-coord":entry.Placemark.Point.coordinates,
					"data-title":entry.title, 
					"data-text":text,
					// "data-group":groups.group,
					"data-symbol":entry.symbolAnimal,
					"data-link":entry.link["@attributes"].href,
					"data-stamp-image":entry.stamp.image["@attributes"].src,
					"data-face-image":entry.symbol.image[1]["@attributes"].src,
					"data-seal-image":entry.seal.image["@attributes"].src
				});
				if(typeof groups != "undefined"){
					// console.log(groups);
					$(jQIKSliderLIA).attr({
						"data-group":groups.group
					});
				}
				liCount++;
			}
			
			$(jQIKSlider).prepend('<li id="'+s.jQIKSliderPrev.replace("#","")+'"><a href="javascript:void(0);" data-min="'+c.min+'" data-max="'+c.max+'" data-navi="prev"><img src="/images/top/btn_prev_n.png" width="16" height="16" alt="前へ"></a></li>');
			$(jQIKSlider).append('<li id="'+s.jQIKSliderNext.replace("#","")+'"><a href="javascript:void(0);" data-min="'+c.min+'" data-max="'+c.max+'" data-navi="next"><img src="/images/top/btn_next_n.png" width="16" height="16" alt="次へ"></a></li>');
			$($(jQIKSlider).parent()).append('<div class="clear_both"></div>');
			$(jQIKSlider).hide();
			$(jQIKSlider).fadeIn("50000");
			jQIKSliderLI = jQIKSlider + " li";
			jQIKSliderLIA = jQIKSliderLI + " a";
			$(jQIKSliderLIA).click(function(){
				$(window.jQIKData.selector.jQIKLoader).hide();
				if(typeof window.oldinfowindow != "undefined"){
					window.oldinfowindow.close();
				}
				var $this=window.$this, s = window.$this.selector();
				if(typeof $(this).attr("data-coord")=="undefined") return;
				var coord = $(this).attr("data-coord").split(","),
				text = $(this).attr("data-text");
				text = text.split("&lt;").join("<");
				text = text.split("&gt;").join(">");
				var contentString = "<div class='gmapVcInfo'>"+
				text +
				"</div>";
				var latlng = new google.maps.LatLng(coord[1], coord[0]);
				var infowindow = new google.maps.InfoWindow({content: contentString});
				var marker = new google.maps.Marker({position: latlng, map: $this.map, visible:false});
				$this.map.panTo(latlng);
				var animalImageSize = {width:$this.size.image.animal.large.width,height:$this.size.image.animal.large.height},
				labelImageSize = {width:$this.size.image.label.width,height:$this.size.image.label.height};
				$this.addImages(s.jQIKSymbolAnimalPhoto,'', $(this).attr("data-face-image"), {size:animalImageSize});
				$this.addImages(s.jQIKStampLabel,'', $(this).attr("data-stamp-image"), {size:labelImageSize});
				$this.addImages(s.jQIKSealLabel,'', $(this).attr("data-seal-image"), {size:labelImageSize});
				$this.infoView( s.jQIKVCInfo, $(this).attr("data-title"), $(this).attr("data-link"), $(this).attr("data-text"), entry.address, $(this).attr("data-symbol"), $(this).attr("data-group") );
				infowindow.open($this.map, marker);
				$(".gmapVcInfo").css({"font-size":"10pt"});
				window.oldinfowindow = infowindow;
				window.jQIKSliderClick = true;
			});
			$(s.jQIKSliderPrevA+","+s.jQIKSliderNextA).click(function(){
				$(window.jQIKData.selector.jQIKLoader).hide();
				var n = Math.floor(Math.random()*(jQIKData.JsonArray.length-1));
				// console.log(jQIKData.animalGroup);
				jQIKData.Xml.entry = jQIKData.animalGroup;// random
				var node = jQGlobalArea[0].area;
				for(var i=0;i<node.length;i++){
					if(jQIKData.Xml.title.indexOf(node[i].name)>-1){
						jQIKData.Area = node[i];
					}
				}
				// Google Map Center panTo
				/* ページ送りの考え方 */
				// paging
				var min,max,avg;
				var avg = c.max-c.min;
				// console.log($(this).attr("data-navi"),c.max-c.min);
				if($(this).attr("data-navi") == "next"){
					// next
					min = Number($(this).attr("data-max")),
					max = Number($(this).attr("data-max"))+avg;
					if(max > jQIKData.Xml.entry.length){
						min = 0,max=avg;
					}
				}
				else if($(this).attr("data-navi") == "prev"){
					// prev
					min = Number($(this).attr("data-min"))-avg,
					max = Number($(this).attr("data-min"));
					if(min < 0){
						min = jQIKData.Xml.entry.length-avg, max = jQIKData.Xml.entry.length;
					}
				}
				// console.log(min,max,avg,jQIKData.Xml.entry.length);
				/* ページ送りの考え方 */
				$this.stampSlider($this, jQIKData.Xml, {min:min, max:max});
			});
		},
		createMap : function(){
			var $this = arguments[1],v = arguments[0],selector = $this.selector();
			$(selector.jQIKMaps).css({width:$this.width,height:$this.height});
			this.map = new google.maps.Map($(selector.jQIKMaps)[0], o);
			$this.addDomListener(marker, 'click', $this.selfMarkerCallback);
		},
		kmlMap : function(){
			/* window.jQIKSliderClick - Sliderがクリックされた。 */
			window.jQIKSliderClick = false;
			var $this = arguments[1],v = arguments[0],selector = $this.selector();
			$(selector.jQIKMaps).css({width:$this.size.width,height:$this.size.height});
			this.map = new google.maps.Map($(selector.jQIKMaps)[0], v.option);
			// var movePos = new google.maps.LatLng(window.jQIKData.Area.x, window.jQIKData.Area.y);
            // this.map.setCenter(movePos);
			var kl = new google.maps.KmlLayer(v.kml, {map: this.map});//suppressInfoWindows:true, 
			window.kml = kl;
			google.maps.event.addListener(kl, 'click', this.featureDataCallBack);
			// console.log(kl.getUrl(),kl.getMetadata(),kl.getMap());
			window.$this = this, map = this.map,count = 0;
			var st = setInterval(function(){
				// if(typeof window.jQIKData != "undefined" && typeof window.jQIKData.Area != "undefined")
				var movePos = new google.maps.LatLng(window.jQIKData.Area.x, window.jQIKData.Area.y);
                $this.map.setCenter(movePos);
				$this.map.setZoom(window.jQIKData.Area.zoom);
				if (count == 3){
					// console.log(window.jQIKData.selector.jQIKLoader);
					$(window.jQIKData.selector.jQIKLoader).hide();
				}
				if (count >= 9) {
					clearInterval(st);
				}else if(window.jQIKSliderClick){
					clearInterval(st);
				}else if(window.jQIKSliderStart){
					clearInterval(st);
				}
				count++;
			}, 1000);
			
		},
		selfMarkerCallback : function(e){/* Native Codes - Maps Loading */},
		infoView : function(selector, title, link, content, address, symbol, groupTitle){
			var html = '<div class="groupTitle">' + groupTitle + '</div>' +
			'<h3>' + title + '</h3>' + 
			'<h4>シンボル生き物</h4>' +
			'<div class="symbolAnimal">' + symbol + '</div>' +
			"<p><a href='" + link + "'>ビジターセンターの情報はこちら</a></p>";
			$(selector).html(html);
		},
		featureDataCallBack : function(kmlEvent){
			$(window.jQIKData.selector.jQIKLoader).hide();
			// KML Object Click Event Callback
			if(typeof window.oldinfowindow != "undefined"){
				window.oldinfowindow.close();
			}
			window.kmlEvent = kmlEvent;
			window.jQIKSliderClick = true;
			/* Native Codes - KML DATA */
			var num = kmlEvent.featureData.name.split(".")[0],entry,vcID;
			switch(num){
				case "":
					// 内容が書き変わった場合の処理
					num = kmlEvent.featureData.num;
				break;
				default:
					// はじめにクリックされたとき
					kmlEvent.featureData.num = num;
				break;
			}
			for (var k = 0; k < jQIKData.JsonArray.length; k++) {
				var entrys = jQIKData.JsonArray[k];	
				for(var i=0;i<entrys.entry.length;i++){
					vcID = entrys.entry[i].vcID;
					if(vcID == num) entry = entrys.entry[i];
				}
			}
			if (typeof entry != "undefined") {
				kmlEvent.featureData.name = '';
				var header = '<h3><a href="' + entry.link['@attributes'].href + '">' + entry.title + '</a></h3>';
				kmlEvent.featureData.description = header;
				$("#jQIKSymbolAnimalPhoto,#jQIKSymbolLabel,#jQIKSealLabel").html("");
				var $this = window.$this, s = window.$this.selector();
				var animalImageSize = {width:$this.size.image.animal.large.width, height:$this.size.image.animal.large.height}, labelImageSize = {width:$this.size.image.label.width, height:$this.size.image.label.height};
				//if (entry.symbol.image[1]["@attributes"].src.indexOf("no.") == -1) {
				$this.addImages(s.jQIKSymbolAnimalPhoto, '', entry.symbol.image[1]["@attributes"].src, {size: animalImageSize});
				//}
				$this.addImages(s.jQIKStampLabel, '', entry.stamp.image["@attributes"].src,{size:labelImageSize});
				$this.addImages(s.jQIKSealLabel, '', entry.seal.image["@attributes"].src,{size:labelImageSize});
				var groups;
				for(var k=0;k<jQGlobalGroups.length;k++){
					if(Number(jQGlobalGroups[k].gID) == entry.vcGID) groups = jQGlobalGroups[k];
				}
				if(typeof groups.group=="undefined") groups.group="";
				$this.infoView( s.jQIKVCInfo, entry.title, entry.link["@attributes"].href, entry.content, entry.address, entry.symbolAnimal, groups.group);
			}
		},
		arroundMarkerCallback : function(e){/* Native Codes */},
		addImages : function(selector, alt, src, option){
			if(typeof selector == "undefined") return;
			if(typeof alt == "undefined") alt = "";
			if(typeof option == "undefined") option = "";
			$(selector).html("");
			selecterIMG = selector + " img";
			if(typeof src != "undefined") {
				if(typeof option != "undefined" && typeof option.type!="undefined"){				
					if(option.type == "click") $(selector).append('<a href="javascript:void(0);"><img src="'+src+'" alt="'+alt+'"></a>');
				}
				else{
					$(selector).append('<img src="'+src+'" alt="'+alt+'">');
				}
			}
			
			
			//<a href="javascript:void(0);"></a>
			if(typeof option != "undefined" && typeof option.size != "undefined") $(selecterIMG).attr({width:option.size.width, height:option.size.height});
		},
		areaSearch : function(){}
	};
	
})(jQuery, window);
/* XML / JSONによる */
/* 通信終了 */

$(document).ajaxStop(
	function(){
		if(jQIKData.rss) return;
		
		
		if(window.jQIKData.JsonArray.length>0){
			window.jQIKData.JsonArray = window.jQIKData.JsonArray.shuffle();
			window.jQIKData.Xml = window.jQIKData.JsonArray[0];
			// alert(window.jQIKData.Xml.entry.length);
			var entry = [];
			if(typeof window.jQIKData.Xml.entry.length == "undefined"){
				entry.push(window.jQIKData.Xml.entry);
			}
			else{
				entry = window.jQIKData.Xml.entry;
			}
			var a = jQGlobalArea[0].area;
			// window.jQIKData.Area = a;
			for(var i=0;i<a.length;i++){
				if(a[i].name == entry[0].category){
					window.jQIKData.Area = a[i];
				}
			}
			
			for(var i=0;i<entry.length;i++){
				var num = Number(entry[i].vcID)-1;
				entry[i].Placemark = jQIKData.Placemark.Document.Placemark[num];
			}
			
			window.jQIKData.Xml.entry = entry;
		}
		
		
		/* スライダー向けグルーピング */
		var opt = {
			zoom : window.jQIKData.Area.zoom,
			center : new google.maps.LatLng( window.jQIKData.Area.x, window.jQIKData.Area.y ),// [ 43.4688676, 142.7563476 ]
			mapTypeId : google.maps.MapTypeId.ROADMAP,
			disableDefaultUI : true,
			disableDoubleClickZoom : true,
			draggable : false,
			scrollwheel: false
		},
		kml = jQIKData.KML.Document.NetworkLink.Link.href;
		var stmp = $.jQIKStamp({selector:"#header", option:opt, kml:kml});//selector:"#wrapper", 
	}
);
/* 通信終了 */



