
function fx_findObj(n, d) { //v4.01
  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;
}
///////////////////////////////////////////////////////////////////////////////
//関数：    fx_popopen()
//
//引数：    開きたいポップアップのIDをしていする。
//          規定値以外はスルーする
//
//戻値：    なし
//
//機能：    WindowsをOpenする
//
////////////////////////////////////////////////////////////////////////////////

      
function fx_popopen(value){
    if (value=='ROS340'){
      fx_NewWin('ROS340','subwin','width=470,height=360,top=100,left=100,scrollbars=no');
    }else if(value=='ROS341'){
      fx_NewWin('ROS341','subwin','width=470,height=360,top=100,left=100,scrollbars=no');
    }
}

///////////////////////////////////////////////////////////////////////////////
//関数：    fmNewWin()
//
//引数：    
//
//戻値：    なし
//
//機能：    WindowsをOpenする
//
////////////////////////////////////////////////////////////////////////////////
var xObjwin;
/**
function fx_NewWin(wURL, wFlameNM, wAttr)
{

    if( !!xObjwin )
    {
        if ( xObjwin.closed == false )
        {
            xObjwin.close();
        }
    }
    if ( wAttr.indexOf('height',0) == -1 )
    {
        wAttr += ',height=' + ( screen.availHeight - 30 )
    }
        
    xObjwin = window.open(wURL, wFlameNM, wAttr);
    //必要に応じてsubmit
    xObjwin.location.href = wURL
}
*/

function fx_NewWin(wURL, wFlameNM, wAttr, lIdx)
{

    if(document.forms[0].i_init)
    {
        document.forms[0].i_init.value= '';
    }

    if( !!xObjwin )
    {
        if ( xObjwin.closed == false )
        {
            xObjwin.close();
        }
    }
    if ( wAttr.indexOf('height',0) == -1 )
    {
        wAttr += ',height=' + ( screen.availHeight - 30 )
    }
   if(typeof(lIdx) == "undefined") {
      lIdx= 0;
   }
   
   if ( wAttr=='' )
   {
        wAttr = 'resizable=yes';
   }
   else
   {
        wAttr = wAttr + ',resizable=yes';
   }
    //alert(wAttr);

    xObjwin = window.open('dummy.html', wFlameNM, wAttr);
    //必要に応じてsubmit
    //xObjwin.location.href = wURL
    //fx_submit(wURL,lIdx,wFlameNM);

   if(typeof(lIdx) == "undefined") {
      lIdx= 0;
   }

   if(typeof(wFlameNM) == "undefined") {
        sTarget = "_self";
   }

   window.document.forms[lIdx].target = wFlameNM;
   window.document.forms[lIdx].action = wURL;
   window.document.forms[lIdx].submit();


}



function fx_submit(sURL,lIdx,sTarget)
{
   var sAttr = '';

    if(document.forms[0].i_init)
    {
        document.forms[0].i_init.value= '';
    }

   if(typeof(lIdx) == "undefined") {
      lIdx= 0;
   }

   if(typeof(sTarget) == "undefined") {
        sTarget = "_self";
   }
   else
   {
        if ( sTarget == 'insatsu' )
        {
            sAttr = 'left=0,top=0,width=1015,height=550,top=0,left=0,scrollbars=yes,menubar=yes';
            fx_NewWin(sURL,sTarget,sAttr,lIdx);
            return;
        }

        if ( sTarget == 'pdf' )
        {

            if(!!window.screen)
            {
              sAttr = 'left=0,top=0,width=' + screen.availWidth/2;  //N4,N6,Moz,IE,共用
            }
            else
            {
                sAttr = 'left=0,top=0,width=650,height=768';
            }
            fx_NewWin(sURL,sTarget,sAttr,lIdx);
            return;
        }
        if ( sTarget == 'pdf3' )
        {
            sAttr = 'left=0,top=0,width=1250,height=1000';
            fx_NewWin(sURL,sTarget,sAttr,lIdx);
            return;
        }
   }

   
   window.document.forms[lIdx].target = sTarget;
   window.document.forms[lIdx].action = sURL;
   window.document.forms[lIdx].submit();
}

///////////////////////////////////////////////////////////////////////////////
//関数：    invoke_count()
//
//引数：    inputArea:カウント対象オブジェクト
//          displayArea:カウント結果出力オブジェクト
//
//戻値：    なし
//
//機能：    テキスト、テキストエリアなどの入力文字数をカウント（2byte単位）する。
//
////////////////////////////////////////////////////////////////////////////////

function invoke_count( inputArea, displayArea )
{
	displayArea.value = Math.round( getBytes( inputArea.value ) / 2 );
}

function getBytes( text )
{
	var count = 0;
	text = escape( text );
	while( text ) {
		if( text.charAt( 0 ) == '%' ) {
			if( text.charAt( 1 ).toLowerCase() == 'u' ) { 
				count += 2;
				text = text.substring( 6 );
			} else {
				count += 1;
				text = text.substring( 3 );
			}
		} else {
			count += 1;
			text = text.substring( 1 );
		}
	}
	return count;
}
