// JavaScript Document
function change_select(locationid,form_name,next_form_name)
{
	var locationid=locationid;
	with(form_name)
	{
		next_form_name.length = 0;
		next_form_name.options[next_form_name.length] = new Option("请选择类别..","0");
		var locationid=locationid;
		var i;
		for (i=0;i < onecount; i++)
		{
		if (catena[i][0] == locationid )
			{
				next_form_name.options[next_form_name.length] = new Option(catena[i][2], catena[i][1]);				
			}
		}
	}
}

/*以下二个函数用于上传图片时的预览
要点：
文件控件：<input name="XXXX" type="file" onchange="javascript:FileChange(uploadimage,this.value);">

新图预览：<IMG id="uploadimage"  onload="javascript:DrawImage(this ,www ,hhh);" width="1" height="1" border="0" onerror="this.src='../../web_up_file/nopic.jpg'">

旧图预览：<IMG id="uploadimage" src=".........." onload="javascript:DrawImage(this ,www ,hhh);" border="0" onerror="this.src='../../web_up_file/nopic.jpg'">
*/
function FileChange(imgObj,Value){
flag=false;
imgObj.width=10;
imgObj.height=10;
imgObj.alt="";
imgObj.src=Value;
}

/*按比例缩小图片,当图片高和宽为0时不处理 -- fire 20061001
传入参数: 
ImgD :图片URL ;
iHH  :高度,可为空
iWW  :宽度,可为空
*/
var flag=false;
function DrawImage(ImgD ,iWW ,iHH){
	if (iHH==""){
		iHH=245;
	}
	if (iWW==""){
		iWW=300
	}
	
	var image=new Image();
	image.src=ImgD.src;
	//当高和宽大于0时处理
	if(image.width>0 && image.height>0){
    	flag=true;
		
		if(image.width/image.height>= iWW/iHH){
		    if(image.width>iWW){  
			    ImgD.width=iWW;
			    ImgD.height=(image.height*iWW)/image.width;
			}else{
			     ImgD.width=image.width;  
			     ImgD.height=image.height;
		    }
	    }
    	else{
    		if(image.height>iHH){  
		    	ImgD.height=iHH;
				ImgD.width=(image.width*iHH)/image.height;     
			}else{
			    ImgD.width=image.width;  
		    	ImgD.height=image.height;
		    }
    	}
    }
   /*else{
    ImgD.src="";
    ImgD.alt=""
    }*/
     ImgD.alt="";
} 

function menuShow(obj,maxh,obj2)
{
  if(obj.style.pixelHeight<maxh)
  {
    obj.style.pixelHeight+=maxh/10;
	obj.filters.alpha.opacity+=20;
	obj2.background="";
    if(obj.style.pixelHeight==maxh/10)
	  obj.style.display='block';
	myObj=obj;
	myMaxh=maxh;
	myObj2=obj2;
	setTimeout('menuShow(myObj,myMaxh,myObj2)','5');
  }
}
function menuHide(obj,maxh,obj2)
{
  if(obj.style.pixelHeight>0)
  {
    if(obj.style.pixelHeight==maxh/5)
	  obj.style.display='none';
    obj.style.pixelHeight-=maxh/5;
	obj.filters.alpha.opacity-=10;
	obj2.background="";
	myObj=obj;
	myMaxh=maxh
	myObj2=obj2;
	setTimeout('menuHide(myObj,myMaxh,myObj2)','5');
  }
  else
    if(whichContinue)
	  whichContinue.click();
}
function menuChange(obj,maxh,obj2)
{
  if(obj.style.pixelHeight)
  {
    menuHide(obj,maxh,obj2);
	whichOpen='';
	whichcontinue='';
  }
  else
    if(whichOpen)
	{
	  whichContinue=obj2;
      whichOpen.click();
	}
	else
	{
	  menuShow(obj,maxh,obj2);
	  whichOpen=obj2;
	  whichContinue='';
	}
}

var tt='start';
var ii='start';
function doDisplay(a)
{
	a.style.display  = ( a.style.display == "none" ) ? "block" : "none";
}
function openWindow(url) {
  popupWin = window.open(url, 'new_page', 'width=400,height=410,scrollbars')
}

function setDisabled(theForm){
	if(theForm.changePwd.checked){
		theForm.member_password.disabled=false;
		obj = document.getElementById("member_password");
		obj.style.background='#FFFFFF';
		theForm.member_password.focus();
		obj1 = document.getElementById("member_password_c")
		obj1.style.background="#FFFFFF";
		theForm.member_password_c.disabled=false;
	}
	else{
		theForm.member_password.disabled=true;
		obj = document.getElementById("member_password")
		obj.style.background="#D4D0C8";
		theForm.member_password_c.disabled=true;		
		obj1 = document.getElementById("member_password_c")
		obj1.style.background="#D4D0C8";
	}
}

function check_edit(theForm){
	if(theForm.changePwd.checked){
		if(theForm.member_password.value.replace(" ","")==""){
			alert("新密码不能为空:)");
			theForm.member_password.focus();
			return false;
		}
		if(theForm.member_password_c.value.replace(" ","")==""){
			alert("请确认你的新密码:)");
			theForm.member_password_c.focus();
			return false;
		}
		if(theForm.member_password.value!=theForm.member_password_c.value){
			alert("前后密码不一致:)");
			theForm.member_password.value="";
			theForm.member_password_c.value="";
			theForm.member_password.focus();
			return false;
		}
	}
	if(theForm.member_password_old.value.replace(" ","")==""){
		alert("要修改信息；请输入你的旧密码:)");
		theForm.member_password_old.focus();
		return false;
	}
	
	if(theForm.form_code.value.replace(" ","")==""){
		alert("请填写验证码:)");
		theForm.form_code.focus();
		return false;
	}
}
