function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function login(flag)
{
xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
	xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	  if(flag=='1')	  
      	document.getElementById('userx').innerHTML=xmlHttp.responseText;
	  else
	  	document.getElementById('passx').innerHTML=xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET","valid_login.php?user="+document.getElementById('user').value+"&pass="+document.getElementById('pass').value+"&flag="+flag,true);
  xmlHttp.send(null);
 }
 
function regis(flag)
{
xmlHttp=GetXmlHttpObject();

if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
	xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		  if(flag=='1')	  
			document.getElementById('namax').innerHTML = xmlHttp.responseText;
		  else if(flag=='2')
			document.getElementById('handphonex').innerHTML = xmlHttp.responseText;
		  else if(flag=='3')
			document.getElementById('emailx').innerHTML = xmlHttp.responseText;
		  else if(flag=='4')
			document.getElementById('norekx').innerHTML = xmlHttp.responseText;
		  else if(flag=='5')
			document.getElementById('namarekx').innerHTML = xmlHttp.responseText;
			else if(flag=='6')
			document.getElementById('userx').innerHTML = xmlHttp.responseText;
			else if(flag=='7')
			document.getElementById('passx').innerHTML = xmlHttp.responseText;
			else if(flag=='8')
			document.getElementById('cpassx').innerHTML = xmlHttp.responseText;
	  }
    }
	xmlHttp.open("GET","valid_register.php?user="+document.getElementById('textUser').value+"&pass="+document.getElementById('textPass').value+"&cpass="+document.getElementById('textCPass').value+"&nama="+document.getElementById('textNama').value+"&handphone="+document.getElementById('textHandphone').value+"&email="+document.getElementById('textEmail').value+"&norek="+document.getElementById('textNorek').value+"&namarek="+document.getElementById('textNamarek').value+"&flag="+flag,true);
  xmlHttp.send(null);
 }
 
function file(idx)
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
	xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {  
      	document.getElementById('show').innerHTML=xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET","file_list.php?idx="+idx,true);
  xmlHttp.send(null);
 }
 
function back()
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
	xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {  
      	//document.getElementById('show').innerHTML=xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET","back.php",true);
  xmlHttp.send(null);
 }
 
function next()
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
	xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {  
      	//document.getElementById('show').innerHTML=xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET","next.php",true);
  xmlHttp.send(null);
 }
 
function message()
{
    var r=confirm("Are you sure?");
	
	if (r==true)
	{
	 	form1.submit();
	}
}

function deletex()
{
    var r=confirm("Are you sure?");
	if (r==true)
	  {
	  	form1.submit();
	  }
}

function lef()
{
	frm.submit();
}

function cen()
{
	frm1.submit();
}

function dropTable(tableName)
{
    var r=confirm("Are you sure?");
	if (r==true)
	  {
	  	window.location = "doDropTable.php?name"+tableName;
	  }
}

function goToIndex()
{
	window.location = "index.php";
}

function goToFileManager()
{
	window.location = "fileManager.php";
}

function selectFileAll()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	
	xmlHttp.onreadystatechange=function()
    {
    	if(xmlHttp.readyState==4)
      	{  
      		alert(xmlHttp.responseText);
      	}
 	}
  	xmlHttp.open("GET","countFile.php",true);
  	xmlHttp.send(null);
}

function deleteFileMany()
{
	var r = confirm("Are you sure ?");
	
	if (r == true)
	{
	 	form1.submit();
	}
}