﻿function openfile(oid)
{
	var path=getObject(oid).value;
	if(path.indexOf("/")<0)
	{
		alert("文件地址不存在");
	}else{
		window.open(path);
	}
}
function delfile(oid)
{
	var path=getObject(oid).value;
	getObject(oid).value="删除中,请稍等....";
	if(path.indexOf("/")<0)
	{
		getObject(oid).value=path
		alert("文件地址不存在");
		return false;
	}else{
		var s = new gineGrid();
		s.eAT(function(){calldelpicback(ajaxGLOBAL,path,oid)},"/Web_Admin/Upload/Delefile.ashx","File="+path);
	}
}
function calldelpicback(str,backpath,oid)
{
	switch (str)
	{
	case "1":
		getObject(oid).value="";
		alert("删除成功");
		break;
	default:
		getObject(oid).value=backpath;
		alert("删除失败");
		break;
	}
}


function resizeImg(vid)
{
	var str=getObject(vid).value
	if(str.length>0)
	{
	 getObject("ImgShowtr").style.display="";
	 getObject("ImgShow").src=str;
	 if(getObject("ImgShow").width>100) getObject("ImgShow").width=100;
	 if(getObject("ImgShow").height>100) getObject("ImgShow").height=100;
	}else{
	 getObject("ImgShowtr").style.display="none";
	}
}

function getObject(objectId) {
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId);
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
}

 function SValue(fm)
 {
     if(fm==null)fm=document.forms['form1'];
     if(fm==null)fm=document.forms['form2'];
     if(fm==null)fm=document.forms[0];
     if(fm==null)return;
	 var s="0";
	 var flag=false;
	 var Elementid=fm.SID;
	 if(fm.SID.length==undefined)
	 {
		 if(fm.SID.checked) s=fm.SID.value;
	 }else{
	    for (var i=0;i<Elementid.length;i++)
			{
				if(Elementid[i].checked)
					{
						s=s+","+Elementid[i].value;
						flag=true;
					}
			}
	 }
	return s;
 }
 
 function Chksel(svalue,object)
 {
	 if(object.length==undefined)
	 {
		 object.checked=true;
	 }else{
		 if(svalue=="")
		 {
			 object[0].checked=true;
		 }else{
			for (var i=0;i<object.length;i++)
				{
					if(object[i].value==svalue)
						{
							object[i].checked=true;
						}
				}
		 }
	 }
 }
function openwin(url,width,height){
   return window.open(url,'win','directorys=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+'px,height='+height+'px')
}
function openwin(url,winid,width,height){
   return window.open(url,winid,'directorys=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+'px,height='+height+'px')
}


function startList(nav) { 
	if (document.all&&document.getElementById) { 
		navRoot = document.getElementById(nav); 
		for (i=0; i<navRoot.childNodes.length; i++) { 
			node = navRoot.childNodes[i]; 
			if (node.nodeName=="LI") { 
				node.onmouseover=function() { 
					this.className+=" over"; 
					} 
				node.onmouseout=function() { 
					this.className=this.className.replace(" over", ""); 
				} 
			} 
		} 
	}
} 

function chgdiv(id){
	for (i=1;i<5;i++)
	{
		getObject("ashow"+i.toString()).style.display="none";
	}
		getObject("ashow"+id.toString()).style.display="";
}

function changecity(cityid,cityname)
{
	/*
	var cname=cityname;
	var oldid=0;
	if(cityname.indexOf("├")>-1) cname=cityname.replace("├","");
	getObject("CurrentCity").innerText=cname;
	changeselect(cityid)
	if (getObject("citynews_"+cityid)!=false)
		getObject("citynews_"+cityid).style.display="";
	if (getObject("oldcity")!=false)
	{
		oldid=getObject("oldcity").value;
		if (getObject("citynews_"+oldid)!=false)
			getObject("citynews_"+oldid).style.display="none";
		getObject("oldcity").value=cityid;
	}
	alert()
	*/
}
function changeselect(sbyid)
{
	var obj=getObject("City");
	for (i=0;i<obj.length;i++)
	{
		if(obj.options[i].value==sbyid)
			obj.options[i].selected=true;
	}
}
function changetrade(tradeid)
{
		if (tradeid>0)
	getObject("Trade").value=id;

}