// <!CDATA[
	
	var activePanel = '';
	var gw = '';
	var gh = '';

function showPanel(panel, w, h)
{
    darkenPage();
	var s_panel = document.getElementById(panel);
    
    // w is a width of the newsletter panel
    //w = 1000;
    // h is a height of the newsletter panel
    //h = 700;
    
    // get the x and y coordinates to center the newsletter panel
    xc = Math.round((document.body.clientWidth/2)-(w/2))
    //yc = Math.round((document.body.clientHeight/2)-(h/2))


		

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	//var yc = arrayPageScroll[1] + (arrayPageSize[3] / 5);    
	var yc = arrayPageScroll[1] + ((arrayPageSize[3] - h) / 2); 

	if ((h+20) > arrayPageSize[3]) {
		if (panel == 'rev_panel') popup('/reviews/dontheverb/index.php', '', 600, 600);
		if (panel == 'ill_panel') popup('/illustrause/hannah/index.php', '', 500, 680);
		if (panel == 'fif_panel') popup('/fif/satyricon/index.html', '', 1000, 475);
		if (panel == 'tnv1_panel') popup('/tnv/solomon/index.php', '', 1000, 700);
		if (panel == 'tnv2_panel') popup('/tnv/telfar/index.php', '', 1000, 700);
		if (panel == 'twy_panel') popup('/throwaway', '', 600, 600);
	}

	else {
	
    // show the newsletter panel
	s_panel.style.width = w + "px";
	s_panel.style.height = h + "px";
    s_panel.style.left = xc + "px";
    s_panel.style.top  = yc + "px";
    s_panel.style.display = 'block';

	//h = 300         ### for dev purposes ###
	//var	i_panel = document.getElementById('ill_panel2');
	//i_panel.style.height = h + "px";
	}
	
	activePanel = panel;

	
	// make the close panel show
	gw = xc + (w-9);
	gh = yc - 10;
	
	var x_panel = document.getElementById('x_panel');
	x_panel.style.left = gw + "px";
	x_panel.style.top  = gh + "px";
	x_panel.style.display = 'block';
		
}

function hidePanel()
{
    // hide the main panel
    var s_panel = document.getElementById(activePanel);
    s_panel.style.display = 'none';
	// hide the close panel
	var x_panel = document.getElementById('x_panel');
	x_panel.style.display = 'none';
    // lighten the page again
    LightenPage();
}

// this function puts the dark screen over the entire page
function darkenPage()
{
	var opacStart = 0;
	var opacEnd = 80;
	var millisec = 500;
	var id = 'bg_layer';
	
    var bg_layer = document.getElementById('bg_layer');
    bg_layer.style.height = document.body.parentNode.scrollHeight + 'px';
    bg_layer.style.display = 'block';

	    var speed = Math.round(millisec / 100);
	    var timer = 0;

	    //determine the direction for the blending, if start and end are the same nothing happens
	    if(opacStart > opacEnd) {
	        for(i = opacStart; i >= opacEnd; i--) {
	            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
	            timer++;
	        }
	    } else if(opacStart < opacEnd) {
	        for(i = opacStart; i <= opacEnd; i++)
	            {
	            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
	            timer++;
	        }
	    }
	}

// this function removes the dark screen and the page is light again
function LightenPage()
{
    var bg_layer = document.getElementById('bg_layer');
    bg_layer.style.display = 'none';
    bg_layer.style.opacity = 0;
	bg_layer.style.MozOpacity = 0;
	bg_layer.style.KhtmlOpacity = 0;
	bg_layer.style.filter = "alpha(opacity=0)";
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}


// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------

function popup(mylink, name, width, height)
 {
 	ww = (parseInt(width));
 	wh = (parseInt(height));

     settings="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+ww+",height="+(wh);


 	var windowname = (name.indexOf(' ')!=-1)?name.substring(0, name.indexOf(' ')):name;

 	if (! window.focus)return true;
 	var href;
 	if (typeof(mylink) == 'string')
    		href=mylink;
 	else
    		href=mylink.href;
 	MyNewWindow=window.open(href, windowname, settings);

 	return false;
 }

 function targetopener(mylink, closeme, closeonly)
 {
 if (! (window.focus && window.opener))return true;
 window.opener.focus();
 if (! closeonly)window.opener.location.href=mylink.href;
 if (closeme)window.close();
 return false;
 }

function movepic(img_name,img_src) {
document[img_name].src=img_src;
}

if (document.images)
{
  preload_image_object = new Image();
  // set image url
  image_url = new Array();
  image_url[0] = "http://www.tofrommag.com/wod_colors_r.gif";
  image_url[1] = "http://www.tofrommag.com/wod_colors.gif";

   var i = 0;
   for(i=0; i<=1; i++) 
     preload_image_object.src = image_url[i];
}

// ]]>


