// JavaScript Document

var root = location.protocol + '//' + location.hostname;
var path = root + location.pathname;
	
/*
// Global Navigation Current
*/

function globalNavigation(){
	var dirArray = new Array("/xxx/","/xxx/", "/xxx/", "/xxx/", "/forum/");
	var current = function(event){
		return this.src.replace(/(\.gif|\.jpg|\.png)/,'_on'+"$1");
	}
	
	for(var i=1; i < dirArray.length; i++){
		if(path.match(dirArray[i])){
			$("#navi li:eq(" + i + ") img").removeClass("hover").attr("src", current);
		}
	}
}

/*
	Rollover Script on [ jQuery ]
	Rollover class = over
	Rollover FileName = ***_on.jpg/gif/png
*/
function initRollovers() {
	var conf = { className : 'hover', postfix : '_on' };
	$('img.' + conf.className).each(function(){
		this.originalSrc = new Image;
		this.preloadSrc = new Image;
		this.originalSrc = this.src;
		this.preloadSrc = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1" + conf.postfix + "$2");
		$(this).hover(function(){
			this.src = this.preloadSrc;
		},function(){
			this.src = this.originalSrc;
		});
	});
};

/*
	Striped Table on [ jQuery ]
	Rollover class = odd,even
*/
function initStripedTable() {
	var conf = {	
		className : "stripedTable",
		childElement : "tr",
		oddClassName : "odd",
		evenClassName : "even"
	};
	$('.'+conf.className+' '+conf.childElement+':odd').addClass(conf.evenClassName);
	$('.'+conf.className+' '+conf.childElement+':even').addClass(conf.oddClassName);
};

/*
// Open New Window on [ jQuery ]
// Rollover class = popup
*/
function initNewWindow() {
	var popupEvent = function(event) {
		if( this.rel ) {
			window.open(this.href, 'popup', this.rel).focus();
		} else {
			window.open(this.href, '_blank').focus();
		}
		event.preventDefault();
		event.stopPropagation();
	}
	$("a.popup, a.external, a.pdf").each(function(i) {
		$(this).click(popupEvent);
		$(this).keypress(popupEvent);
	});
}

function googleMap(){
	var map = new google.maps.Map2(document.getElementById("map"));
    map.setCenter(new GLatLng(35.698414230290815,139.74596500396729),16);
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setMapType(G_NORMAL_MAP);

	var point = new GPoint(139.7458791732788,35.69698094794248);
	var marker = new GMarker(point);
	map.addOverlay(marker);
	
	var offset = new GSize(10, -20);
	var textnode = '<div style=width:210px;><p>株式会社HeadShot</p><img src="http://www.headshot.co.jp/common/images/map_logo.gif" width="36" height="36" align="right"><p><small>〒102-0071<br>東京都千代田区富士見1-11-23<br>フジミビル3階<br>TEL : 03-6380-2227<br>FAX : 03-6380-2227</small><p><div align="right"><a href="http://maps.google.co.jp/maps?f=q&source=s_q&hl=ja&geocode=&q=%E6%9D%B1%E4%BA%AC%E9%83%BD%E5%8D%83%E4%BB%A3%E7%94%B0%E5%8C%BA%E5%AF%8C%E5%A3%AB%E8%A6%8B1-11-23&sll=36.5626,136.362305&sspn=61.175097,135.351563&ie=UTF8&ll=35.699000,139.74555&spn=0.007746,0.016522&z=16&iwloc=addr&pw=2" target="_blank"><small>地図を印刷する</small></a></div></div>';
	marker.openInfoWindowHtml(textnode);
	GEvent.addListener(map, "click", function(marker){
		marker.openInfoWindowHtml(textnode);
	});
}

/*
// Regulation on [ jQuery ]
*/
function regulate(){
		
	$("h3").wrapInner(document.createElement("span"));
	
	$("table.col tr th:last-child").css("border-right", "none");
	$("table.col tr td:first-child").css("border-left", "none");
	
	$(".hide:visible").toggle();
}

/*
// Page Loaded on [ jQuery ]
*/
$(document).ready(function(){
	$(globalNavigation);
	$(initStripedTable);
	$(initRollovers);
	$(initNewWindow);
	$(regulate);
})

