﻿// Ajax Engine
if ( typeof XMLHttpRequest != "undefined" )
	{
	var Ajax	=	new XMLHttpRequest();	
	}
else if ( window.ActiveXObject )
	{
		var aVersions = ["MSXML2.XMLHTTP.5.0","MSXML.XMLHTTP.4.0","MSXML.XMLHTTP.3.0","MSXML.XMLHTTP","Microsoft.XMLHTTP"];
		for ( var i = 0 ; i < aVersions.length; i++ )
			{
			try {
				var Ajax = new ActiveXObject(aVersions[i])	;
				} catch (oError) { }
			}
	}
if ( !Ajax )
	{
	alert("The Ajax Cannot install. Please Set The Ajax Settings. Powered By Mehrdad Design");
	} 

var $_L = function image_s(div)
{
document.getElementById(div).innerHTML = "Loading ... Please Wait";
document.body.style.cursor="wait";
}

function randnumber(){
randstr = parseInt(Math.random()*(9999999999999))
return randstr
}

function get(div,url){
$_L(div);
Ajax.open("GET",url+"&rand="+randnumber(),true);
Ajax.onreadystatechange = function()
	{
	if ( Ajax.readyState == 4 )
		{
			if ( Ajax.status == 200 )
				{
					document.getElementById(div).innerHTML = Ajax.responseText ;
					document.body.style.cursor="default";
				}
			else
				{
				document.getElementById("posttitle").innerHTML = "Error" ;
				document.getElementById(div).innerHTML = "The page could not find !" ;
				document.body.style.cursor="default";
				}
		}
	}
	Ajax.send(null);
}


/* AutoMatic - Don't Change */
function getformcontent(oForm,randnumber)
{
var aParams = new Array();
for (var i = 0 ; i < oForm.elements.length; i++ )
	{
		var sParam = encodeURIComponent(oForm.elements[i].name);
		sParam += "=" ;
		sParam += encodeURIComponent(oForm.elements[i].value);
		aParams.push(sParam);
	}
	return aParams.join("&");
}
/* AutoMatic - Don't Change */

function post(oForm,div)
{
var sBody = getformcontent(oForm,randnumber());
$_L(div);
Ajax.open("POST",oForm.action+"?randnumber="+randnumber(),true);
Ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
Ajax.onreadystatechange = function()
	{
		if ( Ajax.readyState == 4 )
			{
			 if ( Ajax.status == 200 )
			 	{
				document.getElementById(div).innerHTML = Ajax.responseText ;
				document.body.style.cursor="default";
				}
			else
				{
				document.getElementById("posttitle").innerHTML = "Error";
				document.getElementById(div).innerHTML = "<font color='#FF0000'>The Page Could Not Find</font>" ;
				}
			}
	}
	Ajax.send(sBody);
}

function openpage(div,url,title){
$_L(div);
Ajax.open("GET",url+"?rand="+randnumber(),true);
Ajax.onreadystatechange = function()
	{
	if ( Ajax.readyState == 4 )
		{
			if ( Ajax.status == 200 )
				{
					document.getElementById("posttitle").innerHTML = title ;
					document.getElementById(div).innerHTML = Ajax.responseText ;
					document.body.style.cursor="default";
				}
			else
				{
					document.getElementById("posttitle").innerHTML = "Error" ;
					document.getElementById(div).innerHTML ="The Page Could Not Find" ;
					document.body.style.cursor="default";
				}
		}
	}
	Ajax.send(null);
}