//$Id: index_js.js 1 2008-07-09 07:11:07Z wucg $
//$Date: 2008-07-09 15:11:07 +0800 (星期三, 09 七月 2008) $

//自适应父窗口中Ifream的高度,兼容ff ie写法
function TuneHeight() {
//var frm = parent.document.getElementById("frmright");
//var subWeb = parent.document.frames ? parent.document.frames["frmright"].document : frm.contentDocument;
//if(frm != null && subWeb != null) {
//   frm.height = subWeb.body.scrollHeight;
//}
}

function menuChange(obj){
	obj.nextSibling.style.display=(obj.nextSibling.style.display=='none'?'block':'none');
}
function menushow(obj,allnum,oname){
	if(document.getElementById(obj).style.display=="none"){
		for(var i=1;i<allnum+1;i++){
		document.getElementById(oname+i).style.display="none";
		}
		document.getElementById(obj).style.display="block";
	}else{
		document.getElementById(obj).style.display="none";
	}
}
function classcheck(){
	if (document.myform.classname.value==""){
		alert("栏目名称不能为空！");
		document.myform.classname.focus();
		return false;
	}
}
var tID=0;
function ShowTabs(ID){
  if(ID!=tID){
    TabTitle[tID].className="title5";
    TabTitle[ID].className="title6";
    Tabs[tID].style.display="none";
    Tabs[ID].style.display="block";
    tID=ID;
  }
}
function Num(){
  var berr=false;
  if (!(event.keyCode>=46 && event.keyCode<=57)) berr=true;
  return !berr;
}
function unselectall(form){
	if(form.chkall.checked){
	form.chkall.checked = form.chkall.checked&0;
    } 	
}
function CheckAll(form){
	for (var i=0;i<form.elements.length;i++){
		var e = form.elements[i];
		if (e.Name != "chkall"&&e.type=="checkbox")
		e.checked = form.chkall.checked;
	}
}
function regcheck(){
	if (document.myform.admin.value==""){
		alert("管理员用户名不能为空！");
		document.myform.admin.focus();
		return false;
	}
	if (document.myform.pwd.value==""){
		alert("管理员密码不能为空！");
		document.myform.pwd.focus();
		return false;
	}
}
function addname(used){
	var thisfield="";
	var tishi=prompt("请输入字段内容(格式:显示内容,值)：",thisfield);
	if(tishi!=null&&tishi!=""){
		if(tishi.indexOf(",")<0){tishi=tishi+","+tishi;};
	used.options[used.length]=new Option(tishi,tishi);
	}
}
function modifyname(used){
	if(used.length==0) return false;
	var thisfield=used.value;
	if(thisfield==""){alert("请先选择一个字段内容，再点修改按钮！");return false;}
	var tishi=prompt("请输入字段内容：",thisfield);
	if(tishi!=thisfield&&tishi!=null&&tishi!=""){
		if(tishi.indexOf(",")<0){tishi=tishi+","+tishi;};
	used.options[used.selectedIndex]=new Option(tishi,tishi);
	}
}
function delname(used){
	if(used.length==0) return false;
	var thisfield=used.value;
	if(thisfield==""){alert("请先选择一个字段内容，再点删除按钮！");return false;}
	used.options[used.selectedIndex]=null;
}
function selall(used){
	for(var i=0;i<used.length;i++){
		used.options[i].selected=true;
	}
}
function fieldcheck(){
	if(document.myform.fieldname.value==""){
		alert("字段名称不能为空！");
		document.myform.fieldname.focus();
		return false;
	}
	if(document.myform.fieldcontent.length==0){
		alert("字段内容不能为空！");
		document.myform.fieldcontent.focus();
		return false;
	}
	selall(document.myform.fieldcontent);
}
function doChange(objText, objDrop){
	if (!objDrop) return;
	var str = objText.value;
	var arr = str.split("|");
	var nIndex = objDrop.selectedIndex;
	objDrop.length=1;
	for (var i=0; i<arr.length; i++){
		objDrop.options[objDrop.length] = new Option(arr[i], arr[i]);
	}
	objDrop.selectedIndex = nIndex;
}
function newscheck(){
	if (document.myform.newstitle.value==""){
		alert("信息标题不能为空！");
		document.myform.newstitle.focus();
		return false;
	}
	if (document.myform.classid.value==""){
		alert("所属栏目不能指定为含有子栏目的栏目！");
		document.myform.classid.focus();
		return false;
	}
//	if (eWebEditor1.getHTML()==""){
//		alert("信息内容不能为空！");
//		return false;
//	}
}
function selectphoto(formname,uploaddir){
	var arr=showModalDialog("admin_UpPhoto.asp?uploaddir="+uploaddir+"","","dialogWidth:800px; dialogHeight:600px; help:no; scroll:yes; status:no");
	if(arr!=null){
		formname.value=arr;
	}
}
function DrawImage(ImgD,ImgDWidth,ImgDHeight){
	var image=new Image();
	image.src=ImgD.src;
	if(image.width/image.height>=ImgDWidth/ImgDHeight){
		if(image.width>ImgDWidth){
			ImgD.width=ImgDWidth;
			ImgD.height=(image.height*ImgDWidth)/image.width;
		}else{
			ImgD.width=image.width;
			ImgD.height=image.height;
		}
	}else{
		if(image.height>ImgDHeight){
			ImgD.width=(image.width*ImgDHeight)/image.height;
			ImgD.height=ImgDHeight;
		}else{
			ImgD.width=image.width;
			ImgD.height=image.height;
		}
	}
}
function uppicup(formname,imgfrom){
	var picname=showModalDialog("admin_UpPic.asp?imgname="+formname.value+"&imgform="+imgfrom+"","","dialogWidth:500px; dialogHeight:350px; help:no; scroll:no; status:no;")
	if(picname!=null){
		formname.value=picname;
	}
}
function upmorepic(formname,imgname,imgfrom){
	var picname=showModalDialog("admin_UpPic.asp?imgname="+imgname+"&imgform="+imgfrom+"","","dialogWidth:500px; dialogHeight:350px; help:no; scroll:no; status:no;")
	if(picname!=null){
		formname.value=picname;
	}
}
function productscheck(){
	if (document.myform.productsname.value==""){
		alert("商品名称不能为空！");
		document.myform.productsname.focus();
		return false;
	}
	if (document.myform.classid.value==""){
		alert("所属栏目不能指定为含有子栏目的栏目！");
		document.myform.classid.focus();
		return false;
	}
}
