// JavaScript Document

// menu
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_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;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//概況
function openGaikyo()
{
	if(subWinCK != false){
		if(!subWin.closed){		
			subWin.close();
			subWinCK=false;
		}
	}
	
	subWin=window.open('http://www.masudaasi.com/gaikyo.html','gaikyo','left=0,top=0,Width=540,Height=590,titlebar=0,toolbar=0,location=0,directories=0,status=yes=0,menubar=0,scrollbars=0,resizable=0');
	subWinCK=true;
	openChannel="";
}

/*
function openWinSoft(strPath)
{
 	window.open(strPath,'softWin','Width=1000,Height=718,scrollbars=yes,top=0,left=0');
}
*/

// column chart link
var subWinCK=false;
var StockCodeTemp="";
function openWebChart(strStockCode)
{
	
	StockCodeTemp=strStockCode;
	if(subWinCK != false){
//		if(!subWin.closed){
//			subWin.close();
			subWinCK=false;
//		}
	}
 	subWin=window.open('http://www.masudaasi.com/webchart/homechart.php?iniMeigara=' + strStockCode,'homewindow','Width=1000,Height=718,scrollbars=no,top=0,left=0');
	subWin.focus();
 	subWinCK=true;
	StockCodeTemp="";
	
//	return true;
}

/* ------- created by hirayama ------- */
function openWebChart4D(_strStockCode)
{
	var _strStockCode;
	
	var _url='./';
	var _name='popupWin';
	
	var popupWin = window.open(_url, _name, 'toolbar=no,location=no,menubar=no,resizable=no,scrollbars=no,width=1020,height=718');
	popupWin.document.open("text/html; charset=utf-8");
	popupWin.focus();
	//popupWin.document.write(_strStockCode);
	
	/* ロケーションパスを取得し条件分岐する */
	//alert(location.pathname);
	if (location.pathname == '/site025/') {
		var _action='./webchart4/homechart4.html';
	} else if (location.pathname == '/') {
		var _action='./webchart4/homechart4.html';
	} else {
		var _action='./homechart4.html';
	}
	
	var _fname='goAction';
	//var _action='./webchart4/homechart4.html';
	var _target='popupWin';
	
	popupWin.document.write('<form name="',_fname,'" action="',_action,'" method="post" target="',_target,'">');
	popupWin.document.write('<input type="hidden" name="request" value="',_strStockCode,'" />');
	popupWin.document.write('</form>');
	
	
	if(navigator){
		if(navigator.userAgent){
			if(navigator.userAgent.indexOf("Gecko/") != -1){
				popupWin.document.write('document.getElementsByTagName(_fname)[0].name');
			}
		}
	}
	
	popupWin.document.getElementsByName(_fname)[0].submit();	
}

/* ------- created by hirayama ------- */
function goAction(_strStockCode, _urlName) {
	var _urlName;
	var _strStockCode;
	
	var _fname='goAction';
	var _action='./webchart4/'+_urlName+'.html';
	
	/* ---debug--- */
	//alert(_strStockCode,' ',_action);
	
	
	document.write('<form name="',_fname,'" action="',_action,'" method="post">');
	document.write('<input type="hidden" name="request" value="',_strStockCode,'" />');
	document.write('</form>');
	
	if(navigator){
		if(navigator.userAgent){
			if(navigator.userAgent.indexOf("Gecko/") != -1){
				document.write('document.getElementsByTagName(_fname)[0].name');
			}
		}
	}
	
	document.getElementsByName(_fname)[0].submit();	
	
}

/* ------- created by hirayama ------- */
function eraseTextField(obj) {
	//obj.value = "";
	_fobj = document.membersroom;
		_faccount = _fobj.account.value;			//alert(_faccount);
		_fpassword = _fobj.password.value;		//alert(_fpassword);
	if ( _faccount != "" && _fpassword != "" ) {
		
	} else {
		_fobj.account.value = "";
		_fobj.password.value = "";
	}
}

function popupblock() {
	
	winOpen = window.open('dummy','subwindow','width=0,height=0,scrollbars=no,resizable=no,status=no');
	//alert(winOpen);
	
	if ( winOpen == null || winOpen == 'undefined' ) {
		alert('ポップアップブロックを解除してください!!!');
	} else {
		winOpen.blur();
		document.openwebchartForm.account.focus();
		winOpen.close();
	}
	
	return false;
}

function numCount(Obj) {
	var Obj;
	
	var Digitnumber = 4;
	var subWin = null;
	
	txt = document.openwebchartForm.code.value;
	result = '';
	for (i=0; i<txt.length; i++) {
		result = txt;
		if (i==(Digitnumber-1)) {
			strStockCode = eval(result);
			//alert(strStockCode);
			
		 	subWin=window.open('http://www.masudaasi.com/webchart/homechart.php?iniMeigara=' + strStockCode,'','Width=1000,Height=718,scrollbars=no,top=0,left=0');
			subWin.focus();
			
			/* fujisima add */
			document.openwebchartForm.code.value = '';
			
		}
	}
	
}
/*
function goMembersRoom() {
	alert('aaaaa');
	
	var _fobj;
	
	var _fname='goAction';
	var _action='../membersroom2/';
	var _url='otazune';
	
	// 変数への代入
	_fobj = document.membersroom;
		_faccount = _fobj.account.value;			alert(_faccount);
		_fpassword = _fobj.password.value;		alert(_fpassword);
	
	// 通常の処理
	document.write('<form name="',_fname,'" action="',_action,'" method="post" target="_blank">');
	document.write('<input type="hidden" name="request" value="',_url,'" />');
	document.write('<input type="hidden" name="account" value="',_faccount,'" />');
	document.write('<input type="hidden" name="password" value="',_fpassword,'" />');
	document.write('</form>');
	
	if(navigator){
		if(navigator.userAgent){
			if(navigator.userAgent.indexOf("Gecko/") != -1){
				document.write('document.getElementsByTagName(_fname)[0].name');
			}
		}
	}
	
	document.getElementsByName(_fname)[0].submit();	
}

function goMembersRoom2(_account, _password, _name) {
	var _account;
	var _password;
	var _name;
	
	var _fname='goAction';
	var _action='../membersroom2/';
	var _url='';
	
	document.write('<form name="',_fname,'" action="',_action,'" method="post" target="_blank">');
	document.write('<input type="hidden" name="request" value="',_url,'" />');
	document.write('<input type="hidden" name="account" value="',_faccount,'" />');
	document.write('<input type="hidden" name="password" value="',_fpassword,'" />');
	document.write('<input type="hidden" name="name" value="',_name,'" />');
	document.write('</form>');
	
	if(navigator){
		if(navigator.userAgent){
			if(navigator.userAgent.indexOf("Gecko/") != -1){
				document.write('document.getElementsByTagName(_fname)[0].name');
			}
		}
	}
	
	document.getElementsByName(_fname)[0].submit();	
	
}
*/
/* ------- created by hirayama ------- */

function errorHandler() {
	subWinCK=false;
	if(StockCodeTemp !="")
	{
		openWin(StockCodeTemp);
	}
	return true;
}
window.onerror = errorHandler;
// 親ウィンドウがクローズしたら、子ウィンドウもクローズします。
function subWinClose(){
//if(window.subWin)subWin.close();
}

window.onunload = subWinClose;


//お茶の間教室へ接続 /ochanoma/
function MM_goToURL() {

 window.open('http://www.masudaasi.com/services/ochanoma/ocha_school.html','admission','Width=1000,Height=718,scrollbars=no,resizable=yes,statusbar=no');

}

function MM_callJS(jsStr) { //v2.0

  return eval(jsStr)

}

/* index.html ウェブ電話の小窓を出す */

function openWin_pop01(url, winName) {
	wx = 500;
	wy = 630;
	x = (screen.width - wx) / 2;
	y = (screen.height - wy) / 2 - 40;
	window.open(url,winName,"resizable=1,scrollbars=1,status=1,toolbar=no,left="+x+",top="+y+",width="+wx+",height="+wy);
}


function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function showImg(name, map, alt)
{
	document.yojigen_images.src = name;
	document.yojigen_images.useMap = map;
	document.yojigen_images.alt = alt;
}

function showImg_new(name, map, alt)
{
	document.new_images.src = name;
	document.new_images.useMap = map;
	document.new_images.alt = alt;
}

function showImg_mobile(name, map, alt)
{
	document.mobile_images.src = name;
	document.mobile_images.useMap = map;
	document.mobile_images.alt = alt;
}

function change(obj)
{
	switch(obj.value){
		case "1001":	// 日経２２５
		case "1002":	// TOPIX
		case "1003":	// ドル／円
		case "1004":	// ユーロ／円
		case "1020":	// 日経２２５先物
		case "1021":	// ミニ日経２２５先物
		case "1022":	// TOPIX先物
			document.forms[0].code.value = '';
			document.forms[0].submit();
			break;
	}		
}

function changecategory(obj)
{
	openWebChart(obj.value);	
}

function change_code(market, brand)
{
	document.forms[0].categoryName.value = market;
	document.forms[0].code.value = brand;
	document.forms[0].submit();
	
}

function GetHeight(Y,NAME)
{
    var app = navigator.appName.charAt(0);
    if(navigator.userAgent.indexOf('Safari') != -1){
        document.getElementById(Y).height = parent.frames[NAME].document.body.scrollHeight + 80;
    }else if (app == "N")
    {
        document.getElementById(Y).height = parent.frames[NAME].document.height +1;
    }
    else
    {
        document.getElementById(Y).height = parent.frames[NAME].document.body.scrollHeight + 1;
    }
}

function addBookmark(title,url) { 
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) { 
		window.external.AddFavorite( url, title); 
	} else if( window.opera && window.print ) { 
	return true; 
	} 
}

// 2009-07-21 fujishima add
function MM_swapImage2(NAME, IMAGE) {
	
	var i = 1;
	for(i = 1; i < 10; i++){
		document.getElementById('service' + i).height = 48;
		document.getElementById('service' + i).width = 115;
	}
	
	document.getElementById(NAME).src = IMAGE;
	document.getElementById(NAME).height = 191;
	document.getElementById(NAME).width = 460;
}

function MM_swapImgRestore2(NAME, IMAGE) {
	document.getElementById(NAME).src = IMAGE;
	
	var i = 1;
	for(i = 1; i < 10; i++){
		document.getElementById('service' + i).height = 96;
		document.getElementById('service' + i).width = 230;
	}

}

/* --- 株式用語 --- */
function goRetrieval( _word ) {
	var _word;
	var _fname='goAction';
	
	//alert(_word);
	
	var _action='./';
	
	document.write('<form name="',_fname,'" action="',_action,'" method="post">');
	document.write('<input type="hidden" name="requestword" value="',_word,'" />');
	document.write('</form>');
	
	if(navigator){
		if(navigator.userAgent){
			if(navigator.userAgent.indexOf("Gecko/") != -1){
				document.write('document.getElementsByTagName(_fname)[0].name');
			}
		}
	}
	
	document.getElementsByName(_fname)[0].submit();	
	
}

function ExtendMenu(tmNum) {
	var tmNum;
	var tObj;
	var mID;
	var mObj;
	
	/*
		a_hiragana
		k_hiragana
		s_hiragana
		t_hiragana
		n_hiragana
		h_hiragana
		m_hiragana
		y_hiragana
		r_hiragana
		w_hiragana
		xq_hiragana
	*/

	if (document.getElementById){
		
		//alert( tmNum );
		tObj = document.getElementById( tmNum );
		//alert( tObj );
		
		/* Disp. Tree Menu */
		if ( tObj.style.display == 'none' ){
			tObj.style.display = "block";
		} else {
			if (tObj.style.display == 'block') {
			
			} else {
				tObj.style.display = "none";
			}
		}
		
	}
	
	/* clear others menu-id */
	mID = new Array(1);
	mID[0] = "a_hiragana";
	mID[1] = "k_hiragana";
	mID[2] = "s_hiragana";
	mID[3] = "t_hiragana";
	mID[4] = "n_hiragana";
	mID[5] = "h_hiragana";
	mID[6] = "m_hiragana";
	mID[7] = "y_hiragana";
	mID[8] = "r_hiragana";
	mID[9] = "w_hiragana";
	mID[10] = "xq_hiragana";

	var i;
	for (i in mID) {
		if (mID[i] != tmNum) {
			//alert( mID[i] + ':' + i );
			mObj = document.getElementById(mID[i]);
			mObj.style.display = "none";
		}
		mObj = null;
	}
}

function goRetrievalResult() {
	var Obj;
	
	var _word = new String(_word);
	var _fname = 'goAction';
	var _action='./';
	
	_word = document.retrievalresult.retrieval.value;
	//alert(_word);
	
	/* スペースの置換処理(全角を半角へ) */
	var _replacedword = _word.replace('　',' ');
	
	/* スペースの有無判断処理 */
	var _isolateword = _replacedword.indexOf(' ',0);
	
	if (_isolateword == -1 ) {
		//alert('複合キーワードなし');
		
		document.write('<form name="',_fname,'" action="',_action,'" method="post">');
		document.write('<input type="hidden" name="retrievalword" value="',_word,'" />');
		document.write('</form>');
		
		if(navigator){
			if(navigator.userAgent){
				if(navigator.userAgent.indexOf("Gecko/") != -1){
					document.write('document.getElementsByTagName(_fname)[0].name');
				}
			}
		}
		
		document.getElementsByName(_fname)[0].submit();	
		
	} else {
		//alert('複合キーワードあり'+_isolateword);
		var _word1 = _replacedword.substring(0,Number(_isolateword));
		var _word2 = _replacedword.substring(Number(_isolateword)+1);
		
		document.write('<form name="',_fname,'" action="',_action,'" method="post">');
		document.write('<input type="hidden" name="retrievalword1" value="',_word1,'" />');
		document.write('<input type="hidden" name="retrievalword2" value="',_word2,'" />');
		document.write('</form>');
		
		if(navigator){
			if(navigator.userAgent){
				if(navigator.userAgent.indexOf("Gecko/") != -1){
					document.write('document.getElementsByTagName(_fname)[0].name');
				}
			}
		}
		
		document.getElementsByName(_fname)[0].submit();	
		
	}
	
}

/* --- WEB版楽らく四次元増田足 --- */
function goTry3days() {
	var fOBJ  = document.trythreedays;
	
	/* 銘柄コード */
	var fBrandcode = fOBJ.brandcode.value;
	/* 環境変数 */
	var fEnvinfo = fOBJ.envinfo.value;
	
	/* お名前(ご担当者名) */
	var fHandlename = fOBJ.handlename.value;
	/* メールアドレス(フリーメール可) */
	var fMailaddress = fOBJ.mailaddress.value;
	
	/* === 内容の確認 === */
	if ( fBrandcode && fEnvinfo && fHandlename && fMailaddress ) {
		fOBJ.handlename.style.borderColor = '#9ACD32';
		check = /.+@.+\..+/;
		if (!fMailaddress.match(check)) {
			alert('メールアドレスが不適切です');
			fOBJ.mailaddress.value = '';
			return false;
		} else {
			fOBJ.mailaddress.style.borderColor = '#9ACD32';
		}
		
	} else {
		if (fHandlename == '') {fOBJ.handlename.style.borderColor = 'red';} else {fOBJ.handlename.style.borderColor = '#9ACD32';}
		if (fMailaddress == '') {
			fOBJ.mailaddress.style.borderColor='red';
		} else {
			check = /.+@.+\..+/;
			if (!fMailaddress.match(check)) {
				alert('メールアドレスが不適切です');
				fOBJ.mailaddress.value = '';
			} else {
				fOBJ.mailaddress.style.borderColor = '#9ACD32';
			}
		}
		return false;
		
	}
	
	/* === フォーム内容の送信 === */
	var _fname='goAction';
	var _action='./trythreedays.html';
	
	alert(fHandlename);
	alert(fMailaddress);
	alert(fBrandcode);
	alert(fEnvinfo);
	
	document.write('<form name="',_fname,'" action="',_action,'" method="post">');
	document.write('<input type="hidden" name="brandcode" value="',fBrandcode,'" />');
	document.write('<input type="hidden" name="envinfo" value="',fEnvinfo,'" />');
	
	document.write('<input type="hidden" name="handlename" value="',fHandlename,'" />');
	document.write('<input type="hidden" name="mailaddress" value="',fMailaddress,'" />');
	document.write('</form>');
	
	if(navigator){
		if(navigator.userAgent){
			if(navigator.userAgent.indexOf("Gecko/") != -1){
				document.write('document.getElementsByTagName(_fname)[0].name');
			}
		}
	}
	
	document.getElementsByName(_fname)[0].submit();	
	
}

function goHtml(_url){
	var _url;
	var _gourl = _url + '.html';
	
	//alert(_gourl);
	location.href = _gourl;
	
}

/* ------- デイトレ実践教室 ------- */
function CodeRetrieval( _Obj ){
	var _Obj;
	
	var _txt='';
	var _result='';
	var _digitnumber = 4;
	var _brandCode='';
	
	_txt = _Obj.value;
	
	for (i=0; i<_txt.length; i++) {
		_result = _txt;
		if (i==(_digitnumber-1)) {
			_brandCode = eval(_result);
			alert(_brandCode);
			
			/* --- 初期化 --- */
			_Obj = null;
			
			var _url='Index';
			var _fname='goAction';
			var _action='./';
			
			document.write('<form name="',_fname,'" action="',_action,'" method="post">');
			document.write('<input type="hidden" name="request" value="',_url,'" />');
			document.write('<input type="hidden" name="brandCode" value="',_brandCode,'" />');
			document.write('</form>');
			
			if(navigator){
				if(navigator.userAgent){
					if(navigator.userAgent.indexOf("Gecko/") != -1){
						document.write('document.getElementsByTagName(_fname)[0].name');
					}
				}
			}
			
			document.getElementsByName(_fname)[0].submit();
		}
	}
	
}
