var loginis = 0;
function appear() {
	if (loginis == 0) {
		document.getElementById('login').style.display = "inline";
		loginis++;
	} else if (loginis == 1) {
		document.getElementById('login').style.display = "none";
		loginis--;
	}
}

var XMLHttpRequestObject = false;

if (window.XMLHttpRequest) {
	XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
	XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
var gotot;
function login(arti, gotot) {

	var urly = "login.php";
	document.getElementById('status').innerHTML = "<i>Please wait...</i>";
	var scheme = document.loginform.username.value;
	var scheme2 = document.loginform.password.value;

	if (arti != "") {
		var urly = "../login.php";
	}


	if (XMLHttpRequestObject) {
		XMLHttpRequestObject.open("POST", urly);
		XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

		XMLHttpRequestObject.onreadystatechange = function()
		{
			if (XMLHttpRequestObject.readyState == 4 &&
				XMLHttpRequestObject.status == 200) {

				var texty = XMLHttpRequestObject.responseText;
				if (texty == "false") {
					document.getElementById('status').innerHTML = "<b>Login failed.</b>";
				} else if (gotot) {
					window.location = gotot;
				} else if (arti != "") {
					window.location = "article.php?article=" + arti;
				} else if (texty == "true") {
					window.location = "member.php";
				}
			}
		}
		XMLHttpRequestObject.send("using=div&login_x=80&username=" + scheme + "&password=" + scheme2);
	}


}
var searchh = 0;
var searchcolor;
function runit(typer) {
  if (typer == 1) {
         if (searchh == 0) {
                  searchcolor = document.search1.search.style.color;
                  document.search1.search.value='';
                  document.search1.search.style.fontStyle = 'normal';
                  document.search1.search.style.color = '#000000';
                  document.search1.search.style.fontFamily = '"MS Sans Serif", Geneva, sans-serif';
                  searchh = 1;
         }
   } else if (typer == 2) {

         if (document.search1.search.value == '') {
                  searchh = 0;
                  document.search1.search.style.fontFamily = 'Verdana';
                  document.search1.search.style.fontStyle = 'italic';
                  document.search1.search.style.color = searchcolor;
                  document.search1.search.value = 'Search the resources';


         }

   }

}
function formempty(typer, which) {
  if (which == 'search') {
     thefield = document.paragraphform.search;
  }
  if (typer == 1) {
         if (searchh == 0) {
                  searchcolor = thefield.style.color;
                  thefield.innerHTML='';
                  thefield.style.fontStyle = 'normal';
                  thefield.style.color = '#000000';
                  thefield.style.fontFamily = '"MS Sans Serif", Geneva, sans-serif';
                  searchh = 1;
         }
   } else if (typer == 2) {

         if (thefield.value == '') {
                  searchh = 0;
                  thefield.style.fontFamily = 'Verdana';
                  thefield.style.fontStyle = 'italic';
                  thefield.style.color = searchcolor;
                  thefield.innerHTML = 'e.g. which specific questions you\'d like answering';


         }

   }

}