/* 
	Filename: jPopups.js
	Author: Steve Mansell
	Company: S&C Consulting Limited 
	Description: Provides popup support for contact us page
*/

var jPopup_container = null;
var jPopup_background = null;

function showPopup(url, title, refreshOnExit)
{
   jPopup_background = $('<div class="popupBackground"></div>');
   jPopup_container = $('<div class="popup"></div>');
   jPopup_container.html('<div class="titleBar"><h2>' + title + '</h2><a href="#" onclick="return(popup_close(' + refreshOnExit + '))"><img id="closeButton" src="/images/closeButton.gif" /></a></div><iframe scrolling="off" frameborder="0" src="' + url + '"></iframe>');
   
   // Hide both
   jPopup_background.hide();
   jPopup_container.hide();

   // Insert into the DOM
   $('body').prepend(jPopup_container);
   $('body').prepend(jPopup_background);


   // Position/size the background
   jPopup_background.css( { 
		'width' : document.documentElement.clientWidth,
		'height' : $(document).height(),
		'opacity' : '0.7',
		'position' : 'absolute'});

   // Position the popup

   jPopup_container.css( { 
		'left' : (document.documentElement.clientWidth/2) - jPopup_container.width()/2 + $(document).scrollLeft(),
		'top' : (document.documentElement.clientHeight/2) - jPopup_container.height()/2 + $(document).scrollTop()
		 });

   // Show the background
   jPopup_background.fadeIn('medium');

   // Show the dialogue
   jPopup_container.fadeIn('medium');
}

function popup_close(refreshOnExit)
{
   
   jPopup_container.hide();
   jPopup_background.fadeOut('medium');

   if (refreshOnExit)
   {
      document.location.href = document.location.href ;
   }
   return false;
}
