// JavaScript Document

 this.obj=document.getElementsByName("ObjId");
 function sel1(){
    for(i=0;i<obj.length;i++)
     obj[i].checked=true;
     
  }
  
   function sel2(){
     for(i=0;i<obj.length;i++)
     obj[i].checked=!obj[i].checked;
  }
  
 function sel3(){
    for(i=0;i<obj.length;i++)
    obj[i].checked=false;
 }
 
//客户端Cookies创建函数

function SetCookie(name, value){
				var argv = SetCookie.arguments;
				var argc = SetCookie.arguments.length;
				var expires = argc > 2 ? argv[2] : null;
				var path = argc > 3 ? argv[3] : null;
				var domain = argc > 4 ? argv[4] : null;
				var secure = argc > 5 ? argv[5] : false;
				document.cookie = name + "=" + escape (value) + (expires == null ? "" : ("; expires=" + expires.toGMTString())) + (path == null ? "" : ("; path=" + path)) + (domain == null ? "" : ("; domain=" + domain)) + (secure == true ? "; secure" : "");
}
//COOKIES获取

function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1) endstr = document.cookie.length;
	return URLStringCov(unescape(document.cookie.substring(offset, endstr))).replace("'","");
}

function GetCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function URLStringCov(aStr){
	bStr="";
	cStr="";
	for(position=0;position<aStr.length;position++){
		bStr=aStr.substring(position,position+1);
		if(bStr=="+"){
			bStr=" ";
		}
		cStr=cStr+bStr;
	}
	return cStr
}

//当客户端进行FORM数据提交时，使该FORM区域内所有对象不可用
function FormSubmit(aForm){
	return true;
	for (var i=0;i<aForm.elements.length;i++)
    {
    var e = aForm.elements[i];
    e.disabled=true;
    }
	
}

//判断对象是否是一个可能的日期格式值，日期格式：YYYY-MM-DD
function isdate(strDate){
   var strSeparator = "-"; //日期分隔符
   var strDateArray;
   var intYear;
   var intMonth;
   var intDay;
   var boolLeapYear;

   strDateArray = strDate.split(strSeparator);

   if(strDateArray.length!=3) return false;

   intYear = parseInt(strDateArray[0],10);
   intMonth = parseInt(strDateArray[1],10);
   intDay = parseInt(strDateArray[2],10);

   if(isNaN(intYear)||isNaN(intMonth)||isNaN(intDay)) return false;

   if(intMonth>12||intMonth<1) return false;

   if((intMonth==1||intMonth==3||intMonth==5||intMonth==7||intMonth==8||intMonth==10||intMonth==12)&&(intDay>31||intDay<1)) return false;

   if((intMonth==4||intMonth==6||intMonth==9||intMonth==11)&&(intDay>30||intDay<1)) return false;

   if(intMonth==2){
      if(intDay<1) return false;

      boolLeapYear = false;
      if((intYear%100)==0){
         if((intYear%400)==0) boolLeapYear = true;
      }
      else{
         if((intYear%4)==0) boolLeapYear = true;
      }

      if(boolLeapYear){
         if(intDay>29) return false;
      }
      else{
         if(intDay>28) return false;
      }
   }

   return true;
}

//客户端图片渐变处理效果
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;
    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}
//控制图片对象在一定区域内等级显示
////////////////////////////////////////////////////////////////
//ImgAre(ImgObj,DWidth,DHeight),ImgAre(图片对象,指定宽,指定高)//
////////////////////////////////////////////////////////////////
function ImgAre(obj,MaxWidth,MaxHeight){
        //if(obj.resized) return;
        img=new Image();
        img.src=obj.src;
        if (img.width>MaxWidth && img.height>MaxHeight){
                if (img.width/img.height>MaxWidth/MaxHeight) {
                        obj.height=MaxWidth*img.height/img.width;
                        obj.width=MaxWidth;
                }else {
                        obj.width=MaxHeight*img.width/img.height;
                        obj.height=MaxHeight;
                }
        }else if (img.width>MaxWidth) {
                obj.height=MaxWidth*img.height/img.width;
                obj.width=MaxWidth;
        }else if (img.height>MaxHeight) {
                obj.width=MaxHeight*img.width/img.height;
                obj.height=MaxHeight;
        }else{
                obj.width=img.width;
                obj.height=img.height;
        }
        obj.resized=true;

}
