// 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 = "لطفا صبر کنید ...";
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 = "خطا" ;
				document.getElementById(div).innerHTML = "صفحه مورد نظر یافت نشد." ;
				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 = "خطا" ;
				document.getElementById(div).innerHTML = "<font color='#FF0000'>صفحه درخواست شده یافت نشد</font>" ;
				}
			}
	}
	Ajax.send(sBody);
}

function openpage(div,url,prev){
$_L(div);
Ajax.open("GET",url+"?rand="+randnumber(),true);
Ajax.onreadystatechange = function()
	{
	if ( Ajax.readyState == 4 )
		{
			if ( Ajax.status == 200 )
				{
					page = "show";
					showme("show");
					document.getElementById(div).innerHTML = Ajax.responseText ;
					$("#"+div).fadeIn("fast");
					document.body.style.cursor="default";
					
				}
			else
				{
					document.getElementById(div).innerHTML = "صفحه مورد نظر یافت نشد." ;
					document.body.style.cursor="default";
				}
		}
	}
	Ajax.send(null);
}

function chg_scrollid(id,should)
{
alert("CHG_SCROLLID");
	if ( should == 0 ) 
		{
		document.getElementById("scrollid").value = ((document.getElementById("scrollid").value*(-1))-1)*(-1)
		}
	else
		{
		document.getElementById("scrollid").value = document.getElementById("scrollid").value-1
		}	
}

function comedown(id)
{
	height = document.getElementById("page_"+id).scrollHeight ;
	if ( height >= 270 && (document.getElementById("scrollid").value*(-1)+0.3)*270 < height)
	{
		$("#page_"+id).animate({ 
			marginTop: "-=230px",
		}, 1000 );
		chg_scrollid(id,1);
	}
	
}

function comeup(id)
{
	height = document.getElementById("page_"+id).scrollHeight ;
	if ( height >= 270 && document.getElementById("scrollid").value < 0 )
	{
		$("#page_"+id).animate({ 
			marginTop: "+=230px",
		}, 1000 );
		chg_scrollid(id,0);
	}
}

function showme(id)
{
for ( i = 0 ; i <= 7 ; i++ )
	{
	$("#page_"+i).hide();
	}
	$("#page_show").hide();
	document.getElementById("page_"+id).style.marginTop="0px" ;
	$("#page_"+id).fadeIn("slow");
	document.getElementById("scrollid").value = 0 ;
	
}