// copyright ) 1999-2002 David Frenkiel, Beitar Jerusalem F.C. web site
// permission to use this source or portions of it in other sites is 
// granted only if the site gives clear and visible (on the page) credit
// in its main 'about' page or in its main page to David Frenkiel and links to
// http://www.beitar-jerusalem.org.il/

var gIconDir = "";
var __beitar__ = 6;
var __nS = navigator.appName.toLowerCase().indexOf("netscape") >= 0;
var __mC = navigator.appVersion.toLowerCase().indexOf('mac') >= 0;
var _nver = parseFloat(navigator.appVersion);
var __lC = "א".charCodeAt(0);
var __bcS = ((__mC && __lC == 224) || __lC > 65000); // bad charset
var gImgDown = '<img height=22 width=22 src='+getIconDir()+'buttons/empty_arrow_down.gif border=0>';
var gImgUp = '<img height=22 width=22 src='+getIconDir()+'buttons/empty_arrow_up.gif border=0>';
var gMonth = 0, gYear = 0;
var gDate = null;

var hMonths = new Array("ראוני","ראורבפ","ץרמ","לירפא","יאמ","ינוי","ילוי","טסוגוא","רבמטפס","רבוטקוא","רבמבונ","רבמצד");
var gLogHeb = -1;


function HasLogicalHebrew() {
	if (gLogHeb != -1)
		return gLogHeb;
	var bName = navigator.appName.toLowerCase();
	var bAgent = navigator.userAgent.toLowerCase();
	
	gLogHeb = (bName.indexOf("microsoft") != -1) && (bAgent.indexOf("win") != -1);
	if (gLogHeb == false)
		gLogHeb = (bAgent.indexOf("gecko") != -1);
	return gLogHeb;
}

if ((__mC) && (! gLogHeb)) {
		document.write("<meta http-equiv=\"content-type\" content=\"text/html;charset=x-mac-roman\">");
}
else if (__nS  && __bcS) {
		document.writeln("<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">");
}

function getSpacerString(width, height) {
	var theStr = "<img height="+height+" width="+width+" src="+getIconDir()+"dot_clear.gif border=0>";
	return theStr;
}

function spacer(width, height) {
	var spcStr = getSpacerString(width, height);
	document.write(spcStr);
}


function getIconDir() {
	if (gIconDir.length > 0)
		return gIconDir;

	var thePath = location.pathname.toLowerCase();
	if (location.protocol.toLowerCase().indexOf("file") != -1) {
		var ind = thePath.indexOf("beitar/");
		thePath = thePath.substring(ind+7, thePath.length);
		var theArr = thePath.split("/");
		var nMembers = theArr.length-1;
		for (i = 0; i <	nMembers; i++) {
			gIconDir += "../";
		}
	}
	else {
		gIconDir = "/";
	}

	gIconDir += "icondir/";
	
	return gIconDir;
}

var _bLines = new Array("This world is totally Fugazy",
	"I've seen the future, baby, it is murder",
		"It's not an optical illusion, it just looks like one",
		'.לגרודכל תילארשיה תודחאתהה ר"וי ןיידע אוה יול ירבג',
		'(הנחוא ילא) הטלור ומכ הז םילדנפ .לזמ היה הזש בשוח אל ינא',
		'(ןמטוג ילא) ותוא דבכל ןווכתמ ינאו הזוח יל שי',
		' (סיסקובא יסוי) הנחוא ילא לש שרויה ינא',
		'קאיטירט "קט-קיט" ייגרסל הצרעהב שדקומ',
		 '(יול ירבג) יבויח דואמ שיא אוה שדד השמ',
		 "There's someone in my head, but it's not me.",
		 "There is no dark side to the moon, really. As a matter of fact, it's all dark.",
		 "The time is gone, the song is over, thought I'd something more to say.",
		 "Women seem wicked when you're unwanted.",
		 "(ןהכ ילא) ונל םגו ,םידדצה ינשל השק היה קחשמה",
		 "I've got a strong urge to fly, but I've got nowhere to fly to.",
		 '(ר"תיב תא בוזעי אל םלועלש חיטבמ וסור ינאבו\'ג) "סוטנבויל אל וליפא"',
		 '(2002 יאמ ,שדד השמ) "?התיבה ךלי יול ירבגש המל"'
		);
function getTLine() {
	var dt = new Date();
	var ind = dt.getSeconds() % _bLines.length;
	return _bLines[ind];
}

function writeTrailer() {
	with (document) {
		write('<CENTER><P><IMG SRC=/icondir/chainmrg.gif WIDTH=404 HEIGHT=2 ALT="[Beitar Separator]" BORDER=0></P>');
		write('<P><TABLE CELLSPACING=0 BORDER=0 CELLPADDING=1>');
		write('<TR><TD ALIGN=CENTER><FONT CLASS=smallEnglishFont SIZE=2>Copyright &copy; 1996-2002 Beitar Jerusalem FC <A href=/about.htm CLASS=eSmallLink>Web Committee</A>, </FONT></td></tr>');
		write("<tr valign=center><td align=center><FONT CLASS=smallEnglishFont>Your <A href=mailto: CLASS=eSmallLink>feedback</A> is welcome</FONT><IMG SRC=/icondir/mailto.gif WIDTH=14 HEIGHT=10 BORDER=0 VSPACE=0  HSPACE=10 align=middle><FONT CLASS=smallFont SIZE=2><A href=mailto: CLASS=smallLink>ונל ובתכת</A> םא חמשנ</FONT><BR><font class=smallEnglishFont SIZE=2>");
	write(getTLine());
	write('<BR><IMG SRC=/icondir/mac/macmade5.gif WIDTH=104 HEIGHT=32 BORDER=0 ALT=[Macintosh!] vspace=0><BR></TD></TR></TABLE></P></CENTER>');
	}
}

function writeSmallTrailer() {
	with (document) {
		write('<CENTER><IMG SRC=/icondir/chainmrg.gif WIDTH=404 HEIGHT=2 ALT="[Beitar Separator]" BORDER=0></P>');
		write('<P><TABLE CELLSPACING=0 BORDER=0 CELLPADDING=1>');
		write('<TR><TD ALIGN=CENTER><FONT CLASS=smallEnglishFont SIZE=2>Copyright &copy; 1996-2002 Beitar Jerusalem FC <A href=/about.htm CLASS=eSmallLink>Web Committee</A> </FONT></td></tr></TABLE></CENTER>');
	}
}
function makeDateLocation(theMonth, theYear) {
	theYear = theYear % 100;

	if (theYear < 10)
		theYear = "0"+theYear;
	else
		theYear = ""+theYear;
	if (theMonth == 0)
		theMonth = 1;
	if (theMonth < 10)
		theMonth = "0"+theMonth;
	else
		theMonth = ""+theMonth;
	return  theMonth+theYear;
}

function makeTodayString() {
	var today = new Date();
	var theYear = today.getYear();
	var theMonth = today.getMonth();
	return makeDateLocation(theMonth, theYear);
}

function writeDate(dateStr) {
	var theStr = makeDateString(dateStr);
	document.write(theStr);
}

function writeDateValues(theDay, theMonth, theYear) {
	var theD = makeStringFromDate(theDay, theMonth, theYear);
	document.write(theD);
}

function myIsNaN(thevar) {
	var ret = false;
	if ((thevar == null) || ((""+thevar) == "NaN")) {
		ret = true;
	}
	return ret;
}

function makeDate(dateStr) {
	if (gDate != null)
		return gDate;

	this.curDate = dateStr;
	this.year = 0;
	this.month = 0;
	this.valid = true;

	var theMonth = dateStr.substr(0, 2);
	var theYear = dateStr.substr(2, 4);
	var thefmonth = parseFloat(theMonth);
	var thefyear = parseFloat(theYear);

	if (isNaN(thefmonth) || isNaN(thefyear)) {
		this.valid = false;
		return this;
	}
	this.month = Math.round(thefmonth);
	this.year = Math.round(thefyear);
//	alert("themonth is "+theMonth+" and the year is "+theYear+" found month "+this.month+" foundyear "+this.year);
	if (this.year < 90)
		this.year = 2000 + this.year;
	else
		this.year = 1900 + this.year;

	this.prevYear = this.year;
	this.nextYear = this.year;

	if (this.month == 12) {
		this.nextMonth = 0;
		this.nextYear++;
	}
	else
		this.nextMonth = this.month + 1;

	if (this.month == 1) {
		this.prevMonth = 12;
		this.prevYear--;
	}
	else
		this.prevMonth = this.month - 1;
	if (this.prevYear < 0)
		this.prevYear = 1999;
	this.prevString = makeDateLocation(this.prevMonth, this.prevYear);
	this.nextString = makeDateLocation(this.nextMonth, this.nextYear);
	gDate = this;
	return this;
}

function makeDateFromLocation() {
	if (gDate != null)
		return gDate;

	var theDate = getDateFromLocation();
	return makeDate(theDate);
}

function makeDateString(dateStr) {
	var theDate = makeDate(dateStr);
	var theStr = "";
	if (theDate.valid) {
		theStr = ""+theDate.year+" "+hMonths[theDate.month - 1];
	}
	return theStr;
}

function makeStringFromDate(d, m, y) {
	var ret = "";
	if (y == null)
		y = "";
	else  {
		if (y != null && y > 0 && y < 100) {
			if (y < 90)
				y += 2000;
			else
				y += 1900;
		}
	}
	if (m < 1 || m > hMonths.length)
		m = 1;
	ret = ""+y+" "+hMonths[m - 1]+"ב "+d;
	return ret;
}

function writeDateFromLocation() {
	var theStr = getDateFromLocation();
	writeDate(theStr);
}

function getDateFromLocation() {
	var theLoc = location.pathname.toLowerCase();
	var theInd = theLoc.lastIndexOf("/");
	var theFName = theLoc.substring(theInd+1, location.pathname.length - 4);
	theFName = theFName.substr(theFName.length - 4, 4);
	return theFName;
}
