function setFreeWord(e){
	var t = document.getElementById("txtFreeWord");
	if(t){
		t.value = t.value + " " + e.innerHTML;
	}
}
function setKensakuOptionOff(){
//	this.document.getElementById("ISOption").style.display = "none";
}
function setKensakuOptionOn(){
//	this.document.getElementById("ISOption").style.display = "block";
}
function setChangeSelectForm(id){
	this.document.forms["selectForm"].radio_search.value = id;
}
function changeTarget(id){
	document.forms['selectForm'].radio_search.value = id;
}
function kutikomiDisp(id , param){
  if( param == "hidden"){
	  this.document.getElementById("dispKutikomi" + id).style.display = "none";
  }else{
	  this.document.getElementById("dispKutikomi" + id).style.display = "block";
  }	
}
function onFocusTextHotelName(){
	this.document.forms["selectForm"].radio_search.value = "freeword";
	if(document.getElementById("serch_word_box")){
		this.document.getElementById("serch_word_box").style.display = "block";
	}
	try{
		startLayer();
	}catch(e){}
}

function onFocusTextAddress(){
	this.document.forms["selectForm"].radio_search.value = "addr";
	if(document.getElementById("serch_word_box")){
		this.document.getElementById("serch_word_box").style.display = "block";
	}
}

function onClickSelectArea(){
	try{
		this.document.forms["selectForm"].radio_search.value = "area";
	}catch(e){}
}

function closeFree(){
	this.document.getElementById("serch_word_box").style.display = "none";
	try{
		startLayer();
	}catch(e){}
}
function planDisp(id , num , param, max){
	if(max == undefined){
		max = 4;
	}
  if( isNaN(num) || num < max){
	return;
  }
  if( param == "hidden"){
	for(var i = max; i <= num;i++){
	  document.getElementById("hiddenPlan" + id + "_" + i).style.display = "block";
	}
	this.document.getElementById("allPlan" + id).style.display = "none";
	this.document.getElementById("hiddenAllPlan" + id).style.display = "block";
  }else{
	for(var i = max; i <= num;i++){
	  this.document.getElementById("hiddenPlan" + id + "_" + i).style.display = "none";
	}
	this.document.getElementById("allPlan" + id).style.display = "block";
	this.document.getElementById("hiddenAllPlan" + id).style.display = "none";
  }	
}

function chkKensaku(){
    var f = this.document.forms["selectForm"];
    if(f.sT.selectedIndex == 0 || f.sL.selectedIndex == 0){
       return false;
    }
    return true;
}

function onClickKensaku(){
	var url = "";
    var f = this.document.forms["selectForm"];
    if(f.radio_search.value == "area"){
       if(!chkKensaku()){
          alert("都道府県と地域は必ず選択して下さい。");
          return false;
       }
    }else if(f.radio_search.value == "addr"){
       if( f.elements["address"].value == ""){
          alert("キーワードを入力して下さい。");
          return false;
	   }
    }else{
       if( f.elements["free_word"].value == ""){
          alert("キーワードを入力して下さい。");
          return false;
	   }
	}
	if(!chkCalDate()){
		return false;
	}
	/*
	if(f.radio_search.value == "hotel"){
		// freeword検索
		url = "/search/free_search.php";
	}else{
		url = "/search/hotel_search.php";
	}
	f.action = url;
	*/
	f.submit();
}

function onClickRestSearch( url )
{
//	var url = "/gourmet/search.php";
	var f   = this.document.forms["selectForm"];

	f.action = url;
	f.submit();
}

function chkCalDate(){
	var f = this.document.forms["selectForm"];
	var d = f["day"].value;
	var m = f["month"].value;
	var y = f["year"].value;
	if(d<=0 || d>30+((m==4||m==6||m==9||m==11)?0:1) || (m==2&&d>28+(((y%4==0&&y%100!=0)||y%400==0)?1:0))){
	alert("日付が不正です。");
		return false;
	}
	var dat = new Date(y, m - 1, d, 23, 59, 59);
	var t = new Date();
	if ( t > dat ){
		alert("本日以降の日付を選択してください。");
		return false;
	}else{
	}
	var l = new Date();
	l.setMonth(l.getMonth()+2);
	if (dat > l){
		alert("本日より2ヶ月以内の日付を選択してください。");
		return false;
	}
	return true;
}

function ancClick( a, site_id, plan_id ){

  var str = "";
  for(var i =0; i < a.length; i++){
    if(a.charAt(i) == "?"){
      str += "%3F";
      continue;
    }else if(a.charAt(i) == "&"){
      str += "%26";
      continue;
    }else if(a.charAt(i) == "="){
      str += "%3D";
      continue;
    }
    str += a.charAt(i);
  }
	if(site_id == 4 && arguments.length == 7){
		str += "&y=" + arguments[3];
		str += "&m=" + arguments[4];
		str += "&d=" + arguments[5];
		str += "&ninzu=" + arguments[6];
	}
  
	  window.open( "http://"+window.location.host+"/search/plan_click.php?url="+str+"&site_id="+site_id+"&plan_id="+plan_id );	  
}

function openform(){
	var so = document.getElementById('serchOption');
	var iso = document.getElementById('ISOption');
	if(so.style.display != "block"){
		so.style.display='block';
		iso.style.display='none';
	}else{
		so.style.display='none';
		iso.style.display='block';
	}
	try{
		startLayer();
	}catch(e){}
}
function msOver(obj) {
	obj.style.backgroundColor = '#FFFF99';
}
function msOut(obj) {
	obj.style.backgroundColor = '#FFFFFF';
}
