String.prototype.trim = function() {
	return this.replace(/(^ +| +$)/, "");
}
//document.body.style.display='none';
function SetImgAutoSize(vWidth,vHeight) 
{ 
	//document.body.style.display='none';
	//alert(document.all.im.length);
	if (document.all.im == 'undefined' || document.all.im == null)
	{
		return;
	}
	
	if(document.all.im.length>1){
		for(i=0;i<document.all.im.length;i++){
			img = document.all.im[i];
			if(img.readyState=="complete"){
				AutoSize(img,vWidth,vHeight);
				//return false;//????????????????
			}
			else {
				img.onreadystatechange = ifComplete;				
				//ifComplete.arguments[0]=img;
			}
		}
	}else if(document.all.im.length=1){
		img = document.all.im;
		if(img.readyState=="complete"){
			AutoSize(img,vWidth,vHeight);
			//return false;//????????????????
		}
		else {
			img.onreadystatechange = ifComplete;
			//ifComplete.arguments[0]=img;
		}
	}
	//document.body.style.display='';
} 

function AutoSize1(img,vWidth,vHeight){
	//alert("("+img.width+","+img.height+")");
	var MaxWidth=vWidth;//???????????????? 
	var MaxHeight=vHeight;//???????????????? 
	var HeightWidth=img.offsetHeight/img.offsetWidth;//?????????? 
	var WidthHeight=img.offsetWidth/img.offsetHeight;//?????????? 
	var DefaultHeightWidth=MaxHeight/MaxWidth;
	//alert("test"+img.offsetHeight+img.fileSize);
	//if(img.offsetHeight>1) alert(img.offsetHeight);
	if(HeightWidth >= DefaultHeightWidth){ 
		if(img.height>MaxHeight){
			img.width=MaxHeight*WidthHeight;
			img.height=MaxHeight; 
		}
		//alert("("+img.width+","+img.height+")");
	}else{
		if(img.width>MaxWidth){
			img.height=MaxWidth*HeightWidth; 
			img.width=MaxWidth; 
		}
		//alert("("+img.width+","+img.height+")");
	} 
}

var flag=false; 
function AutoSize(ImgD,iwidth,iheight){ 
 //ImgD.style.display='none';
 var image=new Image(); 
 image.attachEvent("onload",loadImg);
 image.src=ImgD.src; 
 //alert(image.width + "="+image.height+image.width/image.height+" - "+ iwidth/iheight);
 
 function loadImg() {
 	
 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+"x"+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+"x"+image.height; 
  } 
 }
 ImgD.style.display='';
}
}

function search()
{
var url = "maincontrol?url=search&taskParams=";
//alert(url);
   //url = url+document.all.textfield.value;
   url = url+encodeURIComponent(document.all.textfield.value);
   url = url+","+document.all.selectedItem.value;
  // alert(url);
   window.location.href=url;
}

function SetDivStyle() {
	//var d = document.getElementsByTagName("DIV");
	var divColl = document.all.tags("DIV");
	for (i=0; i<divColl.length; i++) {
		whichEl = divColl(i).id;
		if (whichEl.indexOf("layer") != -1) {
			//alert("=="+whichEl.id);
			if (document.getElementById('tab2_'+whichEl).tBodies[0].rows[0].cells[0] == undefined) {
				document.getElementById('tab1_'+whichEl).tBodies[0].deleteRow(document.getElementById('tab1_'+whichEl).tBodies[0].rows[0].rowIndex);
			} else {
				var doc_ = eval(document.body.clientWidth) - 770;
				var tab1_ = eval(document.getElementById('tab1_'+whichEl).offsetWidth);
				var wid_ = 250 + 80*(i+1) + 0.5*doc_ - 0.5*tab1_;
				
				document.getElementById(whichEl).style.left=wid_+"px";//"255px";
			}
		}
  }
	
}

//ÆÁ±ÎÓÒ¼ü
if (window.Event) 
  document.captureEvents(Event.MOUSEUP); 
 
function nocontextmenu() 
{
 event.cancelBubble = true
 event.returnValue = false; 
 return false;
}
 
function norightclick(e) 
{
 if (window.Event) 
 {
  if (e.which == 2 || e.which == 3)
   return false;
 }
 else
  if (event.button == 2 || event.button == 3)
  {
   event.cancelBubble = true
   event.returnValue = false;
   return false;
  } 
}
 
document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others

//document.onselectstart=function(){return false;} 

//document.attachEvent("onclick", forbiddenClick);
//function forbiddenClick()
//{
//	return false;
//}

