var popsrcdiv="<div ID='popsrcdiv' style='position:absolute;top:0px;left:0px;display:none;background-color:#fff;border:2px solid #ccc;filter:Alpha(Opacity=100);'><img style='position:absolute;left:0px;top:0px;margin:0px;filter:Alpha(Opacity=30);' ID='popsrcimg' /></div>";
document.write(popsrcdiv);


function InitPopsrc(){
	var objs=document.getElementsByTagName('img');
	for (var i=0;i<objs.length;i++){
		var oimg=objs[i];
		if (oimg.popsrc){
			//var add_hidden_img="<img src='"+oimg.popsrc+"' style='display:none;' />";
			//document.write(add_hidden_img);
			oimg.style.cursor='pointer';
			oimg.onmouseover=function(){
				AlphaStart('popsrcimg');
				ShowPopsrcdiv(this.popsrc,getLeft(this),getTop(this));
			}
			oimg.onmouseout=function(){
				AlphaEnd('popsrcimg');
				HidePopsrcdiv();
			}
		}
	}
}

var c_x=0;
var c_y=0;

function ResizePopsrc(){
	var pdiv=document.getElementById('popsrcdiv');
	var pimg=document.getElementById('popsrcimg');
    if (pimg.src){
		pdiv.style.width=pimg.width+4;
		pdiv.style.height=pimg.height+4;
		//debug.innerHTML=((c_x-pimg.width)-parseInt(pdiv.style.left));
		//debug.innerHTML=parseInt(pdiv.style.left);
		pdiv.style.left=parseInt(pdiv.style.left)+((c_x)-parseInt(pdiv.style.left))*0.12;
		pdiv.style.top=parseInt(pdiv.style.top)+((c_y-pimg.height-10)-parseInt(pdiv.style.top))*0.12;
		//pdiv.style.top+=((c_y-pimg.height)-pdiv.style.top);
    }else{
		pdiv.style.width=50+4;
		pdiv.style.height=50+4;
	}
	setTimeout('ResizePopsrc()',10);
}


function ShowPopsrcdiv(img,x,y){
	var pdiv=document.getElementById('popsrcdiv');
	var pimg=document.getElementById('popsrcimg');
	//pdiv.style.backgroundImage='url('+img+')';
	c_x=x;
	c_y=y;
	pimg.src=img;
	pdiv.style.display='';
}

function HidePopsrcdiv(){
	var pdiv=document.getElementById('popsrcdiv');
	pdiv.style.display='none';
}

function AlphaStart(o){
	obj=document.getElementById(o);
	if (obj.filters.Alpha.Opacity<100){
		obj.filters.Alpha.Opacity+=2;
		setTimeout("AlphaStart('"+o+"')",10);
	}else{
		obj.filters.Alpha.Opacity=100;
	}
}

function AlphaEnd(o){
	obj=document.getElementById(o);
	obj.filters.Alpha.Opacity=0;
}

//获取元素的纵坐标
function getTop(e){
var offset=e.offsetTop;
if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
return offset;
}
//获取元素的横坐标
function getLeft(e){
var offset=e.offsetLeft;
if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
return offset;
}

window.onload=function(){
	InitPopsrc();
	ResizePopsrc();
}
