if (window.ActiveXObject && !window.XMLHttpRequest)
{
  window.XMLHttpRequest = function()
    {
      try
      {
        return (new ActiveXObject('Msxml2.XMLHTTP'));
      }
      catch (e) {}

      try
      {
        retrurn (new ActiveXObject('Microsoft.XMLHTTP'));
      }
      catch (e) {}

      return (null);
    }
}
function show_section( idname ) {						//	Directionの表示／非表示
	var allsection = document.getElementsByTagName("section");
	for (var i=0; i<allsection.length; i++ ) {
		if( allsection[i].id == idname ) {
			allsection[i].style.display = "block";
		} else {
			allsection[i].style.display = "none";
		}
	}
}

function submitForm( value ){
    var frm = document.createElement('form'); 
    document.body.appendChild( frm );
    var input = document.createElement('input');
    input.setAttribute('type', 'hidden');
    input.setAttribute('name', 'selectedGroup');
    input.setAttribute('value', value );
    frm.appendChild( input );
    frm.setAttribute('action', 'index.php');
    frm.setAttribute('method', 'post');
    frm.submit();
}

function highlight( strMenu ) {
	var menuTab = document.getElementById( strMenu );
	menuTab.style.backgroundColor = "#ffcccc";
	menuTab.fontSize = "20pt";
}

function menu(i) {
	if( i===0 ) {
		obj = document.getElementById("stage");
		obj.style.display="block";
		obj = document.getElementById("target");
		obj.style.display="block";
		obj = document.getElementById("materials");
		obj.style.display="block";
		obj = document.getElementById("class");
		obj.style.display="none";
		obj = document.getElementById("area");
		obj.style.display="none";
		obj = document.getElementById("ret");
		obj.style.display="none";
		objs = document.getElementsByName("stage[]");
/*
		for( var i=0; i<objs.length; i++ ) {
			objs[i].checked = true;
		}
*/
	} else if( i===1) {
		obj = document.getElementById("stage");
		obj.style.display="none";
		obj = document.getElementById("target");
		obj.style.display="none";
		obj = document.getElementById("materials");
		obj.style.display="none";
		obj = document.getElementById("class");
		obj.style.display="block";
		obj = document.getElementById("area");
		obj.style.display="block";
		obj = document.getElementById("ret");
		obj.style.display="none";
	} else {
		obj = document.getElementById("stage");
		obj.style.display="none";
		obj = document.getElementById("target");
		obj.style.display="none";
		obj = document.getElementById("materials");
		obj.style.display="none";
		obj = document.getElementById("class");
		obj.style.display="none";
		obj = document.getElementById("area");
		obj.style.display="none";
		obj = document.getElementById("ret");
		obj.style.display="block";
	}
	return false;
}

function click_count() {

	var el = document.activeElement;
	var url = el.href;

    var xmlhttp = new XMLHttpRequest();
/*
		if( xmlhttp ) {
	    xmlhttp.onreadystatechange = function() {
  	  	if( xmlhttp.readyState == 4  && xmlhttp.status == 200 ) {
					alert(xmlhttp.responseText);
					change_myname(xmlhttp.responseText);
      	}
    	}
		}
*/
	  xmlhttp.open('GET', 'count.php?url='+url, true);
    xmlhttp.send(null);
}

function dwn_count() {

	var el = document.activeElement;
	var url = el.href;

    var xmlhttp = new XMLHttpRequest();
/*
		if( xmlhttp ) {
	    xmlhttp.onreadystatechange = function() {
  	  	if( xmlhttp.readyState == 4  && xmlhttp.status == 200 ) {
					alert(xmlhttp.responseText);
					change_myname(xmlhttp.responseText);
      	}
    	}
		}
*/
		if( ( n = url.lastIndexOf("/")) != -1 ) {
			fileName = url.substring(n);
		}
	  xmlhttp.open('GET', 'dwn_count.php?filename='+fileName, true);
/*		alert('dwn_count.php?filename='+fileName); */
    xmlhttp.send(null);
}

function pagechange( imode, istart, ikensuu, irows ) {
	/*	imode=0:top, =1:prev, =2:next, =3:last	*/
	/*	istart:現在表示されている先頭レコードの番号	*/
	/*	ikensuu: 全レコード数 */
	/*	irows:一度に表示するレコード数	*/
	/*	alert( "imode="+imode+", istart="+istart+", irows="+irows );	*/
	switch( imode ) {
		case 0:
					window.document.navform.start.value=0;
					break;
		case 1:
					if( istart-irows< 0 ) {
						istart=0;
					} else {
						istart = istart - irows;
					}
					window.document.navform.start.value=istart;
					break;
		case 2:
					istart = istart+irows;
					window.document.navform.start.value=istart;
					break;
		case 3:
					istart = ikensuu-irows;
					if( istart<0 ) {
						istart = 0;
					}
					window.document.navform.start.value=istart;
					break;
		default:
					alert( "Programing error at pagechane");
					break;
	}
	window.document.navform.submit();
}

