function AJAXUpdateRequest(updateobjectid,url){AJAXRequest(url,{updatediv:updateobjectid,callbackfunc:AJAXUpdateRequestCallback});}
function AJAXUpdateRequestCallback(funcoptions,responsevalue){var updatediv=document.getElementById(funcoptions.updatediv);updatediv.innerHTML=responsevalue;}
function AJAXRequest(url,funcoptions){var page_request=false;var debug=false;if(funcoptions!=null){if(typeof(funcoptions.debug)!="undefined"){debug=funcoptions.debug;}
if((typeof(funcoptions.indicatordiv)!="undefined")&&(typeof(funcoptions.containerdiv)!="undefined")){AJAXDivUpdateStart(funcoptions.indicatordiv,funcoptions.containerdiv);}}
if(window.XMLHttpRequest){page_request=new XMLHttpRequest();}else if(window.ActiveXObject){try{page_request=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{page_request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}else{return false;}
page_request.onreadystatechange=function(){AJAXRequestFinish(page_request,funcoptions);}
anticache=(url.indexOf("?")!=-1)?"&"+(new Date().getTime()):"?"+(new Date().getTime());if(debug){prompt("AJAXRequest",url);}
page_request.open("GET",url+anticache,true);page_request.send(null);}
function AJAXRequestPost(url,postdata,funcoptions){var page_request=false;var debug=false;if(funcoptions!=null){if(typeof(funcoptions.debug)!="undefined"){debug=funcoptions.debug;}
if((typeof(funcoptions.indicatordiv)!="undefined")&&(typeof(funcoptions.containerdiv)!="undefined")){AJAXDivUpdateStart(funcoptions.indicatordiv,funcoptions.containerdiv);}}
if(window.XMLHttpRequest){page_request=new XMLHttpRequest();}else if(window.ActiveXObject){try{page_request=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{page_request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}else{return false;}
page_request.onreadystatechange=function(){AJAXRequestFinish(page_request,funcoptions);}
anticache=(url.indexOf("?")!=-1)?"&"+(new Date().getTime()):"?"+(new Date().getTime());if(debug){prompt("AJAXRequest",url);}
try{page_request.open("POST",url+anticache,true);page_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");page_request.setRequestHeader("Content-length",postdata.length);page_request.setRequestHeader("Connection","close");page_request.send(postdata);}catch(e){alert("err:"+e);}}
function AJAXRequestFinish(page_request,funcoptions){if(page_request.readyState==4&&(page_request.status==200||window.location.href.indexOf("http")==-1)){if(funcoptions!=null){if(typeof(funcoptions.updatediv)!="undefined"){var updatediv=document.getElementById(funcoptions.updatediv);AJAXProcessResponse(updatediv,page_request.responseText);}
if(typeof(funcoptions.callbackfunc)!="undefined"){funcoptions.callbackfunc(funcoptions,page_request.responseText);}
if((typeof(funcoptions.indicatordiv)!="undefined")){var stopindicator=true;if((typeof(funcoptions.stopindicator)!="undefined")){stopindicator=funcoptions.stopindicator;}
if(stopindicator){AJAXDivUpdateEnd(funcoptions.indicatordiv);}}}}}
function AJAXDivUpdateStart(indicatorid,containerid,funcoptions){var opacity=0.5;if(funcoptions!=null){if(typeof(funcoptions.opacity)!="undefined"){opacity=funcoptions.opacity;}}
var progressDiv=document.getElementById(indicatorid);var divView=document.getElementById(containerid);progressDiv.style.width=divView.offsetWidth+"px";progressDiv.style.height=divView.offsetHeight+"px";$("#"+indicatorid).fadeTo("fast",opacity);}
function AJAXDivUpdateEnd(indicatorid){$("#"+indicatorid).hide();}
function AJAXProcessResponse(updatediv,responsetext){var r=responsetext.split('<div class="ajax-seperator"></div>');if(r.length>1){updatediv.innerHTML=r[1];var scriptCode=r[0].replace('</script>',"").replace('<script type="text/javascript">',"").replace('<script language="JavaScript">',"");eval(scriptCode);var scriptElement=document.createElement("script");scriptElement.type="text/javascript";scriptElement.text=scriptCode;$("#"+updatediv.id).append(scriptElement);}else{updatediv.innerHTML=responsetext;}}
