var sPath = window.location.pathname; 
var sPage = sPath.substring(sPath.lastIndexOf("/") + 1);
sPage = sPage.split(".")[0].toLowerCase();

function writeheader(sHeader) {
      document.write ("<div id=\"headbox\"><div id=\"line1\">Tifereth Israel Congregation</div><div id=\"line2\">New Bedford, Massachusetts</div></div>");
      document.write("<div id=\"pagetitle\"><h1>" + sHeader + "</h1></div>");
}
function writeheader2() {
      document.write ("<div id=\"headbox3\"><div id=\"line1\">Tifereth Israel Congregation</div><div id=\"line2\">New Bedford, Massachusetts</div></div>");
}
function writebanner() {
      document.write ("<div id=\"headbox2\"><img src=\"images/play5b.jpg\"></div>");
}
function writebanner2() {
      document.write ("<div id=\"headbox2\"><img src=\"images/newhead.gif\"></div>");
}
function writetitle(sHeader) {
      document.write("<div id=\"pagetitle2\"><h1>" + sHeader + "</h1></div>");
}

function writefooter() {
	document.write("<div id=\"blockcenter\">Tifereth Israel Copyright&copy; 2010 All Rights Reserved</div>");
}

function writehomefooter() {
	document.write("<div id=\"homecenter\">Tifereth Israel Copyright&copy; 2010 All Rights Reserved</div>");
}
function writeright(bQ,bWN,bMAP,iQ) {
  document.write ("<div style=\"background-color:#151B8D\">");
	if(bQ) {
		document.write("<div id=\"block1\"><p class=\"type2\">" + writequote(iQ) + "</p>");
		document.write("<hr /><a href=\"onlinedonation1.html\"><img src=\"images/tzedakahbox.jpg\" alt=\"\" /></a>");
		document.write("<a href=\"onlinedonation1.html\">Click here to make a <b>DONATION</b> to<br />Tifereth Israel.</a></div>");
	}	
	if(bWN) {
		document.write("<div id=\"block2\"><div id=\"header\">What's New</div><div id=\"contents\"><p>The new<br /><a href=\"SeptemberOctober2010.pdf\"><i>Tifereth Israelight</i></a><br />is now available.</p><hr /><p><b><a href=\"HighHolyDays5771.html\">Click</a> for<br />High Holy Days<br />Information</b></p><hr /><p><a class=\"nyroModal\" href=\"http://www.tinewbedford.org/images/ThisWeeksServices.jpg\">Click</a> for this week's schedule of services<br />and events.</p><hr /><p>Ziskind School<br /><a class=\"nyroModal\" href=\"http://www.tinewbedford.org/images/dates_to_remember.jpg\">Dates to Remember.</a></p></div></div>");
	}	
	if(bMAP) {
		document.write("<div id=\"block3\"><div id=\"header\">Directions and Maps</div><div id=\"contents\"><p class=\"typeright\"><a href=\"http://www.mapquest.com/maps/map.adp?address=145 Brownell Ave&amp;city=New Bedford&amp;state=MA&amp;zipcode=02740-1654&amp;country=US&amp;title=&lt;b&gt;145 Brownell Ave&lt;/b&gt;&lt;br /&gt; New Bedford, MA 02740-1654,  US&amp;cid=lfmaplink2&amp;name=&amp;dtype=s\">Tifereth Israel Synagogue</a></p><a href=\"http://www.jcam.org/Pages/Cemeteries_New/Cemetery_Pages_08/New_Bedford_Plainville.html\">Plainville Cemetery</a></div></div>");
	}
  document.write("<div id=\"rightbottomimg\"><img src=\"" + pickpicture(iQ) + "\" alt=\"bottom\" /></div></div>");
}
function writeright2(bQ,bWN,bMAP,iQ) {
  document.write ("<div style=\"background-color:#151B8D\">");
	if(bQ) {
		document.write("<div id=\"block1\"><p class=\"type2\">" + writequote(iQ) + "</p></div>");
	}	
	if(bWN) {
		document.write("<div id=\"block2\"><div id=\"header\">What's New</div><div id=\"contents\"><p>The new<br /><a href=\"SeptemberOctober2010.pdf\"><i>Tifereth Israelight</i></a><br />is now available.</p><hr /><p><b><a href=\"HighHolyDays5771.html\">Click</a> for<br />High Holy Days<br />Information</b></p><hr /><p><a class=\"nyroModal\" href=\"http://www.tinewbedford.org/images/ThisWeeksServices.jpg\">Click</a> for this week's schedule of services<br />and events.</p><hr /><p>Ziskind School<br /><a class=\"nyroModal\" href=\"http://www.tinewbedford.org/images/dates_to_remember.jpg\">Dates to Remember.</a></p></div></div>");
	}	
	if(bMAP) {
		document.write("<div id=\"block3\"><div id=\"header\">Directions and Maps</div><div id=\"contents\"><p class=\"typeright\"><a href=\"http://www.mapquest.com/maps/map.adp?address=145 Brownell Ave&amp;city=New Bedford&amp;state=MA&amp;zipcode=02740-1654&amp;country=US&amp;title=&lt;b&gt;145 Brownell Ave&lt;/b&gt;&lt;br /&gt; New Bedford, MA 02740-1654,  US&amp;cid=lfmaplink2&amp;name=&amp;dtype=s\">Tifereth Israel Synagogue</a></p><a href=\"http://www.jcam.org/Pages/Cemeteries_New/Cemetery_Pages_08/New_Bedford_Plainville.html\">Plainville Cemetery</a></div></div>");
	}	
  document.write("<div id=\"rightbottomimg\"><img src=\"" + pickpicture(iQ) + "\" alt=\"bottom\" /></div></div>");
}
function writequote(i) {
	var sQuote;
	var aQuotes = new Array (
		"The world rests on three things; on Torah,<br /> on service of G-d, on deeds of love.<br /> -- Shimon Ha-Tzaddik",
		"When you assess people, tip the balance<br />in their favor.<br /> -- Joshua ben Perakhyah",
		"Be a disciple of Aaron: loving peace and pursuing peace, loving your fellow creatures and attracting them to the study of Torah.<br /> -- Hillel",
		"If I am not for me, who will be? If I am for myself alone, what am I? And if not now, when?<br /> -- Hillel",
		"Make the study of Torah your primary occupation; Say little, do much; Greet every person with a cheerful face.<br /> -- Shammai",
		"You are not obliged to finish the task, neither are you free to neglect it.<br /> -- Rabbi Tarfon",
		"Tradition is a protection for Torah.<br /> -- Rabbi Akiva",
		"Silence is a protection<br />for wisdom.<br /> -- Rabbi Akiva",
		"There are three crowns: the crown of Torah, the crown of Priesthood, the crown of Royalty. The crown of a good name is superior to them all.<br /> -- Rabbi Shimon");
	if(typeof(i) == "undefined" || isNaN(i) || i < 0 || i > (aQuotes.length-1))
		i = Math.round(Math.random()*(aQuotes.length-1));
	sQuote = aQuotes[i];
	return sQuote;
}	

function pickpicture(i) {
	var sPicture;
	var aPictures = new Array (
		"images/p1.jpg",
		"images/p2.jpg",
		"images/p3.jpg",
		"images/p4.jpg",
		"images/p5.jpg",
		"images/p6.jpg",
		"images/p7.jpg",
		"images/p8.jpg",
		"images/p9.jpg");
	if(typeof(i) == "undefined" || isNaN(i) || i < 0 || i > (aPictures.length-1))
		i = Math.round(Math.random()*(aPictures.length-1));
	sPicture = aPictures[i];
	return sPicture;
}	

function writemenu(iCurrentPage) {
	var i, c;
	var menulinks = new Object();
		menulinks['0'] = "index.html";
		menulinks['1'] = "leadership2.html";
		menulinks['2'] = "officers2.html";
		menulinks['3'] = "education2.html";
		menulinks['4'] = "community2.html";
		menulinks['5'] = "membership2.html";
		menulinks['6'] = "minyan2.html";
		menulinks['7'] = "events2.html";
		menulinks['8'] = "publications2.html";
		menulinks['9'] = "photographs2.html";
		menulinks['10'] = "links2.html";
		menulinks['11'] = "forms2.html";
		menulinks['12'] = "contact2.html";
		menulinks['13'] = "calcalc2.html";
	
	var menutext = new Object();
		menutext['0'] = "Shalom";
		menutext['1'] = "Leadership";
		menutext['2'] = "Officers";
		menutext['3'] = "Education";
		menutext['4'] = "Community";
		menutext['5'] = "Membership";
		menutext['6'] = "Services";
		menutext['7'] = "Events &amp; Calendars";
		menutext['8'] = "Publications";
		menutext['9'] = "Photographs";
		menutext['10'] = "Links";
		menutext['11'] = "Forms";
		menutext['12'] = "Contact Us";
		menutext['13'] = "Date Converter";
	
	c = iCurrentPage.toString();
	// alert(c);
  document.write ("<div style=\"background-color:#151B8D\">");
	document.write("<div id=\"menu\">");
	for(i in menulinks) {
		// alert(i);
		if(i==c)
			document.write("<a href=\"" + menulinks[i] + "\" id=\"mcurrent\">" + menutext[i] + "</a>");
		else
			document.write("<a href=\"" + menulinks[i] + "\" id=\"mlink\">" + menutext[i] + "</a>");
	}
	document.write("<div id=\"spacer\">&nbsp;</div></div>");	
	delete menulinks;
	delete menutext;
	document.write("<div id=\"leftblock1\"><div id=\"header\">USCJ NEWS</div><div id=\"contents\"><p class=\"type4\">Check out this month's <a href=\"http://www.uscj.org/eNews\">United Synagogue eNews</a></p><hr /><p><a href=\"http://www.tinewbedford.org/viewpage.html\">Watch</a> a video about our new Machzor, <i>Lev Shalem</i></p></div></div>");
	document.write("<div id=\"leftblock2\"><div id=\"header\">LOOKING FOR A<br />DAILY MINYAN?</div><div id=\"contents\"><p class=\"type4\">Click <a class=\"nyroModal\" href=\"http://www.tinewbedford.org/images/ThisWeeksServices.jpg\">here!</a></p></div></div>");
	document.write("<div id=\"smallspacer\">&nbsp;</div></div>");	
}

function setheight() {
	var l = document.getElementById("pageleft");
	var c = document.getElementById("pagecontent");
	var r = document.getElementById("pageright");
 	var heights = new Array(
 		l.offsetHeight,
 		r.offsetHeight,
 		c.offsetHeight);
 	heights.sort(compare);
 	var h = heights[0];
	l.style.height = h+"px";
 	c.style.height = h+"px";
 	r.style.height = h+"px";
}

function compare(a, b) {
	return b - a;
}
function writecalinfo() {
  document.write ("<div id=\"calinfo\">");
//	document.write("Today is the");
//	document.write("<script type=\"text/javascript\" src=\"http://www.hebcal.com/etc/hdate-en.js\"></script>");
//  document.write("&nbsp\;&nbsp\;&nbsp\;&nbsp\;");
//	document.write("<script type=\"text/javascript\" src=\"http://www.hebcal.com/etc/hdate-he.js\"></script>");
	document.write("<script type=\"text/javascript\" src=\"http://www.hebcal.com/shabbat/?geo=zip;zip=02740;m=60;cfg=j\"></script>");
	document.write("<noscript><a href=\"http://www.hebcal.com/shabbat/?geo=zip;zip=02740;m=0\"> Shabbat Candle Lighting times for New Bedford, MA 02740</a> courtesy of hebcal.com.</noscript>");
	document.write("</div>");	
}
