var image1 = new Image();
image1.src = "./images/loading.gif";

function loadElement(url, targeted, type, pos) {
	document.getElementById(targeted).innerHTML = "<center><img src=\"./images/loading.gif\" /><br />Loading...</center>";
	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) {
				document.getElementById(targeted).innerHTML = "<center>Sorry, Page Failed to Load, please contact <a href=\"mailto:jaitaiwan@gmail.com\">Daniel Holmes</a></center>";
				return false;
			}
		}
	}
	xmlHttp.open(type ,url,true);
if(type == "POST"){
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", pos.length);
xmlHttp.setRequestHeader("Connection", "close");
}
xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState==4) {
			document.getElementById(targeted).innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.send(pos);
}
function login(ele1, ele2) {
	var url = "./scripts/php/ajax.php?action=login&usrn="+ele1+"&pasw="+ele2;
	var targeted = "content";
	loadElement(url, targeted);
}


/* Ajax Beta1
*/
/*************************
 * Copyright
 * Daniel Holmes
 * This copyright must stay intact for use
 * Use under GPL Licence
 *************************/

function dynamic() {
	this.version = 1;
	this.method = "GET";
	this.parseFile = "";
	this.params = null;
	
	this.submitForm = function(ele) {
        document.getElementById(ele).innerHTML = "<center><img src=\"./images/loading.gif\" /><br />Loading...</center>";
	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(ele).innerHTML=xmlHttp.responseText;
        }
	}
    xmlHttp.open(ajax.method,ajax.parseFile,true);
	if(this.method == "POST"){
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", this.params.length);
		xmlHttp.setRequestHeader("Connection", "close");
	}
    xmlHttp.send(ajax.params);
}
}
var ajax = new dynamic();