function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}
//flash插入函数
function InsertFlash(Flash,Width,Height,ID){
	document.writeln("<embed src=\"" + Flash + "\"  type=\"application\/x-shockwave-flash\" width=\""+Width+"\" height=\""+Height+"\"  wmode=\"transparent\" ><\/embed>")
	
}
//获得上一级目录url
function get2url(url){
		var tempstr
		tempstr=url
		if(tempstr!=""){
			tempstr = tempstr.substring(0,tempstr.lastIndexOf("?"));
			tempstr = tempstr.substring(0,tempstr.lastIndexOf("/"));
			tempstr = tempstr.substring(0,tempstr.lastIndexOf("/")+1); 
			return tempstr;
		}
	}
//获得本目录url
function get1url(url){
		var tempstr
		tempstr=url
		if(tempstr!=""){
			tempstr = tempstr.substring(0,tempstr.lastIndexOf("?"));
			tempstr = tempstr.substring(0,tempstr.lastIndexOf("/")+1); 
			return tempstr;
		}
}
//展开树状分支
function showList(show)
{
	if (show.style.display == 'none') 
	{
		show.style.display = 'block';
	}
	else 
	{
		show.style.display = 'none';
	}
}
//返选
function checkAll(thisform){
		var ids = thisform.elements['id'];
		var type = typeof(ids.name); 
		if ( type != 'undefined' )
		{
			ids.checked = !ids.checked;
		}else{
			for(i=0; i<ids.length; i++)
			{
				ids[i].checked = !ids[i].checked;
			}
		}
}
//是否已经选中操作行
function isSelected(thisform)
      {
		var ids = thisform.elements['id'];
			
		var type = typeof(ids.name); 
		if ( type != 'undefined' )
		{
			if( ids.checked )
			{
				return true;
			}
		}else{
			for(i=0; i<ids.length; i++)
			{
				if( ids[i].checked ){
					return true;
				}
			}
		}
     return false;
}
//选择删除确认
function confirmDelete(thisform){
		if(!isSelected(thisform)){
			alert("请选中要删除的图片！");
			return false;
		}
		if (!confirm("确认删除图片？")){
			return false;
		}
		return true;
}
function confirmDelete_bbs(thisform){
		if(!isSelected(thisform)){
			alert("请选中要删除的评论！");
			return false;
		}
		if (!confirm("确认删除评论？")){
			return false;
		}
		return true;
}
//选择删除确认
function confirmMove(thisform){
		if(!isSelected(thisform)){
			alert("请选中要移动的图片！");
			return false;
		}
		if (!confirm("确认移动图片？")){
			return false;
		}
		return true;
}
//导入图片确认
function confirmImport(thisform){
		if(!isSelected(thisform)){
			alert("请选中要删除的图片！");
			return false;
		}
		return true;
}

function DrawImage(ImgD,width_s,height_s){
var image=new Image(); 
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>=width_s/height_s){
if(image.width>width_s){
ImgD.width=width_s;
ImgD.height=(image.height*width_s)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>height_s){
ImgD.height=height_s;
ImgD.width=(image.width*height_s)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
/*else{
ImgD.src="";
ImgD.alt=""
}*/
}
function zoomimg(o)
{
var zoom=parseInt(o.style.zoom, 10)||100;
zoom+=event.wheelDelta/12;
if (zoom>0) o.style.zoom=zoom+'%';
return false;
}
//guest.asp
function upload_big(big_obj,small_obj,path,f)
  {
   if(f==1){
   big_obj.focus();
   }else{
   small_obj.focus();
   }
  var arr = showModalDialog("guest_upfile.asp?f="+f+"&path="+path, "", "dialogWidth:245px; dialogHeight:80px; status:0;help:0");
  if (arr != null){
  var ss;
  ss=arr.split("*")
  if(f==1){
    big_obj.value=ss[0];
	//当缩略图有是赋值
    if(ss[1].indexOf(".")>0){
    small_obj.value=ss[1];
    }
  }else{
  small_obj.value=ss[0];
  }
 }
}
/*****************************
TreeMenu
*****************************/
function Ob(o){
 var o=document.getElementById(o)?document.getElementById(o):o;
 return o;
}
function Hd(o) {
 Ob(o).style.display="none";
}
function Sw(o) {
 Ob(o).style.display="";
}
function ExCls(o,a,b,n){
 var o=Ob(o);
 for(i=0;i<n;i++) {o=o.parentNode;}
 o.className=o.className==a?b:a;
}
function CNLTreeMenu(id,TagName0) {
  this.id=id;
  this.TagName0=TagName0==""?"li":TagName0;
  this.AllNodes = Ob(this.id).getElementsByTagName(TagName0);
  this.InitCss = function (ClassName0,ClassName1,ClassName2,ImgUrl) {
  this.ClassName0=ClassName0;
  this.ClassName1=ClassName1;
  this.ClassName2=ClassName2;
  this.ImgUrl=ImgUrl || "images/s.gif";
  this.ImgBlankA ="<img src=\""+this.ImgUrl+"\" class=\"s\" onclick=\"ExCls(this,'"+ClassName0+"','"+ClassName1+"',1);\" alt=\"展开/折叠\" />";
  this.ImgBlankB ="<img src=\""+this.ImgUrl+"\" class=\"s\" />";
  for (i=0;i<this.AllNodes.length;i++ ) {
   this.AllNodes[i].className==""?this.AllNodes[i].className=ClassName1:"";
   this.AllNodes[i].innerHTML=(this.AllNodes[i].className==ClassName2?this.ImgBlankB:this.ImgBlankA)+this.AllNodes[i].innerHTML;
   }
 }
 this.SetNodes = function (n) {
  var sClsName=n==0?this.ClassName0:this.ClassName1;
  for (i=0;i<this.AllNodes.length;i++ ) {
   this.AllNodes[i].className==this.ClassName2?"":this.AllNodes[i].className=sClsName;
  }
 }
}
//-----------------
function tbladdrow(item_name,item_value) 
{ 
    var i=lines.rows.length            ; 
    var row = lines.insertRow(i); 
    var col = row.insertCell(0); 
    col.innerHTML = "<INPUT  name=\"item"+i+".name\"　type=\"text\" size=\"40\" value=\'"+item_name+"\'><font color=\"#FF0000\">*</font>"; 
    col = row.insertCell(1); 
    col.innerHTML = "替换为<INPUT  name=\"item"+i+".value\" type=\"text\" size=\"30\" value=\'"+item_value+"\'>"; 
	col = row.insertCell(2); 
    col.innerHTML = "<input  type=\"button\" value=\"删除\" language=\"javascript\" onclick=\"return delrow(this)\" />"; 
} 
function tbladdrows(items) 
{
   for( i = 1 ; i <= items ; i++) 
    { 
        tbladdrow("",""); 
    } 
} 
function delrow(obj) 
{ 
var objTD =obj.parentElement;
var objTR =objTD.parentElement;
var objTable = objTR.parentElement;
var currRowIndex = objTR.rowIndex;
if (currRowIndex>=0){
//alert(objTable.rows(currRowIndex).cells(0).all(0).name)
objTable.deleteRow(currRowIndex);
currRowIndex = 0;
}
for (var i=0;i<objTable.rows.length;i++){
objTable.rows(i).cells(0).all(0).name="item"+i+".name";
objTable.rows(i).cells(1).all(0).name="item"+i+".value";
}
}


