getXMLHttpRequest=function(){
	var xh;
	if(window.XMLHttpRequest)
	{
		xh=new XMLHttpRequest();
	}
	else if(window.ActiveXObject){	
			var p=["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
			for(var i=0;i<p.length;i++){
				try{
					xh=new ActiveXObject(p[i]);
				}catch(e){
					m=e.description;
				};
			}
	}
	if(!xh){
		throw new Error("can't create XMLHttpRequest");
	}
	return xh;
}

var ajaxLinkUpdate=function (anchor,targetID,evt,callBack){
	try{
		ajaxLinkUpdate._xh.abort();
	}catch(ignore){};
	var href = anchor.getAttribute("href");
	if(href=="" || href==null)
		return;
	href = href.replace(/#.*$/,"");
	 /\?(.*)$/.test(href);
	var queryString =RegExp.$1;
	/(\?|&)modulepage=([^&]+)($|&)/.test(href);
	var modulepage = RegExp.$2;
	//alert(act);
	var xh = getXMLHttpRequest();
	ajaxLinkUpdate._xh= xh;
	if(xh==null || modulepage=="" || modulepage==null)
	{
		return false;
	}
	document.getElementById(targetID).innerHTML="<div class='loading'><span>loading...</span></div>";
	xh.open("GET",modulepage+".jsp?"+queryString,true);
	xh.onreadystatechange=function(){
		//alert(xh.readyState);
		if(xh.readyState=="4")
		{
			
			document.getElementById(targetID).innerHTML = xh.responseText;
			
			var scripts = document.getElementById(targetID).getElementsByTagName("script");
			for(var i=0;i<scripts.length;i++)
			{
					ajaxLinkUpdate._eval( scripts[i].innerHTML );
					
			};
			if(callBack)
				callBack(anchor,targetID,evt,xh);
			anchor=null;
			targetID=null;
			xh=null
			callBack=null;
			ajaxLinkUpdate._xh = null;
		}
	}
	xh.send(null);
	if(evt){
		evt.returnValue = false;
		if(evt.preventDefault)
		{
			evt.preventDefault();
			evt.stopPropagation();
		}
	}
	return false;
}
ajaxLinkUpdate._eval=function(s){return eval(s);}

var hashMonitor={
	scriptPath:"../../script/",
	forward:function(hash){
		var ifrm = document.getElementById("__ifrm_hashMonitor")
		if(ifrm==null)
		{
			ifrm = document.createElement("iframe");
			//ifrm.style.width="1px";
			//ifrm.style.height="1px";
			//ifrm.style.display="none";
			document.body.appendChild(ifrm); 
			ifrm.setAttribute("id","__ifrm_hashMonitor");
		}
		ifrm.setAttribute("src",this.scriptPath+"hashMonitor.html#"+hash);
	},
	callBack:function(hash){
	}
}




