// JavaScript Document
var cbQuotes = new Array("<img src='images/whyte.jpg' width='85' height='100' vspace='3' align='right' /><b>David Whyte (2002)</b><br />The Heart Aroused (Doubleday)<br />",
						 "<img src='images/gandhi.jpg' width='79' height='100' vspace='3' align='right' /><b>Mahatma Gandhi</b><br />1869 - 1948<br />",
						 "Colloquial term for a cigarette rolled from marijuana<br />",
						 "see <a href='http://www.human-inquiry.com/cishortg.htm' target='_blank'>http://www.human-inquiry.com/cishortg.htm</a><br />for the whole article<br />",
						 "<img src='images/anne_schuster.jpg' width='73' height='100' align='right' /><b>Anne Schuster</b><br />Foolish Delusions (Jacana Media 2005)<br />",
						 "<img src='images/whyte.jpg' width='85' height='100' align='right'/>&lsquo;Enough&rsquo; from The Heart Aroused<br />by David Whyte (Doubleday 2002)<br />",
						 "<img src='images/maternal_desire.jpg' width='67' height='100' hspace='5' vspace='2' align='right'/><b>Daphne De Marneffe (2004)</b><br />Maternal Desire: on children, love and  the inner life (Virago)<br />",
						 "<img src='images/RobertAJohnson.jpg' width='73' height='100' hspace='5' vspace='2' align='right' /><b>Robert A. Johnson (1991)</b><br />Owning your own shadow: understanding the  dark side of the psyche (Harper)<br />",
						 "<img src='images/wright_kit.jpg' width='80' height='110' align='right' /> <b>Kit Wright</b><br /><a href='magicbox-kit-wright.html' target='_blank'>'The Magic Box' </a>from CAT AMONG THE PIGEON  (Viking Kestrel, 1987)")


var ppQuotes = new Array("The CDRA  Biennial Practice Conference described as a &ldquo;space for development  practitioners from all over the world to meet learn and innovate together&rdquo; took  place over four days in May 2007, in the village of McGregor, South Africa. It was attended by 83 development  practitioners from 15 different countries and sought to contribute to an  &ldquo;emerging developmental discipline in the development sector, not from the  perspective of theory, but from the experience of thinking practitioners&rdquo;.<br />",
						 "The purpose  of the process inquiry group was to examine how the Biennial process served its  stated intentions by inquiring into our own experience of it. The group of 10  included artists, facilitators and participants. Its report will serve to  inform CDRA&rsquo;s planning of and preparations for future Biennials. <br />",
						 "<b><img src='images/B-Lievegoed.jpg' width='64' height='90' align='right' />Bernard Lievegoed  (1979)<br /></b>Phases: The Spiritual Rhythms in Adult Life.<br />Sophia Books Rudolf Steiner  Press: London <br />",
						 "<b><img src='images/tony-demello.jpg' width='78' height='90' align='right' />Anthony de  Mello S.J. (1990)</b><br />Awareness. Doubleday: New York<br />",
						 "<b><img src='images/whyte.jpg' width='85' height='100' align='right' />David Whyte  (2002)</b><br />The Heart Aroused: Poetry &amp; Preservation of the Soul in Corporate America.<br />New York: Doubleday<br />")
						 




// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false;

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE);

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var mouseX = 0;
var mouseY = 0;
var maxWidth = 0;

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
  	//alert('Browser is IE!');
    //mouseX = event.clientX + document.body.scrollLeft;
    //mouseY = event.clientY - document.body.scrollTop;
	mouseX = window.event.x + document.documentElement.scrollLeft;
	mouseY = window.event.y + document.documentElement.scrollTop;
	maxWidth = document.body.clientWidth+document.documentElement.scrollLeft;
  } else {  // grab the x-y pos.s if browser is NS
    mouseX = e.pageX;
    mouseY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (mouseX < 0){mouseX = 0}
  if (mouseY < 0){mouseY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  //document.Show.MouseX.value = tempX
  //document.Show.MouseY.value = tempY
  window.status = "mousePos X = " + mouseX + ", mousePos Y = " + mouseY + ', maxWidth = ' + maxWidth;
  return true
}

/// CLICK TO OPEN BOX  ///////////////
// Script by: www.jtricks.com
// Version: 20070301
// Latest version:
// www.jtricks.com/javascript/window/box_alone.html
//
// Moves the box object to be directly beneath an object.


/*
// Hides other alone popup boxes that might be displayed
function hide_box(obj)
{
    if (!document.getElementsByTagName)
        return;

    var all_divs = document.body.getElementsByTagName("DIV");

    for (i = 0; i < all_divs.length; i++)
    {
        if (all_divs.item(i).style.position != 'absolute' ||
            all_divs.item(i) == obj ||
            !all_divs.item(i).alonePopupBox)
        {
            continue;
        }

        all_divs.item(i).style.display = 'none';
    }
    return;
}
*/
// Shows a box if it wasn't shown yet or is hidden
// or hides it if it is currently shown
var boxdiv = null;
var boxid = 'q-box';
var lastQuote = '';
var closeTxt = '';

function quote_box(width, height, quote, ind){
    //var href = an.href;
	
    //boxdiv = document.getElementById(boxid);
	
    if (boxdiv != null){
		//alert("existing BOX!");
        if (boxdiv.style.display=='none'){
            //hide_other_alone(boxdiv);
            // Show existing box, move it
            // if document changed layout
            //move_box(an, boxdiv);
			
			//boxdiv.style.left = x + 'px';
			//boxdiv.style.top = y + 'px';
			//boxdiv.style.width = width + 'px';
			//boxdiv.style.height = height + 'px';
			
			boxdiv.style.display='block';
			

            // Workaround for Konqueror/Safari
            //if (!boxdiv.contents.contentWindow)
            //    boxdiv.contents.src = href;
        }
        else if(lastQuote == (quote+ind)){
            // Hide currently shown box.
            boxdiv.style.display='none';
        //return false;
		}
    }else{
		//alert("creating new BOX!");
		//hide_other_alone(null);
	
		// Create box object through DOM
		
		boxdiv = document.createElement('div');
		// italic bold size family
		boxdiv.style.font='normal normal 12px arial,serif';
					
		// Assign id equalling to the document it will show
		//boxdiv.setAttribute('id', href);
		boxdiv.setAttribute('id', boxid);
		
	
		// Add object identification variable
		boxdiv.alonePopupBox = 1;
	
		boxdiv.style.display = 'block';
		boxdiv.style.position = 'absolute';
		
		boxdiv.style.border = '1px solid';
		boxdiv.style.textAlign = 'left';
		boxdiv.style.padding = '4px';
		//boxdiv.style.border-color='#CCCCCC';
		boxdiv.style.background = '#FFF5EC'; //'#FFFFFF';
		document.body.appendChild(boxdiv);
	

		
	
		// Remove the following code if 'Close' hyperlink
		// is not needed.
		//<div class="close-button" align="center"><a href="javascript:;" onclick="closeBox()">Close</a></div>
		closeTxt = "<a href='javascript:;' onclick='closeBox()' class='close-button' align='center'>Close</a>";
		/*
		var offset = 0;
		var close_href = document.createElement('a');
		close_href.href = 'javascript:void(0);';
		close_href.onclick = function(){ closeBox(); }
		close_href.appendChild(document.createTextNode('Close'));
		boxdiv.appendChild(close_href);
		offset = close_href.offsetHeight;
		*/
	}
    // End of 'Close' hyperlink code.
	/*
    var contents = document.createElement('iframe');
    //contents.scrolling = 'no';
    contents.overflowX = 'hidden';
    contents.overflowY = 'scroll';
    contents.frameBorder = '0';
    contents.style.width = width + 'px';
    contents.style.height = (height - offset) + 'px';

    boxdiv.contents = contents;
    boxdiv.appendChild(contents);
	*/
	//alert('display style: ' + boxdiv.style.display);
	 //if (boxdiv.style.display != 'none' && lastQuote != (quote+ind)){
	if (boxdiv.style.display != 'none'){
		//alert('X: ' + x + ', Y: ' + y + ', W: ' + width + ',H : ' + height);
		var x = mouseX - (width/2);
		if(x < 5){x = 5;}
		
		var y = mouseY - height - 30;
		if(y < 5){
			y = mouseY + 15;
		}
		boxdiv.style.left = x + 'px';
		boxdiv.style.top = y + 'px';
		//boxdiv.style.left = x + 'px';
		//boxdiv.style.top = y  + 'px';
		boxdiv.style.width = width + 'px';
		boxdiv.style.height = height + 'px';
		
		// add the contents
		var txt = '';
		if (quote == 'cb'){
			txt = cbQuotes[ind];
		}
		else if(quote =='pp'){
			txt = ppQuotes[ind];
		}
		if(txt){
			boxdiv.innerHTML = txt+closeTxt;
		}
		lastQuote = quote+ind;
	 }
	
    //move_box(an, boxdiv);

	/*
    if (contents.contentWindow)
        contents.contentWindow.document.location.replace(href);
    else
        contents.src = href;
	*/
    // The script has successfully shown the box,
    // prevent hyperlink navigation.
    return false;
}

function closeBox(){
	if(boxdiv != null && boxdiv.style.display != 'none'){
		boxdiv.style.display = 'none';	
	}
}

/*
// FORM CODE
<a href="box_demo_history.html"
   onclick="return show_hide_box(this, 200, 270, '2px solid')">
Page history
</a>


*/
