// Cadbury colors	
var lightRed = "#f0a0b8";
var darkRed = "#a00000";
var pureWhite = "#ffffff";
var darkWhite = "#d6d6d6";
var pureBlack = "#000000";
var lightBlue = "#7888d8";
var darkBlue = "#1020b0";
var theYellow = "#ffffd0";
var lightGray = "#cccccc";
var pureBlack = "#000000";
var pDescriptor = 0;
var currMaterial = "what";
var boo = "shit";

var mEntry1 = new Entry ("prog", "Programming", "pointers.php", null);
var mEntry2 = new Entry ("map", "Google Map API", "/map.php", null);
var mEntry3 = new Entry ("elo", "ELO Ratings", "ratings.php", null);
var mEntry4 = new Entry ("res", "Digital Paintings", "painting.php", null);
var mEntry5 = new Entry ("for", "Experimental Forum", "/phpbb/nfphpbb", null);

var mainEntries = new Array (mEntry1, mEntry2, mEntry3, mEntry4, mEntry5);

function Menu (id, title, entries)
{
	this.id = id;
	this.title = title;
	this.entries = entries;
	this.Create = Create;
	this.Place = Place;
	this.ShowTitle = ShowTitle;
}
function Create ()
{
	alert ("Create method");
}
function Place2 ()
{
	document.write ('<div class="drop"><div class="contents" id="' + this.id + '">');
	for (i = 0; i < this.entries.length; i++)
	{
		if (this.entries [i].eType == "page")
		{
			//alert (' onclick="Click \(\"' + this.entries [i].eType + '\")";>');
			document.write ('<div class="section" id="' + this.id + '-' + i + '"' +
						' onclick="Click (' + i + ')";>');
			document.write (this.entries [i].text);
			document.write ('</div>');
		}
		else
		{
			placeSub (this.entries [i]);
		}
							
	}
	document.write ('</div></div>');
}

function Place ()
{
	document.write ('<div class="drop"><div class="contents" id="' + mainMenu.id + '">');
	for (i = 0; i < mainMenu.entries.length; i++)
	{
		if (mainMenu.entries [i].eType == "page")
		{
			theVar = '<div class="section" id="' + mainMenu.id + '-' + i + '" >';
			theVar += '<a class="poop" href="' + mainMenu.entries [i].page + '">';
			theVar += mainMenu.entries [i].text;
			theVar += '</a></div>';
			document.write (theVar);
		}
	}
	document.write ('</div></div>');
}

function placeSub (subMenu)
{
	alert (subMenu.title);
}

function ShowTitle ()
{
	document.getElementById (this.id).innerHTML = "<center><b>" + this.title + "</b></center>";
}
function Click (index)
{
	//alert (index);
	location = mainMenu.entries [index].page;
}
function Entry (id, text, page, menu)
{
	this.id = id;
	this.text = text;
	if (page != null) 
	{
		this.eType = "page";
		this.page = page;
	}else{
		this.eType = "menu";
		this.menu = menu;
	}
	/*
	alert (page);
	this.Click = function (page)
	{
		alert (page);
	}
	*/
}
/*
menuEntry
	text
	destination
	submenu
	onclick
	onmouseover
	onmouseout
	
menu
	entry array
	positionType
	coordinates
	dropShadow image
	background color
	background image
	outerBorderThickness
	innerBorderThickness
	outerPadding
	innerPadding
*/	


function buildMenu (descriptor)
{
var menu = '<div class="drop"><div class="contents"><div class="section" id="what" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #000000; border: 0px solid #ff0000;">What is a Pointer?</div>';
menu += '<div class="section" id="how" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">How Pointers Work</div>';
menu += '<div class="section" id="conf" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Confustoids</div>';
menu += '<div class="section" id="not" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">What is <strong><em>not</em></strong> a Pointer?</div>';
menu += '<div class="section" id="arith" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Pointer Arithmetic</div>';
menu += '<div class="section" id="sneak" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Sneaky Pointers</div>';
menu += '<div class="section" id="nullp" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">The NULL Pointer</div></div></div>';
document.write (menu);

}
function apiMenu (descriptor)
{
var menu = '<div class="drop"><div class="contents"><div class="section" id="api" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #000000; border: 0px solid #ff0000;">The Google Maps API</div>';
menu += '<div class="section" id="place" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Placing a Map</div>';
menu += '<div class="section" id="info" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">The Information Area</div>';
menu += '<div class="section" id="firing" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Firing the Sucker Up</div>';
menu += '<div class="section" id="marker" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Placing Markers</div>';
menu += '<div class="section" id="event" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Events & Listeners</div>';
menu += '<div class="section" id="wind" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Information Windows</div></div></div>';
document.write (menu);

}
function exceptMenu (descriptor)
{
var menu = '<div class="drop"><div class="contents"><div class="section" id="except" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #000000; border: 0px solid #ff0000;">Using Exceptions</div>';
menu += '<div class="section" id="feature" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Features</div>';
menu += '<div class="section" id="info" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">The Information Area</div>';
menu += '<div class="section" id="firing" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Firing the Sucker Up</div>';
menu += '<div class="section" id="marker" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Placing Markers</div>';
menu += '<div class="section" id="event" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Events & Listeners</div>';
menu += '<div class="section" id="wind" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Information Windows</div></div></div>';
document.write (menu);

}
function rateMenu (descriptor)
{
var menu = '<div class="drop"><div class="contents"><div class="section" id="QandA" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #000000; border: 0px solid #ff0000;">Questions &amp; Answers</div>';
menu += '<div class="section" id="how" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">How Ratings Work</div>';
menu += '<div class="section" id="FV" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Freeverse Ratings</div></div></div>';
document.write (menu);
}
function mainMenu (descriptor)
{
var menu = '<div class="drop"><div class="contents"><div class="section" id="prog" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #000000; border: 0px solid #ff0000;">Programming</div>';
menu += '<div class="section" id="map" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">Google Map API Usage</div>';
menu += '<div class="section" id="elo" onClick="moveNext (this.id);" style="cursor: pointer; font-weight: bold; font-size: smaller; line-height: 1.5; color: #1020b0; border: 0px solid #ff0000;">ELO Ratings</div></div></div>';
document.write (menu);
}

function itemLeft (obj)
{
	var mb = document.getElementById ('obj');
	return mb.offsetLeft;
}
function itemTop (obj)
{
	var mb = document.getElementById ('obj');
	return mb.offsetTop;
}
function itemHeight (obj)
{
	var mb = document.getElementById ('obj');
	return mb.offsetHeight;
}
function pageWidth ()
{
	return document.body.clientWidth;
}
function dickhover (mode)
{
	//alert ("hover");
	var o = document.getElementById ("dicksub");
	if (mode == 'over')
	{
		o.style.visibility = "visible";
		o.style.display = "block";
	}
	else
	{
		o.style.visibility = "hidden";
		o.style.display = "none";
	}
}
function flyout (oID, state)
{
	//alert ("flyout");
	box = document.getElementById (oID.id + "box");
	if (state == "visible")
	{
		bg = darkBlue;
		fg = pureWhite;
	}
	else
	{
		bg = theYellow;
		fg = pureBlack;
	}
	oID.style.backgroundColor = bg;
	oID.style.color = fg;
	box.style.visibility = state;
	box.style.top = oID.offsetTop + oID.offsetHeight + "px";
	box.style.left = oID.offsetLeft + "px";
	//alert (box.offsetWidth + ", " + (pageWidth () / 3));
	//alert (box.offsetWidth + box.offsetLeft + ", " + pageWidth ());
	if ((box.offsetWidth < (pageWidth () / 3)) &&
		(box.offsetWidth + box.offsetLeft > (pageWidth () - 30)))
	{
		//alert ("shift it");
		box.style.left = oID.offsetLeft - (pageWidth () / 3) + "px";
	}
	/*
	else 
	{
		alert ("okay");
		box.style.left = oID.offsetLeft + "px";
	}
	*/
	return false;
}
function moveNext (mPage)
{
	//alert ("mpage: " + mPage);
	if (mPage == currMaterial) return;
	//alert (currMaterial);
	scroll (0, 0);
	var thePart = document.getElementById (currMaterial);
	var theNew = document.getElementById (mPage);
	thePart.style.color = "#1020b0";
	theNew.style.color = "#000000";
	//alert (currMaterial + "material");
	thePart = document.getElementById (currMaterial + "material");
	thePart.style.visibility = "hidden";
	thePart.style.display = "none";
	if (mPage == "what" || mPage == "QandA" || mPage == "api")
	{
		thePart = document.getElementById ("masthead");
		thePart.style.visibility = "visible";
		thePart.style.display = "block";
		thePart = document.getElementById ("leadin");
		thePart.style.visibility = "visible";
		thePart.style.display = "block";
		thePart = document.getElementById ("intro");
		thePart.style.visibility = "visible";
		thePart.style.display = "block";
		thePart = document.getElementById ("aq");
		thePart.style.visibility = "visible";
		thePart.style.display = "block";
	} else {
		thePart = document.getElementById ("masthead");
		thePart.style.visibility = "hidden";
		thePart.style.display = "none";
		thePart = document.getElementById ("leadin");
		thePart.style.visibility = "hidden";
		thePart.style.display = "none";
		thePart = document.getElementById ("aq");
		thePart.style.visibility = "hidden";
		thePart.style.display = "none";
	}
	currMaterial = mPage;
//	alert (currMaterial);
	thePart = document.getElementById (currMaterial + "material");
	thePart.style.visibility = "visible";
	thePart.style.display = "block";
//	alert ("Move on, buddy");
}
function initObjects ()
{
	document.write ('<table background="images/paper.jpg" border="1" cellspacing="0" cellpadding="0"><tr><td>');
}
function closeDocument ()
{
	document.write ('</td></tr></table>');
}
function contact ()
{
	location.href = 'mailto:dawei@daweidesigns.com';
}
function credits ()
{
	var cred;
	var credWin;
	var specWin;
	cred = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link rel="stylesheet" type="text/css" href="dawei.css"><title>Credits</title></head><body><div style="background-image: url(&quot;images/paper.jpg&quot;); padding: 50px 50px 50px 50px; border: 2px solid #000000;"><table border="0"><tr><td><h3><center>Credits</center></h3></td></tr><tr><td align="left">Thanks to all the DevShed C/C++ forum members for their suggestions and for contributing to the correctness of the material.<p>A special thanks to Grumpy, Scorpions4ever, and Infamous; Grumpy and Scorp for the time spent in attempting to promote clarity as well as accuracy; Infamous for his suggestions "from the viewpoint of a n00b" and particulary for his suggestion that I add a few definitions that show via flyout when moused over.</p><p>I unashamedly ripped and adapted some presentational thangys from Scorpions4ever\'s tutorial on <a href="http://www.mayukhbose.com/tutorials/overloading/">overloading operators</a>, which I highly recommend.</td></tr></table></div></body></html>';
	specWin = "width=700,height=450,top=30,left=30," +
	  			"screenx=30,screeny=30," +
			  	"resizable=yes,scrollbars=yes";
	credWin = enlarge ("", specWin);
	credWin.document.write (cred);
	credWin.document.close ();
}
function mapCredits ()
{
	var cred;
	var credWin;
	var specWin;
	cred = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link rel="stylesheet" type="text/css" href="dawei.css"><title>Credits</title></head><body><div style="background-image: url(&quot;images/paper.jpg&quot;); padding: 50px 50px 50px 50px; border: 2px solid #000000;"><table border="0"><tr><td><h3><center>Credits</center></h3></td></tr><tr><td align="left"><p>Son, you too can be a stah! Contribute to the correctness of this material in any way you like, and yo\' name will go up in lights! That includes typos, spelling and grammatical errors, technical errors, and good suggestions on how to improve the application. </p><p>Thanks to&lt;fill in the blank&gt;</p><p>A special thanks &lt;fill in some more&gt; </p></td></tr></table></div></body></html>';
	specWin = "width=700,height=450,top=30,left=30," +
	  			"screenx=30,screeny=30," +
			  	"resizable=yes,scrollbars=yes";
	credWin = enlarge ("", specWin);
	credWin.document.write (cred);
	credWin.document.close ();
}
var globalWin;
function enlarge (wURL, sp)
{
	var specs = "width=800,height=600,top=30,left=30," +
	  			"screenx=30,screeny=30," +
			  	"resizable=yes,scrollbars=yes";
	if (sp) specs = sp;
	if (globalWin)
	{
		globalWin.close ();
		globalWin = "";
	}
	popWin = open (wURL, "popWindow", specs);
	popWin.focus ();
	globalWin = popWin;
	return popWin;
}
function show (picChoice)
{
	var dest = document.getElementById ("enlargement");
	var ident = picChoice.id;
	var txt;
	dest.src = picChoice.alt;
	if (ident == "thumb1")
	{
		txt = document.getElementById ("textOne");
		txt.innerText = "First Round";
		txt = document.getElementById ("textTwo");
		txt.innerText = "#10 Thread, Rings and Chains.";
		txt = document.getElementById ("textThree");
		txt.innerText = "The coin, for size reference, is a quarter.";
	}
	else if (ident == "thumb2")
	{
		txt = document.getElementById ("textOne");
		txt.innerText = "Inner Ring Detail";
		txt = document.getElementById ("textTwo");
		txt.innerText = "The knots are free to slide until fastened off or too much friction accumulates.";
		txt = document.getElementById ("textThree");
		txt.innerText = "Approximately dime sized.";
	}
	else if (ident == "thumb3")
	{
		txt = document.getElementById ("textOne");
		txt.innerText = "Josephine Knot";
		txt = document.getElementById ("textTwo");
		txt.innerText = "Not a true knot, but just loops.";
		txt = document.getElementById ("textThree");
		txt.innerText = "Because it isn't a symmetrical knot, this is about as large as they get without accumulating twist.  The coin is a dime.";
	}
	else if (ident == "thumb4")
	{
		txt = document.getElementById ("textOne");
		txt.innerText = "The Finished Motif";
		txt = document.getElementById ("textTwo");
		txt.innerText = "A gift for Boop, not too shabby for ol' Bubba's first attempt.";
		txt = document.getElementById ("textThree");
		txt.innerText = "The coin, again, is a quarter.";
	}
}

