<!--
// FILE NAME:  ARTICLES_CLIENT.JS
// AUTHOR:  ADAM LANGHALS - marchFIRST
// PURPOSE: THIS FILE HOLDS THE CODE USED BY CLIENT-SIDE PORTION OF THE
//          ARTICLES ENGINE.

/******************************************************************************/

// The aParagraph array stores the information required to build the
// article paragraph.
//
// It's structure is as such
//
//    Element 0: paragraph style
//    Element 1: main image name
//    Element 2: headline
//    Element 3: body text
//    Element 4: bullet number
//
// Here is a sample array.
//
// aParagraph = [1, "lifestyle1.jpg", "Hanging Blinds", "blah <b>blah</b> blah", 1];


/*********************************************************************************/

var aParagraph      = new Array();

var imgSpacer       = "/smith_noble/images/spacer.gif";

var imgBullet       = "/smith_noble/images/articles/bullet_";
var imgBulletType   = "gif";

var mainImgWidth    = 'width="106"';
var secImgWidth     = 'width="184"';
var fullImgWidth    = 'width="450"';
var bulletImgWidth  = 'width="17"';

var mainImgHeight   = 'height="106"';
var secImgHeight    = 'height="230"';
var bulletImgHeight = 'height="17"';

var mainImgSize     = mainImgWidth + " " + mainImgHeight;
var secImgSize      = secImgWidth + " " + secImgHeight;
var fullImgSize     = fullImgWidth + " " + mainImgHeight;
var bulletImgSize   = bulletImgWidth + " " + bulletImgHeight;

/*********************************************************************************/
// This code reads the article array and determines the type of paragraph to build.
function writeParagraph(array)
{
     switch (array[0])
     {
          case "1":
               writeStyle1Paragraph(array);
               break;
          case "2":
               writeStyle2Paragraph(array);
               break;
          case "3":
               writeStyle3Paragraph(array);
               break;
          case "4":
               writeStyle4Paragraph(array);
               break;
          case "5":
               writeStyle5Paragraph(array);
               break;
          case "6":
               writeStyle6Paragraph(array);
               break;
          case "7":
               writeStyle7Paragraph(array);
               break;
          case "8":
               writeStyle8Paragraph(array);
               break;
          case "9":
               writeStyle9Paragraph(array);
               break;
          case "10":
               writeStyle10Paragraph(array);
               break;
          default:
               writeStyle1Paragraph(array);
               break;
     }
}

/*********************************************************************************/
// This code reads the article array and determines the type of paragraph to build.
function writeSpecificParagraph(paragraphNumber)
{
    var paragraphName;

    paragraphArray = eval("Paragraph" + paragraphNumber);
    writeParagraph(paragraphArray);
}

/*********************************************************************************/

// This function builds the style 1 paragraph.

function writeStyle1Paragraph(array)
{
     var html = "";

     html = html.concat('<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td class="bodyCopy11Grey">', array[3], '</td></tr>',
                        '<tr><td><img src="', imgSpacer, '" width="1" ',
                        'height="10"></td></tr>',
                        '</table>');

     document.write(html);
}

/*********************************************************************************/
// This function builds the style 2 paragraph.
function writeStyle2Paragraph(array)
{
     var html = "";

     html = html.concat('<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td class="subhead">', array[2], '</td></tr>',
                        '<tr><td><img src="', imgSpacer, '" width="1" ',
                        'height="5"></td></tr>',
                        '<tr><td class="bodyCopy11Grey">', array[3], '</td></tr>',
                        '<tr><td><img src="', imgSpacer, '" width="1" ',
                        'height="20"></td></tr>',
                        '</table>');

     document.write(html);
}

/*********************************************************************************/
// This function builds the style 3 paragraph.
function writeStyle3Paragraph(array)
{
     var imgSize = mainImgWidth + ' height="1"';
     var imgSource = imgSpacer;

     if (array[1] != "")
     {
         imgSource = array[1];
         imgSize = mainImgSize;
     }

     var html = "";

     html = html.concat('<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td valign="top"><img src="',
                        imgSource, '" ', imgSize, ' border="0"></td>',
                        '<td width="10"><img src="', imgSpacer, '" width="10" ',
                        'height="1"></td>',
                        '<td valign="top" class="bodyCopy11Grey">', array[3], '</td></tr>',
                        '<tr><td colspan="3"><img src="', imgSpacer, '" width="1" ',
                        'height="20"></td></tr>',
                        '</table>');

     document.write(html);
}

/*********************************************************************************/
// This function builds the style 4 paragraph.
function writeStyle4Paragraph(array)
{
     var imgSize      = mainImgWidth + ' height="1"';
     var bulletSize   = bulletImgWidth + ' height="1"';
     var mainImage    = imgSpacer;
     var bulletImage  = imgSpacer;

     if (array[1] != "")
     {
         mainImage = array[1];
         imgSize   = mainImgSize;
     }

     if ( (array[4] != "") && (array[4] != 0) )
     {
        bulletImage = imgBullet + array[4] + '.' + imgBulletType;
        bulletSize  = bulletImgSize;
     }

     var html = "";

     html = html.concat('<span class="subhead">', array[2], '</span><br>',
                        '<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td valign="top"><img src="', mainImage, '" ', imgSize, ' " border="0"></td>',
                        '<td width="10"><img src="', imgSpacer, '" width="5" ',
                        'height="1"></td>',
                        '<td valign="top" class="bodyCopy11Grey">', array[3], '</td>',
                        '</tr></table>',
                        '<img src="', imgSpacer, '" width="1" ', 'height="20"><br>');

     document.write(html);
}

/*********************************************************************************/
// This function builds the style 5 paragraph.
function writeStyle5Paragraph(array)
{
     var imgSize = mainImgWidth + ' height="1"';
     var imgSource = imgSpacer;

     if (array[1] != "")
     {
         imgSource = array[1];
         imgSize = mainImgSize;
     }

     var html = "";

     html = html.concat('<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr>',
                        '<td valign="top" class="bodyCopy11Grey">', array[3], '</td>',
                        '<td width="10"><img src="', imgSpacer, '" width="10" height="1"></td>',
                        '<td valign="top"><img src="',
                        imgSource, '" ', imgSize, ' border="0"></td><tr>',
                        '<tr><td colspan="3"><img src="', imgSpacer, '" width="1" ',
                        'height="20"></td></tr>',
                        '</table>');

     document.write(html);
}

/*********************************************************************************/
// This function builds the style 6 paragraph.
function writeStyle6Paragraph(array)
{
     var imgSize = mainImgWidth + ' height="1"';
     var imgSource = imgSpacer;

     if (array[1] != "")
     {
         imgSource = array[1];
         imgSize = mainImgSize;
     }

     var html = "";

     html = html.concat('<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td valign="top"><img src="',
                        imgSource, '" ', imgSize, ' border="0"></td>',
                        '</tr>',
                        '<tr><td align="right" class="bodyCopyBold">', array[2], '</td></tr>',
                        '<tr><td><img src="', imgSpacer, '" width="1" ',
                        'height="20"></td></tr>',
                        '</table>');

     document.write(html);
}

/*********************************************************************************/
// This function builds the style 7 paragraph.
function writeStyle7Paragraph(array)
{
     var imgSize = bulletImgWidth + ' height="1"';
     var imgSource = imgSpacer;

     if (array[1] != "")
     {
         imgSource = array[1];
         imgSize = bulletImgSize;
     }

     var html = "";

     html = html.concat('<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td valign="top"><img src="',
                        imgSource, '" border="0" ', bulletImgSize, '></td>',
                        '<td width="5"><img src="', imgSpacer, '" width="5" ',
                        'height="1"></td>',
                        '<td valign="top" class="bodyCopy11Grey">', array[3], '</td></tr>',
                        '<tr><td colspan="3"><img src="', imgSpacer, '" width="1" ',
                        'height="20"></td></tr>',
                        '</table>');

     document.write(html);
}

/*********************************************************************************/
// This function builds the style 8 paragraph.
function writeStyle8Paragraph(array)
{
     var bulletSize   = bulletImgWidth + ' height="1"';
     var bulletImage  = imgSpacer;

     if ( (array[4] != "") && (array[4] != 0) )
     {
        bulletImage = imgBullet + array[4] + '.' + imgBulletType;
        bulletSize  = bulletImgSize;
     }

     var html = "";

     html = html.concat('<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td valign="top"><img src="', bulletImage, '" ', bulletSize, ' border="0"></td>',
                        '<td width="5"><img src="', imgSpacer, '" width="5" ',
                        'height="1"></td>',
                        '<td valign="top"><table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td height="2"><img src="', imgSpacer, '" height="2" width="1"></td></tr>',
                        '<tr><td valign="top" class="subhead" height="5">', array[2], '</td></tr>',
                        '<tr><td height="2"><img src="', imgSpacer, '" width="5" ',
                        'height="2"></td></tr>',
                        '<tr><td valign="top" class="bodyCopy11Grey">', array[3], '</td></tr></table>',
                        '</td><td width="20"><img src="', imgSpacer, '" width="20" ',
                        'height="1"></td></tr>',
                        '<tr><td colspan="4"><img src="', imgSpacer, '" width="1" ',
                        'height="20"></td></tr>',
                        '</table>');

     document.write(html);
}

/*********************************************************************************/
// This function builds the style 9 paragraph.
function writeStyle9Paragraph(array)
{
     var imgSize = fullImgWidth + ' height="1"';
     var imgSource = imgSpacer;

     if (array[1] != "")
     {
         imgSource = array[1];
         imgSize = fullImgSize;
     }

     var html = "";

     html = html.concat('<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td valign="top"><img src="',
                        imgSource, '" ', imgSize, ' border="0"></td>',
                        '</tr>',
                        '<tr><td><img src="', imgSpacer, '" width="1" ',
                        'height="20"></td></tr>',
                        '</table>');

     document.write(html);
}

/*********************************************************************************/
// This function builds the style 10 paragraph.
function writeStyle10Paragraph(array)
{
     var imgSize      = secImgWidth + ' height="1"';
     var secImage     = imgSpacer;

     if (array[1] != "")
     {
         secImage = array[1];
         imgSize   = secImgSize;
     }

     var html = "";

     html = html.concat('<table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td valign="top"><img src="', secImage, '" ', imgSize, ' " border="0"></td>',
                        '<td width="10"><img src="', imgSpacer, '" width="10" ',
                        'height="1"></td>',
                        '<td valign="top"><table border="0" cellpadding="0" cellspacing="0">',
                        '<tr><td height="2"><img src="', imgSpacer, '" height="2" width="1"></td></tr>',
                        '<tr><td valign="top" class="pageHeader" height="5">', array[2], '</td></tr>',
                        '<tr><td height="10"><img src="', imgSpacer, '" width="1" ',
                        'height="10"></td></tr>',
                        '<tr><td valign="top" class="bodyCopy11Grey">', array[3], '</td></tr></table>',
                        '</td><td width="20"><img src="', imgSpacer, '" width="20" ',
                        'height="1"></td></tr>',
                        '<tr><td colspan="4"><img src="', imgSpacer, '" width="1" ',
                        'height="20"></td></tr>',
                        '</table>');

     document.write(html);
}
//-->
