var sources = new Array();
var theIconDir = "../icondir/logo/";
var dimstr = " width=50 height=50 border=0 align=right";

var gReadyToSubmit = false;

function makeSource(inName, inImage, inURL) {
	this.iName = inName;
	this.iURL = "http://"+inURL;
	this.iImage = inImage;
	return this;
}

function addSource(inName, inImage, inURL) {
	var src = new makeSource(inName, inImage, inURL);
	sources[sources.length] = src;
}

addSource("לא ידוע", "generic_media.gif", "");
addSource("מעריב","maariv_round.gif", "www.maariv.co.il");
addSource("ידיעות אחרונות","yediot_round.gif", "");
addSource("הארץ","haaretz_button.gif", "www.haaretz.co.il");
addSource("Ynet","ynet_round.gif", "www.ynet.co.il");
addSource("One","one_button.gif", "www.one.co.il");
addSource("ערוץ 5","channel5_round.gif", "www.sport5.nonstop.il");
addSource("רדיו", "radio.gif", "");
addSource("וואלה","walla_button.gif", "sport.walla.co.il");
addSource("כל העיר","colair_button.gif", "");

function writeSources(theOption) {
	for (i in sources) {	
		document.write("<option value="+i);
		if (i == theOption)
			document.write(" selected");
		document.write(">"+sources[i].iName);
	}
}

function print1Item(theDocument, theSource, theAuthor, theTitle, theDay, theMonth, theYear, theText, theURL) {
	if (theDocument == null)
		theDocument = document;
	var sourceRec;
	if (typeof(theSource) == "string")
		theSource = parseInt(theSource);
	if (theSource > 0 && theSource < sources.length)
		sourceRec = sources[theSource];
	else
		sourceRec = sources[0];
	var theDate = makeStringFromDate(theDay, theMonth, theYear);
	with (theDocument) {
		 write("<table cellpadding=0 cellspacing=0 border=0 background=../icondir/backgrounds/y-w-stripes.gif><tr valign=middle>");
		 write("<td  align=left width=55><table cellpadding=0 cellspacing=0 border=1 width=50><tr valign=middle><td align=center");
		if (sourceRec.iURL.length)
			write("<a href="+sourceRec.iURL+" target=bjNew>");
		write("<img src="+theIconDir+sourceRec.iImage+dimstr+">");
		if (sourceRec.iURL.length)
			write("</a>");
		write("</td></tr></table></td>");
		write("<td align=right background=../icondir/backgrounds/y-w-stripes.gif><b>"+theDate+"</b></td>");
		write("</tr>");
		write ("<tr><td colspan=2 align=center nowrap bgcolor=#ffff00>");
		if (theAuthor && theAuthor.length) {
			 write(theAuthor+" / ");
		}
		write("<font class=title>"+theTitle+"</font></td></tr>");

		 write("<tr><td align=right colspan=2 bgcolor=#ffffcc nowrap>"+theText+"</td></tr>");
		if (theURL) {
			write("<tr><td colspan=2>&nbsp;<BR></td></tr>");
			write("<tr><td align=right colspan=2 nowrap><table border=1 cellpadding=0 cellspacing=0><tr><td bgcolor=#ffffdd><a href=\""+theURL+"\" target=bjNew>");
			write("העידיל רושיק");
			write("</a></td></tr></table></td></tr>");
		}		
		write("</table>");
	}
} 


function condReset() {
	return (confirm("Are you shua you want to reset the form?")) ;
}

function NotNumeric(val) {
	return val.toString().toLowerCase().indexOf("nan") != -1;
}

function testDate() {
	var ret = true;
	with (document.theForm) {
		var d, m, y;
		var astr = "";
		d = parseInt(day.value);
		m = parseInt(month.value);
		y = parseInt(year.value);

		if (NotNumeric(d) || NotNumeric(m) || NotNumeric(y)) {
			astr = "Illegal non numeric value in one of the date fields";
		}
		else if (d < 0 || d > 31 || m < 1 || m > 12 || y < 1999 || y > 2002) {
			astr = "Illegal date value";
		}
		else {
			day.value = d; month.value = m; year.value = y;
		}
	}
	if (astr.length) {
		ret = false;
		alert(astr);
	}
	return ret;
}

