var imgArr = new Array();

function showPopUp(e) {
	if (!e) var e = window.event;
	
	var obj = (window.event) ? e.srcElement : e.target;
	
	
      var x = 0,y = 0;
       x = e.clientX;
       y = e.clientY;
       if (document.pageYOffset)
       {
           x += document.pageXOffset;
           y += document.pageYOffset;
       }
       else if(document.documentElement && document.documentElement.scrollTop)
       {
           x += document.documentElement.scrollLeft;
           y += document.documentElement.scrollTop;
       }
       else if(document.body)
       {
           x += document.body.scrollLeft;
           y += document.body.scrollTop;
       }
	
   	var divWidth = 34+parseInt(obj.getAttribute("width"));
   	var divHeight = 34+parseInt(obj.getAttribute("height"));
   	
    var newLeft = x-divWidth;  
    if(newLeft < 5) {
	newLeft = 5;   
    } 
    
    var newTop = y-20-divHeight;
    if(newTop < 0) {
	newTop = y+30;
    }
         	  
	while( obj.tagName != 'BODY' && obj.className != "screenshot_pop_up_link" ) 
		obj = (w3)? obj.parentNode : obj.parentElement;
		
	if(obj) {
		var imgTag = document.getElementById('pop_up_img');
		imgTag.src = obj.getAttribute('href');
		
		var theDiv = document.getElementById('screenshot_pop_up');
		
		theDiv.style.width = (divWidth-35)+'px';
		theDiv.style.height = (divHeight-35)+'px';
		
		theDiv.style.left = newLeft+'px';
		theDiv.style.top= newTop+'px';	   
		theDiv.style.visibility = 'visible';
	}
	return false;
}

function hidePopUp(e) {
	var theDiv = document.getElementById('screenshot_pop_up');
	theDiv.style.visibility = 'hidden';
	return false;
}

function initPage() {
	var links = getElementsByClass('screenshot_pop_up_link');
	
	for(var i=0; i<links.length; ++i) {
		links[i].onmouseover=showPopUp;
		links[i].onmouseout=hidePopUp;
		
		imgArr[i] = new Image(
			links[i].getAttribute("width"),
			links[i].getAttribute("height")
		);
		imgArr.src = links[i].getAttribute("href");
	}
}

function getElementsByClass(pClass, pContainer) {
	pContainer = pContainer||document;
	var allTags = pContainer.all||pContainer.getElementsByTagName('*');
	var result = new Array();

	for(var i=0; i<allTags.length; ++i) {
		if( allTags[i].className == pClass)
			result[result.length] = allTags[i];
	}
	return result;
}

onload=initPage;
