function ajaxSend(ajaxUrl, ajaxDiv, ajaxEval)
{ 
    function ajaxObject()
    {
	    if (document.all && !window.opera)
	    { 
		    obj = new ActiveXObject("Microsoft.XMLHTTP");
	    }else{ 
		    obj = new XMLHttpRequest();
	    }
	    return obj;
    }
    var ajaxHttp = ajaxObject(); 
    ajaxHttp.open("GET", ajaxUrl, true); 
    ajaxHttp.onreadystatechange = function()
    { 
	    if(ajaxHttp.readyState == 4)
	    { 
		    var ajaxResponse = ajaxHttp.responseText; 
			document.getElementById(ajaxDiv).innerHTML = ajaxResponse;
            if(ajaxEval)
                evalScripts(ajaxResponse);
            document.getElementById("loading").style.visibility ="hidden"; 
            document.getElementById("loading").style.display ="none";                                 
        }else{
            document.getElementById(ajaxDiv).innerHTML ="<center><img src=images/load.gif vspace=4 align=center></center>";          
            document.getElementById("loading").style.display ="block";          
            document.getElementById("loading").style.visibility ="visible";          
            document.getElementById("loading").innerHTML = "<center><br><img src=images/wait.gif vspace=4><br><font class=text1> در حال بارگزاری... </font><br><br></center>";       
        }
    }
	ajaxHttp.send(null);
}

function evalScripts(ajaxResponse){
    var script, scripts;
    scripts = [];
    var regexp = /<script[^>]*>([\s\S]*?)<\/script>/gi;
    while ((script = regexp.exec(ajaxResponse))) 
        scripts.push(script[1]);
    scripts = scripts.join('\n');

    if (scripts) (window.execScript) ? window.execScript(scripts) : window.setTimeout(scripts, 0);
} 
