//============================================================
//                    DECLARATIONS
//============================================================

// global arrays
var rec=new Array();
var bioBase = new Array();


var baseURL='http://www.cooeeart.com.au/wandjina/';



var iNumber = 0;
var iAuthor = 1;
var iTitle = 2;
var iMedium = 3;
var iSizeX = 4;
var iSizeY = 5;
var iPrice = 6;
var iRange = 7;
var iRegion = 8;
var iStory = 9;
var iImageformat = 10;


//---DABSE in rangebase.js

//============================================================
//                    FUNCTIONS
//============================================================

function pageGenerator (cNum,pageReplace) {
    var rNum = null;
    var midContent = new String;
    var strContent = new String;
    var titleLine = new String;
    
    switch (cNum) {
    case "artist" :
	titleLine = "Featured Artists";
	midContent = artistList;
	break;
    case "lilykaredada" :
	titleLine = "Lily Karedada";
	midContent = bioBase['lilykaredada'];
	break;
    case "jackdale" :
	titleLine = "Jack Dale";
	midContent = bioBase['jackdale'];
	break;
    case "derekoobagooma" :
	titleLine = "Derek Oobagooma";
	midContent = bioBase['derekoobagooma'];
	break;
    case "press" :
	titleLine = "Press Release";
	midContent = pressRelease;
	break;
    case "contact" :
	titleLine = "Contacts";
	midContent = contactPage;
	break;
    case "story" :
	titleLine = "Wandjina Story";
	midContent = theStory;
	break;
    default:
	//------find theRecord i.e. rNum
	for (i=0; i < rec.length; i++) {
	    if (cNum == rec[i][iNumber]) {
		rNum = i; 
	}
	}
    }
    
    if (rNum != null) {
	titleLine = rec[rNum][iAuthor];
	midContent = '<img src="./pics/';
	midContent += rec[rNum][iNumber];
	midContent += '.jpg" alt="#';
	midContent += rec[rNum][iNumber];
	midContent += '" >\n';
	midContent += '<!----------ANNOT---------->\n';
	midContent += '<div class="artist">';
	midContent += rec[rNum][iAuthor];
	midContent += '</div>\n';
	midContent += '<div class="title">';
	midContent += rec[rNum][iTitle];
	midContent += '</div>\n';
	midContent += '<div class="other">';
	midContent += rec[rNum][iMedium];
	midContent += '</div>\n';
	midContent += '<div class="other">';
	midContent += 'catalog#&nbsp;';
	midContent += rec[rNum][iNumber];
	midContent += '</div>\n';
	if (rec[rNum][iSizeX] != '' && rec[rNum][iSizeY] != '') {
	    midContent += '<div class="other">size:&nbsp;';
	    midContent += rec[rNum][iSizeX];
	    midContent += '&nbsp;x&nbsp;';
	    midContent += rec[rNum][iSizeY];
	    midContent += '&nbsp;m</div>\n';
	    midContent += '<div class="other">';
	}
	if (rec[rNum][iPrice] == 'SOLD') {
	    midContent += '<img width=20 height=20 src="sold.jpg" >';
	}
	else {
	    midContent += rec[rNum][iPrice];
	}
	midContent += '</div>\n';
	midContent += '<div class="smallprint">&nbsp;</div>\n';
	//Prices, if indicated, are given in Australian dollars, GST inclusive.
	midContent += '<!----------STORY---------->\n';
	midContent += '<p class="othertext">';
	midContent += rec[rNum][iRegion];
	midContent += '</p>\n';
	midContent += '<p class="othertext">';
	midContent += rec[rNum][iStory];
	midContent += '</p>\n';
    }
    

    
	//stream to string

    strContent = '<html>\n';
    strContent += '<head>\n';
    strContent += '<title>';
    strContent += titleLine;
    strContent += '</title>\n';
    //    strContent += '<base href="';
    //strContent += baseURL;
    //strContent += '">\n';
    
    strContent += '<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">\n';
    strContent += '<link rel="stylesheet" href="wandjina.css" type="text/css">\n';
    strContent += '<script type="text/javascript" src="contacts.js"> </script>\n';
    strContent += '<script type="text/javascript" src="press.js" > </script>\n';
    strContent += '<script type="text/javascript" src="artist.js" > </script>\n';
    strContent += '<script type="text/javascript" src="story.js" > </script>\n';
    strContent += '<script type="text/javascript" src="pgen.js"> </script>\n';
    strContent += '<script type="text/javascript" src="rangebase.js"> </script>\n';
    strContent += '<script type="text/javascript" src="lilykaredada.js"> </script>\n';
    strContent += '<script type="text/javascript" src="jackdale.js"> </script>\n';
    strContent += '<script type="text/javascript" src="derekoobagooma.js"> </script>\n';
    strContent += '</head>\n';
    strContent += '<body>\n';
    strContent += '<table height=100% width=100% align="center" border=0 cellpadding=4 cellspacing=0>\n';
    strContent += '<tr>\n';
    strContent += '<!-----------LEFT-------------->';
    strContent += '<td width=180 valign="top" align="right">\n';
    //---------------------------------------------------------
    for (i = 0; i < Math.round(rec.length / 2); i++) {
	strContent += '<a href="';
	strContent += 'javascript:void(pageGenerator(';
	strContent += "'";
	strContent += rec[i][iNumber];
	strContent += "',1";
	strContent += '))"><img src="./pics/';
	strContent += rec[i][iNumber];
	strContent += 't.gif" alt="#';
	strContent += rec[i][iNumber];
	strContent += '" border=0 width=80 height=80></a>\n';
    }
    //------------------------------------------------------------
    strContent += '</td>\n';
    strContent += '<!------MAIN PICTURE---->\n';
    strContent += '<td valign="middle" align="center">\n';
    strContent += '<img width=400 height=1 src="width.gif"><br>\n';
    //====================central panel========================
    strContent += midContent;
    //=========================================================
    strContent += '</td>\n';
    strContent += '<!----------RIGHT------------->';
    strContent += '<td width=180 valign="top" align="left">\n';
    //---------------------------------------------
    for (i = Math.round(rec.length / 2); i < rec.length; i++) {
	strContent += '<a href="';
	strContent += 'javascript:void(pageGenerator(';
	strContent += "'";
	strContent += rec[i][iNumber];
	strContent += "',1";
	strContent += '))"><img src="./pics/';
	strContent += rec[i][iNumber];
	strContent += 't.gif" alt="#';
	strContent += rec[i][iNumber];
	strContent += '" border=0 width=80 height=80></a>\n';
    }
    //------------------------------------------------------------
    strContent += '</td>\n';
    strContent += '</tr>\n';
    strContent += '<tr>\n';
    strContent += '<td colspan=3 class="tabhdotstrut"><span style="font-size: 2px">&nbsp;</span></td>\n';
    strContent += '</tr>\n';
    strContent += '<tr>\n';
    strContent += '<td colspan=3 valign="top" align="center">\n';
    // cooee home
    strContent += '<a href="http://www.cooeeart.com.au" target="_top">cooee&nbsp;home</a>';
    strContent += '&nbsp;|&nbsp;';
    // contact pop
    strContent += '<a href="javascript:void(pageGenerator(';
    strContent += "'";
    strContent += 'contact';
    strContent += "',1";
    strContent += '))">contacts</a>';
    strContent += '&nbsp;|&nbsp;';
    // artists
    strContent += '<a href="javascript:void(pageGenerator(';
    strContent += "'";
    strContent += 'artist';
    strContent += "',1";
    strContent += '))">artists</a>';
    strContent += '&nbsp;|&nbsp;';
    // story
    strContent += '<a href="javascript:void(pageGenerator(';
    strContent += "'";
    strContent += 'story';
    strContent += "',1";
    strContent += '))">story</a>';
    // press
    strContent += '&nbsp;|&nbsp;';
    strContent += '<a href="javascript:void(pageGenerator(';
    strContent += "'";
    strContent += 'press';
    strContent += "',1";
    strContent += '))">press&nbsp;release</a><br>\n';
    strContent += '&copy;&nbsp;Coo-ee&nbsp;Aboriginal&nbsp;Art,&nbsp;2001</td>\n';
    strContent += '</tr>\n';
    strContent += '</table>\n';
    strContent += '</body>\n';
    strContent += '</html>\n';

    if (pageReplace == true) {
	document.open("text/html","replace"); 
    }
    else {
	document.open("text/html");
    }
    document.write(strContent);
    document.writeln();
    document.close();
    
    //return void(0);
}

//============================================================

function catalogError(cNum) {
    var strContent= new String;
    strContent = "<html><head><title>Catalog Error</title>\n";
    strContent += "<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>\n";
    strContent += '<base href="';
    strContent += baseURL;
    strContent += '">\n';
    strContent += "<link rel='stylesheet' href='ajjnstyle.css'>\n";
    strContent += "</head>\n<body><span class='bignote'>Record #";
    strContent += cNum;
    strContent += " not found</span>\n";
    strContent += "</body></html>";
    return strContent;
    }

//============================================================

function altTextValue (recIndex) {
    var tempString = new String;
    tempString = "#";
    tempString += rec[recIndex][iNumber];
    tempString += ": ";
    tempString += rec[recIndex][iTitle];
    return tempString;
}
	    
//============================================================
