/**
  * 下麵是公用的
  */
function onchangeMyType(form) {
        form.method = "get";
        form.submit();
}
function checkValueIsEmpty(obj,flag,message){
        if (flag) {
            if (trim(obj.value) == "") {
                alert(message); 
                return false;    
            } else {
                return true;
            }
        }
        return true;
}

function checkEmail(obj) {
        var strm = obj.value;
		//
        var regm = /^[a-zA-Z\d\.\-_]+@[a-zA-Z\d\.\-_]+(\.[a-zA-Z\d\-_]+)+$/;
        if (!strm.match(regm)) {
                alert("邮箱地址格式错误或含有非法字符!\n请检查！");
                return false;
        }
        return true;
}

function trim(s){
  return s.replace(/^\s+|\s+$/, '');
}

function isFloat(value) {
	if ((event.keyCode < 45) || (event.keyCode > 57) )
	{
		return false;
	} else {
		var re =/^(-)?(\d)*(\.(\d){2})?$/;

		if (value.indexOf("\.") == -1) {
			;
		} else {
			if (event.keyCode == 46) {
				return false;
			} else {
				if (re.test(value)) {
					return  false;
				}
			}
		}
	}
}
function isInt(value) {
	if ((event.keyCode < 45) || (event.keyCode > 57 ) )
	{
			var re =/^\d*$/;
			if (re.test(value)) {
				return  false;
			}	
	} else if (event.keyCode == 46)  {
		return false;
	}
}
/**
* 顏色選擇器
*/
function   selcolor(strCaller,URLToOpen){
        var   temp   =   window.showModalDialog(URLToOpen,strCaller,'dialogWidth:18.5em;dialogHeight:17.5em;help:1;status:0;resizable:0;center:1')
        if(   temp   ==   "undefined"   ||   temp   ==   null   ||   temp   ==   ""   )
        temp   =   strCaller;
        if(   temp   ==   "#NaNNaNNaN"   )   temp   =   ""
        return   temp;
}

function   fnInit(){
        for   (i=0;   i<document.all.length;   i++)
        document.all(i).unselectable   =   "on";
}

var   sInitColor   =   null;
function   callColorDlg(obj){

        if   (sInitColor   ==   null)
        //display   color   dialog   box
        var   sColor   =   dlgHelper.ChooseColorDlg();
        else
        var   sColor   =   dlgHelper.ChooseColorDlg(sInitColor);
        //change   decimal   to   hex
        sColor   =   sColor.toString(16);
        //add   extra   zeroes   if   hex   number   is   less   than   6   digits
        if   (sColor.length   <   6)   {
                var   sTempString   =   "000000".substring(0,6-sColor.length);
                sColor   =   sTempString.concat(sColor);
        }
        //change   color   of   the   text   in   the   div
        obj.value ="#"+sColor;
        sInitColor   =   sColor;
}

var flag=false;
function DrawImage(ImgD,ImgW,ImgH){
        var image=new Image();
        var iwidth = ImgW;  //定义允许图片宽度
        var iheight = ImgH;  //定义允许图片高度
        image.src=ImgD.src;
        if(image.width>0 && image.height>0){
                flag=true;
                if(image.width/image.height>= iwidth/iheight){
                        if(image.width>iwidth){
                                ImgD.width=iwidth;
                                ImgD.height=(image.height*iwidth)/image.width;
                        }else{
                                ImgD.width=image.width;
                                ImgD.height=image.height;
                        }
                        ImgD.alt=image.width+"×"+image.height;
                }
                else{
                        if(image.height>iheight){
                                ImgD.height=iheight;
                                ImgD.width=(image.width*iheight)/image.height;
                        }else{
                                ImgD.width=image.width;
                                ImgD.height=image.height;
                        }
                        ImgD.alt=image.width+"×"+image.height;
                }
        }
        else
        {
                ImgD.width=0;
                ImgD.height=0;
        }
}

var thumbShowLayer = null;
function show_icon(src, evt)
{
	var event = evt || window.event;
	
	var ltop = document.documentElement.scrollTop + event.clientY;
	var lleft = event.clientX;
	
	if(thumbShowLayer)
	{
		with(thumbShowLayer)
		{
			if(ltop > document.body.clientHeight/2)
				style.top = parseInt(ltop) - 200 - 10+"px";
			else
				style.top = 10 + parseInt(ltop)+"px";
			
			if(lleft > document.body.clientWidth/2)
				style.left = parseInt(lleft)-400-10+"px";
			else
				style.left = 10 + parseInt(lleft)+"px";
		}			
	}
	else
	{	
		thumbShowLayer = document.createElement("DIV");		
		with(thumbShowLayer)
		{
			style.position = "absolute";		
			style.top = 10+parseInt(ltop)+"px";
			style.left = 10 + parseInt(lleft)+"px";
				
			innerHTML = "<img src='"+src+"' width=250 style='border:1px solid black'>";
		}
		
		document.body.appendChild(thumbShowLayer);
	}
}
