﻿



/* ---------------------------------------------------------------------------- */



function show_id(id)
{
	if(document.getElementById(id))
	{ 
      	document.getElementById(id).style.display ='';
	}
}
function write_in_id(id,note)
{
	if(document.getElementById(id))
	{
		show_id(id);
		document.getElementById(id).innerHTML=note;
	}
}
function hide_id(id)
{
	if(document.getElementById(id))
	{
		document.getElementById(id).style.display ='none';
	}
}
function page_loader(this_page)
{
	main_ajax_do(this_page, 'main_page', '');
}

function write_in_blank_id(id)
{
	if(document.getElementById(id))
	{  
		show_id(id);
		document.getElementById(id).innerHTML=' ';
	}
}
function get_value_for_ajax(this_id)
{
	if(! document.getElementById(this_id) )
	{
		return '';
	}
	else if(document.getElementById(this_id).type == 'checkbox')
	{ 
		return document.getElementById(this_id).checked;
	}
	else
	{ 
		return encodeURIComponent(replace_for_ajax(document.getElementById(this_id).value));
	}
}
function replace_for_ajax(note)
{
	note= note.replace(/&/g,"**am**");
	note= note.replace(/=/g,"**Salim**");
	note= note.replace(/\+/g,"**jam**");
	return note;
}
function loading_effect(k)
{
	ht = document.getElementsByTagName("html");
	if(k==1)
	{
		ht[0].style.cursor = 'wait';
	}
	else
	{
		ht[0].style.cursor = 'auto';
	}
}
function main_ajax_do(url , thisid, post)
{ 
	var xmlhttp=false;
	show_id(thisid); write_in_id(thisid ,'<center><img src="template/default/images/loading.gif" width="32" height="32" alt="Loading... Please Wait..." border="0"><br>&#1604;&#1591;&#1601;&#1575;&#32;&#1670;&#1606;&#1583;&#32;&#1604;&#1581;&#1592;&#1607;&#32;&#1589;&#1576;&#1585;&#32;&#1603;&#1606;&#1610;&#1583;&#32;&#46;&#46;&#46;</center>') ;
	
	loading_effect(1);        /*@cc_on @*/        /*@if (@_jscript_version >= 5)        	try {             

       		   xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');                }                 catch (e) {        

       		       try {xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');} 				catch (E) {              

       		          xmlhttp = false;                 }    		}    	@end @*/ 

if(!xmlhttp)
{
	xmlhttp=new XMLHttpRequest();
}
xmlhttp.open('POST', url, true); 
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
post=post+'&my_time='+escape(new Date().getTime());
xmlhttp.send(post);
xmlhttp.onreadystatechange = function()
{
	if(xmlhttp.readyState == 4  && xmlhttp.status == 200)
	{
		document.getElementById(thisid).innerHTML =xmlhttp.responseText;
        loading_effect(0);
	}
}
}


