function writePageWrapTop(debug) {
	if(debug=="debug") {document.write('<a name="top"></a><table class="pagewrapper" border="1" cellspacing="0" cellpadding="0">');}
	else {document.write('<a name="top"></a><table class="pagewrapper" border="0" cellspacing="0" cellpadding="0">');}
}

function writeFBstartup() {
	document.write('<div id="fb-root"></div>');  // This code is from http://developers.facebook.com/docs/reference/plugins/like-box/
	(function(d, s, id) {
	  var js, fjs = d.getElementsByTagName(s)[0];
	  if (d.getElementById(id)) return;
	  js = d.createElement(s); js.id = id;
	  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
	  fjs.parentNode.insertBefore(js, fjs);
		}
		(document, 'script', 'facebook-jssdk'));
}

function writeHeader(debug) {
	if((typeof(window.cols) === "undefined") && (typeof(cols) === "undefined")) {cols=5;}
	else if (cols!=3) {cols=5;}
	else {;}//cols==3 is the only other expected condition right now. let it fall through. 
	document.write('<tr style="height:70px"><td colspan="' + cols + '" valign="top">');  // colspan of entire page
	if(debug=="debug") {document.write('<table width="100%" border="1" cellspacing="0" cellpadding="0">');alert("Cols: " + cols);}
	else {document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');}
	document.write('<tr>');
	document.write('<td><IMG SRC="/images/logo_banner4.jpg" border="0" width="828" height="115" alt="logo"></td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('</td></tr>');
}




function writeFooter(debug) {
	if((typeof(window.cols) === "undefined") && (typeof(cols) === "undefined")) {cols=5;}
	else if (cols!=3) {cols=5;}
	else {;}//cols==3 is the only other expected condition right now. let it fall through. 
	document.write('<tr><td colspan="' + cols + '" class="horizontal_line"></td></tr>');
	document.write('<tr style="height:0px"><td colspan="' + cols + '" valign="bottom">'); // colspan of entire page
	if(debug=="debug") {document.write('<table width="100%" border="1" cellspacing="0" cellpadding="0" class="footer">');}
	else {document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" class="footer">');}
	document.write('<tr>');
	document.write('<td width="33%" align="left">');
	document.write('&nbsp;&nbsp;&copy;&nbsp;Santa Clara Dog Training Club');
	document.write('</td>');
	
	document.write('<td width="33%" align="center">');
	document.write('P.O. Box 6407 San Jose, CA 95150');
	document.write('</td>');
	
	document.write('<td width="33%" align="right">');
	document.write('(408) 377-0221&nbsp;&nbsp;');
	document.write('</td>');
	
	document.write('</tr>');
	document.write('</table>');
	document.write('</td></tr>');
}

function writeNav() {
	document.write('<tr>');
	document.write('	<td width="110" valign="top" class="navBar">');  // width was set here to 140


	document.write('<div class="nav"><a href="/index.html">Home</a></div>');
	document.write('<div class="nav"><a href="/classes.html">Classes</a></div>');
	document.write('<div class="nav"><a href="/testing.html">Testing</a></div>');
	document.write('<div class="nav"><a href="/faq.html">FAQ</a></div>');
	document.write('<div class="nav"><a href="/calendar.html">Calendar</a></div>');
	document.write('<div class="nav"><a href="/links.html">Links</a></div>');
	document.write('<div class="nav"><a href="/about.html">About Us</a></div>');
	document.write('<div class="nav"><a href="/contact.html">Contact Us</a></div>');
	document.write('<div class="nav"><a href="/galleries/galleries.html">Photo Gallery</a></div>');
	document.write('<div class="nav"><a href="/members.html">For Members</a></div><br><br>');
//	document.write('<div class="nav"><a href="faq//faq.html">FAQ</a></div>');
	
	document.write('<!-- Facebook Badge START --><div class="ad"><a href="http://www.facebook.com/SantaClaraDog" target="_new_facebook" title="Santa Clara Dog Training Club"><img src="/images/facebook.gif" width="100" height="38" style="border: 0px;" /></a></div><!-- Facebook Badge END -->');

	document.write('<!-- AKC LOGO --><div class="ad"><a href="about.html#akc_member_club"><img src="/images/akc.png" width="100" height="100" border="0"><br>AKC Member Club</a></div>');


	document.write('	</td>');
	document.write('	<td width="6">&nbsp;'); // This is the spacer from the page content. Set in pixels.
	document.write('	</td>');
}

function loadAdCatalog() {
linkArray = new Array();
imageArray = new Array();
altArray = new Array();
count=0;
// this is the list of possible ads
// 1) location to link to, 2) image to show, 3) alt text for image
//	"/events/rattlesnake_aversion.html","/images/ad_rat.jpg","sign up for rattlesnake aversion training",
var loadArray = [
	"/events/rattlesnake_aversion.html","/images/ad_rat.jpg","sign up for rattlesnake aversion training",
	"/classes.html#agility_fundamentals","/images/AgilityAd2.jpg","sign up for agility fundamentals",
	"/classes.html#puppy","/images/PuppyClassAd2.jpg","sign up for puppy class",
	"/classes.html#novice_rally","/images/ad_rally.jpg","try rally"]
	for(var i=0; i<loadArray.length; i++)
	{
		if (count==0) {
			currDim=linkArray.length;
			linkArray[currDim]=loadArray[i];}
		if (count==1) {
			currDim=imageArray.length;
			imageArray[currDim]=loadArray[i];}
		if (count==2) {
			currDim=altArray.length;
			altArray[currDim]=loadArray[i];}
		count=count+1;
		if (count==3) {
			count=0;}
	}
numAds = linkArray.length;
}

function adChooser() {
	loadAdCatalog();
	// numAds, number of ads, is determined by number loaded in above function
	adNumOne = Math.floor(Math.random()*numAds); // Gives a random number between 0 and 3
	//alert(altArray[adNumOne]);
	do
		{adNumTwo = Math.floor(Math.random()*numAds);}
	while (adNumOne==adNumTwo);
	//alert(altArray[adNumTwo]);
}

function writeRightCol() { // This is the ad strip
	adChooser();
	document.write('	<td width="0">&nbsp;');  // This is the spacer from the page content. Set in pixels.
	document.write('	</td>');
	document.write('	<td width="168" valign="top">');  // This is the width of the ad strip. Set in pixels.
	document.write('	<a href="' + linkArray[adNumOne] + '"><IMG class="photo_ad" SRC="' + imageArray[adNumOne] + '" border="0" width="168" height="280" alt="' + altArray[adNumOne] + '"></a>');  // Ad 1
	document.write('	<a href="' + linkArray[adNumTwo] + '"><IMG class="photo_ad" SRC="' + imageArray[adNumTwo] + '" border="0" width="168" height="280" alt="' + altArray[adNumTwo] + '"></a>');  // Ad 2
	document.write('	<div class="fb-like-box" data-href="http://www.facebook.com/santaclaradog" data-width="168" data-height="280" data-show-faces="false" data-stream="true" data-header="false" style="height:280px;"></div>');
	document.write('	</td>');
}

function loadQuoteCatalog() {
quoteArray = new Array();
authorArray = new Array();
count=0;
// this is the list of possible quotes
// 1) quote, 2) author (unknown if not known)
var loadQArray = [
	"Dogs are our link to paradise. They don't know evil or jealousy or discontent. To sit with a dog on a hillside on a glorious afternoon is to be back in Eden, where doing nothing was not boring--it was peace.","Milan Kundera",
	"Did you ever walk into a room and forget why you walked in? I think that is how dogs spend their lives.","Sue Murphy",
	"No matter how little money and how few possesions you own, having a dog makes you rich.","Louis Sabin"]
	for(var i=0; i<loadQArray.length; i++)
	{
		if (count==0) {
			currDim=quoteArray.length;
			quoteArray[currDim]=loadQArray[i];}
		if (count==1) {
			currDim=authorArray.length;
			authorArray[currDim]=loadQArray[i];}
		count=count+1;
		if (count==2) {
			count=0;}
	}
numQuotes = quoteArray.length;
}

function quoteChooser() {
	loadQuoteCatalog();
	// numQuotes, number of quotes, is determined by number loaded in above function
	quoteNumOne = Math.floor(Math.random()*numQuotes); // Gives a random number between 0 and 3
	//alert(altArray[adNumOne]);
	do
		{quoteNumTwo = Math.floor(Math.random()*numQuotes);}
	while (quoteNumOne==quoteNumTwo);
	//alert(altArray[adNumTwo]);
}


function writeRightColQuote() { // This is the quote strip
	quoteChooser();
	quoteText1=quoteArray[quoteNumOne];
	quoteAuthor1=authorArray[quoteNumOne];
	quoteText2=quoteArray[quoteNumTwo];
	quoteAuthor2=authorArray[quoteNumTwo];
	document.write('	<td width="1"><img src="/images/spacer.gif"></td>');  // This is the spacer from the page content. Set in pixels.
	document.write('	<td width="158" valign="top">');  // This is the width of the ad strip. Set in pixels.
	document.write('	<div class="quote">' + quoteText1 + '<br><br>-' + quoteAuthor1 + '</div>');  // This is the quote
	document.write('	<div class="quote">' + quoteText2 + '<br><br>-' + quoteAuthor2 + '</div>');  // This is the quote
	document.write('	</td>');
}


function writeNextSession() { // This writes an announcement for the next session on any page. Update date for each session.
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	//alert(sPage);
	document.write('<div class="session_announce_wrapper"><div class="announce"><b>Next Session<br>February 21<br>');
	if (sPage == "class_signup.html" || sPage == "class_signup_tes.html" || sPage == "class_signup_new.html") { // Don't write Sign up now! 
	}
		else
	{document.write('<a href="/class_signup.html">Sign up now!</a>');}
	document.write('</b></div></div>');
}


function writeSignUpFor() { // This writes a smaller accouncement meant to be sprinkled around pages - classes or cgc/tdi
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
	//alert(sPage);
	if (sPage == "classes.html") {  
	document.write('<div class="session_announce_wrapper"><div class="announce"><b><a href="/class_signup.html">Sign Up for Class!</a></b></div></div>');
	}
		else
	{
	document.write('<div class="session_announce_wrapper"><div class="announce"><b><a href="/class_signup.html">Sign Up for a Class!</a></b></div></div>');
	}
}


function doStats() {
	// _gat isn't defined. not sure how this would have worked. commenting all out for now.
	//var gaJsHost = (("https:" == document.location.pronavol) ? "https://ssl." : "http://www.");
	//document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	//var pageTracker = _gat._getTracker("UA-4881869-1");
	//pageTracker._initData();
	//pageTracker._trackPageview();
}
