/* mini-site popup */
function openMBBmini()
{
var theURL = "/shows/murder_by_the_book/minisite/index.html"
var theWindow = window.open(theURL,"mbbpop","width=800,height=650,resizable=yes,top=10,left=10,scrollbars=no");
theWindow.focus();
}

/* code for chats layer on index page */
//write out the style
document.write ('<style type="text/css">');
document.write ('#popitmenu{position: absolute;background-color: #000000;;border:1px solid black;font: normal 12px Verdana;line-height: 18px;z-index: 100; display: none;padding:3px;font-size:10px;}');
document.write ('#popitmenu textarea{font-size:11px;}');
document.write ('#popitmenu img{ margin-bottom:5px; padding-left:5px;}');
document.write ('.rssgrplinks a{padding-right:10px;}');
document.write ('#rssindex .headline{font-size:13px;}');
document.write ('</style>');

/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var defaultWidth = "125"
var defaultHeight = "116"
var defaultMenuWidth=defaultWidth + "px" //set default menu width.


////No need to edit beyond here

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenu(e, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=writeButtons();
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=defaultWidth
menuobj.contentheight=defaultHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
eventX += 3;
eventY -= 50;
//need to double check on safari
//scroll = different location
//alert(mouseX(e));
//alert(mouseY(e));
//Find out how close the mouse is to the corner of the window

var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth){}
//move the horizontal position of the menu to the left by it's width
//menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight){}
//menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+eventY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.display="block"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.style.display="none"
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

//disable hide onclick
//if (ie5||ns6) document.onclick=hidemenu;

function writeButtons()
{
	var thistemp = "";
	thistemp += "<div><b>TRANSCRIPTS</b></div>";
	thistemp += '<div>&nbsp;<a class="mbb_whitetext" href="/chat/transcripts/2006/0920ellroy.html" target="_blank">James Ellroy</a><br />&nbsp;<a class="mbb_whitetext" href="/chat/transcripts/2006/0503connelly.html" target="_blank">Michael Connelly</a><br />&nbsp;<a class="mbb_whitetext" href="/chat/transcripts/2006/0424kellerman.html" target="_blank">Jonathan Kellerman</a><br />&nbsp;<a class="mbb_whitetext" href="/chat/transcripts/2006/0608fayekellerman.html" target="_blank">Faye Kellerman</a><br />&nbsp;<a class="mbb_whitetext" href="/talk/chat_transcripts/2004/0609scottoline.html" target="_blank">Lisa Scottoline</a></div>';
	return thistemp;
}

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

function writeMBBtunein(){
	document.write("Mondays at 10pm");
}

function openMBBgallery(ep){
	var theURL = "";
	var theWindow;
	if((ep == null) || (ep == "bios")){
		theURL = "/shows/murder_by_the_book/gallery/bios.html";
		theWindow = window.open(theURL,"mbbgallery","width=765,height=820,resizable=yes,top=10,left=10,scrollbars=yes");
	} else {
		theURL = "/shows/murder_by_the_book/gallery/" + ep + ".html";
		theWindow = window.open(theURL,"mbbgallery","width=765,height=670,resizable=yes,top=10,left=10,scrollbars=yes");
	}
	theWindow.focus();
}

function openMBBauthor(auth){
	var theURL = "/shows/murder_by_the_book/gallery/authors/";
	var theWindow;
	if(auth == null){
		theURL += "sbrown.html";
	} else {
		theURL += auth + ".html";
	}
	theWindow = window.open(theURL,"mbbauthor","width=765,height=670,resizable=yes,top=10,left=10,scrollbars=yes");
	theWindow.focus();
}

function openMBBbio(auth){
	var theURL = "/shows/murder_by_the_book/gallery/bios.html";
	var theAuthId = "?pic=";
	var theWindow;
	if(auth == null){
		theAuthId = "";
	} else {
		switch(auth){
			case 'sbrown':
				theAuthId += "1"
				break
			case 'dbaldacci':
				theAuthId += "2"
				break
			case 'lgardner':
				theAuthId += "3"
				break
			case 'jwambaugh':
				theAuthId += "4"
				break
			case 'lscottoline':
				theAuthId += "5"
				break
			case 'lfairstein':
				theAuthId += "6"
				break
			case 'hcoben':
				theAuthId += "7"
				break
			case 'fkellerman':
				theAuthId += "8"
				break
			case 'egeorge':
				theAuthId += "9"
				break
			case 'kreichs':
				theAuthId += "10"
				break
			case 'jkellerman':
				theAuthId += "11"
				break
			case 'lchild':
				theAuthId += "12"
				break
			case 'nsantora':
				theAuthId += "13"
				break
			case 'jellroy':
				theAuthId += "14"
				break
			case 'mconnelly':
				theAuthId += "15"
				break
			default:
				break
		}
		theURL += theAuthId;
	}
	theWindow = window.open(theURL,"mbbbio","width=765,height=820,resizable=yes,top=10,left=10,scrollbars=yes");
	theWindow.focus();
}
