
   //query airport db
function findairport()
{

var xmlHttp;
var icao;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
	 			  	
      icaovalidated=1;
      document.getElementById("airportinfo").innerHTML=xmlHttp.responseText;//write response messaga
		

      }
    }
	icao=document.getElementById("icao").value;
var url="include/ajax.php?action=findairport&icao="+icao;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
  }
  //end findairport
  
  //check aircraft dropdown
  function CheckAircraftDropdown(elm)
{
	if(elm.options[elm.selectedIndex].value==10)
	{
		document.getElementById("newaircraft").innerHTML="<input name='newaircraft' type='text' id='newaircraft' size='30' maxlength='150' value='enter aircraft. e.g. Airbus A380' onclick=this.value=''; />";
	}
	else
	 {
		 document.getElementById("newaircraft").innerHTML="";
	 }
}
 //check aircraft dropdown
 
  //check airlines dropdown
  function CheckAirlinesDropdown(elm)
{
	if(elm.options[elm.selectedIndex].value==10)
	{
		document.getElementById("newairline").innerHTML="<input name='newairline' type='text' id='newairline' size='30' maxlength='150' value='Enter airline. e.g. Alaska Air' onclick=this.value=''; />";
	}
	else
	 {
		 document.getElementById("newairline").innerHTML="";
	 }
}
 //check aircraft dropdown
 
 //show form for password change
  function change_pasword_form()
{
if (check=="1"){document.getElementById("pass_field").innerHTML="";check=0;}
else
{
var FormBody = "<span class='bodytext'><form name='chpass' method='get'>Old Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='password' id='oldpass' name='oldpass'><br />New Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='password' id='newpass' name='newpass'><br />Repeat Password:&nbsp;<input type='password'  id='newpassr' name='newpassr'><br /><input value='Change' type='button' onclick='change_pasword();' class='button'><div id='message'></div></form></span><br/>";

document.getElementById("pass_field").innerHTML=FormBody;
check="1";

}
}

  function change_pasword()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById("pass_field").innerHTML=xmlHttp.responseText;//write response messaga

      }
    }


//input check

if(document.getElementById("newpass").value != document.getElementById("newpassr").value)
{
document.getElementById("message").innerHTML="Passwords don't match!";
}
else if(document.getElementById("newpass").value==0 || document.getElementById("newpassr").value==0 || document.getElementById("oldpass").value==0)
{
document.getElementById("message").innerHTML="Please fill the fields!";
}
else
{

var url="include/lbedit.php";
url=url+"?oldpass="+document.getElementById("oldpass").value;
url=url+"&newpass="+document.getElementById("newpass").value;
url=url+"&newpassr="+document.getElementById("newpassr").value;

  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}
  }
  
  //delete account part
//show form
//show form for password change
  function delete_my_account_form()
{
if (check=="1"){document.getElementById("del_field").innerHTML="";check=0;}
else
{
var FormBody = "<span class='bodytext'><form name='delacc' method='get'>This will erase all data you have on mySIMSHOTS.NET, including images, collections and profile. Are you sure you want to do that, there is no way to restore your account once it is deleted? Type I agree in the box below to delete it.<br/><input type='text' id='agreedel' name='agreedel' width='10'><br/><input value='Yes - Delete my account.' type='button' onclick='delete_my_account();' class='button'><div id='message'></div></form></span>";

document.getElementById("del_field").innerHTML=FormBody;
check="1";

}
}


//delete my account
     function delete_my_account()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById("message").innerHTML=xmlHttp.responseText;//write response messaga

      }
    }
		
if (checklb=="1"){document.getElementById("lb_field").innerHTML="";checklb=0;}
else
{
if(document.getElementById("agreedel").value=="I agree")
 {
checklb="1";
var url="include/lbedit.php?deletemyaccount=1";

  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
 }
 else
  {
	  alert('You need to type I agree to delete the account!');
  }
}
}

//MMjump used for going to dropdown value
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



  function delete_user(user)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById(user).innerHTML=xmlHttp.responseText;
      }
    }
var url="include/lbedit.php";
url=url+"?deluser="+user;
answer=confirm("Are you sure you want to delete user: "+user) ;
if(answer)
{
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}
  }
 
  
  //make photographer
  function makephotographer(user,status)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById("mkphoto-"+user).innerHTML=xmlHttp.responseText;
      }
    }

var url="include/lbedit.php";
url=url+"?mkphoto="+user+"&status="+status;
answer=confirm("Are you sure you want to change user: "+user) ;
if(answer)
{
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}
  }

//delete comment

function delete_comment(id,author)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById(id).innerHTML=xmlHttp.responseText;
      }
    }
var url="/include/lbedit.php";
url=url+"?id="+id;
url=url+"&author="+author;
answer=confirm("Are you sure you want to delete comment: "+id) ;


if(answer)
{
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}
  }
  



//ban ip from commenting
  function ban(ip)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById("ban"+ip).innerHTML=xmlHttp.responseText;
      }
    }
var url="/include/lbedit.php";
url=url+"?ip="+ip;

alert(url);

answer=confirm("Are you sure you want to ban: "+ip) ;
if(answer)
{
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}
  }
  
  function delete_lb(lbid)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById(lbid).innerHTML=xmlHttp.responseText;
      }
    }
var url="/include/lbedit.php";
url=url+"?adellbid="+lbid;

answer=confirm("Are you sure you want to delete lb: "+lbid) ;
if(answer)
{
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}
  }
  
  
  function delmyimage(user, photoid,filename)
{
if(confirm("Delete picture: "+photoid))
  {
  window.location ="photosearch.php?photographer="+user+"&delete="+photoid+"&filename="+filename;
  }
}


//refresh showimage pictures
  function refreshsimilar()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById("resultsarea").innerHTML=xmlHttp.responseText;
      }
    }

var url="include/lbedit.php?refreshimages=1";
var test=0;

if(document.getElementById("ckphotographer").checked)
{
	url=url+"&ckphotographer="+document.getElementById("checkphotographer").value;
	test=1;
}
if(document.getElementById("cksimulator").checked)
{
	url=url+"&cksimulator="+document.getElementById("checksimulator").value;
	test=1;
}
if(document.getElementById("ckaircraft").checked)
{
	url=url+"&ckaircraft="+document.getElementById("checkaircraft").value;
	test=1;
}
if(document.getElementById("ckairline").checked)
{
	url=url+"&ckairline="+document.getElementById("checkairline").value;
	test=1;
}
if(document.getElementById("ckairport").checked)
{
	url=url+"&ckairport="+document.getElementById("checkairport").value;
	test=1;
}


 if(test)
 {
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
 }

  }

