function Quoted(txt)
{
    return '"'+txt+'"';
}
function TransGif(w,h)
{
    return '<img src="t.gif" width=' + w.toString() + ' height=' + h.toString() + '>';
}
var TransparentGif = TransGif(1,1);
var ThumbsWidth = 406;
function TableStart()
{
    document.write("<table width=" + Quoted("95%") + " border=0 cellspacing=0 cellpadding=0><tr>");
    document.write("<td><img src=" + Quoted("brdTL.gif") + " width=5 height=5></td>");
    document.write("<td background=" + Quoted("borderh5.gif") + " width=" + Quoted("100%") + "></td>");
    document.write("<td><img src=" + Quoted("brdTR.gif") + " width=5 height=5></td></tr>");
    document.write("<tr><td background=" + Quoted("borderv5.gif") + "></td><td>");
        document.write("<table width=" + Quoted("100%") + " border=0 cellspacing=0 cellpadding=0 class=tw>");
        document.write("<tr><td class=cg></td><td class=cg></td>");
        document.write("<td><img src=" + Quoted("Movies/t.gif") + " width=1 height=1></td></tr>");
        document.write("<tr><td class=cg width=1></td><td>");
            document.write("<table width=" + Quoted("100%") + " border=0 cellspacing=0 cellpadding=0 class=tg>");
            document.write("<tr><td class=cb></td><td class=cb></td>");
            document.write("<td><img src=" + Quoted("Movies/t.gif") + " width=1 height=1></td>");
            document.write("</tr><tr><td class=cb width=1></td><td>");
                document.write("<table width=" + Quoted("100%") + " border=0 cellspacing=0 cellpadding=1 class=t0>");
}
function TableEnd()
{
                document.write("</table>");
            document.write("</td><td width=1></td></tr><tr>");
			document.write("<td><img src=" + Quoted("Movies/t.gif") + " width=1 height=1></td>");
			document.write("<td></td><td></td></tr></table>");
		document.write("</td><td width=1></td></tr><tr>");
		document.write("<td><img src=" + Quoted("Movies/t.gif") + " width=1 height=1></td>");
		document.write("<td></td><td></td></tr></table>");
	document.write("</td><td background=" + Quoted("borderv5.gif") + "></td></tr><tr>");
	document.write("<td><img src=" + Quoted("brdBL.gif") + " width=5 height=5></td>");
	document.write("<td background=" + Quoted("borderh5.gif") + "></td>");
	document.write("<td><img src=" + Quoted("brdBR.gif") + " width=5 height=5></td>");
	document.write("</tr></table>");
}
function Rating(rati)
{
    var Temp = "<table height=8 border=0 cellpadding=0 cellspacing=2><tr>";
    var i, colour = "000000";

    if (rati == 1) colour = "C0C0C0";
    if (rati == 3) colour = "0000FF";
    if (rati == 4) colour = "008000";
    if (rati == 5) colour = "FF8000";
    for (i = 0; i < 5; ++i)
    {
        Temp = Temp + '<td'
        if (i < rati) Temp = Temp + ' bgcolor="#' + colour + '"';
        Temp = Temp + '>' + TransGif(4,8) + '</td>';
    }

    return Temp + "</tr></table>";
}
function AreaTag(x, href)
{
	var x81 = x * 81 + 1;
	var z81 = x81 + 79;
	var x1 = x + 1;
	return "<area shape=" + Quoted("rect") + " coords=" + Quoted(x81.toString() + ",1," + z81.toString()+ ",60")
		 + " href=" + Quoted(href) + " alt=" + Quoted(x1.toString()) + ">";
}
function WriteRow(frow,title,rowtoggle,inva,pic1,pic2,pic3,pic4,pic5,actr,id,cond,rati,note)
{
    var MovieFolder = "Movies/";
    var temp, condClass, thumb, map, w, wt;

	if (window.location.search == "?lite")
	{
		OldWriteRow(frow,title,rowtoggle,inva,pic1,pic2,pic3,pic4,pic5,actr,cond,rati,note);
		return;
	}

	thumb = "0000" + id.toString();
	thumb = thumb.substr(thumb.length - 4);
	
	temp = "<map name=" + Quoted("n" + thumb) + ">"; w = 0;
	if (pic1 != "") { temp = temp + AreaTag(0, MovieFolder +  pic1); w = 1; }
	if (pic2 != "") { temp = temp + AreaTag(1, MovieFolder +  pic2); w = 2; }
	if (pic3 != "") { temp = temp + AreaTag(2, MovieFolder +  pic3); w = 3; }
	if (pic4 != "") { temp = temp + AreaTag(3, MovieFolder +  pic4); w = 4; }
	if (pic5 != "") { temp = temp + AreaTag(4, MovieFolder +  pic5); w = 5; }
	map = temp + "</map>";

	w = w * 81 + 1;
	wt = ThumbsWidth - w;
	
	temp = "<span><img src=" + Quoted(MovieFolder + "thumbs/" + thumb + ".jpg")
		 + " width=" + w.toString() + " height=62 border=0 usemap=" + Quoted("#n" + thumb) + ">"
		 + "<img src=" + Quoted("t.gif") + " width=" + wt.toString() + " height=62>"
		 + "</span>" + map;

	if (cond.length > 4) condClass = " class=s7";
	if (note.length > 0) note = "Note: " + note;

    if (inva == 0)
    	title = "<b>" + title + "</b>";
    else
        title = "<span class=" + ((rowtoggle!=0)?"r1x":"t0x") + ">" + title + "</span>";

	if (rowtoggle==1)
	{
		document.write("<tr class=r1><td width=" + Quoted("80%") + ">");
			document.write("<table width=" + Quoted("100%") + " border=0 cellspacing=0 class=t0>");
			document.write("<tr class=r1><td>" + title + "<br>" + actr + "</td>");
			document.write("<td width=" + Quoted("1%") + condClass + ">" + cond + "</td>");
			document.write("<td width=" + Quoted("1%") + ">" + Rating(rati));
            document.write("</td></tr><tr class=r1><td colspan=3 class=s7>" + note);
            document.write("</td></tr></table>");
		document.write("</td><td>" + temp + "</td></tr>");
	}
	else
	{
		document.write("<tr><td width=" + Quoted("80%") + ">");
            document.write("<table width=" + Quoted("100%") + " border=0 cellspacing=0>");
			document.write("<tr class=t0><td>" + title + "<br>" + actr + "</td>");
			document.write("<td width=" + Quoted("1%") + condClass + ">" + cond + "</td>");
			document.write("<td width=" + Quoted("1%") + ">" + Rating(rati));
            document.write("</td></tr><tr class=t0><td colspan=3 class=s7>" + note);
            document.write("</td></tr></table>");
		document.write("</td><td>" + temp + "</td></tr>");
	}
}
function Write1(frow,title,rowtoggle,inva,pic1,actr,id,cond,rati,note)
{
    WriteRow(frow,title,rowtoggle,inva,pic1,"","","","",actr,id,cond,rati,note);
}
function Write2(frow,title,rowtoggle,inva,pic1,pic2,actr,id,cond,rati,note)
{
    WriteRow(frow,title,rowtoggle,inva,pic1,pic2,"","","",actr,id,cond,rati,note);
}
function Write3(frow,title,rowtoggle,inva,pic1,pic2,pic3,actr,id,cond,rati,note)
{
    WriteRow(frow,title,rowtoggle,inva,pic1,pic2,pic3,"","",actr,id,cond,rati,note);
}
function Write4(frow,title,rowtoggle,inva,pic1,pic2,pic3,pic4,actr,id,cond,rati,note)
{
    WriteRow(frow,title,rowtoggle,inva,pic1,pic2,pic3,pic4,"",actr,id,cond,rati,note);
}
function Write0(frow,title,rowtoggle,inva,actr,id,cond,rati,note)
{
	var condClass;

	if (window.location.search == "?lite")
	{
		OldWriteRow(frow,title,rowtoggle,inva,"","","","","",actr,cond,rati,note);
		return;
	}
	
	if (cond.length > 4) condClass = " class=s7";
	if (note.length > 0) note = "Note: " + note;

    if (inva == 0)
    	title = "<b>" + title + "</b>";
    else
        title = "<span class=" + ((rowtoggle!=0)?"r1x":"t0x") + ">" + title + "</span>";

	if (rowtoggle==1)
	{
        document.write("<tr class=r1><td width=" + Quoted("80%") + ">");
            document.write("<table width=" + Quoted("100%") + " border=0 cellspacing=0 class=t0>");
			document.write("<tr class=r1><td>" + title + "<br>" + actr + "</td>");
			document.write("<td width=" + Quoted("1%") + condClass + ">" + cond + "</td>");
			document.write("<td width=" + Quoted("1%") + ">" + Rating(rati));
			document.write("</td></tr></table>");
		document.write("</td><td width=" + Quoted("20%") + ">");
			document.write("<table border=0 cellspacing=0><tr>");
			document.write("<td><img src=" +Quoted("t.gif") + " width="+ThumbsWidth.toString()+" height=1></td></tr>");
			document.write("<tr><td class=s7>" + note + "</td></tr></table>");
		document.write("</td></tr>");
	}
	else
	{
        document.write("<tr><td width=" + Quoted("80%") + ">");
            document.write("<table width=" + Quoted("100%") + " border=0 cellspacing=0>");
			document.write("<tr class=t0><td>" + title + "<br>" + actr + "</td>");
			document.write("<td width=" + Quoted("1%") + condClass + ">" + cond + "</td>");
			document.write("<td width=" + Quoted("1%") + ">" + Rating(rati));
			document.write("</td></tr></table>");
		document.write("</td><td width=" + Quoted("20%") + ">");
			document.write("<table border=0 cellspacing=0><tr>");
			document.write("<td><img src=" +Quoted("t.gif") + " width="+ThumbsWidth.toString()+" height=1></td></tr>");
			document.write("<tr><td class=s7>" + note + "</td></tr></table>");
		document.write("</td></tr>");
	}
}
function QueryLink(page,title,hash)
{
	document.write("<a href=" + Quoted(page + window.location.search + hash) + ">" + title + "</a>");
}

var FirstRow;
function StartCell(cellclass,widthpercent)
{
    var Temp = "<td";
    if (cellclass != "n") Temp = Temp + " class=" + cellclass;
    if (FirstRow != 0) Temp = Temp + " width=" + Quoted(widthpercent.toString() + "%");
    return Temp + ">";
}
function OldWriteRow(frow,title,rowtoggle,inva,pic1,pic2,pic3,pic4,pic5,actr,cond,rati,note)
{
    var MovieFolder = "Movies/";
    var Temp;
    FirstRow = frow;
    Temp = (rowtoggle == 1) ? "<tr class=r1>" : "<tr>";
    if (pic1 != "")
    {
        Temp = Temp + StartCell("n",30) +
               "<a href=" + Quoted(MovieFolder + pic1) + ">" + title + "</a>";
        if (pic2 != "") Temp = Temp + " | " + "<a href=" + Quoted(MovieFolder + pic2) + ">pic2</a>";
        if (pic3 != "") Temp = Temp + " | " + "<a href=" + Quoted(MovieFolder + pic3) + ">pic3</a>";
        if (pic4 != "") Temp = Temp + " | " + "<a href=" + Quoted(MovieFolder + pic4) + ">pic4</a>";
        if (pic5 != "") Temp = Temp + " | " + "<a href=" + Quoted(MovieFolder + pic5) + ">pic5</a>";
    }
    else
    {
        if (inva == 0)
            Temp = Temp + StartCell("n",30) + title;
        else
            Temp = Temp + StartCell((rowtoggle!=0)?"r1x":"t0x",30) + title;
    }
    document.write(Temp + "</td>");
    document.write(StartCell("n",20) + actr + "</td>");
    document.write(StartCell((cond.length>4)?"s7":"n",10) + cond + "</td>");
    document.write(StartCell("n",1) + Rating(rati) + "</td>");
    document.write(StartCell((note.length>10)?"s7":"n",30) + note + "</td>");
    document.write("</td>");
}