//============================================================
//                    DECLARATIONS
//============================================================

var baseURL='http://www.cooeeart.com.au/ajjnexpo/';
var rec=new Array();
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;

//============================================================
//                    FUNCTIONS
//============================================================

function pageGenerator (cNum,pageReplace) {
    var rNum = null;
    var otherKeys = new Array;
    var strContent = new String;
    //------find theRecord i.e. rNum
    for (i=0; i < rec.length; i++) {
	if (cNum == rec[i][iNumber]) {
	    rNum = i; 
	}
    }

    if (rNum != null) {

	var theAuthor = rec[rNum][iAuthor];

	// find all other keys with the same author
	var counter = 0;
	for (i=0; i < rec.length; i++) {
	    if (theAuthor == rec[i][iAuthor] && cNum != rec[i][iNumber]) {
		otherKeys[counter] = rec[i][iNumber];
		counter++;
	    }
	}
    
	//stream to string

	strContent = '<html>\n';
	strContent += '<head>\n';
	strContent += '<title>';
	strContent += rec[rNum][iAuthor];
	strContent += ' - ';
	strContent += rec[rNum][iTitle];
	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="ajjnstyle.css" type="text/css">\n';
	strContent += '<script type="text/javascript" src="../contactpop.js"> </script>\n';
	strContent += '<script type="text/javascript" src="imgswap.js" > </script>\n';
	strContent += '<script type="text/javascript" src="pgen.js"> </script>\n';
	strContent += '<script type="text/javascript" src="rangebase.js"> </script>\n';
	strContent += '</head>\n';
	strContent += '<body onLoad="MM_preloadImages(' + "'" + './iconartistx.jpg' + "'" + ',' + "'" + './iconfrontx.jpg' + "'" + ',' + "'" + './iconpressx.jpg' + "'" + ',' + "'" + './iconpaintingsx.jpg' + "'" + ',' + "'" + './iconcontactx.jpg' + "'" + ',' + "'" + './iconhomex.jpg' + "'" + ')">\n';
	strContent += '<table height=100% width=100% align="center" border=0 cellpadding=4 cellspacing=0>\n';
	strContent += '<!--------------------top.lines---------->\n';
	strContent += '<tr>\n';
	strContent += '<td width=3% rowspan=5 valign="top" align="right">\n';
	strContent += '<!----------inner.table---------->\n';
	strContent += '<table border=0 cellspacing=0 cellpadding=2>\n';
	strContent += '<tr>\n';
	strContent += '<!----------NAVBAR---------->\n';
	strContent += '<tr>\n';
	strContent += '<td><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(' + "'" + 'frontpage' + "'" + ',' + "'" + '' + "'" + ',' + "'" + './iconfrontx.jpg' + "'" + ',1)"><img name="frontpage" border="0" src="./iconfront.jpg" width="50" height="50"></a></td>\n';
	strContent += '</tr>\n';
	strContent += '<!-------ARTIST------------------>\n';
	strContent += '<tr>\n';
	strContent += '<td><a href="artistpage.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(' + "'" + 'artist' + "'" + ',' + "'" + '' + "'" + ',' + "'" + './iconartistx.jpg' + "'" + ',1)"><img name="artist" border="0" src="./iconartist.jpg" width="50" height="50"></a></td>\n';
	strContent += '</tr>\n';
	strContent += '<!--------PAINT----------------->\n';
	strContent += '<tr>\n';
	strContent += '<td><a href="paintings.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(' + "'" + 'paintings' + "'" + ',' + "'" + '' + "'" + ',' + "'" + './iconpaintingsx.jpg' + "'" + ',1)"><img name="paintings" border="0" src="./iconpaintings.jpg" width="50" height="50"></a></td>\n';
	strContent += '</tr>\n';
	strContent += '<!-----------CONTACT-------------->\n';
	strContent += '<tr>\n';
	strContent += '<td><a href="javascript:contactpop()" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(' + "'" + 'contact' + "'" + ',' + "'" + '' + "'" + ',' + "'" + './iconcontactx.jpg' + "'" + ',1)"><img name="contact" border="0" src="./iconcontact.jpg" width="50" height="50"></a></td>\n';
	strContent += '</tr>\n';
	strContent += '<!-----------HOME-------------->\n';
	strContent += '<tr>\n';
	strContent += '<td><a href="../index.html" target="_top" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(' + "'" + 'home' + "'" + ',' + "'" + '' + "'" + ',' + "'" + './iconhomex.jpg' + "'" + ',1)"><img name="home" border="0" src="./iconhome.jpg" width="50" height="50"></a></td>\n';
	strContent += '</tr>\n';
	strContent += '</table>\n';
	strContent += '<!----------^^^^^^^^^^---------->\n';
	strContent += '</td>\n';
	strContent += '<!-------VDOTS---------->\n';
	strContent += '<td rowspan=5 class="tabvdotstrut" width=1%><span style="font-size: 2px">&nbsp;</span></td>\n';
	strContent += '<!----------MAIN---------->\n';
	strContent += '<td rowspan=3 valign="middle" align="right">\n';
	strContent += '<img width=450 height=1 src="width.gif"><br>\n';
	strContent += '<img src="./pics/';
	strContent += rec[rNum][iNumber];
	strContent += '.gif" alt="#'
	    strContent += rec[rNum][iNumber];
	strContent += '" ';
	strContent += ' >';
	strContent += '</td>\n';
	strContent += '<td class="tabvlinestrut" width=1%><span style="font-size: 2px">&nbsp;</span></td>\n';
	strContent += '<!----------THUMBS---------->\n';
	strContent += '<td colspan=1 valign="bottom" align="left">\n';
	//-----------------------------------------------------------
	for (i = 0; i < otherKeys.length; i++) {
	    strContent += '<a href="';
	    strContent += 'javascript:void(pageGenerator(';
	    strContent += "'";
	    strContent += otherKeys[i];
	    strContent += "',1";
	    strContent += '))"><img src="./pics/';
	    strContent += otherKeys[i];
	    strContent += 't.gif" alt="#';
	    strContent += otherKeys[i];
	    strContent += '" border=0 width=50 height=50></a>\n';
	}
	//------------------------------------------------------------
	strContent += '</td>\n';
	strContent += '</tr>\n';
	strContent += '<!----2nd row---->\n';
	strContent += '<tr>\n';
	strContent += '<!---------HLINE----------->\n';
	strContent += '<td colspan=2 class="tabhlinestrut" height=1%><span style="font-size: 2px">&nbsp;</span></td>\n';
	strContent += '<!------------------------->\n';
	strContent += '</tr>\n';
	strContent += '<tr>\n';
	strContent += '<!----------VLINE---------->\n';
	strContent += '<td class="tabvlinestrut"><span style="font-size: 2px">&nbsp;</span></td>\n';
	strContent += '<!----------ANNOT---------->\n';
	strContent += '<td valign="bottom" align="left">\n';
	strContent += '<img src="./separator.jpg" width=200 height=10>\n';
	strContent += '<div class="artist">';
	strContent += rec[rNum][iAuthor];
	strContent += '</div>\n';
	strContent += '<div class="title">';
	strContent += rec[rNum][iTitle];
	strContent += '</div>\n';
	strContent += '<div class="other">';
	strContent += rec[rNum][iMedium];
	strContent += '</div>\n';
	strContent += '<div class="other">';
	strContent += 'catalog#&nbsp;';
	strContent += rec[rNum][iNumber];
	strContent += '</div>\n';
	if (rec[rNum][iSizeX] != '' && rec[rNum][iSizeY] != '') {
	    strContent += "<div class='other'>";
	    strContent += rec[rNum][iSizeX];
	    strContent += "&nbsp;x&nbsp;";
	    strContent += rec[rNum][iSizeY];
	    strContent += "&nbsp;m</div>\n";
	}
	if (rec[rNum][iPrice] == 'SOLD') {
	    strContent += '<img width=20 height=20 src="sold.jpg" >';
	}
	else {
	    strContent += rec[rNum][iPrice];
	}
	strContent += '</div>\n';
	strContent += '<div class="smallprint">&nbsp;</div>\n';
	//Prices, if indicated, are given in Australian dollars, GST inclusive.
	strContent += '</td>\n';
	strContent += '</tr>\n';
	strContent += '<tr>\n';
	strContent += '<!----------HLINE---------->\n';
	strContent += '<td colspan=3 class="tabhlinestrut" height=1% ><span style="font-size: 2px">&nbsp;</span></td>\n';
	strContent += '</tr>\n';
	strContent += '<tr>\n';
	strContent += '<!----------STORY---------->\n';
	strContent += '<td class="tabstory" colspan=3>\n';
	strContent += '<p class="othertext">';
	strContent += rec[rNum][iRegion];
	strContent += '</p>\n';
	strContent += '<p class="othertext">';
	strContent += rec[rNum][iStory];
	strContent += '</p>\n';
	strContent += '</td>\n';
	strContent += '</tr>\n';
	strContent += '</table>\n';
	strContent += '</body></html>\n';
    }
    else {
	strContent = catalogError(cNum);
    }
	
	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;
}
	    
//============================================================

