var curObj = null;
function SelMst_Change(selObj){
    var selectedIdx = 0;
    var selectedCount = 1;

    if(selObj.length>0 && selObj.selectedIndex >=0){
        selectedIdx = selObj.selectedIndex;     

        for(var i = 0; i<selObj.length-1;i++){
            if(selObj.options[i].selected&&i != selectedIdx){
                ++selectedCount;
            }
        }

        if(selectedCount=1){
            selObj.selectedIndex =-1;
            curObj = selObj;
        }
    }
    
}

function SelMst_CheckedFalse(){
    if (curObj != null)
    {
//      curObj.selectedIndex=-1;
//      curObj = null;
    }
}

function open_wnd(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable) {
	toolbar_str = toolbar ? 'yes' : 'no';
	menubar_str = menubar ? 'yes' : 'no';
	statusbar_str = statusbar ? 'yes' : 'no';
	scrollbar_str = scrollbar ? 'yes' : 'no';
	//  resizable_str = resizable ? 'yes' : 'no';
	resizable_str='yes';
	window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function open_wndEx(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable) {
	toolbar_str = toolbar ? 'yes' : 'no';
	menubar_str = menubar ? 'yes' : 'no';
	statusbar_str = statusbar ? 'yes' : 'no';
	scrollbar_str = scrollbar ? 'yes' : 'no';
	resizable_str = resizable ? 'yes' : 'no';
	return window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function LenB(vStr){
	var clen;
	var vlen;
	vlen = 0 ;
	clen = vStr.length;
	for(var i = 0; i < clen; i++){
		vlen++;
		if(Test( escape( vStr.substr(i,1) ),"%u([0-9A-Z]{4})", "i" ) ) vlen++;
	}

	return vlen;
}

function onlyNumber() {
	if(event.keyCode==45||event.keyCode==46){		//45:- 45:.
	}else if ((event.keyCode<48)|| (event.keyCode>57)){
		event.returnValue=false;
	}	
}

/*
窓のサイズを自分のコンテンツサイズで調整します。
*/
function adjWndSzToCont(pWnd_){
	var clientAreaOffsetW;
	var clientAreaOffsetH;
	
	var wndNewW;
	var wndNewH;

	var bndW=0;
	var bndH=0;

	var pAmW=0;
	var pAmH=0;

	if(!pWnd_)pWnd_ = self;

	//窓を最小化にする。
	pWnd_.resizeTo(150, 150);

	//見られないように。
	pWnd_.moveBy(pWnd_.screen.width, pWnd_.screen.height);

	var txtRng = pWnd_.document.body.createTextRange();
	with(pWnd_.document.body.style){
		pAmW+=isNaN(parseInt(paddingLeft))?0:parseInt(paddingLeft);
		pAmW+=isNaN(parseInt(paddingRight))?0:parseInt(paddingRight);
		pAmW+=isNaN(parseInt(marginLeft))?0:parseInt(marginLeft);
		pAmW+=isNaN(parseInt(marginRight))?0:parseInt(marginRight);

		pAmH+=isNaN(parseInt(paddingTop))?0:parseInt(paddingTop);
		pAmH+=isNaN(parseInt(paddingBottom))?0:parseInt(paddingBottom);
		pAmH+=isNaN(parseInt(marginTop))?0:parseInt(marginTop);
		pAmH+=isNaN(parseInt(marginBottom))?0:parseInt(marginBottom);
	}
	
	//document.body.boundingにはdocument.body.padding及びmarginを含んでいないために、数値を足す。
	//この値がコンテンツの実サイズが成ります。
	bndW=txtRng.boundingWidth+pAmW;
	bndH=txtRng.boundingHeight+pAmH;
	//alert("different of bnd and off cli W" + bndW +","+document.body.offsetWidth+","+document.body.clientWidth);
	//alert("different of bnd and off cli H" + bndH +","+document.body.offsetHeight+","+document.body.clientHeight);

	//クライアントエリアと窓のオプセット。
	clientAreaOffsetW=150-pWnd_.document.body.clientWidth;
	clientAreaOffsetH=150-pWnd_.document.body.clientHeight;

	//var clientAreaOffsetOW=150-pWnd_.document.body.offsetWidth;
	//var clientAreaOffsetOH=150-pWnd_.document.body.offsetHeight;
	//alert("offset with client "+clientAreaOffsetW+","+clientAreaOffsetOW+"|"+clientAreaOffsetH+","+clientAreaOffsetOH);

	//変更するサイズです。
	//コンテンツサイズとクライアントエリアの合です。
	wndNewW = bndW+clientAreaOffsetW;
	wndNewH = bndH+clientAreaOffsetH;

	//窓のサイズを変更
	pWnd_.resizeTo(wndNewW, wndNewH);
	
	//alert("different of bnd and off W" + bndW +","+document.body.offsetWidth);
	//alert("different of bnd and off H" + bndH +","+document.body.offsetHeight);

	//alert((bndW - document.body.clientWidth));
	//alert((bndH - document.body.clientHeight));
	//下の再調整は窓サイズを150,150で減らす時にスクロールバーが現れる場合,再び窓を広くなければ
	//スクロールが消えうせるんで、clientWidht及びclientHeigtはスクロールバーほどもっと大きくて、
	//それを調整します。
	wndNewW += (bndW - document.body.clientWidth);	
	wndNewH += (bndH - document.body.clientHeight);
	wndNewW=(window.screen.availWidth<wndNewW)?window.screen.availWidth:wndNewW;
	wndNewH=(window.screen.availHeight<wndNewH)?window.screen.availHeight:wndNewH;
	//窓のサイズを変更
	pWnd_.resizeTo(wndNewW, wndNewH);
	
	//見られるように。
	pWnd_.moveBy(-pWnd_.screen.width, -pWnd_.screen.height);
	
	//窓の一部が見られなければ窓の位置を調整
	if((wndNewW+pWnd_.screenLeft)>pWnd_.screen.availWidth)
		pWnd_.moveTo(0,pWnd_.screenTop);
	if(wndNewH+pWnd_.screenTop>pWnd_.screen.availHeight)
		pWnd_.moveTo(pWnd_.screenLeft,0);
}

function hwnd_onError(arrImages){
	var imageIdx;
	imageIdx = event.srcElement.getAttribute("image_index");
	if(imageIdx != null){
		imageIdx++;
		event.srcElement.setAttribute("image_index",imageIdx);		
	}else{
		imageIdx=0;
		event.srcElement.setAttribute("image_index",imageIdx);
	}
	
	if(imageIdx>=arrImages.length){
		event.srcElement.onerror=null;
		return;
	}
	event.srcElement.src = arrImages[imageIdx];
}