﻿//-------------------------------------------------
//ファイル名 : regist_favorite_tour.js
//説明       : お気に入りツアーで使用するJavaScipt
//新規作成日 : 2010/03/19
//           : 2010/07/07
//-------------------------------------------------

//------------------------------------------
//IDで指定された、お気に入りツアーの詳細情報を開く、または閉じる。
//------------------------------------------
function open_close_detail(open_or_close, ID)
{
	var is_ie6 = true;
    var is_ie7 = false;
	if (typeof document.documentElement.style.maxHeight != "undefined")
	{
		// IE 7.0 以上 または Gecko などモダンブラウザー
		is_ie6 = false;
		if(typeof document.documentElement.style.msInterpolationMode != "undefined")
		{
			is_ie7 = true;
		}
	}
	// FireFoxであるか判定
	var is_f =/a/[-1]=='a';	
	
	// ie6かie7ただし、FireFoxは除く。
	if( ( is_ie6 || is_ie7 ) && !is_f )
	{
		//alert("this is ie6");
		// 詳細行
		var trs = document.getElementsByName(ID);		
		for(var i=0; i<trs.length;i++)
		{
			trs[i].style.display = open_or_close  ? 'block' : 'none';		
		}
		// 閉じる・開く
		var open_tr=document.getElementById(ID + "_Open");
		open_tr.style.display = open_or_close  ?    'none'     :'block';
		var close_tr=document.getElementById(ID+ "_Close");
		close_tr.style.display = open_or_close  ?    'block'     :'none';
	}
	else
	{
		// 詳細行
		var trs = document.getElementsByName(ID);	
		for(var i=0; i<trs.length;i++)
		{
		//	alert(trs[i].style.display);
			trs[i].style.display = open_or_close  ? 'table-row' : 'none';	
		}
		// 閉じる・開く
		var open_tr=document.getElementById(ID + "_Open");
		open_tr.style.display = open_or_close  ?    'none'     :'table-row';
		var close_tr=document.getElementById(ID+ "_Close");
		close_tr.style.display = open_or_close  ?    'table-row'     :'none';
	}
}


//------------------------------------------
//指定ページを画面中央にポップアップする。
//------------------------------------------
function m_win(url,windowname,width,height) {
 var features="location=no, menubar=no, status=yes, scrollbars=yes, resizable=yes, toolbar=no";
 if (width) {
  if (window.screen.width > width)
   features+=", left="+(window.screen.width-width)/2;
  else width=window.screen.width;
  features+=", width="+width;
 }
 if (height) {
  if (window.screen.height > height)
   features+=", top="+(window.screen.height-height)/2;
  else height=window.screen.height;
  features+=", height="+height;
 }
 features+=", menubar=no, toolbar=no,location=no,scrollbars=no";
 window.open(url,windowname,features);
}


//------------------------------------------
//お気に入り追加時のメッセージを表示する
//------------------------------------------
function showResult(originalRequest)
{
	if(result_of_favorite_function == 0)
	{
		m_win('/jrnetsbyu/jsp/CommonMessage.jsp?id=regist','登録しました',400,110);
	}
	if(result_of_favorite_function == 1)
	{
		m_win('/jrnetsbyu/jsp/CommonMessage.jsp?id=full','満杯です',400,110);
	}
	if(result_of_favorite_function == 2)
	{
		m_win('/jrnetsbyu/jsp/CommonMessage.jsp?id=duplication','既に登録済みです',400,110);
	}
}

//------------------------------------------
//お気に入りツアーに登録を行う
//------------------------------------------
var result_of_favorite_function = 0;
function addFavoriteCid(cid, cTitle)
{

	// 同期通信で登録処理
	var myAjax = new Ajax.Request(
	"/jrnetsbyu/servlet/AjaxFavoriteFunction",
		{
			"method":"post",
			"asynchronous":false,
			"parameters":"add="+ cid,
			onComplete: function(response)
			{			
				var result = response.responseText;
				result_of_favorite_function = result;
			}
		}
	);
	// 通信結果を表示
	showResult();
}
