var hostname = window.location.hostname;

//--子ウインドウの有無確認関数 
function win_closed(winVar) {

  var ua = navigator.userAgent
  if( !!winVar )
      if( ( ua.indexOf('Gecko')!=-1 || ua.indexOf('MSIE 4')!=-1 )
           && ua.indexOf('Win')!=-1 ) 
           return winVar.closed
      else return typeof winVar.document  != 'object'
  else return true
}

//--サブウインドウを開く/フォーカス
function openwin(winVar, cgiparam, targetName, winparam){
	if(win_closed(winVar)){
	  winVar = window.open(cgiparam,targetName
	                   ,winparam);
  }
  winVar.focus()
}

function cartadd(cate, no)
{
	if((cate != 'r' && cate != 's') || no <= 0){
		alert('エラー');
	}
	else {
		if(confirm("候補カゴに追加します。よろしいですか？")){
		  script = 'http://'+ hostname +'/web/inquiry/cartadd.php';
		  query = '?c=' + cate + '&n=' + no;
		  requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );
	  }
  }
}
function cartdel(cd)
{
	if(cd == ''){
		return;
	}
	if(confirm("候補カゴから削除します。よろしいですか？")){
	  script = 'http://'+ hostname +'/web/inquiry/cartdel.php';
	  query = '?cd=' + cd;
	  requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );
  }
}
function cartview()
{
  script = 'http://'+ hostname +'/web/inquiry/cartview.php';
  requestFile( '' , 'GET', script + "?rd=" + Math.random(), true );
}
function rent_list()
{
  script = 'http://'+ hostname +'/admin/rent/list.php';
  requestFile( '' , 'GET', script + "?rd=" + Math.random(), true );
}

function showRentPictEdit(no)
{
	if(no == ''){
		return;
	}
  script = 'http://'+ hostname +'/admin/rent/showpictedit.php';
	query = '?n=' + no;
	//document.getElementById('debug').innerHTML = script + query;
  requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );
}
function showSalePictEdit(no)
{
	if(no == ''){
		return;
	}
  script = 'http://'+ hostname +'/admin/sale/showpictedit.php';
	query = '?n=' + no;
	//document.getElementById('debug').innerHTML = script + query;
  requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );
}
function moveRentPict(ud, sno, no)
{
	if(ud == '' || sno == '' || no == ''){
		return;
	}
  script = 'http://'+ hostname +'/admin/rent/movepict.php';
	query = '?s=' + sno + '&n=' + no + '&f=' + ud;
	//document.getElementById('debug').innerHTML = script + query;
  requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );
}
function moveSalePict(ud, sno, no)
{
	if(ud == '' || sno == '' || no == ''){
		return;
	}
  script = 'http://'+ hostname +'/admin/sale/movepict.php';
	query = '?s=' + sno + '&n=' + no + '&f=' + ud;
	//document.getElementById('debug').innerHTML = script + query;
  requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );
}
function search(no)
{
  script = 'search.php?';
  query = 'n='+ no + '&cd=' + document.getElementById('n' + no).value;
  //document.getElementById('debug1').innerHTML = script + query;
  requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );
}
function searchAll()
{
  script = 'search.php?';
  for(no=1; no <= 10; no++){
    if(document.getElementById('n'+no).value != ''){
      query = 'n='+ no + '&cd=' + document.getElementById('n'+no).value;
      //document.getElementById('debug1').innerHTML = script + query;
      requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );
    }
  }
}
function getCount()
{
  script = 'count.php?';
  //document.getElementById('debug1').innerHTML = script + query;
  requestFile( '' , 'GET', script + "rd=" + Math.random(), true );
}

function changePW()
{
  script = 'change_passwd.php?';
  if(document.getElementById('newpw1').value != document.getElementById('newpw2').value){
		alert('新しいパスワードが一致しません。');
		return;
	}
  if(document.getElementById('oldpw').value == ''){
		alert('現在のパスワードを入力してください。');
		return;
	}
  if(document.getElementById('newpw1').value == ''){
		alert('新しいパスワードを入力してください。');
		return;
	}
  query = 'o='+ document.getElementById('oldpw').value + '&n1=' + document.getElementById('newpw1').value + '&n2=' + document.getElementById('newpw2').value;
  //document.getElementById('debug1').innerHTML = script + query;
  requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );
}

function calc_tb(fid, tid){
	/*var m2 = document.getElementById(fid).value;
	if(m2.match(/[^0-9\.]/)){
		return;
	}
	script = 'm2t.php';
	query = '?t=' + tid + '&m2=' + m2;
	requestFile( '' , 'GET', script + query + "&rd=" + Math.random(), true );*/
}

