function doForward(showDiv,requestUrl,select) {
		dojo.io.bind({
			url:requestUrl,
			load: function(type,data,evt){
				if(select != null) {
					select.disabled = false;
				}
				//alert(data);
				showDiv.innerHTML = data;
			},
			timeoutSeconds: 5000,
			error: function(type, error) { alert(error.message); },
    		timeout: function(type) { alert("timeout"); },
		    preventCache: true,
			mimetype:"text/plain"
		});
}
function doForwardByForm(showDiv,requestUrl){
     var href = requestUrl;
		dojo.io.bind({
			url:href,
			error: function(type, error){alert(error.message); },
			load: function(type,data,evt){	
			   // alert(data);	      
				showDiv.innerHTML = data;
			},
			encoding: 'utf-8',
			method:"post",
			formNode: dojo.byId("byForm"),
		    preventCache: false,
			mimetype:"text/plain"
		});
}
function doForwardByAjax(form,showDivId,requestUrl){
	 var showDiv = dojo.byId(showDivId);
     var href = requestUrl;
		dojo.io.bind({
			url:href,
			error: function(type, error){alert(error.message); },
			load: function(type,data,evt){	
			   // alert(data);	      
				showDiv.innerHTML = data;
			},
			encoding: 'utf-8',
			method:"post",
			formNode: form,
		    preventCache: false,
			mimetype:"text/plain"
		});
}
function doForwardOfOrder(showDiv,requestUrl){
     var href = requestUrl;
		dojo.io.bind({
			url:href,
			error: function(type, error){alert(error.message); },
			load: function(type,data,evt){	
			   // alert(data);	      
				showDiv.innerHTML = data;
			},
			encoding: 'utf-8',
			method:"post",
			formNode: dojo.byId("orderForm"),
		    preventCache: false,
			mimetype:"text/plain"
		});
}
function doValidateEngine(succeedShowDivId,defeatedShowDivId,errorMsg,requestUrl,loginFlag){  
        var succeedShowDiv = dojo.byId(succeedShowDivId);
        var defeatedShowDiv = document.getElementById(defeatedShowDivId);
		var href = requestUrl;
		dojo.io.bind({
			url:href,
			error: function(type, error){alert(error.message); },
			load: function(type,data,evt){	
			   // alert(data);	      
				if(data=="error"){
				   defeatedShowDiv.innerHTML = errorMsg;
				}else{
				   if(data=="toLogin"){
				       dojo.addOnLoad(toLogin);
				   }else{
				       succeedShowDiv.innerHTML = data;
				   }
				}	
			},
			encoding: 'utf-8',
			method:"post",
			formNode: dojo.byId("validateForm"),
		    preventCache: false,
			mimetype:"text/plain"
		});
	
}
function doFormEngine(succeedShowDivId,defeatedShowDivId,errorMsg,requestUrl,loginFlag){  
        var succeedShowDiv = dojo.byId(succeedShowDivId);
        var defeatedShowDiv = document.getElementById(defeatedShowDivId);
		var href = requestUrl;
		dojo.io.bind({
			url:href,
			encoding: 'utf-8',
			error: function(type, error){alert(error.message); },
			load: function(type,data,evt){	
			   // alert(data);	      
				if(data=="error"){
				   defeatedShowDiv.innerHTML = errorMsg;
				}else{
				   succeedShowDiv.innerHTML = data;
				}	
			},
			method:"post",
			formNode: dojo.byId("validateForm"),
		    preventCache: false,
			mimetype:"text/plain"
		});
	
}

function toLogin(){
window.location.href="https://www.zmzart.com:8443/login.htm";    
}

function doEngine(requestType,showDivId,requestUrl,selectId){
      var showDiv =  dojo.byId(showDivId);
      var select  =  dojo.byId(selectId);
      if(requestType=="byForm"){
         doForwardByForm(showDiv,requestUrl);
      }else{
        if(select != null)	 doForward(showDiv,requestUrl,select);
		else  doForward(showDiv,requestUrl,null);
            
      }

}
function doEngineControl(requestType,showDiv,requestUrl,select){
    if(requestType=="byForm"){
         doForwardByForm();
      }else{
        if(select != null)	 doForward(showDiv,requestUrl,select);
		else  doForward(showDiv,requestUrl);
            
     }

}
function showInnterText(showId,showText){
    document.getElementById(showId).innerHTML = showText;
}
function formatAsMoney(mnt)
    {
	mnt-=0;
	mnt=(Math.round(mnt*100))/100;
	return(mnt==Math.floor(mnt))?mnt+'.00':((mnt*10==Math.floor(mnt*10))?mnt+'0':mnt);
}
function showNewWindow(theURL,winName,features) { //v2.0
          window.open(theURL,winName,features);
          return false;
}
function changePage(requestUrl) {
		var pageSelect= dojo.byId("curP");
		pageSelect.disabled = true;
		var selectHref = requestUrl + (pageSelect.selectedIndex + 1);
		doPageForward(selectHref,"curP");
}
function doOrderBy(showDivId,requestUrl,selectId) {	
	    var select = dojo.byId(selectId);
		var selectHref = requestUrl + (select.selectedIndex + 1);
		selectHref = encodeURI(selectHref);
		doEngine("byGet",showDivId,selectHref,selectId);
	    return false;
}
function doOrderByVal(showDivId,requestUrl,selectId) {	
	    var select = dojo.byId(selectId);
		var selectHref = requestUrl + (select.value);
		selectHref = encodeURI(selectHref);
		doEngine("byGet",showDivId,selectHref,selectId);
	    return false;
}
