//Powered By Hamed Saati , www.HAM3D.net


function block_loader(page,this_block,post,pic_num_hamed,check){
main_ajax_do(page+'.php','main_part',post);		
if(check==0)
{
document.getElementById('HAM3D_net_title').innerHTML = '<img src=\"theme/images/title_'+pic_num_hamed+'.gif\">'
}
}
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 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 get_div_value_for_ajax ( id ){
	return encodeURIComponent(document.getElementById(id).innerHTML);
}
function replace_for_ajax(note){
	note= note.replace(/&/g,"**am**");
	note= note.replace(/=/g,"**mosavi**");
	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><BR><BR><BR><BR><font face="Tahoma" style="font-size: 8pt"><img src="theme/images/loading.gif" border="0" style="margin: 5px; "><span dir=ltr><br>Waiting ...</span></font></center><br>') ;
       
		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);
             }
        }
}

function image_loader(image){
        newdiv = document.createElement("div");
        newdiv.className = "i_am_hide";
        newdiv.id = escape(image);
        newdiv.innerHTML = '<img src="'+image+'">'
        document.body.appendChild(newdiv);
}

//coded by HAMED SAATI <www.HAM3D.net> <hamed.saati@gmail.com>