// JavaScript Document
function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 1001;
  var opacity = options.opacity || 20;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var parentdiv = options.parentdiv || '';
  if (parentdiv=='true')
  	{
  	var dark=parent.document.getElementById('darkenScreenObject');
	} else
		{
		var dark=document.getElementById('darkenScreenObject');
		}
  if (!dark) {	
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='fixed';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.  
  }
  if (vis) {
// Calculate the page width and height 
	if (parentdiv=='true')
		{
		if( parent.window.innerHeight) // Firefox 
			{
			var pageWidth = parent.window.innerWidth + parent.window.scrollMaxX + 'px';
			var pageHeight = parent.window.innerHeight + parent.window.scrollMaxY + 'px';
			}
			else if( parent.document.body.scrollHeight > parent.document.body.offsetHeight ) // all but Explorer Mac
				{
				var pageWidth = parent.document.body.scrollWidth + 'px';
				var pageHeight = parent.document.body.scrollHeight + 'px';
				}
				else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
					{ 
					var pageWidth = parent.document.body.offsetWidth + parent.document.body.offsetLeft + 'px'; 
					var pageHeight = parent.document.body.offsetHeight + parent.document.body.offsetTop + 'px'; 
					}
		} else
			{
			if(window.innerHeight) // Firefox 
				{
				var pageWidth = window.innerWidth + window.scrollMaxX + 'px';
				var pageHeight = window.innerHeight + window.scrollMaxY + 'px';
				}
				else if( document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
					{
					var pageWidth = document.body.scrollWidth + 'px';
					var pageHeight = document.body.scrollHeight + 'px';
					}
					else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
						{ 
						var pageWidth = document.body.offsetWidth + document.body.offsetLeft + 'px'; 
						var pageHeight = document.body.offsetHeight + document.body.offsetTop + 'px'; 
						}
			}

    // Calculate the page width and height   
	var pageWidth='100%';
    var pageHeight='100%';
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display='inline';    
  } else {
     dark.style.display='none';
  }
}


function open_window ()
	{
	window.scrollTo (0,0);
	grayOut(true,{'parentdiv':'true'});
	parent.document.getElementById('inline_frame').src="newsletter_frame.php";
	parent.document.getElementById('inline_frame_wrapper').style.display="inline";
	}
	
function close_window ()
	{
	grayOut(false,{'parentdiv':'true'});
	var newdiv = parent.document.createElement('div');
	parent.document.getElementById('inline_frame').src="";
	parent.document.getElementById('inline_frame_wrapper').style.display="none";
	}