<!--
/**
* Create the XMLHttp object 
*/
function createXMLHttpRequest(){
	var xmlHttp;
	if(isIE()){
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else{
		xmlHttp=new XMLHttpRequest();
	}
	return xmlHttp;
}
/**
* Check browser type 
*/
function isIE(){
	if(document.attachEvent) return true;
	else return false;
}

/**
*  The call back function.
*  Just called when server has responsion.
*  The status of request is completed and HTTP status code of server is OK ,
*/
function gethandleState(xmlHttp){
	// readyState:The status of request.(4:completed)
	// status:HTTP status code of server:(200: OK 404: Not Found)
	if(xmlHttp.readyState==4&&xmlHttp.status==200) return true;
	else return false;
}
/**
* Get the Dom object from the XMLHttp object
*/
function getReturnXmlObj(xmlHttp){
	var results ;
	if(isIE()){
		results = xmlHttp.responseXML;
	}else{
		var domPar = new DOMParser();
		var resultDOM = domPar.parseFromString(xmlHttp.responseText,"text/xml");
		results = resultDOM.documentElement;	
	}
	return results;
}
/**
* Get the post's parameter
*/
function getParameter(objId){
	var parameter = "";
	var elementObj = document.getElementById(objId);
	var elementvalue= elementObj.value;
	if( elementvalue == ""){
		parameter= false;
	}else{
		parameter = "value=" + elementvalue;
	}
	return parameter;
}
/**
* Ajax examples
*/
function ajaxDoSometing(actionUrl,parameter){
	//Create XMLHttpRequest
	var xmlHttp = createXMLHttpRequest();	
	try{
		//create the callback function which be called when server is reactive.
		//function is the name of callback function.
		xmlHttp.onreadystatechange=function(){
			if(gethandleState(xmlHttp)){							
				doSometing(getReturnXmlObj(xmlHttp));
			}
		}
		//create the Call to the server.
		//open(String method,String url,boolean IsAsynchronousCall);
		//method :             GET , POST.
		//url:                 The request string to the server.
		//IsAsynchronousCall:  Is or not AsynchronousCall.(true default)
		xmlHttp.open("POST",actionUrl,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		//send request to server
		//when the parameter method in xmlHttp.open() is POST,the parameter here should be
		//specialfy as the POST string.
		xmlHttp.send(parameter);
	}catch (e){
		alert(e.toString());
	}
}
/**
* Use Ajax get the list option 
*/
function getListOption(actionUrl,updateObjId){
	var xmlHttp = createXMLHttpRequest();	
	try{
		xmlHttp.onreadystatechange=function(){
			if(gethandleState(xmlHttp)){
				doUpdateList(updateObjId,getReturnOption(xmlHttp));
				}
		}
		xmlHttp.open("POST",actionUrl,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.send(null);
	}catch (e){
		alert(e.toString());
	}
}
/**
* Use Ajax get the list option 
*/
function getListOptionSetChoose(actionUrl,updateObjId,defaultChoose){
	var xmlHttp = createXMLHttpRequest();	
	try{
		xmlHttp.onreadystatechange=function(){
			if(gethandleState(xmlHttp)){		    
				doUpdateSetList(updateObjId,getReturnOption(xmlHttp),defaultChoose);
				}
		}
		xmlHttp.open("POST",actionUrl,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.send(null);
	}catch (e){
		alert(e.toString());
	}
}
/**
* Use Ajax update the linkage list option
*/
function updateLinkageList(actionUrl,objId,updateObjId){	
	var xmlHttp = createXMLHttpRequest();
	var parameter = getParameter(objId);
	if(parameter==false){
		clearList(document.getElementById(updateObjId));
		return;	
	}
	try{
		xmlHttp.onreadystatechange=function(){						
			if(gethandleState(xmlHttp)){						
				doUpdateList(updateObjId,getReturnOption(xmlHttp));					
			}
		}		
		xmlHttp.open("POST",actionUrl,true);	
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");	
		xmlHttp.send(parameter);
	}catch (e){
		alert(e.toString());
	}
}
/**
*
*/
function getLinkageListOption(actionUrl,LinkageId,parentListValue,chooseOptionValue){	
	var xmlHttp = createXMLHttpRequest();
	var parameter = "value=" + parentListValue;
	if(parentListValue==null||parentListValue==''){
		clearList(document.getElementById(LinkageId));
		return;	
	}
	try{
		xmlHttp.onreadystatechange=function(){						
			if(gethandleState(xmlHttp)){
								
				doUpdateSetList(LinkageId,getReturnOption(xmlHttp),chooseOptionValue);					
			}
		}		
		xmlHttp.open("POST",actionUrl,true);	
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");	
		xmlHttp.send(parameter);
	}catch (e){
		alert(e.toString());
	}
}


/**
* Get the list option  from xmlhttp obj which return from server
*/
function getReturnOption(xmlHttp){
	var results;
	var options;
	results = getReturnXmlObj(xmlHttp);
	options = results.getElementsByTagName("option");
	return options;
}

/**
* Clear the list option
*/
function clearList(listObj){
	if(listObj!=undefined&&listObj.childNodes!=undefined&&listObj.childNodes.length!=undefined){	
		while(listObj.childNodes.length>1){
			listObj.removeChild(listObj.childNodes[1]);
		}
	}
}
/**
* Update the listOption
*/
function doUpdateList(updateObjId,results){
	var updatelist = document.getElementById(updateObjId);
	if(updatelist!=undefined){
		clearList(updatelist);
		var listOption = null;
		var oneResult ;
		var optionValue;
		var optionShow;
		//Traversing the collection of results.
		for(var i=0;i<results.length;i++){
			oneResult= results[i];
			listOption = document.createElement("option");
			optionValue = oneResult.getElementsByTagName("value")[0].firstChild.nodeValue;
			optionShow = oneResult.getElementsByTagName("show")[0].firstChild.nodeValue;
			listOption.setAttribute("value",optionValue);
			listOption.appendChild(document.createTextNode(optionShow));
			updatelist.appendChild(listOption);
		}
	}
}
function doUpdateSetList(updateObjId,results,chooseOptionValue){	
	doUpdateList(updateObjId,results);
	//alert("step002")
	setOptionChoose(updateObjId,chooseOptionValue);
}

/**
*
*/
function setOptionChoose(objId,chooseOption){
	var listElement = document.getElementById(objId);
	if(listElement!=undefined){    
		for(var i=0;i<listElement.options.length;i++){
			
			if (listElement.options[i].value== chooseOption){
				if(isIE()){
					listElement.options[i].setAttribute("selected",true);	
				}else{
					listElement.options[i].selected=true;
				}				
				break;
			}else{
				if(isIE()){
					listElement.options[i].setAttribute("selected",false);	
				}else{
					listElement.options[i].selected=false;
				}
			}
		}
	}
}
/**
* Use Ajax get the list option 
*/
function printLink(actionUrl,divID,actionTo,parameter){
	var xmlHttp = createXMLHttpRequest();	
	try{	
		xmlHttp.onreadystatechange=function(){		
			if(gethandleState(xmlHttp)){
				doPrintLink(divID,actionTo,getReturnOption(xmlHttp));
			}
		}
		xmlHttp.open("POST",actionUrl,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.send(parameter);
	}catch (e){
		alert(e.toString());
	}
}
/**
*
*/
function doPrintLink(divID,actionTo,results){	
	var oneResult ;
	var optionValue;
	var optionShow;
	var strhtml = "";
	//Traversing the collection of results.
	for(var i=0;i<results.length;i++){
		oneResult= results[i];	
		optionValue = oneResult.getElementsByTagName("value")[0].firstChild.nodeValue;
		optionShow = oneResult.getElementsByTagName("show")[0].firstChild.nodeValue;
		strhtml += '<li>'+optionShow.link(actionTo+"?maker="+optionValue)+"</li>&nbsp;";
	}
	var divobj = document.getElementById(divID);
	divobj.innerHTML= strhtml;
}

/**
* Use Ajax get the list option 
*/
function printMakerLink(actionUrl,divID,actionTo,parameter){
	
	var xmlHttp = createXMLHttpRequest();	
	try{	
		xmlHttp.onreadystatechange=function(){		
			if(gethandleState(xmlHttp)){
				doMakerPrintLink(divID,actionTo,getReturnOption(xmlHttp));
			}
		}
		xmlHttp.open("POST",actionUrl,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.send(parameter);
	}catch (e){
		alert(e.toString());
	}
}
/**
*
*/
function doMakerPrintLink(divID,actionTo,results){
	var oneResult ;
	var optionValue;
	var optionShow;
	var strhtml = "";	
	//Traversing the collection of results.
	for(var i=0;i<results.length;i++){
		oneResult= results[i];	
		optionValue = oneResult.getElementsByTagName("value")[0].firstChild.nodeValue;
		optionShow = oneResult.getElementsByTagName("show")[0].firstChild.nodeValue;
		strhtml += optionShow.link("javascript:toSearchList('"+optionValue+"');")+"&nbsp;";
		strhtml += "@|@";		
	}
	var divobj = document.getElementById(divID);
	divobj.innerHTML= strhtml;
}
-->