//	album.js
//	functions for managing a series of images in a flip-book

//	Image/Title/Description swap functions ...............................

//	set paint title and description arrays ..............................
//	format:  1-Image name, 2-Title, 3-Description (first line), 4-Description (second line), 5-More Description, 6-apparent image width parameter (empty is full width)
//	Use pipe (|) for delimiter

var paintArr = new Array(
	'paint_1|Echoes, (Tara, Co. Meath), 1997|Oil on canvas, 38 X 46 in. (96.5 X 116.8 cm)|Private Collection, New Jersey',
	'paint_2|Red Sky, 1986|Acrylic on canvas, 60 X 60 in. (152.4 X 152.5 cm)|Private Collection, New Jersey||368',
	'paint_3|The Abbey (Naven, Co. Meath), 1995|Oil on canvas, 58 X 72 in. (147.3 X 182.8 cm)|Private Collection, New Jersey',
	'paint_4|Another Autumn, 2001|Oil on canvas, 16 X 20 in. (40.6 X 50.8 cm.)|Artist\'s Collection, Connecticut',
	'paint_5|After Eden, 2005|Oil on canvas, 48 X 54 in. (121.9 X 137 cm.)|The Sexton/Goldberg Collection, New York||342',
	'paint_9|Ruins, Co. Meath|Oil on canvas, 20" x 30" (50.8cm x 76.2cm)|Private Collection||413',
	'paint_11|San Mamet, Italy|Oil on canvas, 20" x 30" (50.8cm x 76.2cm)|Private Collection||',
	'paint_6|Summer School (Florence), 1990|Oil on canvas, 30 X 46 in. (76.2 X 116.8 cm.)|Private Collection',
	'paint_7|First Light (Vermont), 1982|Oil on canvas, 20 X 30 in. (50.8 X 76.2 cm.)|Private Collection',
	'paint_8|Lazy Day|Mixed media on paper, 11" x 14"(29cm x 37.2cm)|Knapp Collection'
);

var drawArr = new Array(
	'draw_1|Ashes (Glendalough, Co. Wicklow), 1984|Graphite on paper, 20 X 30in.  (50.8 X 76.2cm)|Private Collection, Dublin, Ireland||405',
	'draw_2|Barn Study, 1988|Graphite on paper, 18 X 22 in. (45.7 X 55.8 cm)|Private Collection, Boston, Massachusetts',
	'draw_3|Well Earned, 1994|Graphite on paper, 20 X 30 in. (50.8 X 76.2 cm)|Artist\'s Collection, New York',
	'draw_4|Winter Silence, 1982|Graphite on paper, 18 X 24 in. (45.7 X 60.9 cm)|Duffy Family Collection Co. Meath, Ireland',
	'draw_13|The Outcast|Graphite on paper, 22" x 30" (58cm x 76.2cm)|Private Collection',
	'draw_5|Male Nude #11, 2005|Graphite on paper, 14 X 22 in. (35.5 X 55.8 cm)|Private Collection, Boston, Massachusetts||326',
	'draw_6|Still Life with Shell, 1995|Graphite on paper, 14 X 18 in. (35.5 X 45.7 cm)|Rosenfeld Collection, New York',
	'draw_7|Rock Road, 2003|Graphite on paper, 22 X 30 in. (55.8 X 76.2 cm)|Private Collection, Japan',
	'draw_10|Roseland, (New York), 1990|Mixed media on pencil, 18 X 24 in. (45 X 60.9 cm)|Private Collection||413',
	'draw_11|Bill, 2000|Mixed media on board, 8 x 10in. (20.3 x 25.4 cm)|Limpert Collection, Connecticut.||371',
	'draw_12|Great Swamp|Graphite on paper, 14" x 18"|Private Collection||438',
	'draw_14|Self Portrait|8" x 10" (20.5cm x 25.5cm), Graphite on paper|Private Collection||'
);

var portraitArr = new Array(
	
	'portrait_6|The Thinker, (Professor Charles Reich), 2002|Oil on canvas, 46 X 60 in. (116.8 X 152.4 cm)|Yale Law School||305',
	'portrait_4|Portrait of Dean John Sexton, 2001|Oil on canvas, 54 X 60 in. (137 X 152.4 cm)|New York University School of Law, New York||348',
	'portrait_14|James A. Thomas|Jack B. Tate Senior Fellow and Decanal Adviser|44" x 60" (112cm x 153cm), Oil on canvas |Yale Law School Collection|312',
	'portrait_12|Frederick D.S. Choi|Dean of the Undergraduate College and Vice Dean of The Stern School of Business|32" x 44" (91cm x 112cm), Oil on canvas|Stern School Collection|326',
	'portrait_1|Professor Boris Bittker, 2002|Oil on canvas, 42 X 46 in (106.6 X 116.8 cm)|Yale Law School||330',
	'portrait_15|John G. Simon|Augustus E. Lines Professor Emeritus and Professorial Lecturer in Law|46" x 54" (117.5cm x 138.2cm), Oil on canvas|Yale Law School Collection|323',
	'portrait_30|William Casey|CIA Chief, Washington, DC|16" x 20" (40.6cm x 50.8cm), Graphite on paper|Private Collection|342',
	'portrait_13|Carroll D, Stevens, Senior Fellow in Law|34" x 46" (96.3cm x 117.5cm), Oil on canvas|Yale Law School Collection||322',
	'portrait_8|Portrait of Quinlan, 1984|Graphite on paper, 20 X 30 in. (50.8 X 76.2 cm)|The Caan Collection, Bermuda',
	'portrait_2|Head Study (Andrew Carnegie), 1987|Mixed media on panel, 14 X 18 in. (35.5 X |Carnegie Mellon University, Pittsburgh, PA||316',
	'portrait_16|Martin and Helen Kimmel|60" x 60" (153cm x 153cm), Oil on canvas| Kimmel Center for Student Life|New York University, N.Y.|336',
	'portrait_5|Portrait in Black and Red, 2001|Oil on canvas, 30 X 42 in. (76.2 X 106.6 cm)|The Goldberg/Sexton Collection',
	'portrait_28|The Shawl, 1984|Graphite on paper, 18 X 24 in. (45.7 X 60.9 cm)|Private Collection||386',
	'portrait_10|Portofino, 1999|Graphite on paper, 20 X 30 in. (50.8 X 76.2 cm)|Limpert Collection, Connecticut.',
	'portrait_9|Molly (#5 of six), 1982|Graphite on paper, 10 X 12in (25.4 X 30.4 cm)|Duffy Family Collection, Co. Meath, Ireland||354',
	'portrait_17|Mrs. Stevens Baird|16" x 22"(41cm x 70.5cm), Graphite on paper|Stevens Institute of Technology Collection||344',
	'portrait_7|Portrait of Marianna, 2001|Oil on canvas, 38 X 50 in. (96.5 X 127 cm)|The Deutche Family Collection, New York||313',
	'portrait_18|Andrew|30" x 40" (76.5cm x 102cm), Oil on canvas|Kastner Collection||334',                                               
	'portrait_27|Tanner 2005|30" x 40" (76.2cm x 101.4cm), Oil on canvas|||324',
	'portrait_29|Aidan|30" x 40" (76.5cm x 102cm), Oil on canvas|Private Collection||334',
	'portrait_20|Haley|30" x 40" (76.5cm x 102cm), Oil on canvas|Kastner Collection||315',          
	'portrait_26|Weston 2005|30" x 40" (76.2cm x 101.4cm), Oil on canvas|Private Collection||336',
	'portrait_22|Three Sons|22" x 30" (56cm x 76.5cm), Graphite on paper|Private Collection||315',
	'portrait_23|Baby Girl|6" x 6" (15.3cm x 15.3cm), Graphite on paper|Private Collection||360',
	'portrait_11|Portrait of a Young Lady, 2000|Graphite on board, 30 x 40 in. (76.2 X 101.6 cm)|Goldberg/Sexton Collection, New York||317',
	'portrait_19|Audrey|6" x 6" (15.3cm x 15.3cm), Graphite on paper|Burkey Collection||330',             
	'portrait_24|Blonde Boy|8" x 10" (20.5cm x 25.5cm), Graphite on paper|Artist\'s Collection||314',
	'portrait_3|Portrait in Red and Green (Rachel), 1999|Oil on canvas, 34 X 46 in. (86.3 X 116.8 cm)|Private Collection||311'
);

var printArr = new Array
(
	'print_3|Summer School|signed edition of 100, trim size 27" x 42" (68.6 cm x 106.7 cm)|unframed $1200',
	'print_2|Winter Silence|signed edition of 500, trim size 18" x 22" (45.7 cm x 55.8 cm)|unframed $300',
	'print_1|First Snow|signed edition of  500, trim size 18" x 22" (45.7 cm x 55.8 cm)|unframed $300',
	'print_5|Well Earned|signed edition of 150, trim size 18" x 24" (45.7 cm x 60.9 cm)|unframed $500',
	'print_6|Left Behind|signed edition of 125, trim size 18" x 22" (45.7 cm x 55.8 cm)|unframed $400'
);

/*
	Sample hidden input values
	<input type="hidden" name="add" value="1">
	<input type="hidden" name="cmd" value="_cart">
	<input type="hidden" name="business" value="danielmarkduffy@yahoo.com">
	<input type="hidden" name="item_name" value="Winter Silence">
	<input type="hidden" name="framed" value="895.00">
	<input type="hidden" name="no_note" value="1">
	<input type="hidden" name="currency_code" value="USD">
	<input type="hidden" name="lc" value="US">
	<input type="hidden" name="bn" value="PP-ShopCartBF">
	<input type="hidden" name="unframed" value="795.00">
	
	The amount field is set on submit to either the framed or unframed price
	<input type="hidden" name="amount" value="">
	
	for arrays below, values are for the above named fields:
	1.	add
	2.	cmd
	3.	business
	4.	item_name
	5.	framed
	6.	no_note
	7.	currency_code
	8.	lc
	9.	bn
	10.	unframed
*/

var payPalInputArr = new Array
(
	'1|_cart|danielmarkduffy@yahoo.com|Summer School|1200.00|1|USD|US|PP-ShopCartBF|1700.00',
	'1|_cart|danielmarkduffy@yahoo.com|Winter Silence|300.00|1|USD|US|PP-ShopCartBF|500.00',
	'1|_cart|danielmarkduffy@yahoo.com|First Snow|300.00|1|USD|US|PP-ShopCartBF|500.00',
	'1|_cart|danielmarkduffy@yahoo.com|Well Earned|500.00|1|USD|US|PP-ShopCartBF|750.00',
	'1|_cart|danielmarkduffy@yahoo.com|Left Behind|400.00|1|USD|US|PP-ShopCartBF|650.00',
	'1|_cart|danielmarkduffy@yahoo.com|Another Autumn|150.00|1|USD|US|PP-ShopCartBF|300.00'
)
function swapPayPalInputValues(n) {
	var inputArray = new Array('add','cmd','business','item_name','unframed','no_note','currency_code','lc','bn','framed');
	var form = document.paypal;
	var loopArray = payPalInputArr[n].split('|');
	//	reset hidden field values
	for(i=0;i<inputArray.length;i++) {
		hiddenField = eval("form." + inputArray[i]);
		hiddenField.value = loopArray[i];
	}
}

//	Properties ............................................................
//	currentArray = which art array is used for the current page.  This variable is set on each page.
//		paint, draw, portrait, print 
var artID = 1;
divArr = eval(currentArray +'Arr');
var titleDescArr;
var paypalCnt = 0;
function swapArt(n) {
	//	get/set the id, artID
	if((artID + n) > divArr.length || (artID + n) < 1) {
		return;
	} else {
		artID += n;
	}
	
	titleDescArr = divArr[artID-1].split('|');
	var currentImg = '/images/' + currentArray + '/' + titleDescArr[0] + '.jpg';
	
	//	swap the main image
	swap('mainImg',currentImg);
	//	swap the number image
	swap('currentCnt','/images/num_' + artID + '.gif');
	//	write the Title/Description Div
	writeDiv(artID);
	
	//	reset paypal input fields
	if(currentArray=='print') {
		paypalCnt += n;
		payPalArr = payPalInputArr[paypalCnt];
		swapPayPalInputValues(artID-1);
	}
}

function getTitleDesc(n) {
	// if(titleDescArr.length > 0)
		return titleDescArr[n];
}

function setTitleDescArr(n) {
	titleDescArr = divArr[n-1].split('|');
}

function getCurrentImgP() {
		var imgStr = document.images['mainImg'].src;
		var lastSlash = 0;
		lastSlash = parseInt(imgStr.lastIndexOf('/'))+1;
		var newImgStr = 'p_' + imgStr.substring(lastSlash);
		var newImg = '<img src="/images/' + currentArray + '/' + newImgStr + '" border="0" alt="">';
		return newImg;
}

function swap (img,newSrc) { document.images[img].src = newSrc; }

function writeEndCnt() { document.writeln('<img src="/images/num_'+divArr.length+'.gif" width="20" height="12" id="totalCnt" name="totalCnt" border="0" alt="">'); }

function writeDiv(n) {
	//	split the arrays into Title (0) and Description (1)
	setTitleDescArr(n);
	
	//	set link colors and href to on or off
	var backColor = n==1?'off':'on'; 
	var backLink1 = n==1?'':'<a href="javascript: swapArt(-1)" onmouseover="blank();return true" class="'+backColor+'">';
	var backLink2 = n==1?'':'</a>';
	var nextColor = n==divArr.length?'off':'on';
	var nextLink1 = n==divArr.length?'':'<a href="javascript: swapArt(1)" onmouseover="blank();return true" class="'+nextColor+'">';
	var nextLink2 = n==divArr.length?'':'</a>';
	var newDiv = "";
	
	//	size the title
	// 	innerW = width of inner table
	var innerW = titleDescArr[5]?titleDescArr[5]:437;
	//	cellW = innerW - 82 (for back | next)
	var cellW = innerW-82;
	
	//	create the div table
	newDiv+=('<table cellpadding="0" cellspacing="0" width="437" border="0">');
	newDiv+=('<tr>');
	newDiv+=('<td align="right">');
	
	newDiv+=('<table cellpadding="0" cellspacing="0" width="'+innerW+'" border="0">');
	
	//	title
	newDiv+=('<tr>');
	newDiv+=('<td><span class="gray999"><i>');
	newDiv+=titleDescArr[1];
	newDiv+=('</i></span></td>');
	newDiv+=('<td valign="top" align="right" rowspan="4">');

	//	new popup icon function
	newDiv+=('<a href="javascript: openPop()"><img src="/images/glass.gif" width="57" height="17" border="0" alt="enlarge image"></a><br>');
	newDiv+=('<img src="/images/spacer.gif" width="1" height="10" border="0" alt=""><br>');
	
	//	next - back links
	newDiv+=(backLink1);
	newDiv+=('<span class="'+backColor+'">');
	newDiv+=('back');
	newDiv+=('</span>');
	newDiv+=(backLink2);
	newDiv+=(' | ');
	newDiv+=(nextLink1);
	newDiv+=('<span class="'+nextColor+'">')
	newDiv+=('next')
	newDiv+=('</span>');
	newDiv+=(nextLink2);
	newDiv+=('</td>')          
	newDiv+=('</tr>');
	
	newDiv+=('<tr><td><img src="/images/spacer.gif" width="1" height="2" border="0" alt=""></td></tr>')
	
	//	description 1
	newDiv+=('<tr>')
	newDiv+=('<td><span class="smgrey999">');
	newDiv+=titleDescArr[2];
	newDiv+=('</td></tr>');
	
	//	description 2
	newDiv+=('<tr>')
	newDiv+=('<td><span class="smgrey999">');
	newDiv+=titleDescArr[3];
	newDiv+=('</span></td></tr>');
	newDiv+=('<tr>');
	
	//	description 3
	if(titleDescArr[4]) {
		newDiv+=('<tr>')
		newDiv+=('<td colspan="2"><span class="smgrey999">');
		newDiv+=titleDescArr[4];
		newDiv+=('</span></td></tr>');
		newDiv+=('<tr>');
	}
	
	newDiv+=('<td><img src="/images/spacer.gif" width="'+cellW+'" height="1" border="0" alt=""></td>')
	newDiv+=('<td><img src="/images/spacer.gif" width="82" height="1" border="0" alt=""></td>')
	newDiv+=('</tr>');
	newDiv+=('</table>');
	
	newDiv+=('</td></tr>');
	newDiv+=('</table>');
	
	//	write out the div
	if(bw.ns4)
	{
		document.titleDesc.document.write(unescape(newDiv)); document.close()
	} else if (document.getElementById) {
		document.getElementById('titleDesc').innerHTML = unescape(newDiv);
	} else {
		document.titleDesc.innerHTML = unescape(newDiv);
	}
}

