/*
--------------------------------------------------------------------------------
7NoTrumps

Main JavaScript to create objects from the input file
Now populates layers
---------------------------------------------------------------------------------
   Version        Date       Name                          Desc
      1  	15/01/2001       AEK     Clone of local_main.js + next_article + prev_article
      2  	26/01/2002       AEK     Code for dummy article of only one page

---------------------------------------------------------------------------------
*/
var start;
var main;
var vul;
var contract;
var north;
var east;
var south;
var westmain;
var west;
var table;
var bidding;
var comments;
var textWindow;
var first;
var prev;
var next;
var last;
var yesterday;
var tomorrow;
var dateWindow;

var noArticle = 'There was no article on this date.';
//DON'T CHANGE - FLAG!!!!! This string will be contained in many CCYYMMDD.js files

//Main input file.
var infile=main_load();

//Call the bridge constructor for each record found.
var records = infile.split('@~@');

var num_of_recs = (records.length)-1==1 ? 0 : (records.length)-1;

for (var rec_count=0;rec_count<=num_of_recs;rec_count++)
	{
	eval('var REC' + rec_count + ' = new record(records[' + rec_count + '],' + rec_count + ')');
	}




//---------------------------functions-------------------------------------------//
function init()
{
start       = new DynLayer('startDiv');
main        = new DynLayer('mainDiv');
vul         = new DynLayer('vulnerabilityDiv');
contract    = new DynLayer('contractDiv');
north       = new DynLayer('northDiv');
dateWindow  = new DynLayer('dateDiv');
east        = new DynLayer('eastDiv');
south       = new DynLayer('southDiv');
westmain    = new DynLayer('westmainDiv');
west        = new DynLayer('westDiv');
table       = new DynLayer('tableDiv');
bidding     = new DynLayer('biddingDiv');
comments    = new DynLayer('commentDiv');
textWindow  = new DynLayer('textwindowDiv');
first       = new DynLayer('firstDiv');
prev        = new DynLayer('prevDiv');
next        = new DynLayer('nextDiv');
last        = new DynLayer('lastDiv');
yesterday   = new DynLayer('yesterdayDiv');
tomorrow    = new DynLayer('tomorrowDiv');
//Store the total record count.
if (is.ns)
	document.mainDiv.document.rec_store.total_rec.value=num_of_recs
if (is.ie)
	document.rec_store.total_rec.value=num_of_recs;
//alert("num_of_recs " + num_of_recs;
build_screen('first');//First time in.
}



function GoDay(direction) {
//go to the article that follows the current one
var nextDay = new Date(2001,01,07); // initialise Date object
var strHref = "";
var strday;
var strmonth;
var str;
var oneMinute = 60 * 1000;
var oneHour = oneMinute * 60;
var oneDay = oneHour * 24;
var oneWeek = oneDay * 7;
var dateInMilliseconds; 
var d;
var m;
var y;
var strlen;
var strlenmonth;
var strDate = ""; 
var nought = "0";
var windowloc = new String; 
var posn1 = 0;
var targetDate;

windowloc = window.location + "<" ;
      //alert("windowlocX = " + windowloc);
posn1 = windowloc.indexOf("arch.html?");
if (posn1 == -1) {              //not via archive must be via today's article!
  targetDate = new Date(); //pick up today's date
}
else {
   strlen  = windowloc.length; 
   str = windowloc.substring(posn1+14,strlen);
   //alert("posn1 = " + posn1 + '\n' + "str = " + str );  
   d = windowloc.substring(posn1+14,posn1+16);
   m = windowloc.substring(posn1+23,posn1+25);
   y  = windowloc.substring(posn1+31,posn1+35);
   //alert("ymd = " + y + "/" + m + "/" + d);        
   targetDate = new Date(y,m-1,d); 
}
//alert("tartgetDate = " + targetDate);
dateInMilliseconds = targetDate.getTime();
if (direction=='forward') {
   dateInMilliseconds = dateInMilliseconds + oneDay; //tomorrow
} 
else {  
   dateInMilliseconds = dateInMilliseconds - oneDay; //back or yesterday
}   
targetDate.setTime(dateInMilliseconds); 
d = targetDate.getDate(); 
m = targetDate.getMonth() + 1; 
y = targetDate.getFullYear();
//alert("ymd (after +1) = " + y + "/" + m + "/" + d); 
//d = d + 0; 
//m = m + 0; 
if (d < 10) {
   d = nought + d; 
}   
if (m < 10) {
   m = nought + m;
} 
      
//alert("ymd (after length) = " + y + "/" + m + "/" + d); 
strHref = "arch.html?day=" + d + "&month=" + m + "&year=" + y;
windowloc = window.location + "<";
      //alert("windowloc = " + windowloc);
posn1 = windowloc.indexOf("arch");      
if (posn1 == -1) {              //not via archive muts be va today's article!
  posn1 = windowloc.indexOf("daily");
}      

str = windowloc.substring(0,posn1);
      //alert("posn1 = " + posn1);
      //str = windowloc.substring(0,pos);
      //alert("str = " + str);

//alert("str + strHref = " + str + strHref );
window.location = str + strHref; 


}

function build_screen(direction)
{
var cur_rec;
var rec_ref;
var first_time;
table.hide();
		
if (is.ns)
	first_time = document.mainDiv.document.rec_store.first_time.value;
if (is.ie)
	first_time = document.rec_store.first_time.value;	

//Retrieve current record number from form.
if (is.ns) {
	cur_rec = parseInt(document.mainDiv.document.rec_store.current_rec.value);
}        

if (is.ie) {
	cur_rec = parseInt(document.rec_store.current_rec.value);

}        	

//Current record
rec_ref=eval('REC'+cur_rec);

//Hide current components if paging backwards. 
if (direction == 'first');
	{
	vul.hide();
	bidding.hide();
	contract.hide();
	comments.hide();
	north.hide();
	east.hide();
	south.hide();
	west.hide();
	}

if (direction == 'prev')
	{
	if (!rec_ref.vul_lines.empty)
		vul.hide();
	if (!rec_ref.bidding.empty)
		bidding.hide();
	if (!rec_ref.contract.empty)
		contract.hide();
	if (!rec_ref.comments.empty)
		comments.hide();	
	if (!rec_ref.north.empty)
     		north.hide();
	if (!rec_ref.east.empty)
     		east.hide();
	if (!rec_ref.south.empty)
     		south.hide();
	if (!rec_ref.west.empty)
     		west.hide();
	}

//Calculate new record number and store.
if (direction == 'first')
	cur_rec=0;

if (direction == 'prev')
	cur_rec = (cur_rec-1 < 0) ? 0 : cur_rec-1;

if (direction == 'next')
	cur_rec = ((cur_rec + 1) > num_of_recs) ? num_of_recs : cur_rec+1;

if (direction == 'last')
	{
	//Store total number of records.
	if (is.ns)
 		cur_rec = parseInt(document.mainDiv.document.rec_store.total_rec.value);
	if (is.ie)
		cur_rec = parseInt(document.rec_store.total_rec.value);
	}

//Display controls.

if (cur_rec==0)
	{
	first.hide();
	prev.hide();
        next.show();
	last.show();
	}    

if (cur_rec==num_of_recs)
	{
	next.hide();
	last.hide();
	prev.show();
	first.show();
	}
if (cur_rec>0 && cur_rec<num_of_recs)
	{
	first.show();
	last.show();
	next.show();
	prev.show();
	}

if (is.ns)
	document.mainDiv.document.rec_store.current_rec.value=cur_rec;
if (is.ie)
	document.rec_store.current_rec.value=cur_rec;

rec_ref=eval('REC'+cur_rec);

//if (first_time=='TRUE')
//	start_seq();
showArticleDate();
//alert('Hello');
show_cardtable(cur_rec);
show_vulnerability(rec_ref);
show_bidding(rec_ref);
show_bidding_comments(rec_ref);
show_contract(rec_ref);
show_text(rec_ref);
play_north(rec_ref);
play_east(rec_ref);
play_south(rec_ref);
play_west(rec_ref);



} //function

function show_cardtable(rec)
{
if (rec==0)
	return;
//Have to define table size because Netscape is crap.	
var html='<TABLE WIDTH="70" HEIGHT="70" CELLPADDING="0" CELLSPACING="0" BORDERCOLOR="green">';
html+='<TR>';
html+='<TD></TD>';
html+='<TD ALIGN="MIDDLE" VALIGN="CENTER"><STRONG><FONT CLASS="table">N</FONT></STRONG></TD>';
html+='<TD></TD>';      //VALIGN was BOTTOM
html+='</TR>';
html+='<TR>';
html+='<TD ALIGN="MIDDLE" VALIGN="CENTER"><STRONG><FONT CLASS="table">W</FONT></STRONG></TD>';
html+='<TD></TD>';  //ALIGN was "RIGHT"
html+='<TD ALIGN="MIDDLE" VALIGN="CENTER"><STRONG><FONT CLASS="table">E</FONT></STRONG></TD>';
html+='</TR>';     //ALIGN was "LEFT" 
html+='<TR>';
html+='<TD></TD>';
html+='<TD ALIGN="MIDDLE" VALIGN="CENTER"><STRONG><FONT CLASS="table">S</FONT></STRONG></TD>';
html+='<TD></TD>';      //VALIGN was TOP
html+='</TR>';
html+='</TABLE>';

table.write(html);
table.show();
}

function showArticleDate() {
var str;
var d;
var m;
var y;
var strlen;
var windowloc = new String; 
var posn1 = 0;
var targetDate;
var html='<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">';

windowloc = window.location + "<" ;
      //alert("windowlocX = " + windowloc);
posn1 = windowloc.indexOf("arch.html?");

if (posn1 == -1) {              //not via archive must be via today's article!
  //targetDate = new Date(); //pick up today's date
  targetDate = GetTodayDD_YY_CCYY(); //pick up today's date
//  alert("targetDate = " + targetDate);
  d = targetDate.substring(8,targetDate.length+1);
  m = targetDate.substring(5,7);
  y = targetDate.substring(0,4);    
  }
else {
  strlen  = windowloc.length; 
  str = windowloc.substring(posn1+14,strlen);
  //alert("posn1 = " + posn1 + '\n' + "str = " + str );  
  d = windowloc.substring(posn1+14,posn1+16);
  m = windowloc.substring(posn1+23,posn1+25);
  y  = windowloc.substring(posn1+31,posn1+35);
  //alert("d/m/y" + d + "/" + m + "/" + y);
}
html+='<TR>';
html+='<TD><FONT class="datewin">';

html+= 'Article Date: ' + d + "/" + m + "/" + y;
html+='</FONT>';
html+='</TD>';
html+='</TR>';
html+='</TABLE>';

dateWindow.write(html);
dateWindow.show();
}	
function GetTodayDD_YY_CCYY() {
	
targetDate = new Date(); //today	
var d = targetDate.getDate(); 
var m = targetDate.getMonth() + 1; 
var y = targetDate.getFullYear();
nought = "0";

//alert("ymd (after +1) = " + y + "/" + m + "/" + d); 
//d = d + 0; 
//m = m + 0; 

if (d < 10) {
   d = nought + d; 
}   
if (m < 10) {
   m = nought + m;
} 
return y + "/" + m + "/" + d;
}
function show_vulnerability(rec)
{
if (rec.vul_lines.empty)
	return;
	
var lines=rec.vul_lines;
var len=lines.length;

var html='<TABLE CELLPADDING="0" CELLSPACING="0">';
html+='<TR>';
html+='<TD ALIGN="LEFT">';

for (var i=0;i<len;i++)
	{
	html+='<TR NOWRAP>';
	html+='<TD><FONT class="vuln">' + lines[i] + '</FONT></TD>';	//<FONT class="vuln" COLOR="yellow">
//	html+='<TD > class="vuln">' + 'cheese'+ lines[i] + '</TD>'; //<P CLASS="test">Behold the power of cheese.</P> 
	html+='</TR>';
	}

html+='</TABLE>';

vul.write(html);
vul.show();
}

function show_bidding(rec)
{
if (rec.bidding.empty)
	return;

var lines    = rec.bidding;
var len      = lines.length;

var html='<TABLE CELLSPACING="0" CELLPADDING="0">';
html+='<TR>';
html+='<TD><FONT class="bidhead">' + "South" + '</FONT></TD>';
html+='<TD><FONT class="bidhead">' + "West" + '</FONT></TD>';
html+='<TD><FONT class="bidhead">' + "North" + '</FONT></TD>';
html+='<TD><FONT class="bidhead">' + "East" + '</FONT></TD>';
html+='</TR>';

for (var i=0;i<len;i++)
	{
	var row=lines[i].split(',');
	var row_len=row.length;
	html+='<TR NOWRAP>';
	for (var j=0;j<row_len;j++)
		{
		html+='<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="60" HEIGHT="12"><FONT class="bids">' + row[j] + '</FONT></TD>';
		}
	html+='</TR>';
	}

html+='</TABLE>';
bidding.write(html);
bidding.show();
}

function show_bidding_comments(rec)
{
if (rec.comments.empty)
	return;

var comm     = rec.comments;
var comm_len = comm.length;

var html='<TABLE CELLSPACING="0" CELLPADDING="0">';
for (var i=0;i<comm_len;i++)
	{
	html+='<TR>';
//	html+='<TD ALIGN="LEFT" VALIGN="TOP"><FONT FACE="Times New Roman" SIZE="2">' + comm[i] + '</FONT></TD>';
        html+='<TD ALIGN="LEFT" VALIGN="TOP"><FONT class="comments">' + comm[i] + '</FONT></TD>';
	html+='</TR>';
	}

html+='</TABLE>';
comments.write(html);
comments.show();
}

function show_contract(rec)
{
if (rec.contract.empty)
	return;

var lines=rec.contract;
var len=lines.length;
var html='<TABLE CELLSPACING="0" CELLPADDING="0">';

for (var i=0;i<len;i++)
	{
	html+='<TR>';
//	html+='<TD><FONT SIZE="2" FACE="Times New Roman"><STRONG>' + lines[i] + '</STRONG></FONT></TD>';
	html+='<TD><FONT class="contract">' + lines[i] + '</FONT></TD>';
	html+='</TR>';
	}

html+='</TABLE>';
contract.write(html);
contract.show();
}

function show_text(rec){
if (rec.text.empty) {
   return;
   }
//AEK frig 21/01/2001 - if the character string in the text starts with &nbsp;
// - don't show the table!!
else {   
//    table.show();	
    if (rec.text.substring(0,6) == '&nbsp;') {
       table.hide()
    }
    else {
        if (rec.text.indexOf(noArticle) != -1) {
           table.hide();
           first.hide();
           next.hide();
           prev.hide();
           last.hide();
        }   
    }     	
}    

var lines=rec.text;
var html='<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">';
html+='<TR>';
html+='<TD><FONT class="article">';
html+='<p style="text-align:justify">';
html+=lines;
html+='</p>';
html+='</FONT>';
html+='</TD>';
html+='</TR>';
html+='</TABLE>';

//textContent.moveTo(null,0);
textWindow.write(html);
//textScroll  = new MiniScroll(textWindow,textContent);
}

function play_north(rec)
{
//Displays the north hand if not empty.
if (rec.north.empty)
	return;

var html='<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" HEIGHT="100%">';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/s.gif" BORDER="0">';
html+='<FONT class="north"><STRONG>&nbsp;' + rec.north.spades + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/h.gif" BORDER="0">';
html+='<FONT class="north"><STRONG>&nbsp;' + rec.north.hearts + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/d.gif" BORDER="0">';
html+='<FONT class="north"><STRONG>&nbsp;' + rec.north.diamonds + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images//c.gif" BORDER="0">';
html+='<FONT class="north"><STRONG>&nbsp;' + rec.north.clubs + '</STRONG></FONT>';
html+='</TABLE>';

north.write(html);
north.show();
}

function play_east(rec)
{
//Displays the east hand if not empty.
if (rec.east.empty)
	return;

var html='<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" HEIGHT="100%">';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/s.gif" BORDER="0">';
html+='<FONT class="east"><STRONG>&nbsp;' + rec.east.spades + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/h.gif" BORDER="0">';
html+='<FONT class="east"><STRONG>&nbsp;' + rec.east.hearts + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/d.gif" BORDER="0">';
html+='<FONT class="east"><STRONG>&nbsp;' + rec.east.diamonds + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images//c.gif" BORDER="0">';
html+='<FONT class="east"><STRONG>&nbsp;' + rec.east.clubs + '</STRONG></FONT>';
html+='</TABLE>';

east.write(html);
east.visibility='inherit';///not sure about this??????
east.show();
}

function play_south(rec)
{
//Displays the south hand if not empty.
if (rec.south.empty)
	return;

var html='<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH=100% HEIGHT=100%>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/s.gif" BORDER="0">';
html+='<FONT class="south"><STRONG>&nbsp;' + rec.south.spades + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/h.gif" BORDER="0">';
html+='<FONT class="south"><STRONG>&nbsp;' + rec.south.hearts + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/d.gif" BORDER="0">';
html+='<FONT class="south"><STRONG>&nbsp;' + rec.south.diamonds + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images//c.gif" BORDER="0">';
html+='<FONT class="south"><STRONG>&nbsp;' + rec.south.clubs + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='</TABLE>';

south.write(html);
south.show();
}

function play_west(rec)
{
//Displays the west hand if not empty.
if (rec.west.empty)
	return;

//Width parameter removed - child must not be same size as parent. Height set to parent height.
var html='<TABLE CELLSPACING="0" CELLPADDING="0" HEIGHT="70">';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/s.gif" BORDER="0">';
html+='<FONT class="west"><STRONG>&nbsp;' + rec.west.spades + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/h.gif" BORDER="0">';
html+='<FONT class="west"><STRONG>&nbsp;' + rec.west.hearts + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images/d.gif" BORDER="0">';
html+='<FONT class="west"><STRONG>&nbsp;' + rec.west.diamonds + '</STRONG></FONT>';
html+='</TD>';
html+='</TR>';
html+='<TR>';
html+='<TD VALIGN="TOP" ALIGN="LEFT">';
html+='<IMG SRC="images//c.gif" BORDER="0">';
html+='<FONT class="west"><STRONG>&nbsp;' + rec.west.clubs + '</STRONG></FONT>';
html+='</TABLE>';

//Reset child before next move.
west.moveTo(0,null);
west.write(html);

//Align child west to the right.
var width = (is.ns) ? west.doc.width : west.elm.scrollWidth;
//Max of 4 chars (60 pixels);
width = (width<60) ? 60 : width;
west.moveBy((westmain.w-width),null);

west.show();
}

function start_seq()
{
main.hide();
start.write('<IMG SRC="images/Rimg0006.jpg">');
start.slideInit();
sequence();

if (is.ns)
	document.mainDiv.document.rec_store.first_time.value="FALSE"
if (is.ie)
	document.rec_store.first_time.value="FALSE";
}

seq = 0
function sequence() 
{
seq++
if (seq==1) 
	{
	start.moveTo(0,0)
	start.slideTo(150,150,30,10,'sequence()')
	}
else if (seq==2)
	{
 	start.slideTo(50,150,30,10,'sequence()')
	}
else if (seq==3)
	{
	start.slideTo(null,50,30,10,'sequence()')
	}
else if (seq==4)
	{
	start.slideTo(150,150,30,10,'sequence()')
	}
else if (seq==5)
	{
	start.slideTo(0,450,30,10,'sequence()')
	}

else seq = 0
}

function record(record,rec_num)
{
//Splits the input file into records and records into components.
//Uses the components to create object properties.
var vul_lines    = new Array();
var bidding      = new Array();
var contract     = new Array();
var comments     = new Array();
var components=record.split('~=~');

var north_hand  = components[0];
var east_hand   = components[1];
var south_hand  = components[2];
var west_hand   = components[3];
this.vul_lines  = components[4].split(';');
this.bidding    = components[5].split(';'); //Split into lines.
this.comments   = components[6].split(';');
this.contract   = components[7].split(';');
var text        = components[8];

var heart   = /\{H\}/ig;
var spade   = /\{S\}/ig;
var diamond = /\{D\}/ig;
var club    = /\{C\}/ig;

//Replace suit references in text.
var new_text = text.replace(heart,'<IMG SRC="images/h.gif" BORDER="0">');
new_text     = new_text.replace(spade,'<IMG SRC="images/s.gif" BORDER="0">');
new_text     = new_text.replace(diamond,'<IMG SRC="images/d.gif" BORDER="0">');
new_text     = new_text.replace(club,'<IMG SRC="images//c.gif" BORDER="0">');

this.text=new_text;

//Replace suit references in contract.
for (var i=0;i<this.contract.length;i++)
	{
	var new_contract = this.contract[i].replace(heart,'<IMG SRC="images/h.gif" BORDER="0">');
	new_contract     = new_contract.replace(spade,'<IMG SRC="images/s.gif" BORDER="0">');
	new_contract     = new_contract.replace(diamond,'<IMG SRC="images/d.gif" BORDER="0">');
	new_contract     = new_contract.replace(club,'<IMG SRC="images//c.gif" BORDER="0">');
	this.contract[i] = new_contract;
	}

//Replace suit references in bidding.
for (var i=0;i<this.bidding.length;i++)
	{
	var new_bidding = this.bidding[i].replace(heart,'<IMG SRC="images/h.gif" BORDER="0">');
	new_bidding     = new_bidding.replace(spade,'<IMG SRC="images/s.gif" BORDER="0">');
	new_bidding     = new_bidding.replace(diamond,'<IMG SRC="images/d.gif" BORDER="0">');
	new_bidding     = new_bidding.replace(club,'<IMG SRC="images//c.gif" BORDER="0">');
	this.bidding[i] = new_bidding;
	}

//Replace suit references in comments.
for (var i=0;i<this.comments.length;i++)
	{
	var new_comment  = this.comments[i].replace(heart,'<IMG SRC="images/h.gif" BORDER="0">');
	new_comment      = new_comment.replace(spade,'<IMG SRC="images/s.gif" BORDER="0">');
	new_comment      = new_comment.replace(diamond,'<IMG SRC="images/d.gif" BORDER="0">');
	new_comment      = new_comment.replace(club,'<IMG SRC="images//c.gif" BORDER="0">');
	this.comments[i] = new_comment;
	}

this.vul_lines.empty = (this.vul_lines == '' ? true : false);
this.bidding.empty   = (this.bidding   == '' ? true : false);
this.contract.empty  = (this.contract  == '' ? true : false);
this.comments.empty  = (this.comments  == '' ? true : false);

this.north = new hand(north_hand);
this.east  = new hand(east_hand);
this.south = new hand(south_hand);
this.west  = new hand(west_hand);
}

function hand(loc)
{
//Constructor for hand object.
var deal      = suits(loc);

this.spades   = deal.spades;
this.hearts   = deal.hearts;
this.diamonds = deal.diamonds;
this.clubs    = deal.clubs;
this.shown    = false;

if (this.spades   == '' &&
    this.hearts   == '' &&
    this.diamonds == '' &&
    this.clubs    == '')
	this.empty=true;
else
	this.empty=false;

}

function suits(hand)
{
//Split each hand into four suits and assign to objects.
var deal = new Object;

var s=hand.indexOf('s');
var h=hand.indexOf('h');
var d=hand.indexOf('d');
var c=hand.indexOf('c');

deal.spades   = convert(hand.substring(s+1,h));
deal.hearts   = convert(hand.substring(h+1,d));
deal.diamonds = convert(hand.substring(d+1,c));
deal.clubs    = convert(hand.substring(c+1));

return deal;
}

function convert(str)
{
//Convert each hand to upper case and translate any 't' to 10.
//2003/04/05 If we need to display x (lower case) for an indeterminate
//low card insert {l} into the card string.
var len=str.length;
var posn1 = 0;
var strlen;

posn1 = str.indexOf('{l}'); //any lower case required?
if (posn1 == -1) {              
  str=str.toUpperCase(); //no lower case required!
}
else {
   strlen  = str.length; 
   str = str.substring(0,posn1)+ str.substring(posn1+3,strlen); //remove {l}
}

new_str='';

for (var i=0;i<len;i++)
	{
	if (str.charAt(i) == 'T')
		new_str=new_str + '10 ';
	else
		new_str=new_str+str.charAt(i) + ' ';
	}
return new_str;
}
