function refreshElement(levelName, elementFieldName){
	if(levelName=="Region")
		RegionListHeader_onclick();
	else if(levelName=="OriginCurrency")
		loadCurrencyList();
	else if(elementFieldName=="Origin_Mint")
		loadMintList();
	else if(elementFieldName=="Origin_Designer")
		loadDesignerList();
	else if(elementFieldName=="Origin_ShortNames")
		loadShortNameList();
	else if(elementFieldName=="Origin_Successors")
		loadOriginSuccessorList();
	else if(elementFieldName=="Origin_Predecessors")
		loadOriginPredecessorList();
	else if(elementFieldName=="Origin_CoinCS")	
		loadCoinCSList();
}

function loadCurrencyList(){
	writeLoadingInfo("tdOriginCurrencyList");
   	sendHttpRequest("./originCurrencyList.do?originId=" + getElementById("elementId").value, showCurrencyList,false);
  	}
  	function showCurrencyList(httpRequest){
  		if(isHttpRequestReady(httpRequest)){
		setControlContent("tdOriginCurrencyList", httpRequest.responseText);
	}
  	}
function loadShortNameList(){
	writeLoadingInfo("tdOriginShortNameList");
   	sendHttpRequest("./orginShortNameList.do?originId=" + getElementById("elementId").value, showShortNameList,false);
  	}
  	function showShortNameList(httpRequest){
  		if(isHttpRequestReady(httpRequest)){
		setControlContent("tdOriginShortNameList", httpRequest.responseText);
	}
  	}
function loadCoinCSList(){
	writeLoadingInfo("tdOriginCoinCSList");
   	sendHttpRequest("./originCoinCSList.do?originId=" + getElementById("elementId").value, showCoinCSList,false);
  	}
  	function showCoinCSList(httpRequest){
  		if(isHttpRequestReady(httpRequest))
		setControlContent("tdOriginCoinCSList", httpRequest.responseText);
  	}
function loadDesignerList(){
	writeLoadingInfo("tdOriginDesignerList");
   	sendHttpRequest("./originDesignerList.do?originId=" + getElementById("elementId").value, showDesignerList,false);
  	}
  	function showDesignerList(httpRequest){
  		if(isHttpRequestReady(httpRequest))
		setControlContent("tdOriginDesignerList", httpRequest.responseText);
  	}
function loadMintList(){
	writeLoadingInfo("tdOriginMintList");			
   	sendHttpRequest("./originMintList.do?originId=" + getElementById("elementId").value, showMintList,false);
  	}
  	function showMintList(httpRequest){   		
  		if(isHttpRequestReady(httpRequest)){   			
		setControlContent("tdOriginMintList", httpRequest.responseText);			
	}
  	}
function ShowOriginDef(elementField){
	OpenInsetPage(500,200,"./originDef.do?changeAction=Modify&elementId=" + getElementById("elementId").value + "&elementField="+elementField);
}
function ShowRegionDef(){
	OpenInsetPage(500,200,"./regionDef.do?changeAction=Create&originId=" + getElementById("elementId").value);
}
function ShowOriginCurrencyDef(){
	OpenInsetPage(500,250,"./originCurrencyDef.do?changeAction=Create&originId=" + getElementById("elementId").value);
}
function wiki_Edit(){
	formMain.action="wikiDef.do?elementId="+getElementById("elementId").value+"&compendiumLevel="+getElementById("compendiumLevel").value;
	formMain.submit();
}
function wiki_History(){
	formMain.action="wikiHistory.do?elementId="+getElementById("elementId").value+"&compendiumLevel="+getElementById("compendiumLevel").value;
	formMain.submit();
}	
function RegionListHeader_onclick(tsLetter){
	if(tsLetter==null) tsLetter = getElementById("regionLetter").value;
	else getElementById("regionLetter").value = tsLetter;
	writeLoadingInfo("DivRegionListContent");
	moAjaxRequest.CallBackFunc = ShowRegionList;
	moAjaxRequest.SendRequest("RegionList.do?Letter=" + encodeURIComponent(tsLetter)+"&originId=" + getElementById("elementId").value);
	return false;
}

function ShowRegionList(toResult){	 
	getElementById("DivRegionListContent").innerHTML = toResult.responseText;
}	

function clientOnLoad(){
	loadMintList();
	loadDesignerList();
	loadCoinCSList();
	loadShortNameList();
	loadCurrencyList();
	loadOriginPredecessorList();
	loadOriginSuccessorList();
	RegionListHeader_onclick();
	loadCompAuctionList();
}

function loadOriginSuccessorList(){
	writeLoadingInfo("tdOriginSuccessorList");
   	sendHttpRequest("./originSuccessorList.do?predecessorId=" + getElementById("elementId").value, showOriginSuccessorList,false);
  	}
  	function showOriginSuccessorList(httpRequest){
  		if(isHttpRequestReady(httpRequest)){
		setControlContent("tdOriginSuccessorList", httpRequest.responseText);
	}
  	}
function loadOriginPredecessorList(){
	writeLoadingInfo("tdOriginPredecessorList");
   	sendHttpRequest("./originPredecessorList.do?successorId=" + getElementById("elementId").value, showOriginPredecessorList,false);
  	}
  	function showOriginPredecessorList(httpRequest){
  		if(isHttpRequestReady(httpRequest)){
		setControlContent("tdOriginPredecessorList", httpRequest.responseText);
	}
  	}

function historcalContextList_click(){
	document.location.href = "originHistoricalContextList.do?originId=" + document.all("elementId").value;
}
function originDel_onClick(){
	OpenInsetPage(500,200,"./origindel.do?elementId=" + document.all("elementId").value);

}
function ShortNameDelete_onClick(element){
	OpenInsetPage(500,200,"./shortNameDel.do?elementId=" + element);
}
function showPrecessor(curobject,originshortnameId){
	overlayobj = overlay(curobject, null,100);
	sendHttpRequest("OSPreSucessorList.do?Type=Pre&referenceId=" + originshortnameId, function(){ShowOSPreSuccessorList(overlayobj)});
}
function showSucccessor(curobject,originshortnameId){
	overlayobj = overlay(curobject, null,100);
	sendHttpRequest("OSPreSucessorList.do?Type=Suc&referenceId=" + originshortnameId, function(){ShowOSPreSuccessorList(overlayobj)});
}
function ShowOSPreSuccessorList(curobject){
	if(isHttpRequestReady())
			curobject.innerHTML=defaultHttpRequest.responseText;
}
