﻿//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
function HAM3D_DOT_NET_page_loader(this_page, post ){
main_ajax_do(this_page, 'id='+post+'' ,'NEWS_BLOCK');		
}
//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
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));
	}
}
//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
function hide_id(id){
    if( document.getElementById(id) ){
	document.getElementById(id).style.display ='none';
	}
}
//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
function show_id(id){
    if( document.getElementById(id) ){
    document.getElementById(id).style.display ='';
	}
}
//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
function write_in_id(id,note){
 if( document.getElementById(id) ){
  show_id(id);
 document.getElementById(id).innerHTML=note;
 }
}
//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
function loading_effect(k){
	ht = document.getElementsByTagName("html");
	if(k==1){
                ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";	
	        ht[0].style.cursor = 'wait';
	}else{
                ht[0].style.filter = "";
	       ht[0].style.cursor = 'auto';
	}
}
//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
function replace_for_ajax(note){
	note= note.replace(/&/g,"**am**");
	note= note.replace(/=/g,"**mosavi**");
	note= note.replace(/\+/g,"**jam**");
	return note;
}
//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
function main_ajax_do( url , post , thisid){
 var xmlhttp=false;
         show_id(thisid)
        write_in_id(thisid ,'<p dir="rtl"><font face="Tahoma" style="font-size: 9pt"><img src="theme/image/Sloading2.gif" border="0"> &#1604;&#1591;&#1601;&#1575; &#1670;&#1606;&#1583; &#1604;&#1581;&#1592;&#1607; &#1589;&#1576;&#1585; &#1705;&#1606;&#1610;&#1583; ...</font></p>') ;
       
		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);
                }
                    
        }
               
}
//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>
