//表单判断
function chkFm(Fname,Fmsg,rts){
	rs = rts;
	var CkS = document.getElementById(Fname);
	if(rs == true){
		if (CkS.value == ""){
			alert(Fmsg);
			CkS.focus()
			return false;
		}else{
			return rs;
		}
	}else{
		return rs;
	}
}

//Email检测
function isEmail(emailstr) {
	var emailchk = /^[a-z][\w\-\.]+@[\w\-]+(\.[a-z]+){1,2}$/;
	return emailchk.test(emailstr) ? true : false;
}

//鼠标滚轮缩放图片
function bbimg(o)
{
   var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
   return false;
}

//图片等比例缩放
function DrawImage(ImgD,ImgW,ImgH){
	var flag=false;
	if(ImgD != null)
	{
		var image = ImgD;
		if(image.width > 0 && image.height > 0){
			flag=true;
			if(image.width/image.height>= ImgW/ImgH){
				if(image.width>ImgW){  
					ImgD.width=ImgW;
					ImgD.height=(image.height*ImgW)/image.width;
				}else{
					ImgD.width=image.width;  
					ImgD.height=image.height;
				}
			}
			else{
			if(image.height>ImgH){  
				ImgD.height=ImgH;
				ImgD.width=(image.width*ImgH)/image.height;     
			}else{
				ImgD.width=image.width;  
				ImgD.height=image.height;
			}
			}
		}
	}
}

//选择复选框
function SelChk(sname,type)
{
	var vd = document.getElementsByName(sname);
	if(vd != null)
	{
		for(i = 0; i < vd.length; i++)
		{
			if(type == 0)
			{
				vd[i].checked = false;
			}
			if(type == 1)
			{
				vd[i].checked = true;
			}
			if(type == 2)
			{
				if(vd[i].checked == true)
				{
					vd[i].checked = false;
				}
				else
				{
					vd[i].checked = true;
				}
			}
		}
	}
}

//Array 检测
function InArray(str,arr)
{
    res = false;
    if(str != "" && arr != null)
    {
	    for(i = 0; i < arr.length; i++)
	    {
		    if(str == arr[i])
		    {
			    res = true;
		    }
	    }
    }
    return res;
}

//显示隐藏
function ShowBd(sid,tp)
{
    var si = document.getElementById(sid);
    if(tp = "0")
    {
        si.style.display = "none";
    }
    else
    {
        si.style.display = "";
    }
}

// 设定Obj样式
function SetObjSty(obj,sty)
{
	if(obj != null)
	{
		obj.className= sty;
	}
}

// 字符串转数组
function strToarr(str,ext)
{
	if(str != "")
	{
		if(ext == "")
		{
			ext = "|";
		}
		arr = str.split(ext);
		return arr;
	}
}

//获取Radio值
function GetRadioValue(rn)
{
	var cir = document.getElementsByName(rn);
	var civ = "0";
	if(cir != null)
	{
		for(i = 0; i < cir.length; i++)
		{
			if(cir[i].checked == true)
			{
				civ = cir[i].value;
			}
		}
	}
	return civ;
}

function urlLocation(url)
{
	if(url != "")
	{
		window.location.href = url;
	}
}

function DisObj(obj,typ)
{
	if(obj != null)
	{
		if(typ == 1)
		{
			obj.style.display = '';
		}
		else
		{
			obj.style.display = 'none';
		}
	}
}

//复制到剪切板
function copyToClipBoard(text,alt)
{
	 window.clipboardData.setData("Text",text);
	 if(alt != null && alt != "")
	 {
		 alert(alt);
	 }
}
