/*
 * jcommon.js 1.14
 * Copyright (c) 2007 C.M.A. Co.,Ltd.
 *
 * Last Added: 2008-09-09
 *
 */



var ary = location.pathname.split('/');



var l=0;var isLinkAry=new Array;for(i=0;i<=ary.length-1;i++){isLinkAry[i]=ary.slice(i,i+1);isLinkAry[i]=isLinkAry[i].join('/');isLinkAry[i]=isLinkAry[i].replace(/index.*$/,"")}for(k=i+1;k<=i+ary.length;k++){isLinkAry[k]=ary.slice(0,ary.length-l);isLinkAry[k]=isLinkAry[k].join('/');isLinkAry[k]=isLinkAry[k].replace(/^\//,"");isLinkAry[k]=isLinkAry[k].replace(/index.*$/,"");l++}isLinkAry[0]=isLinkAry[0].replace(/\#.*$/,"");var jcommon={preloader:{loadedImages:[],load:function(url){var img=this.loadedImages;var l=img.length;img[l]=new Image();img[l].src=url}},URI:function(path){path=path.replace(/^https[^a-z]*/,"");path=path.replace(/^http[^a-z]*/,"");path=path.replace(document.domain,"");path=path.replace(/^[^a-z]*/,"");path=path.replace(/index.*$/,"");path=path.replace(/\/$/,"");this.absolutePath=path;this.len=isLinkAry.length;this.isSelfLink=false;while(this.len--){this.isSelfLink=this.isSelfLink||(this.absolutePath==isLinkAry[this.len])}}};

/*ロールオーバー*/			$.fn.addRollOver=function(add){$(this).filter('img').each(function(){$(this).runRollOver(add,$(this));}).end().not('img').each(function(){$(this).runRollOver(add,$(this).find('img'));});};
							$.fn.runRollOver=function(add,target){$(this).each(function(num){this.originalSrc=String(target.attr('src'));this.rolloverSrc=this.originalSrc.replace(/(\.gif|\.jpg|\.png)/,add+"$1");}).hover(function(){target.attr('src',this.rolloverSrc);},function(){target.attr('src',this.originalSrc);});};
/*現在のページへのリンク*/	$.fn.addCurrentImages=function(add){$(this).each(function(){var href=new jcommon.URI($(this).attr('href'));if(href.isSelfLink){$(this).addClass('current');$(this).unbind('mouseenter');$(this).unbind('mouseleave');$(this).find('img').each(function(){$(this).unbind('mouseenter');$(this).unbind('mouseleave');this.currentSrc=this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/,add+"$1");$(this).attr('src',this.currentSrc)});}});};

$(function(){


	//ロールオーバー
	$('a img.btn,a.btn,#globalNav li a').addRollOver('_on');

	//現在のページへのリンク
	$('#globalNav li a').addCurrentImages('_cr');	
		
	//外部リンクは別ウインドウを設定
	$('a[href^="http://"]:not([href^="http://www.izuhako.net/"])').live('click',function(){
		window.open(this.href, '_blank');
		return false;
	}).addClass('externalLink');
		
	//別ウィンドウを設定
	$('a[href$=".pdf"]:not([href^="http://"])').click(function(){
		window.open(this.href, '_blank');
		return false;
	})
	
	//oddとevenを追加
	$('table.table001 tr,table.table002 tr').filter(':odd').addClass('even').end().filter(':even').addClass('odd');


	//以下適宜コメントアウトはずして使用すること

/*
	//ポップアップ ※href="[表示するURL]?width=000&amp;height=000"
	$('a.popup').each(function(){
		this.param = $(this).attr("href");
		this.param = this.param.split('?');
		this.param[1] = this.param[1].split('&');
		this.param[1] = this.param[1].join(',')
		$(this).attr("href","");
	}).click(function(){
		this.pu = window.open(this.param[0], 'popup', "menubar=1,location=1,resizable=1,status=1,"+this.param[1]);
		return false;
	});
*/

/*
	//するするアニメーション ※要scrollTo.js
	if(!$.browser.opera){
		$('a[href^="#"]:not([href^="#TAB"])').each(function(){
			this.target = $(this).attr('href');
		}).click(function(){
			$.scrollTo( this.target, {speed:800} );
			return false;
		});
	}//opera対策
	else if($.browser.opera){$('.toTop a[href^="#"]').each(function(){this.target = $(this).attr('href');}).click(function(){$.scrollTo( this.target, {speed:800} );return false;});}
*/

/*
	//連番nxxxをクラスとして追加
	$('#flowNum li').each(function(num){
		$(this).addClass('n'+(++num));
	});
*/

	//:first-child, :last-childをクラスとして追加
	$('div#footer ul#footerNav li').filter(':last-child').addClass('lastChild');

	/*------------------------------------------
 
 *	セレクタ
 *  --------------------------------------------
 *	個別ページ
 */ if($('body.individual').length){
	 
		// var $info = $('div#data');
		data = [{
			"ID" : "map",
			"latlng" : $('#gmap').text().split(',')
		}];
		gmapLoad('gmapIndexRun');
	};// End if	

	//topブログ読み込み
	$('body.notcms #sub ul')
	.load('/banners/0000_default.html');
	$('body.form #sub ul')
	.load('/banners/0000_default_ssl.html');
	$('body.map #sub ul')
	.load('/banners/0300_map.html');

	/*------------------------------------------



/*
	//タブ
	$('#tabs').each(function(){
		var tabWrapper = $(this);
		var targetTab = location.hash;
		$(this).find('.tabPage').hide();
		if(targetTab == ''||targetTab == '#top'||targetTab == '#content')targetTab = $(this).find('.selected a').attr('href');
		else window.scrollTo(0,0); $(this).find('.tabControl li').removeClass('selected').find('a[href="'+targetTab+'"]').parent().addClass('selected');
		$(targetTab).show();
		$(this).find('.tabControl a').click(function() {
			targetTab = $(this).attr('href');
			tabWrapper.find('.tabPage').hide();
			tabWrapper.find('.tabControl li').removeClass('selected');
			$(this).parent().addClass('selected');
			$(targetTab).show();
			return false;
		});
	});
*/

/*
	//dd要素の非表示 ver1.0
	$('dl.faq').each(function(){
		$(this).children('dd').hide();
		$(this).before('<p class="faq alignR" href=""><a>すべて表示</a></p>');
	});
	$('p.faq a').click(function(){
		$(this).removeAttr("href");
		if($(this).html() == 'すべて非表示'){
			$(this).parent().next().children('dd').hide();
			$(this).text('すべて表示');
		}else{
			$(this).parent().next().children('dd').show();
			$(this).text('すべて非表示');
		}
	});
	$('dl.faq dt').click(function(){
		if($(this).next().is(':visible')){
			$(this).next().hide();
			if(!$(this).nextAll('dd').is(':visible')&&!$(this).prevAll('dd').is(':visible'))$(this).parent().prev().children().text('すべて表示');
		}else{
			$(this).next().show();
			$(this).parent().prev().children().text('すべて非表示');
		}
	});
*/

/*
	//googlemapをiframeで表示 ver1.0
	$('a.map').each(function(){
		this.gmapURI = $(this).attr('href');
		$(this).ayyr('href','');
	}).click(function(){
		$(this).removeAttr('href');
		if($(this).hasClass('show')){
			$(this).next().remove();
			$(this).text('地図を表示');
			$(this).removeClass('show')
		}else{
			$(this).after('<iframe frameborder="0" src="'+this.gmapURI+'"></iframe>');
			$(this).text('地図を非表示');
			$(this).addClass('show')
		}
	});
*/

});

//GLOBAL VAR
var data;
//GMAP LOAD
function gmapLoad(fn){
	//Google Map API ver3
	var script = document.createElement("script");
	script.src = "http://maps.google.com/maps/api/js?sensor=true&callback="+fn;
	script.type = "text/javascript";
	document.getElementsByTagName("body")[0].appendChild(script);		
}
//GMAP MAIN
function gmapIndexRun(){
	var	$g = google.maps,
		gmap = new Object;
	// MAP
	gmap.latlng = new $g.LatLng(data[0].latlng[0],data[0].latlng[1]);	
	gmap.bounds = new $g.LatLngBounds(gmap.latlng,gmap.latlng);
	gmap.div = document.getElementById('gmap');
	gmap.param = {
		zoom:13,
		scrollwheel:false,
		center:gmap.latlng,
		mapTypeControl:false,
		mapTypeId: $g.MapTypeId.ROADMAP
	};
	gmap.go = new $g.Map(gmap.div,gmap.param);
	// MARKER
	gmap.marker = new Object;
	gmap.marker.go = new Array;
//	gmap.marker.shadow = new $g.MarkerImage(
//		'/shared/img/fig_marker_shade.png',
//		new $g.Size(43,23),
//		new $g.Point(0,0),
//		new $g.Point(0,22)
//	);
	var i = 0;
	while(data[i]){
//		gmap.marker.image = new $g.MarkerImage(
//			'/shared/img/fig_marker_green.png',
//			new $g.Size(31,35),
//			new $g.Point(0,0),
//			new $g.Point(4,33)
//		);
		gmap.marker.param = {
			//icon:gmap.marker.image,
			//shadow:gmap.marker.shadow,
			map:gmap.go,
			position:new $g.LatLng(data[i].latlng[0],data[i].latlng[1])
		}
		gmap.marker.go.push(new $g.Marker(gmap.marker.param));
		gmap.marker.go[i].infoHtml = new Array();
		gmap.marker.go[i].infoParam = {
			content:gmap.marker.go[i].infoHtml.join(''),
			maxWidth:240,
			pixelOffset:new $g.Size(-14,35)
		}
		gmap.marker.go[i].infowin = new google.maps.InfoWindow(gmap.marker.go[i].infoParam);
		gmap.bounds.extend( gmap.marker.param.position );
		i++;
	}
}
