/*
 * basic.js - 地球村l Group
 *
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 */

var chikyumura = {
	preloader: {
		loadedImages: [],
		load: function (url){
			var img = this.loadedImages;
			var l = img.length;
			img[l] = new Image();
			img[l].src = url;
		}
	},
	uri: {
		dirName: function(uri){
			var ary = uri.split('/');
			ary.pop();
			return ary.join('/');
		},
		path: function (uri){
			return uri.split('#')[0];
		},
		anchorName: function (uri){
			return uri.split('#')[1];
		},
		isSelfLink: function(href){
			return ((this.path(href) == this.path(location.href)) || (this.path(href) == this.dirName(location.href)+'/'));
		}
	}
};

$(function(){
		
		
//画像ロールオーバー

function initRollOverImages() {
  var image_cache = new Object();
  $("img.btn").each(function(i) {
    var imgsrc = this.src;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
    image_cache[this.src] = new Image();
    image_cache[this.src].src = imgsrc_on;
    $(this).hover(
      function() { this.src = imgsrc_on; },
      function() { this.src = imgsrc; });
  });
}

$(document).ready(initRollOverImages);

});


		
//角丸ボックス　ボーダーカラー：グリーン

$(function() {
  $('div.boxType01').wrap('<div class="cornerWrap"></div>');
  $('div.boxType01').corner("round 5px").parent().corner("round 6px")
});


//ページトップ

$(function(){
   $('.pagetop a').click(function(){
　　$('#wrapper').ScrollTo(1000, 'easeout');
　　return false;
   });
})


$(function(){
   $('.gotoTop a').click(function(){
　　$('#wrapper').ScrollTo(1000, 'easeout');
　　return false;
   });
})

//ページ内リンク


$(function(){
  $('a[@href^="#"]').click(function(){
		$('#'+($(this).attr("href").split('#')[1])).ScrollTo(1000,'easeout'); 
		return false;
		});
});


//lightbox

$(function() {
	$('a.lightbox').lightBox(); 
});

//ウィンドウを閉じる

function close_win(){
  var nvua = navigator.userAgent;
    if(nvua.indexOf('MSIE') >= 0){
      if(nvua.indexOf('MSIE 5.0') == -1) {
        top.opener = '';
      }
    }
    else if(nvua.indexOf('Gecko') >= 0){
      top.name = 'CLOSE_WINDOW';
      wid = window.open('','CLOSE_WINDOW');
    }
    top.close();
}


$(function(){

	//外部リンクは別ウインドウを設定
	$('a[@href^="http"]').not('[@href^="http://www.chikyumura.org/"]').not('[@href^="https://www.chikyumura.org/"]').not('[@href^="http://www.earthvillage.jp/"]').not('[@id^="gmap"]').click(function(){
   window.open(this.href, '_blank');
	return false;
	});

});


