// Open new window for descriptions

var newWindow;
var formVolume;
var flashtext = "";

function makeNewWindow(volume){
	if (!newWindow || newWindow.closed){
		newWindow = window.open("", "NewWin", "toolbar=no, status=yes, scrollbars, height=350, width=400, left=500, top=250, resizable")
		
		formVolume = volume;
		newWindow.focus();
		//force small delay for IE to catch up
		setTimeout("writeToWindow()", 50);
	}else{
		//window's already open; bring to front
		newWindow.focus();
	}
}

function writeToWindow(){
	//var windIntro = "window.document." + formVolume + ".introtitle.value";
	var windIntro = "window.document.getElementById(formVolume).introtitle.value";
	var windIntroTtl = eval(windIntro);
	
	//var windHosts = "window.document." + formVolume + ".hosts.value";
	var windHosts = "window.document.getElementById(formVolume).hosts.value";
	var windHostsTtl = eval(windHosts);
	
	//var windGuest = "window.document." + formVolume + ".guest.value";
	var windGuest = "window.document.getElementById(formVolume).guest.value";
	var windGuestTtl = eval(windGuest);
	
		//var windGuest = "window.document." + formVolume + ".guest.value";
	var windTopic = "window.document.getElementById(formVolume).topic.value";
	var windTopicTtl = eval(windTopic);
	
	//var windDescrip = "window.document." + formVolume + ".description.value";
	var windDescrip = "window.document.getElementById(formVolume).description.value";
	var windDescripTtl = eval(windDescrip);
	
	//var windVolume = "window.document." + formVolume + ".volumenumber.value";
	var windVolume = "window.document.getElementById(formVolume).volumenumber.value";
	var windVolumeTtl = eval(windVolume);
	
	
	//var windPodcast = "window.document." + formVolume + ".podcast.value";
	var windPodcast = "window.document.getElementById(formVolume).podcast.value";
	var windPodcast = eval(windPodcast);
	if (windPodcast !== "") {
		newpodcast = "<a href='http://marriage101.net/template/pages/mediapod2010.php?#" + windPodcast + "' target='_blank'>";
		newpodcastlink = "Listen to Podcast " + windVolumeTtl + "</a>";
		flashtext = " on our Flash podcast player &amp; view more information. Just enter the volume number into the box on the player and press play.";
	}else{
		newpodcast = "&nbsp;";
		newpodcastlink = "&nbsp;";
		flashtext = "&nbsp;";
	}
	
	
	//assemble content for new window
	var newContent = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>Marriage 101 Radio Podcast Show<\/title><link rel="stylesheet" type="text/css" href="http://marriage101.net/template/css/descriptpop.css"/><\/head>';
	newContent += '<body><div class="box2top"><h2>' + windIntroTtl + '<\/h2>';
	newContent += '<h3>' + windHostsTtl + '<\/h3>';
	newContent += '<h5>' + windGuestTtl + '<\/h5>';
	newContent += '<h5>' + windTopicTtl + '<\/h5>';
	newContent += '<p>' + windDescripTtl + '<\/p>';
	newContent += '<p class="italictxt">' + newpodcast + newpodcastlink + flashtext + '<\/p>';
	newContent += '<p class="closewindow"><a href="#" onclick="window.close()">Close Window</a><\/p>';
	newContent += '<\/div><\/body><\/html>';
	
	//write HTML to new window document
	newWindow.document.write(newContent);
	newWindow.document.close(); // close layout stream
}