﻿//SELECT表单选取 Obj 表单名，VAL所选的值
function ChkSelected(Obj,Val)
{
	Val = Val.replace(/\s*/g,"");
	if (Obj)
	{
	for (i=0;i<Obj.length;i++){
		if (Obj.options[i].value==Val||(","+Val+",").indexOf(","+Obj.options[i].value+",")!=-1){
			Obj.options[i].selected=true;
		}
	}
	}
}

//单选表单选取 Obj 表单名，VAL所选的值
function chkradio(Obj,Val){
	if (Obj){
		Val = Val.replace(/\s*/g,"");
		for (i=0;i<Obj.length;i++){
			if (Obj[i].value==Val){
				Obj[i].checked=true;
				break;
			}
		}
	}
}

//多选表单选取 Obj 表单名，VAL所选的值
function chkcheckbox(Obj,Val){
	if (Obj){
		Val = Val.replace(/\s*/g,"");
		Val = ","+Val+",";
		if (Obj.length==null){
			if(Val.indexOf(","+Obj.value+",")!=-1){
				Obj.checked=true;
			}
		}
		for (i=0;i<Obj.length;i++){
			if(Val.indexOf(","+Obj[i].value+",")!=-1){
				Obj[i].checked=true;
			}
		}
	}
}

//复选表单全选事件
function boxCheckAll(obj,chkobj)  {
	if (!obj){return false;}

	for (var i=0;i<obj.length;i++)
	{
		var e = obj[i];
		if (e.type=="checkbox")
		{
			e.checked = chkobj.checked;
		}
	}
}

//图片自动调整的模式，1为按比例调整 ，2 按大小调整。
var resizemode=2;
function imgresize(o){
	if (resizemode==2 || o.onmousewheel){
		if(o.width > 760 ){
			o.style.width='760px';
		}
		if(o.height > 2000){
			//o.style.height='2000px';
		}
	}
	else{
		var parentNode=o.parentNode.parentNode
		if (parentNode){
			if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
		}
		else{
			var parentNode=o.parentNode
			if (parentNode){
				if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
			}
		}
	}
}
function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}

