//------------------------------------------------------------------------------
//
// function Login()
// ログイン用submit
//
//------------------------------------------------------------------------------
function Login(){
document.login.submit();
}

//------------------------------------------------------------------------------
//
// function Search()
// 検索用submit
//
//------------------------------------------------------------------------------
function Search(){
document.search.submit();
}

//------------------------------------------------------------------------------
//
// タブ切り替え用
// seltab(bpref)
// @param bpref：表示ブロックid
//
//------------------------------------------------------------------------------
function seltab(bpref) {
  if (! document.getElementById) return;
	var bplen = bpref.split("_");
	var x = bplen[1].substring(6,5);
	var blockType = bplen[0];
    if (x=="" && bpref=='dmail_block') {
	  if(document.getElementById('dmail_block1')){document.getElementById('dmail_block1').style.display = "block";}
      if(document.getElementById('dmail_block2')){document.getElementById('dmail_block2').style.display = "block";}
      if(document.getElementById('dmail_block3')){document.getElementById('dmail_block3').style.display = "block";}
      if(document.getElementById('tel_block1')){document.getElementById('tel_block1').style.display = "none";}
      if(document.getElementById('tel_block2')){document.getElementById('tel_block2').style.display = "none";}
      if(document.getElementById('tel_block3')){document.getElementById('tel_block3').style.display = "none";}
	}else if(x=="" && bpref=='tel_block'){
	  if(document.getElementById('dmail_block1')){document.getElementById('dmail_block1').style.display = "none";}
      if(document.getElementById('dmail_block2')){document.getElementById('dmail_block2').style.display = "none";}
      if(document.getElementById('dmail_block3')){document.getElementById('dmail_block3').style.display = "none";}
      if(document.getElementById('tel_block1')){document.getElementById('tel_block1').style.display = "block";}
      if(document.getElementById('tel_block2')){document.getElementById('tel_block2').style.display = "block";}
      if(document.getElementById('tel_block3')){document.getElementById('tel_block3').style.display = "block";}
	}else if(x!="" && blockType=='dmail'){
	  if(document.getElementById('dmail_block'+ x)){document.getElementById('dmail_block'+ x).style.display = "block";}
      if(document.getElementById('tel_block'+ x)){document.getElementById('tel_block'+ x).style.display = "none";}
    } else if(x!="" && blockType=='tel'){
	  if(document.getElementById('dmail_block'+ x)){document.getElementById('dmail_block'+ x).style.display = "none";}
      if(document.getElementById('tel_block'+ x)){document.getElementById('tel_block'+ x).style.display = "block";}
    }
}


//------------------------------------------------------------------------------
//
// function ChPage(url)
// ページ移動用
//
//------------------------------------------------------------------------------
function ChPage(url){
    location.href = url;
}


/**
 * サブウィンドウを表示する関数。
 * 
 * @param url     サブウィンドウの対象となるURL
 * @param w       サブウィンドウの幅
 * @param h       サブウィンドウの高さ
 * @param winName サブウィンドウの名前
 */
function subwin(url, w, h, winName) {
    
    var option = "width=" + w + ","
               + "height=" + h + ","
               + "status=no,"
               + "scrollbars=yes,"
               + "directories=no,"
               + "menubar=no,"
               + "resizable=yes,"
               + "toolbar=no";
               
    window.open(url, winName, option);
}

/**
 * アンカーにフォーカスを合わせる関数。
 *
 * @param ancName アンカー名
 */
function focusAnc(ancName) {

	if(!ancName)
		ancName = "messageAnchor";
	
	var anc = window.document.getElementsByName(ancName);
	if(anc != null && anc.length != null && anc.length > 0) {
		window.location.hash = ancName;
	} else if (window.document.forms[0].scrollTop) {
		window.scrollTo(window.document.forms[0].scrollLeft.value,
						window.document.forms[0].scrollTop.value);
	}
}

/**
 * bPath か　pPathに遷移
 * @param bPath bのパス
 * @param pPath pのパス
 */
function borp(bPath,pPath) {
  if (window.location.href.indexOf('\/b\/') > 0) {
    if (!bPath) {bPath='/b/';}
    //window.location.replace(bPath);
    ChPage(bPath);
  }else{
    if (!pPath) {pPath='/p/';}
    //window.location.replace(pPath);
    ChPage(pPath);
  }
  return false;
}

/**
 * w=650のsubwinを開く
 * @param url パス
 */
function subwin650(url) {
  subwin(url,'650','530','');
}

/**
 * w=680のsubwinを開く
 * @param url パス
 */
function subwin680(url) {
  subwin(url,'680','530','');
}

/**
 * w=786のsubwinを開く
 * @param url パス
 */
function subwin786(url) {
  subwin(url,'786','530','');
}

/**
 * bPath か　pPathをwの幅のsubwinで開く
 * @param bPath bのパス
 * @param pPath pのパス
 * @param w 幅 '650'or'680'or'786'
 */
function borpsubwin(bPath,pPath,w) {
  if(!w || w=='650'){
    if (window.location.href.indexOf('\/b\/') > 0) {
      subwin650(bPath);
    } else {
      subwin650(pPath);
    }
  } else if (w=='680') {
    if (window.location.href.indexOf('\/b\/') > 0) {
      subwin680(bPath);
    } else {
      subwin680(pPath);
    }  
  } else if (w=='786') {
    if (window.location.href.indexOf('\/b\/') > 0) {
      subwin786(bPath);
    } else {
      subwin786(pPath);
    }  
  }
}

/**
 * urlをhttpsにして遷移する
 * @param url /p|b/xxx.do形式
 */
function sslurl(url) {
  h=window.location.href;
  s=h.indexOf(':\/\/');
  eb=h.indexOf('\/b\/');
  ep=h.indexOf('\/p\/');
  if (s > 0 && eb > 0) {
    d=h.substring(s,eb);
    //window.location.replace('https'+d+url);
    ChPage('https'+d+url);
  } else if (s > 0 && ep > 0) {
    d=h.substring(s,ep);
    //window.location.replace('https'+d+url);
    ChPage('https'+d+url);    
  } else {
  
  }
}

