﻿
/*	画像ロールオーバー
------------------------------------------------------------------------
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
----------------------------------------------------------------------*/
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');
	var inputImages = document.getElementsByTagName('input');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgNav') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
	for (var i = 0; i < inputImages.length; i++) {
		if (inputImages[i].className == 'imgNav') {
			var src = inputImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			inputImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			inputImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			inputImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

/*	新規ウィンドウ	------------------------------------------------------
------------------------------------------------------------------------*/
function externalLinks() {
	if (!document.getElementsByTagName) return

	var anchors = document.getElementsByTagName("a");
	
	for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") &&
			anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
	}
}


/*	HOME カテゴリから探す・ニーズから探す切り替え	------------------------
------------------------------------------------------------------------*/
function serviceSearch() {
	if (!document.getElementById || !document.getElementById('searchServCategory')) return
	
//	初期値
	var searchServCategory = document.getElementById('searchServCategory');
	var searchServNeeds =	document.getElementById('searchServNeeds');
		searchServCategory.style.display = 'block';
		searchServNeeds.style.display = 'none';

//	h2タイトルを変数に置き換え
	var searchServCategoryTtl =	document.getElementById('searchServCategoryTtl');
	var searchServNeedsTtl =	document.getElementById('searchServNeedsTtl');
//	「カテゴリから探す」クリック
	searchServCategoryTtl.onclick = function (){
		searchServCategory.style.display = 'block';
		searchServNeeds.style.display = 'none';
	}
//	「ニーズから探す」クリック
	searchServNeedsTtl.onclick = function (){
		searchServCategory.style.display = 'none';
		searchServNeeds.style.display = 'block';
	}

/* IE用とモダンブラウザの切り分け --------------------*/
var isMSIE = /*@cc_on!@*/false; 
if (isMSIE) { 
/*	IEであるなら--------------------------------------*/
	//	タイトル画像を変数に置き換え
		var ssearchServCategoryTtlImg =	document.getElementById('searchServCategoryTtlImg');
		var searchServNeedsTtlImg =	document.getElementById('searchServNeedsTtlImg');
	//	「カテゴリから探す」タイトル画像をクリック
		searchServCategoryTtlImg.onclick = function (){
			document.searchServCategoryTtlImg.src = '../img/home/ttl_searchCategory_main_on.png';
			document.searchServNeedsTtlImg.src = '../img/home/ttl_searchNeeds_main.png';
		}
	//	「ニーズから探す」タイトル画像をクリック
		searchServNeedsTtlImg.onclick = function (){
			document.searchServCategoryTtlImg.src = '../img/home/ttl_searchCategory_main.png';
			document.searchServNeedsTtlImg.src = '../img/home/ttl_searchNeeds_main_on.png';
		}
} else {
/*	IEでないなら--------------------------------------*/
	//	タイトル画像を変数に置き換え
		searchServImg1 =	document.getElementById('searchServCategoryTtlImg');
		searchServImg2 =	document.getElementById('searchServNeedsTtlImg');
	//	「カテゴリから探す」タイトル画像をクリック
		searchServImg1.onclick = function (){
				document.searchServCategoryTtlImg.src = '../img/home/ttl_searchCategory_main_on.png';
				document.searchServNeedsTtlImg.src = '../img/home/ttl_searchNeeds_main.png';
		}
	//	「ニーズから探す」タイトル画像をクリック
		searchServImg2.onclick = function (){
				document.searchServCategoryTtlImg.src = '../img/home/ttl_searchCategory_main.png';
				document.searchServNeedsTtlImg.src = '../img/home/ttl_searchNeeds_main_on.png';
		}

	}

}


/*	拡大画像popup	------------------------------------------------------
------------------------------------------------------------------------*/
/*var popup, popWin;

function CenterOpen (img,Xv,Yv) {
	var src = documentS
 var img = a.href
if (popWin=="on") {
if (popup.closed) {} else {popup.close();}
}

popWin = "on";
Xw=Xv+50;
Yw=Yv+80;

new1=window.open("", "newwin", "resizable=1,width="+Xw+",height="+Yw+"");
if(navigator.appVersion.charAt(0)>=3){new1.focus()};
new1.document.clear();
new1.document.write("<html><head><meta http-equiv='content-type' content='text/html; charset=utf-8'><title>拡大画像</title></head><body>");
new1.document.write("<div id=&quot;popupWin&quot;><img src="+img+" width="+Xv+" height=&quot;+Yv+&quot;>");
new1.document.write("<input type=button value='閉じる' onClick='window.close()'></div>");
new1.document.write("</body></html>");
new1.document.close();
}
*/

/*	読み込み	----------------------------------------------------------
------------------------------------------------------------------------*/
onload = function(){
	initRollovers();
	externalLinks();
	serviceSearch();
}




