function makeCall(url,showFunc,params){
	new Ajax.Request(url, 
		{
			method:'post',
			parameters:params,
			onFailure: function(){ alert('connot connection to the server') },  
	  		onSuccess: function(transport){
	        	var json = transport.responseText.evalJSON();
	        	if ( json.SUCCESS==0 ){
	        		alert("Error: "+json.MSG); 
//	        		if(json.MSGCODE=='EC-FRM-1400'){
//	        			window.location.href='/FaqWeb/Login.htm';
//        			return ;
//	        		} 
	        	}else{
					showFunc(json);
	        	}
	 		} 
	 	});
}

	function makeFormCall(url,showFunc,formName){
		//alert(formName);
	    new Ajax.Request(url, 
		{
			method:'post',
			parameters:$(formName).serialize(true),
			onFailure: function(){ alert('connot connection to the server'); },  
	  		onSuccess: function(transport){
	        	var json = transport.responseText.evalJSON();
	        	if ( json.SUCCESS==0 ){
	        		alert("Error: "+json.MSG);   
//	        		if(json.MSGCODE=='EC-FRM-1400'){
//	        			window.location.href='/FaqWeb/Login.jsp';
//	        			return ;
//	        		} 
	        	}else{
					showFunc(json);
	        	}
	 		} 
	 	});
       }

//========================================================================================================

//用于输出表格！
/*		function printTable(json){
			var tab1 = new InfoTable();
			tab1.dataset=json.TAGS;
			tab1.titles=new Array('选择','标签名','引用计数','');
			tab1.cols=new Array(
							"<input type=checkbox value={ID} onClick=\"javascript:alert('{TAG_NAME}');\"/>"
							,'{ID}'
							,'<a href=# title={REF_COUNT}>{TAG_NAME}</a>'
							,'#{REF_COUNT}');	
			var txt=tab1.print();
			var obj = $("tab1");
			alert(txt);
			obj.innerHTML=txt;
		}
*/
function InfoTable(){
	this.titles=null; //表头，类型为数组
	this.cols = null; //表中列的格式
	this.dataset=null; //数据集
	this.style=null;
	this.print=function(){ //打印表格
		var style=(this.style==null?new InfoStyle():this.style);
		var txt = '';
		txt+="<table" +style.tab+ ">";
		if ( this.titles ){
			txt+="<tr "+style.tabTiltle+">";
			for(var i=0;i<this.titles.length;i++){
				if ( this.titles[i]!='' )
					txt+="<td>"+this.titles[i]+"</td>";
				else
					txt+="<td>&nbsp;</td>";
			}
		}
		txt+="</tr>";
		for(var i=0;i<this.dataset.length;i++){
			if ( i%2==0 ){
				txt+="<tr "+style.trLine1+">";
			}else{
				txt+="<tr "+style.trLine2+">";
			}
			for(var j=0;j<this.cols.length;j++){
				txt+="<td"+style.td+">";
				if ( this.cols[j].length!='' ){
					txt +=this.setData(this.dataset[i],this.cols[j]);
				}else{
					txt += "&nbsp;";
				}
				txt+="</td>";
			}
			txt+="</tr>";
		}
		txt+="</table>";
		return txt;
	}
	this.setData=function(dataObj,format){ //根据格式，格式化数据
		var pattern = /\{[^\{\}]*\}/gi;
		var strAry = format.match(pattern);
		var tmp =null;
		if ( strAry && strAry.length>0 ){
			var p2=/([a-zA-Z0-9_])+(,(number|date|time|choice)?(,(short|medium|long|full|integer|currency|percent|[^\{\},]*))?)?/g;
			for(var i=0;i<strAry.length;i++){
				tmp = strAry[i].match(p2); //结果是数组;
				if ( tmp.length >0 ){
					var fary = tmp[0].split(',');
					if ( fary.length==1 ){//没有分段的格式
						format=format.replace('{'+tmp+'}', eval('dataObj.'+tmp));
					}else{
						if ('choice'==fary[1]){
							format = format.replace(strAry[i],choice(eval('dataObj.'+fary[0]),fary[2]) );
						}else if ('number'==fary[1]){
						}else if ('date' == fary[1]){
						}else if ('time' == fary[1]){
						}
					}
				}
			}
		}
		return format;
	}
}

/*
	<table id="1" class="wall_table">
		<tr>
			<td class="wall_td_img"><img src="../images/kevin.jpg" /></td>
			<td>
				<table width="100%">
					<tr>
						<td class="wall_td_top">
						</td>
					</tr>
					<tr>
						<td>
						</td>
					</tr>
					<tr>
						<td class="wall_td_bottom">
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
*/

function WallTable(){
	this.titles=null; //表头，类型为数组
	this.cols = null; //表中列的格式
	this.dataset=null; //数据集
	this.style=null;
	this.print=function(){ //打印表格
		var style=(this.style==null?new InfoStyle():this.style);
		var txt = '';
		
		for(var i=0;i<this.dataset.length;i++){
			txt+="<table class=\"wall_table\">";
			txt+="<tr><td class=\"wall_td_img\">";
			if ( this.cols[0].length!='' ){
				txt +=this.setData(this.dataset[i],this.cols[0]);
			}else{
				txt += "&nbsp;";
			}
			txt+="</td><td><table width=\"100%\"><tr>";
			for(var j=1;j<this.cols.length;j++){
				if(j==1){
					txt+="<td class=wall_td_top>";
					if ( this.cols[j].length!='' ){
						txt +=this.setData(this.dataset[i],this.cols[j]);
					}else{
						txt += "&nbsp;";
					}
				}
				if(j==2){
					txt+="<td>";
					if ( this.cols[j].length!='' ){
						txt +=this.setData(this.dataset[i],this.cols[j]);
					}else{
						txt += "&nbsp;";
					}
				}
				if(j==3){
					txt+="<td class=wall_td_bottom>";
					if ( this.cols[j].length!='' ){
						txt +=this.setData(this.dataset[i],this.cols[j]);
					}else{
						txt += "&nbsp;";
					}
				}
				txt+="</td>";
				txt+="</tr>";
			}
			
			txt+="</table></td></tr></table>";
		}
		
		return txt;
	}
	this.setData=function(dataObj,format){ //根据格式，格式化数据
		var pattern = /\{[^\{\}]*\}/gi;
		var strAry = format.match(pattern);
		var tmp =null;
		if ( strAry && strAry.length>0 ){
			var p2=/([a-zA-Z0-9_])+(,(number|date|time|choice)?(,(short|medium|long|full|integer|currency|percent|[^\{\},]*))?)?/g;
			for(var i=0;i<strAry.length;i++){
				tmp = strAry[i].match(p2); //结果是数组;
				if ( tmp.length >0 ){
					var fary = tmp[0].split(',');
					if ( fary.length==1 ){//没有分段的格式
						format=format.replace('{'+tmp+'}', eval('dataObj.'+tmp));
					}else{
						if ('choice'==fary[1]){
							format = format.replace(strAry[i],choice(eval('dataObj.'+fary[0]),fary[2]) );
						}else if ('number'==fary[1]){
						}else if ('date' == fary[1]){
						}else if ('time' == fary[1]){
						}
					}
				}
			}
		}
		return format;
	}
}

//choice类型的格式化
//{XXXX,choice,0#asdf|1#asdf|3# } 当为3时返回空格
function choice(val,tmp){
	var items = tmp.split('|');
	var sp = null;
	for(var i=0;i<items.length;i++){
		sp = items[i].split('#');
		if ( sp[0]==val ){			
			return sp[1];
		}
	}
	return tmp
}



function InfoStyle(){	
	this.tab=" width=100% border=0 align=center cellpadding=2 cellSpacing=1 bgcolor=#B5DDD7 ";
	this.tabTiltle=" class=\"line3\" ";
	this.trLine1=" class=\"line1\" ";
	this.trLine2=" class=\"line2\" ";
	this.td=" class=\"font3\" ";
}
var style1 = new InfoStyle();
style1.tab=" width=100% border=0 align=center cellpadding=2 cellSpacing=1 ";

var style2 = new InfoStyle();
style2.tab=" width=100% border=0 align=center cellpadding=2 cellSpacing=1 ";
style2.tabTiltle="";
style2.trLine1="";
style2.trLine2="";
style2.td="";

var appStyle = new InfoStyle();
appStyle.tab=" class=\"tab1\" ";

//根据节点信息打印节点路径
function printTreePath(node,funcName){
	var split = "--&gt;";
	var txt = "";
	var nd = '';
	do{
		if ( nd == '' ){
			nd = node;
		}else{
			nd = nd.Childs[0];
		}
		txt+=split;
		txt+="<a href=\"javascript:"+funcName+"('"+nd.Id+"');\">";
		txt+=nd.Name;
		txt+="</a>";
	}while(nd.Childs)
	
	if ( txt=='' )
		return txt;
	else
		return txt.substring(split.length,txt.length);
}

