function popup(caption, links, width, height, ltype)
{
   var newdiv = document.createElement('div');
   var transdiv = document.createElement('div');
   
   newdiv.setAttribute('id', 'cjbinner');
   transdiv.setAttribute('id', 'cjbtrans');
   transdiv.onclick = function() {removepopup();};
   
   //set new outter div style properties.
   transdiv.style.width = '100%';
   transdiv.style.height = '100%';
   transdiv.style.overflow = 'hidden';
   transdiv.style.textAlign = 'center';
   transdiv.style.filter = 'alpha(opacity=90)'; //This changes the opacity of the background 100 being opaque and 0 transparent
   transdiv.style.opacity = '0.9';
   transdiv.style.MozOpacity = '0.9';
   transdiv.style.zIndex = '10';
   transdiv.style.position = "fixed";
   transdiv.style.left = '0';
   transdiv.style.top = '0';
   transdiv.style.background = "#000000"; //This is the colour of the background, #FFFFFF = white and #000000 = black, #89c4e1 is blue.
   transdiv.style.border = "0px solid #000000";
   transdiv.innerHTML = '';
   
   var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body //---------------------gets page scroll offset
   var dsocleft=document.all? iebody.scrollLeft : pageXOffset
   var dsoctop=document.all? iebody.scrollTop : pageYOffset //-----------------------------------------------------------------------------------------------------
   
   if (window.innerWidth) // ---------------------------------------------------------------gets display window width and height
   {//if browser supports window.innerWidth
     var inheight = window.innerHeight;
   }
   else if (document.all) //else if browser supports document.all (IE 4+)
   {
     var inheight = document.body.clientHeight;
   } //-------------------------------------------------------------------------------------------------------------------------
   
   var divtop = ((inheight/2) - ((height+23)/2)) + dsoctop;
   
   if (divtop < 0) //if position of div is less than 0 (off the top of the page) make div starting point 0
   {
	   divtop = 0;
   } //---------------------------------------------------------------------------------------------------
   
   if (inheight >= (height+23)) // if the popup height is greater than the display window height, make pop up scroll with page, else keep it fixed central.
   {
     newdiv.style.position ='fixed';
	 divtop -= dsoctop; //fixed always goes by window rather than page, so remove scroll offset.
   }
   else 
   {
	   newdiv.style.position = 'absolute';
   } //---------------------------------------------------------------------------------------------------------------------------------------------------
   
   //set new inner div style properties.
   newdiv.style.width = width;
   newdiv.style.height = height + 23;
   newdiv.style.left = '50%';
   newdiv.style.top = divtop + 'px';
   newdiv.style.marginLeft = '-' + (width/2) + 'px';
   newdiv.style.zIndex = '20';
   
   var bordercolor = '#9c4e1b';
   var linktype = '';
   
   if(ltype == 'img' || ltype == null) //checks if link if for an img (or not set which defaults to img)
   {
	   linktype = '<img src="' + links + '" width="' + width + '" height="' + height + '"/>';
   }
   else // otherwise uses iframe to display link
   {
	   linktype = '<iframe src="' + links + '" width="' + width + '" height="' + height + '" style="border: none;" frameborder="0"></iframe>';
   }
   
   if (links)
   {
		newdiv.innerHTML = '<table border="0" cellpadding="0" cellspacing="0" margin="0"><tr style="height: 20px;"><td style="padding: 0 0 0 5px; border-width: 1px 0 1px 1px; border-style :solid; border-color: ' + bordercolor +  '; text-align: left; width: ' + (width - 20) + ';" background="scripts/barbg.png"><span id="cjbpopupcaption" style="font-family: Arial; font-weight: bold; color: #000000; font-size: 12px;">' + caption + '</span></td><td style="border-width: 1px 1px 1px 0; border-style: solid; border-color: ' + bordercolor +  '; text-align: right; width: 20px;" background="scripts/barbg.png"><img border="0" src="scripts/close.png" onclick="removepopup()"/></td></tr><tr><td colspan="2"style="border-width: 0 1px 1px 1px; border-style: solid; border-color:' + bordercolor +  '; ">' + linktype + '</td></tr></table>'; 
   }
   else
   {
	  newdiv.innerHTML = "";
   }
   
   document.body.appendChild(transdiv);
   document.body.appendChild(newdiv);
}

function removepopup()
{
  var olddiv = document.getElementById('cjbtrans');
  var olddiv2 = document.getElementById('cjbinner');
  document.body.scroll = 'yes';
  document.body.removeChild(olddiv);
  document.body.removeChild(olddiv2);
}
