$(function()  
{  
  var hideDelay = 500;    
  var currentID;  
  var hideTimer = null;  
  
  // One instance that's reused to show info for the current person  
	var container = $('<div id="popupContainer">' 
		+ '<div id="closeShell"><div class="close" id="popupClose"></div></div>'
		+ '<div id="popupArrowShell"><div id="popupArrow"></div></div>'  
		+ '<div id="popupContentShell"><div id="popupContentArch"></div></div>'  
		+ '</div>');  
  
  $('body').append(container);   
  
 $('#callpop-archive').live('click', function()  
  {  
      var content = $(this).attr('content');
	  
	  //var pageID = $(this).attr('detailid');  
  
  
      if (hideTimer)  
          clearTimeout(hideTimer);  
  
      var pos = $(this).offset();  
      var width = $(this).width(); 
	  if (ie6 || ie7){
	  	var leftAdj = -125;
	  } else {
		  var leftAdj = 0;
	  }
      container.css({  
          left: '668px',  
          top: '156px' ,
		  width:'248px',
		  height:'316px',
		  background:'transparent none',
		  padding:0,
		  margin:0
      });  
	  
  
    $('#popupContentArch').html(content);  
  		$('#popupContentArch').css({
			width:'192px',
			height:'326px'
	});
	
	$('#popupArrow').css({
		top: pos.top - 186 + 'px'  
	});
	$('.close').css ({
		left:'218px',
		top:'25px'
	});


	container.css('display', 'block');  
	var docHeight = $(document).height();
	var winHeight = $(window).height();
	var scrollHeight = pos.top + 400;
	if (scrollHeight > docHeight){
	  if (hideTimer) {
		  clearTimeout(hideTimer);  
	  }
	  hideTimer = setTimeout(function()  
		{  	
		  $(window).scrollTo(scrollHeight);
		}, 250); 
	} else {
		$(window).scrollTo(pos.top);
	}
}); 
 
 
  $('#popupClose').live('click', function()  
	{
         container.css('display', 'none');  
	});

}); 
