function img_resize(){
  var table_width=document.getElementById("viewmain").offsetWidth;
  if(document.resize_image){
	if(document.resize_image.length >= 2){
	  for(i=0;i<document.resize_image.length;i++){
		if(document.resize_image[i].width > table_width){
			document.resize_image[i].width=table_width;
		}
	   }
	}else if(!document.resize_image.length) {
		if(document.resize_image.width > table_width){
			document.resize_image.width=table_width;
		}
		
	}
  }
}

function img_pos(x,y,z){ //modify by alfresco
	if (browser==1) {
		img_pos_x=event.x;
		img_pos_y=event.y;
	} else {
		img_pos_x=mX;
		img_pos_y=mY;
	}
		
	win_width=screen.width;
	new_width=img_pos_x-x + document.body.scrollLeft + parseInt(z);
	//aaa=parseInt(document.getElementById("img_over").style.width)
	if(new_width>win_width){
		 position = img_pos_x+x + document.body.scrollLeft - parseInt(z)-10;		
	}else position=img_pos_x-x + document.body.scrollLeft;
	if (browser==1) {
		document.getElementById("img_over").style.posLeft = position;       
		document.getElementById("img_over").style.posTop = img_pos_y - y + document.body.scrollTop;    
	} else {
		document.getElementById("img_over").style.left = position;       
		document.getElementById("img_over").style.top = img_pos_y - y + document.body.scrollTop;    
	}
} 

function img_show(str,img_width){ 
	var text;
	text ='<table align="center" border="0" cellpadding="0" cellspacing="0" class=shadow>';
	text += '<tr><td align=center><img src='+str+' border=0 name=pre_show width='+img_width+'></td></tr></table>';
	document.getElementById("img_over").innerHTML=text;
} 

function img_hide(){ 
	document.getElementById("img_over").innerHTML=''; 
}

function full_img(img){
	window.open('img_view.php?img='+img,'view_img','toolbar=no,scrollbars=yes,status=no')
}