var o_con=new Array();
o_con["ShowClassList"]={"para0":"image,fl.jpg","para1":"group,","para2":"两个参数函数,ShowClassList2|三个参数函数,ShowClassList3|五个参数函数,ShowClassList5"};

	o_con["ShowClassList2"]={"para1":"html,HTML","para2":"class,分类列表"};
	o_con["ShowClassList3"]={"para1":"html,HTML","para2":"class,分类列表","para3":"size,数量"};
	o_con["ShowClassList5"]={"para1":"html,HTML","para2":"class,分类列表","para3":"size,数量","para4":"text,条件,示例:c_status=1 ","para5":"text,排序,示例: c_update asc "};
	
o_con["ShowClassInfo"]={"para0":"image,info.jpg","para1":"html,HTML","para2":"class,分类列表"};

o_con["ShowClassPage"]={"para0":"image,flpage.jpg","para1":"group,","para2":"两个参数函数,ShowClassPage2|三个参数函数,ShowClassPage3|六个参数函数,ShowClassPage6"};

	o_con["ShowClassPage2"]={"para1":"html,HTML","para2":"class,分类列表"};
	o_con["ShowClassPage3"]={"para1":"html,HTML","para2":"class,分类列表","para3":"size,数量"};
	o_con["ShowClassPage6"]={"para1":"html,HTML","para2":"class,分类列表","para3":"size,数量","para4":"text,条件,示例:c_status=1 ","para5":"text,排序,示例: c_update asc ","para6":"imgbar,翻页样式"};
	
o_con["ShowBreadBar"]={"para0":"image,dh.jpg","para1":"html,HTML","para2":"html,分隔代码"};

	o_con["ShowContentList"]={"para0":"image,list.jpg","para1":"group,","para2":"两个参数函数,ShowContentList2|三个参数函数,ShowContentList3|五个参数函数,ShowContentList5"};
	
	o_con["ShowContentList2"]={"para1":"html,HTML","para2":"class,分类列表"};
	o_con["ShowContentList3"]={"para1":"html,HTML","para2":"class,分类列表","para3":"size,数量"};
	o_con["ShowContentList5"]={"para1":"html,HTML","para2":"class,分类列表","para3":"size,数量","para4":"text,条件,示例:c_status=1 ","para5":"text,排序,示例: c_update asc "};

	
	o_con["ShowContentGoodList"]={"para0":"image,tj.jpg","para1":"group,","para2":"两个参数函数,ShowContentGoodList2|三个参数函数,ShowContentGoodList3"};
	
	o_con["ShowContentGoodList2"]={"para1":"html,HTML","para2":"class,分类列表"};
	o_con["ShowContentGoodList3"]={"para1":"html,HTML","para2":"class,分类列表","para3":"size,数量"};
	
	
o_con["ShowContentInfo"]={"para0":"image,cinfo.jpg","para1":"html,HTML","para2":"content,选择内容"};
	o_con["ShowContentPage"]={"para0":"image,page.jpg","para1":"group,","para2":"三个参数函数,ShowContentPage3|六个参数函数,ShowContentPage6"};

	
	o_con["ShowContentPage3"]={"para1":"html,HTML","para2":"class,分类列表","para3":"size,数量"};
	o_con["ShowContentPage6"]={"para1":"html,HTML","para2":"class,分类列表","para3":"size,数量","para4":"text,条件,示例:c_status=1 ","para5":"text,排序,示例: c_update asc ","para6":"imgbar,翻页样式"};


o_con["ShowContentRelationProduct"]={"para0":"image,xgcp.jpg","para1":"html,HTML"};
o_con["ShowContentRelationInfo"]={"para0":"image,xgzx.jpg","para1":"html,HTML"};
o_con["ShowContentTags"]={"para0":"image,bq.jpg","para1":"none,"};
o_con["ShowContentImage"]={"para0":"image,img.jpg","para1":"none,"};
o_con["ShowContentContent"]={"para0":"image,content.jpg","para1":"none,"};


//获得参数

function SetItem(o_con)
{
	//debugger;
	var i_add=0;
	
	for(var o in o_con)
  {
  	if(i_add==0)
  	{
  		$(s_contentid).value=o;
  		$('spntitle').innerHTML="<a href='/content.aspx?id="+o+"' target='_blank'>"+o_con[o].name+"</a>";
  	}
  	
  	i_add++;	
  }
  
  if(i_add>1)
  {
  	alert("每次只能选择一条内容！");
  }
}

function clearOptions(colls){ 
var length = colls.length; 
for(var i=length-1;i>=0;i--){ 
colls.remove(i); 
} 
} 



var s_contentid="";
function BuildParameter()
{
	clearOptions($('sellst'));
	$('trgroup').style.display="none";

	BuildParameterDo($('selfunc'));
}

function BuildParameter2()
{
	BuildParameterDo($('sellst'));
}



function BuildParameterDo(selObj)
{
	//debugger;
	
	
	if(selObj.value=="0")
		return ;
	
	$('licls').style.display="none";
	
	if(selObj.selectedIndex<8)
	{
		$('licls').style.display="";
	}
	
	var s_html="<table border='0'>";
	
	$('functionname').value=selObj.value;
	$('txtidlst').value="";
	
	$('divman').innerHTML="";
	$('txthtml').value="";
	
	var o_para=o_con[selObj.value];
	for(o in o_para)
	{
	  var s_con=o_para[o].split(',');
	  
		var s_name=s_con[1];
		var s_input="";
		var s_tip="";
		
		if(s_con.length==3)
		{
			s_tip="<br />"+s_con[2];
		}
		
		
		switch(s_con[0])
		{
			case "group":
			{
				$('trgroup').style.display="";
				
				var s_spt=o_para["para2"].split('|');
				for(j=0;j<s_spt.length;j++)
				{
					var s_tmp=s_spt[j].split(',');
					$('sellst').options[$('sellst').length] = new Option(s_tmp[0],s_tmp[1]);	
					
				}
				$('sellst').selectedIndex=0;
				
				BuildParameterDo($('sellst'));
				
				return ;
				
				break;
			}
			case "image"://演示图片
			{
				$('imgshow').src="/admin/images/demo/"+s_con[1];
				continue;
				break;
			}
			case "html"://标准的格式
			{
				s_input="<textarea cols='60' rows='10'  class='inputbox' id='"+o+"'></textarea>";
				break;
			}
			case "class": //分类列表
			{
				s_input=$('divclass').innerHTML.replace("selclass",o);
				
				break;
			}
			case "content": //内容列表
			{
			  s_contentid=o;
				s_input="<input type='hidden' value='0' id='"+o+"'><span id='spntitle'></span><input type=\"button\" class=\"button\" value=\"选择\" onclick=\"GetTitle()\" />";
				
				break;
			}
			case "size":
			{
				s_input="<input type='text' value='5'  class='inputbox' maxlength='5' id='"+o+"'>";
				break;
			}
			case "text":
			{
				s_input="<input type='text' value=''  class='inputbox' style='width:300px;'  id='"+o+"'>";
				break;
			}
			case "imgbar"://翻页样式
			{
				s_input="<select id='"+o+"'><option value='true'>图片样式</option><option value='false'>文字样式</option></select>";
				break;
			}
			case "none": //没有参数
			{
				$('txthtml').value="<%="+$('selfunc').value+"()%>";
				return ;
			}
			case "": //函数说明
			{
				continue;
				break;
			}
		}
		
		s_html+="<tr><td class='tright' valign='top' nowrap='nowrap'>"+s_name+"：</td><td class='tleft'>"+s_input+s_tip+"</td></tr>";
	}
	
	s_html+="</table>";
	
	$('divman').innerHTML=s_html;
	
	$('txthtml').focus();
	
	SelectItem(1);
}

function StartBuild()
{
	if($('divman').style.display=="")
	{
		//手工
		BuildHTML(10,"");
	}
	else
	{
		if($('cid').value=="0")
		{
			alert("请选择栏目！");
			return ;
		}
		
		if($('para1')!=null)
			$('para1').value=GetParaHTML($('txttemp').value);
		
		$('frmauto').submit();
		
	}
}

function BuildHTML(i_top,s_idlst)
{
	var s_html="";
	
	
	
	for(var i=1;i<15;i++)
	{
		if($('para'+i)==null)
		{
			break;
		}
		else
		{
			var b_split=true;
			
			switch($('para'+i).type)
			{
				case "textarea": //大文本 模板
				{
					
					s_para=GetParaHTML($('para'+i).value);
					
					break;
				}
				case "text"://top size 等内容
				{
					if($('divman').style.display=="")
					{
						//手工设置的时候读取
				  	s_para=$('para'+i).value;
				  }
				  else
				  {
				  	s_para=i_top;
				  }		
					break;
				}
				case "select-multiple": //分类ID
				{
					if($('divman').style.display=="")
					{
						//手工设置的时候读取
				  	s_para=GetSelectIdList($('para'+i));
				  }
				  else
				  {
				  	s_para=$('cid').value;
				  }	
				  	
					break;
				}
				case "select-one"://单独分类
				{
					
					s_para=$('para'+i).value;
					b_split=false;
					break;
				}
				case "hidden": //内容ID
				{
					if($('divman').style.display=="")
					{
						s_para=$('para'+i).value;
					}
					else
					{
						s_para=s_idlst;
					}		
				}
			}
		}
		
		if(b_split)
		{
			s_html+=",\""+s_para+"\"";
		}	
		else
		{
			s_html+=","+s_para+"";
		}	
	}
	
	s_html=s_html.substr(1);
	
	
	$('txthtml').value="<"+"%="+$('selfunc').value+"("+s_html+")%>";
	
	alert("生成成功！");
}

function GetParaHTML(s_in)
{
  var s_ret=s_in.replace(/\r\n/ig,"");
  
  s_ret=s_ret.replace(/\"/ig,"\\\"");
  
  return s_ret;
}

function GetSelectIdList(selobj)
{
  var s_idlst="";
  	
	for(var i=selobj.options.length-1;i>=0;i--)
  {
  	if(selobj.options[i].selected)
  	{
  		s_idlst+=","+selobj.options[i].value;
  	}	
  }
  
  if(s_idlst=="")
  {
  	s_idlst="0";
  }
  else
  {
  	s_idlst=s_idlst.substr(1);
  }
  
  return s_idlst;
}

function CopyText()
{
	window.clipboardData.setData('text',$('txthtml').value);
	alert('复制完毕');
}

function GetTitle()
{
	popup_open("/admin/getcontent/default.aspx?tp=5&nid=0","选择内容",510,465);
}


function SelectItem(i_sel)
{
	$('ahrcls').className="unclick";
	$('ahrcnt').className="unclick";
	$('divman').style.display="none";
	$('divauto').style.display="none";
	
	if(i_sel==0)
	{
		$('ahrcls').className="click";
		$('divauto').style.display="";
	}
	else
	{
		$('divman').style.display="";
		$('ahrcnt').className="click";
		
	}
	
}