var gFirstArticles = new Array();
var gLastArticles = new Array();

gFirstArticles['view'] = 1;
gLastArticles['view'] = 121;

gFirstArticles['sitton'] = 1;
gLastArticles['sitton'] = 5;

gFirstArticles['kora'] = 1;
gLastArticles['kora'] = 1;

gFirstArticles['rosto'] = 1;
gLastArticles['rosto'] = 4;

function writeArticle(theLink, theAuthor, theDate, theTitle, theDescription) {
	if (theAuthor == null || theAuthor.length == 0) {
		theAuthor = 'ר"תיב דהוא';
	}
	document.write("<table cellpadding=3 border=0 cellspacing=0><tr valign=middle><td align=right nowrap rowspan=2 bgcolor=#ffff66>");
	document.write(theDescription);
	document.write("</td><td align=center nowrap bgcolor=#ffff99><a href=javascript:gotoArticle(\""+theLink+"\") class=titleLink>");
	document.write(theTitle);
	document.write("</a></td></tr><tr><td align=right nowrap bgcolor=#333333><font style=\"color:#ffffcc;\">");
	document.write(theDate);
	document.write(" ,"+theAuthor);
	document.writeln("</font></td></tr></table><BR>");
}

function gotoArticle(theURL) {
	var theTarget;
	if (self.parent == null || self.parent === self) {
		theTarget = self;
	}
	else {
		theTarget = self.parent;
	}
	theTarget.location.href = theURL;
}

function writePersonal(theLink, theDate, theTitle, theDescription) {
	document.write("<table cellpadding=3 border=0 cellspacing=0><tr valign=bottom><td align=right nowrap bgcolor=#ffffcc><font class=dateFont>");
	document.write(theDate);
	document.write("</font></td><td align=center nowrap bgcolor=#ffff99><a href=javascript:gotoArticle(\""+theLink+"\") class=titleLink>");
	document.write(theTitle);
	document.write("</a></td></tr><tr><td align=right nowrap bgcolor=#333333 colspan=2><font class=descFont>");
	document.write(theDescription);
	document.writeln("</font></td></tr></table><BR>");
}

function makeArticleLocation(theLocation) {
	var start = 0;
	this.serial = 0;
	this.stem = "";
	var ind = theLocation.lastIndexOf("/");
	if (ind == -1)
		ind = 0;
	else
		ind++;
	start = ind;
	while (ind < theLocation.length) {
		if (theLocation.charAt(ind) >='0' && theLocation.charAt(ind) <= '9') {
			this.serial = parseInt(theLocation.substring(ind, theLocation.length));
			break;
		}
		ind++;
	}
	this.stem = theLocation.substring(start, ind);
	if (gFirstArticles[this.stem] != null)
		this.firstArticle = gFirstArticles[this.stem];
	else
		this.firstArticle = this.serial;
	
	if (gLastArticles[this.stem] != null)
		this.lastArticle = gLastArticles[this.stem];
	else
		this.firstArticle = this.serial;

	return this;
}

function writeArticleNavBar() {
	var theURL;
	var theTarget;
	if (window.parent == window.top)
		theTarget = "";
	else
		theTarget = " target="+window.parent.name;
	var iconDir = getIconDir();

	var indRec = new makeArticleLocation(document.location.href);
	with (document) {
		write ("<BR><CENTER><table cellpadding=0 cellspacing=0 border=0><tr valign=middle>");
		write ('<td><IMG SRC='+iconDir+'backgrounds/navbar_left.gif WIDTH=11 HEIGHT=30 BORDER=0></td>');
		write('<td background='+iconDir+'backgrounds/navbar_bg.gif><table cellpadding=0 cellspacing=3 border=0><tr valign=middle>');

		if (indRec.serial < indRec.lastArticle) {
			theURL = indRec.stem+(indRec.serial + 1)+".htm";
			write("<td><a href="+theURL+theTarget+"><IMG SRC="+iconDir+"buttons/phand_left.gif WIDTH=41 HEIGHT=22 BORDER=0></a></td>");
			write("<td> <a href="+theURL+theTarget+" class=smallLink>אבה רמאמל</a>&nbsp;&nbsp;</td>");
		}
		if (location.href.indexOf("file") != -1)
			theURL = "default.htm";
		else
			theURL = "./";
	
		write('<td align=center bgcolor=#ffffdd nowrap>&nbsp;<a href='+theURL+'>םירמאמה תמישרל</a>&nbsp;</td>');
		if (indRec.serial > indRec.firstArticle) {
			theURL = indRec.stem+(indRec.serial -1)+".htm";
			write("<td>&nbsp;&nbsp;<a href="+theURL+" class=smallLink>םדוקה רמאמל</a></td>");
			write("<td> <a href="+theURL+"><IMG SRC="+iconDir+"buttons/phand_right.gif WIDTH=41 HEIGHT=22 BORDER=0></a></td>");
		}
		write ('</tr></table></td>');
		write("<td><IMG SRC="+iconDir+"backgrounds/navbar_right.gif WIDTH=11 HEIGHT=30 BORDER=0></td></tr></table></CENTER><BR>");
	}
}

function writeSittonLogo(theTitle, theDate) {
	with (document) {
		write('<table cellpadding=0 cellspacing=1><tr><td align=center><IMG SRC="../../icondir/banners/sitton-banner.jpg" ALT="[From Gaza to Teddy by Hillel Sitton]" WIDTH=460 HEIGHT=122 BORDER=0></td></tr>');
		if (theTitle && theDate) {
			write('<tr bgcolor=black><td align=right nowrap><font color=#ffff99>'+theDate+' ,<font class=title>'+theTitle+'</font></font></td></tr>');
		}
		write('</table>');
	}	
}

