
	var cords = [0,0];
	
	function update_mouse_cords(e) {		
		cords_tmp = get_mouse_cords(e);			
		if(cords_tmp)
			cords = cords_tmp;
	}
	
	document.onmousemove = update_mouse_cords;
	
	function get_target() {
		if(!target_id)
			return false;
		var preview_div_id = "over_p_" + target_id;
		
		return get_object(preview_div_id);
	}
	
	function enablePreviewPopup(id,img_url) {
		
		target_id = id;	
				
		if(img_url) {
			img = get_object("over_i_" + id);
			if(img) {
				img.onload = update_preview_position;
				img.src = img_url;
			}
		}
		
		
		document.onmousemove = update_preview_position;
	}

	function enablePreviewPopupHTML(id,displayHTML,link) {
		
		target_id = id;
		link_obj = get_object(link);
		if (displayHTML && link_obj) {
			popupDiv = get_target();
			popupDiv.innerHTML = displayHTML;

			if (popupDiv) {
				link_obj.onmousemove = update_preview_position;
			}
			
		}
		document.onmousemove = update_preview_position;
	}

	function disablePreviewPopup() {
	
		document.onmousemove = update_mouse_cords;
		
		hide_object(get_target());
		hide_object("iframe_over_id");
		target_id = null;
	}
	
	var OVER_ANCHOR 	= "right";
	var OVER_OFFSETX 	= 10;
	var OVER_OFFSETY 	= 10;


	target_id		= null;

	var windowSize 		= getWindowSize();
	
	
	function update_preview_position(e) {
		update_mouse_cords(e);
		_update_preview_position();		
	}
	
	
	function _update_preview_position() {
		
		if(!target_id)
			return false;
		
		windowSize = getWindowSize();
		target = get_target();		
		show_object(target);
		
		var newXcoord = newYcoord = 0;		
		var scrollLeft = scrollTop = 0;
		
		offsetHeight = OVER_OFFSETY + target.offsetHeight;
		offsetWidth = OVER_OFFSETX + target.offsetWidth;
		
		var iebody = (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
		scrollTop = document.all ? iebody.scrollTop : pageYOffset;
		scrollLeft = document.all ? iebody.scrollLeft : pageXOffset;
		
		if(document.all)
		{
			cords[0] += scrollLeft;
			cords[1] += scrollTop;
		}
		
		newYcoord = cords[1] + OVER_OFFSETY;		
		var maxHeight = false;
		
		if(newYcoord + offsetHeight > scrollTop + windowSize[1])
		{
			newYcoord = (scrollTop + windowSize[1]) - offsetHeight;
			maxHeight = true;
		}
		
		newXcoord = cords[0] + OVER_OFFSETX;
		
		if(OVER_ANCHOR=="right")
			newXcoord -= offsetWidth + OVER_OFFSETX;
		
		if (cords[0] < offsetWidth)
			newXcoord = 0;
		
		if(newXcoord == 0 && maxHeight == true)
		{
			newYcoord = cords[1] - (offsetHeight + OVER_OFFSETY);
		}
	
		if(target)
		{
			target.style.left = newXcoord + "px";			
			target.style.top = newYcoord + "px";
			target.style.zIndex = 99999;
			
			var iframe = get_object("iframe_over_id");
				
			iframe.style.width 	= target.offsetWidth  + "px";
			iframe.style.height	= target.offsetHeight + "px";
			iframe.style.top 	= target.style.top;
			iframe.style.left 	= target.style.left;
			iframe.style.zIndex 	= target.style.zIndex - 1;
			
			show_object(iframe);							
		}

	}