/* ---------- ---------- ---------- ---------- */

//initUserEnv
function initUserEnv(){
	this.isWin		= navigator.userAgent.indexOf("Win") != -1 ? true : false;
	this.isMac		= navigator.userAgent.indexOf("Mac") != -1 ? true : false;
	this.isNs		= navigator.appName.indexOf("Netscape") != -1 ? true : false;
	this.isNs4		= (document.layers) ? true : false;
	this.isNs4_7	= navigator.userAgent.indexOf("4.7") != -1 ? true : false;
	this.isNs6		= navigator.userAgent.indexOf("Netscape6") != -1 ? true : false;
	this.isNs7		= navigator.userAgent.indexOf("Netscape/7") != -1 ? true : false;
	this.isMoz		= navigator.userAgent.indexOf("Gecko") != -1 ? true : false;
	this.isIe		= navigator.userAgent.indexOf("MSIE") != -1 ? true : false;
	this.isIe4		= navigator.userAgent.indexOf("MSIE 4") != -1 ? true : false;
	this.isIe5		= navigator.userAgent.indexOf("MSIE 5") != -1 ? true : false;
	this.isIe6		= navigator.userAgent.indexOf("MSIE 6") != -1 ? true : false;
	this.isOp		= navigator.userAgent.indexOf("Opera") != -1 ? true : false;
	this.isW3CDom	= (document.getElementById) ? true : false;
	this.isMsDom	= (document.all) ? true : false;
	this.isNsDom	= (document.layers) ? true : false;
	this.isDom		= (this.isW3CDom || this.isMsDom || this.isNsDom) ? true : false;
	return this;
}
var userEnv = new initUserEnv();


//checkBlowser
function checkBlowser(){
	return (userEnv.isW3CDom)? 1:0;
}

//getFlashPlayerVersion
function getSwfVersion(){
	var flashVersion = 0;
	if (userEnv.isIe && userEnv.isWin) {
		try{flashVersion= new ActiveXObject("ShockwaveFlash.ShockwaveFlash").FlashVersion();}catch(e){flashVersion=0};
		flashVersion = Math.floor (flashVersion / 0x10000);
	} else {
		if (userEnv.isNs && !navigator.plugins) {
			flashVersion = 0;
		} else {
			var s = "application/x-shockwave-flash";
			if (navigator.mimeTypes && navigator.mimeTypes[s] && navigator.mimeTypes[s].enabledPlugin) {
				flashVersion=navigator.plugins["Shockwave Flash"].description.match (/\d+/);
			} else {
				flashVersion = 0;
			}
		}
	}
	return flashVersion;
}


//openSubWindow
function openSubWindow(url,name,width,height,misc,centering) {
	var details;
	details = "width="+ width +",height=" + height +",";
	details += "toolbar="+ misc.charAt(0) +",location="+ misc.charAt(1) +",status="+ misc.charAt(2);
	details += ",menubar="+ misc.charAt(4) +",scrollbars="+misc.charAt(5) +",resizable="+misc.charAt(6)+"";
	if (centering =="center") {
		var posX = (screen.width / 2) - (width / 2);
		var posY = (screen.height / 2) - (height / 2);
		details += ",left=" + posX + ",top=" + posY + ",screenX=" + posX + ",screenY=" + posY;
	}
	window.open(url,name,details);
}

//openerWindow
function openerWindow(url){
	if(!window.opener || window.opener.closed){
		window.open(url);
	}else{
		window.opener.location.href = url;
	}
}

//cookie
function checkEnabledCookie(){
	return (document.cookie) ? 1:0;
}
function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  {
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    {
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

//swapImage
function MM_preloadImages() {
	var d = document;
	if (d.images) {
		if (!d.MM_p) {
			d.MM_p = new Array();
		}
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		for (i=0; i<a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.MM_p[j] = new Image();
				d.MM_p[j++].src = a[i];
			}
		}
	}
}
function MM_swapImage() {
	var i, j = 0, x, a = MM_swapImage.arguments;
	document.MM_sr = new Array();
	for (i=0; i<(a.length-2); i += 3) {
		if ((x=MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;
			if (!x.oSrc) {
				x.oSrc = x.src;
			}
			x.src = a[i+2];
		}
	}
}
function MM_swapImgRestore() {
	var i, x, a = document.MM_sr;
	for (i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++) {
		x.src = x.oSrc;
	}
}
function MM_findObj(n, d) {
	var p, i, x;
	if (!d) {
		d = document;
	}
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0, p);
	}
	if (!(x=d[n]) && d.all) {
		x = d.all[n];
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x = d.forms[i][n];
	}
	for (i=0; !x && d.layers && i<d.layers.length; i++) {
		x = MM_findObj(n, d.layers[i].document);
	}
	if (!x && d.getElementById) {
		x = d.getElementById(n);
	}
	return x;
}

///////////////////

//検索　詳細の表示・非表示
function showElementById(_arg) {var targetElement = document.getElementById (_arg);targetElement.style.display = 'block';}
function hideElementById(_arg){var targetElement = document.getElementById (_arg);targetElement.style.display = 'none';}
function openSearchBlock(targetElementID){showElementById(targetElementID);}
function closeSearchBlock(targetElementID){hideElementById(targetElementID);}
var SearchBlockOpenFlg = false;
function toggleSearchBlockArea(cssImgHome){
	if(SearchBlockOpenFlg){
	 	closeSearchBlock('ConditionRowAreaMore')
		SearchBlockOpenFlg =false
		MM_swapImage('search_btn_open-area','',cssImgHome+'/search_btn_open-area.gif',1);
		document.getElementById ('search_btn_open-area').alt = 'エリア選択を開く';
	 } else {
		openSearchBlock('ConditionRowAreaMore')
		SearchBlockOpenFlg =true
		MM_swapImage('search_btn_open-area','',cssImgHome+'/search_btn_close-area.gif',1);
		document.getElementById ('search_btn_open-area').alt = 'エリア選択を閉じる';
	 }
}
function toggleSearchBlockAreaRollOver(cssImgHome){
	if(SearchBlockOpenFlg){
		MM_swapImage('search_btn_open-area','',cssImgHome+'/search_btn_close-area_on.gif',1);
	 } else {
		MM_swapImage('search_btn_open-area','',cssImgHome+'/search_btn_open-area_on.gif',1);
	 }
}
function toggleSearchBlockAreaRollOut(cssImgHome){
	if(SearchBlockOpenFlg){
		MM_swapImage('search_btn_open-area','',cssImgHome+'/search_btn_close-area.gif',1);
	 } else {
		MM_swapImage('search_btn_open-area','',cssImgHome+'/search_btn_open-area.gif',1);
	 }
}

//検索　セレクト項目からのテキストの入れ替え
var changeFormTextArray = new Array;
//changeFormTextArray名前が紛らわしいが、定数のようだ
changeFormTextArray[0] = '社名、特長、地域名…';
changeFormTextArray[1] = '展示場・モデルハウス名・家のイメージ…';
changeFormTextArray[2] = '建てたい家のイメージ、社名…';
changeFormTextArray[3] = '商品名、建てたい家のイメージ…';
changeFormTextArray[4] = '社名、企業の特長…';

//choiseAction()動作中フラグ
var choiseActionflg = false;

/*検索ボタン押下時*/
function choiseAction(){

	choiseActionflg = true;
	if(document.search.select.selectedIndex==0){
		document.search.action="/house/hj/front/HJA3L1101.do";
		document.search.GA.value="HJA3L1101";
		if(document.search.KY.value == changeFormTextArray[0]){
			document.search.KY.value = "";
		}
	}
	if(document.search.select.selectedIndex==1){
		document.search.action="/house/hj/front/HJB3L1101.do";
		document.search.GA.value="HJB3L1101";
		if(document.search.KY.value == changeFormTextArray[1]){
			document.search.KY.value = "";
		}
	}
	if(document.search.select.selectedIndex==2){
		document.search.action="/house/hj/front/HJC3L1101.do";
		document.search.GA.value="HJC3L1101";
		if(document.search.KY.value == changeFormTextArray[2]){
			document.search.KY.value = "";
		}
	}
	if(document.search.select.selectedIndex==3){
		document.search.action="/house/hj/front/HJD3L1102.do";
		document.search.GA.value="HJD3L1102";
		if(document.search.KY.value == changeFormTextArray[3]){
			document.search.KY.value = "";
		}
	}
	if(document.search.select.selectedIndex==4){
		document.search.action="/house/hj/front/HJD3L1101.do";
		document.search.GA.value="HJD3L1101";
		if(document.search.KY.value == changeFormTextArray[4]){
			document.search.KY.value = "";
		}
	}

	document.search.submit();

	choiseActionflg = false;

}

/*コンボボックスの内容が変化したとき*/
function changeFormText() {
	if(choiseActionflg == false) {
		//キーワードが未入力なら、下記の処理を実行
		if(document.search.KY.value == ""
			|| document.search.KY.value == changeFormTextArray[0]
			|| document.search.KY.value == changeFormTextArray[1]
			|| document.search.KY.value == changeFormTextArray[2]
			|| document.search.KY.value == changeFormTextArray[3]
			|| document.search.KY.value == changeFormTextArray[4]) {
			document.search.KY.value = changeFormTextArray[document.search.select.selectedIndex];
			document.search.KY.style.color = "#999999";
		}else{
			document.search.KY.style.color = "#333333";
		}
	}

}

/*inputにフォーカスしたとき*/
function focusFormText() {
	if(document.search.KY.value == changeFormTextArray[document.search.select.selectedIndex]){
		document.search.KY.value = "";
	}
	//文字を黒くする
	document.search.KY.style.color = "#333333";
}

/*inputからフォーカスが離れたとき*/
function blurFormText() {
	if(document.search.KY.value == ""
	|| document.search.KY.value == changeFormTextArray[0]
	|| document.search.KY.value == changeFormTextArray[1]
	|| document.search.KY.value == changeFormTextArray[2]
	|| document.search.KY.value == changeFormTextArray[3]
	|| document.search.KY.value == changeFormTextArray[4]) {
		document.search.KY.value = changeFormTextArray[document.search.select.selectedIndex];
		document.search.KY.style.color = "#999999";
	}else{
		document.search.KY.style.color = "#333333";
	}
}


/*検索ボタン押下時*/
function choiseAction02(){

	choiseActionflg = true;
	if(document.search02.select.selectedIndex==0){
		document.search02.action="/house/hj/front/HJA3L1101.do";
		document.search02.GA.value="HJA3L1101";
		if(document.search02.KY.value == changeFormTextArray[0]){
			document.search02.KY.value = "";
		}
	}
	if(document.search02.select.selectedIndex==1){
		document.search02.action="/house/hj/front/HJB3L1101.do";
		document.search02.GA.value="HJB3L1101";
		if(document.search02.KY.value == changeFormTextArray[1]){
			document.search02.KY.value = "";
		}
	}
	if(document.search02.select.selectedIndex==2){
		document.search02.action="/house/hj/front/HJC3L1101.do";
		document.search02.GA.value="HJC3L1101";
		if(document.search02.KY.value == changeFormTextArray[2]){
			document.search02.KY.value = "";
		}
	}
	if(document.search02.select.selectedIndex==3){
		document.search02.action="/house/hj/front/HJD3L1102.do";
		document.search02.GA.value="HJD3L1102";
		if(document.search02.KY.value == changeFormTextArray[3]){
			document.search02.KY.value = "";
		}
	}
	if(document.search02.select.selectedIndex==4){
		document.search02.action="/house/hj/front/HJD3L1101.do";
		document.search02.GA.value="HJD3L1101";
		if(document.search02.KY.value == changeFormTextArray[4]){
			document.search02.KY.value = "";
		}
	}

	document.search02.submit();

	choiseActionflg = false;

}

/*コンボボックスの内容が変化したとき*/
function changeFormText02() {
	if(choiseActionflg == false) {
		//キーワードが未入力なら、下記の処理を実行
		if(document.search02.KY.value == ""
			|| document.search02.KY.value == changeFormTextArray[0]
			|| document.search02.KY.value == changeFormTextArray[1]
			|| document.search02.KY.value == changeFormTextArray[2]
			|| document.search02.KY.value == changeFormTextArray[3]
			|| document.search02.KY.value == changeFormTextArray[4]) {
			document.search02.KY.value = changeFormTextArray[document.search02.select.selectedIndex];
			document.search02.KY.style.color = "#999999";
		}else{
			document.search02.KY.style.color = "#333333";
		}
	}
}

/*inputにフォーカスしたとき*/
function focusFormText02() {
	if(document.search02.KY.value == changeFormTextArray[document.search02.select.selectedIndex]){
		document.search02.KY.value = "";
	}
	//文字を黒くする
	document.search02.KY.style.color = "#333333";
}

/*inputからフォーカスが離れたとき*/
function blurFormText02() {
	if(document.search02.KY.value == ""
	|| document.search02.KY.value == changeFormTextArray[0]
	|| document.search02.KY.value == changeFormTextArray[1]
	|| document.search02.KY.value == changeFormTextArray[2]
	|| document.search02.KY.value == changeFormTextArray[3]
	|| document.search02.KY.value == changeFormTextArray[4]) {
		document.search02.KY.value = changeFormTextArray[document.search02.select.selectedIndex];
		document.search02.KY.style.color = "#999999";
	}else{
		document.search02.KY.style.color = "#333333";
	}
}


//printTopSwf
function printTopSwf () {
	if (getSwfVersion () < 6) {
		document.write (
			'<a href="http://www.macromedia.com/shockwave/download/download.cgi?P5_Language=Japanese&Lang=Japanese&Lang=Japanese&P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="/house/hj/front/hjcommon/css/img/top_p_noflash.gif" width="375" height="226" alt="" /></a>'
		);
	} else {
		document.write (
			'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
				'width="375" height="226" id="areaSelect" align="middle">' +
				'<param name="base" value="swf">' +
				'<param name="movie" value="/house/hj/front/hjcommon/swf/map.swf">' +
				'<param name="bgcolor" value="#FAF6EC">' +
				'<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ' +
					'base="swf" name="areaSelect" width="375" height="226" ' +
					'src="/house/hj/front/hjcommon/swf/map.swf"' +
				'><\/embed' +
			'><\/object><br />'
		);
	}
}


//======================================================================
//  2006.05.11 課題:1407 Flashの表示方法の仕様変更により追加・修正
//======================================================================


//printPhotoSwf(a4_d10)
function printPhotoSwf (filePath) {
	if (getSwfVersion () < 6) {
		document.write (
			'<a href="http://www.macromedia.com/shockwave/download/download.cgi?P5_Language=Japanese&Lang=Japanese&Lang=Japanese&P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="/house/hj/front/hjcommon/swf/img/photoswf_noflash.gif" width="628" height="478" alt="" /></a>'
		);
	} else {
		document.write (
			'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
				'width="628" height="358" id="photoView" align="middle">' +
				 '<param name="movie" value="'+filePath+'/hj/swf/photo_a4d10.swf?photoDir='+pDir+'&amp;xmlDir='+xDir+'&amp;xmlName='+xName+'" />'+
				 '<param name="quality" value="high" />'+
				'<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ' +
					' name="photoView" width="628" height="358" ' +
				' src="'+filePath+'/hj/swf/photo_a4d10.swf?photoDir='+pDir+'&amp;xmlDir='+xDir+'&amp;xmlName='+xName+'"' +
				'><\/embed' +
			'><\/object><br />'
		);
	}
}
//printPhotoSwf2(d4_d3)
function printPhotoSwf2 (filePath) {
	if (getSwfVersion () < 6) {
		document.write (
			'<a href="http://www.macromedia.com/shockwave/download/download.cgi?P5_Language=Japanese&Lang=Japanese&Lang=Japanese&P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="/house/hj/front/hjcommon/swf/img/photoswf_noflash2.gif" width="628" height="478" alt="" /></a>'
		);
	} else {
		document.write (
			'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
				'width="628" height="478" id="photoView" align="middle">' +
				 '<param name="movie" value="'+filePath+'/hj/swf/photo_d4d3.swf?photoDir='+pDir+'&amp;xmlDir='+xDir+'&amp;xmlName='+xName+'" />'+
				 '<param name="quality" value="high" />'+
				'<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ' +
					' name="photoView" width="628" height="478" ' +
				' src="'+filePath+'/hj/swf/photo_d4d3.swf?photoDir='+pDir+'&amp;xmlDir='+xDir+'&amp;xmlName='+xName+'"' +
				'><\/embed' +
			'><\/object><br />'
		);
	}
}
//printPhotoSwf3(a5_d9)
function printPhotoSwf3 (filePath) {
	if (getSwfVersion () < 6) {
		document.write (
			'<a href="http://www.macromedia.com/shockwave/download/download.cgi?P5_Language=Japanese&Lang=Japanese&Lang=Japanese&P1_Prod_Version=ShockwaveFlash" target="_blank"><img src="/house/hj/front/hjcommon/swf/img/photoswf_noflash2.gif" width="628" height="478" alt="" /></a>'
		);
	} else {
		document.write (
			'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
				'width="628" height="478" id="photoView" align="middle">' +
				 '<param name="movie" value="'+filePath+'/hj/swf/photo_a5d9.swf?photoDir='+pDir+'&amp;xmlDir='+xDir+'&amp;xmlName='+xName+'" />'+
				 '<param name="quality" value="high" />'+
				'<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" ' +
					' name="photoView" width="628" height="478" ' +
				' src="../common/swf/photo_a5d9.swf?photoDir='+pDir+'&amp;xmlDir='+xDir+'&amp;xmlName='+xName+'"' +
				' src="'+filePath+'/hj/swf/photo_a5d9.swf?photoDir='+pDir+'&amp;xmlDir='+xDir+'&amp;xmlName='+xName+'"' +
				'><\/embed' +
			'><\/object><br />'
		);
	}
}

//ページ内リンク
function inPageJump(name) {
	location.hash = name;
	return false;
}