	var ajax=function(){
		var currentUrl,id,login;
		login = 0;
		xmlHttp=GetXmlHttpObject();
		jsonHttp=GetXmlHttpObject();
		xmlHttpRight=GetXmlHttpObject();
		xmlHttpPriv=GetXmlHttpObject();
		xmlHttpLeft=GetXmlHttpObject();
		return{
			ajax:function(obj,u,extra){
				ele = document.getElementById(obj);
				xmlHttp.open("POST",u,true);
				xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				if (extra) {
					extra = "check=1&"+extra;
				} else var extra = "check=1";
				xmlHttp.onreadystatechange=ajax.stateChanged;
				xmlHttp.setRequestHeader("Content-length", extra.length);
				xmlHttp.setRequestHeader("Connection", "close");
				xmlHttp.send(extra);
			},
			stateChanged:function() {
				if (xmlHttp.readyState == 4 && login == 1 && xmlHttp.responseText == 1) {
					window.location.href = "index.php";
					login = 0;
				} else if (xmlHttp.readyState == 4 && login ==1) {
					ele.innerHTML=xmlHttp.responseText;
					login = 0;
				} else if (xmlHttp.readyState==4) { 
					ele.innerHTML=xmlHttp.responseText;
				}
			}
		}
	}();

	function GetXmlHttpObject() {
		var xmlHttp = null;
		try
		{
			//Firefox :)
			xmlHttp = new XMLHttpRequest();
		}
		catch (e)
		{
			//Inter Explorer :(
			try
			{
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
	}
	
	function showComments(pid) {
		ajax.ajax('comments'+pid,'blog.php','comments='+pid);
	}
	function submitComment(pid,form) {
		var name = form.name.value;
		var comment = form.comment.value;
		if (form.captcha) {
		var captcha = form.captcha.value;
		}
		if (name == "Your Name") {
			alert("Please enter a valid name");
		} else if (comment == "Comment") {
			alert("Please enter a comment");
		} else {
			ajax.ajax('comments'+pid,'blog.php','addcomment='+pid+'&comment='+comment+'&name='+name+'&captcha='+captcha);
		}
	}
	function submitTutComment(pid,form) {
		var name = form.name.value;
		var comment = form.comment.value;
		if (form.captcha) {
		var captcha = form.captcha.value;
		}
		if (name == "Your Name") {
			alert("Please enter a valid name");
		} else if (comment == "Comment") {
			alert("Please enter a comment");
		} else {
			ajax.ajax('comments'+pid,'tutorials.php','addcomment='+pid+'&comment='+comment+'&name='+name+'&captcha='+captcha);
		}
	}
	function showTutComments(pid) {
		ajax.ajax('comments'+pid,'tutorials.php','comments='+pid);
	}
	function submitContact(form) {
		var name = form.name.value;
		var text = form.text.value;
		var email = form.email.value;
		
		if (name == "Your Name") {
			alert("Please enter a valid name");
		} else if (text == "Message") {
			alert("Please enter a message");
		} else if (email == "Email") {
			alert("Please enter an email");
		} else {
			ajax.ajax('contact','contact.php','submit=yes&text='+text+'&name='+name+'&email='+email);
		}
	}

