function rNo(){
randscript = parseInt(Math.random()*(9999999999999))
return randscript
}

//Create a boolean variable to check for a valid Internet Explorer instance.
var xmlhttp = false;
//Check if we are using IE.
try {
//If the Javascript version is greater than 5.
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

} catch (e) {
//If not, then use the older active x object.
try {
//If we are using Internet Explorer.
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

} catch (E) {
//Else we must be using a non-IE browser.
xmlhttp = false;
}

}
//If we are using a non-IE browser, create a javascript instance of the object.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
xmlhttp = new XMLHttpRequest();

}
function fk(serverPage, objID) {

var obj = document.getElementById(objID); 

if (objID=='newsFeeder'){ 
	obj.innerHTML = "<center><br><br><img src='images/loading-thickbox.gif' >"; 
}else if(objID=='panel'){	   
	obj.innerHTML = "<center><br><br><img src='images/wait_hrt.gif' width='37'>"; 
}else{	
    obj.innerHTML = "<center><br><br><img src='images/wait_hrt.gif' width='37'>"; 
    //$("#ajax_wait").fadeIn("slow");
} 
obj.style.display='block';
 var url=serverPage+"&cxxx="+rNo();
xmlhttp.open("GET", url);
//request.setRequestHeader('Cache-Control', 'no-cache');
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

obj.innerHTML='';
obj.innerHTML = xmlhttp.responseText;
//$("#"+objID).append(xmlhttp.responseText);
}
}
xmlhttp.send(null);
}

function any (tp){
	     if (tp==0){
                $("#appn").attr("innerHTML","<div id='ajax_wait' class='wait' valign='middle' ><br><br><center><span style='color:red;'>	لطفا چند لحظه تامل نمائید.	</span>	</div>");								
				$("#appn").attr("position","absolute");				
				$("#appn").fadeIn("slow");
				return
		}else{
			$("#appn").fadeOut("slow");
		}
}
function vermana (page,dest,param,msg){
	
	var status=false;
	var resp;	
	if ($("#"+dest).attr('id')){	
		  
		if (isMicrosoft(0)){
			fk(page+'?'+param,dest);
			return
		}	
		any(0);
		var resp = $.ajax({
			type: "GET",
			url : page,
			data: param,
			async: false,
			success: function(pym){
				//alert(dest);
				status=true;
				if (msg){
					if ( msg.length > 1 ) alert( msg );
				}

			}
		}).responseText;
	}
			
	if (status==true){
		$("#"+dest).attr('innerHTML',resp);

	}else{
		var uparam=param.replace('far=1&lng', "page");
		var URL=page+'?'+uparam;
		//alert(URL);
		window.location=URL;
	}

	any(1);

}