// scriptmaster=greg@imaja.com
// This script Copyright (c) 2006 Greg Jalbert - Imaja :: http://www.imaja.com/

// functions: makeProductInfo displayListView writePayPalButton addAttribute 
//     closetag addProductRec viewaslist

var fieldNames = "title,subtitle,description,image,url,price,upgradeprice,shipping";

var fieldnamearray = fieldNames.split(",");

// Array of title,subtitle,description,image,url,price,upgradeprice,shipping
function makeProductInfo(title,subtitle,description,image,url,price,upgradeprice,shipping) {
	this.title = title;
	this.subtitle = subtitle;
	this.description = description;
	this.image = image;
	this.url = url;
	this.price = price;
	this.upgradeprice = upgradeprice;
	this.shipping = shipping;
	// method assignment
	this.displayListView = displayListView;
}

// Array of title,subtitle,description,image,url,price,upgradeprice,shipping
function displayListView(index, includegraphics, includeupgradeprice, displayWholesalePrices) {
	document.write("<tr><td valign='top'>");
	var imagepath = "images/" + this.image;
    if (includegraphics && this.image != "") {
      var imagestr = "<img";

      imagestr = addAttribute(imagestr, "src", imagepath);
//      imagestr = addAttribute(imagestr, "align", "right");
      imagestr = addAttribute(imagestr, "width", "70");
      imagestr = addAttribute(imagestr, "height", "70");
      imagestr = addAttribute(imagestr, "border", "0");
      imagestr = closetag(imagestr);
		if (this.url == "") {
			document.write(imagestr);
		} else {
			document.write("<a href='" + this.url + "'>" + imagestr + "</a>");
		}
    }
//	document.write("<b>");
// 	document.write(this.title);
//	document.write("</b> ");
	document.write("</td><td valign='top'>");

	document.write("<table width='100%' border='0' cellpadding='2' cellspacing='0' background='http://www.joelharrison.com/images/background-violet-grad-tlco.jpg'><tr><td valign='top'>"); //  bgcolor='#DDDDFF'
	var thetitle = "<b>" + this.title + "</b>";
	var itemname =  this.title;
	var selleremail = "burningcro@aol.com";
	var wholesalePrice = "";
	var truncLength = 0;
	if (includegraphics) { document.write("<span class='calloutmedium'>"); }
//	document.write(thetitle.link("/"+this.url));
	document.write(thetitle.link(this.url));
	if (includegraphics) { document.write("</span>"); }
	document.write("<br>");
//	document.write(this.subtitle);
	if (includegraphics) {
		document.write("<font color='#444444'>" + this.description + "</font><br>");
	}

	document.write("</td>");
	document.write("<td width='120' valign='top' align='right'>"); // bgcolor='#DDDDFF' 
	if (!displayWholesalePrices && this.price != "") {
	    writePayPalButton(selleremail, this.price, itemname, this.shipping);
	}
	document.write("</td>");

	if (displayWholesalePrices && this.price != "") {
		document.write("<td bgcolor='#DDDDFF' width='200' valign='top' align='right'>");
		wholesalePrice = " " + this.price * 0.6; // have to add a space to make it a string
		truncLength = wholesalePrice.indexOf(".", 0) + 3;
		wholesalePrice = wholesalePrice.substring(0, truncLength);
		if (wholesalePrice.indexOf(".", 0) == wholesalePrice.length-2) {
			wholesalePrice = "" + wholesalePrice + "0";
		}
		wholesalePrice = wholesalePrice.substring(1, wholesalePrice.length);
		itemname = itemname + " Wholesale";
		writePayPalButton(selleremail, wholesalePrice, itemname, this.shipping);
		document.write("(SRP: $" + this.price + ") <b>Wholesale: $" + wholesalePrice + "</b>");
		document.write("</td>");
	}
	if (includeupgradeprice) {
		document.write("<td bgcolor='#DDDDFF' width='100' valign='top' align='right'>");
		if (this.upgradeprice != "") {
			itemname = itemname + " Upgrade";
			writePayPalButton(selleremail, this.upgradeprice, itemname, this.shipping);
			document.write("Upgrade: $" + this.upgradeprice);
		}
		document.write("</td>");
	}
	document.write("</tr>");
//	document.write("<tr><td colspan='3' valign='top' bgcolor='#DDDDFF'>");
//	document.write("</td></tr>");
	document.write("</table>");

	document.write("</td></tr>");
// 	document.write("<tr><td colspan='2'><img src='images/line-blue-grad.gif' width='200' height='1'></td></tr>");
}

function writePayPalButton(selleremail, price, itemname, shipping)
{
    //  document.write("<br>");
	document.write('<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">');
	document.write("$" + price + " ");
	document.write('<input type="hidden" name="cmd" value="_cart">');
	document.write('<input type="hidden" name="business" value="' + selleremail + '">');
	document.write('<input type="hidden" name="item_name" value="' + itemname + '">');
	document.write('<input type="hidden" name="amount" value="' + price + '">');
	if (shipping != "") {
		document.write('<input type="hidden" name="shipping" value="' + shipping + '">');
	}

//	document.write('<input type="hidden" name="image_url" value="http://www.joelharrison.com/logo-paypal.jpg">');
	document.write('<input type="hidden" name="return" value="http://www.joelharrison.com/store/paymentsuccess.html">');
	document.write('<input type="hidden" name="cancel_return" value="http://www.joelharrison.com/store/paymentcancelled.html">');
	document.write('<input type="hidden" name="cn" value="Notes:">');
	document.write('<input type="image" src="http://www.joelharrison.com/store/images/AddtoCart.gif" border="0" name="submit" alt="Add to Cart">');
	document.write('<input type="hidden" name="add" value="1">');
	document.write('</form>');
}

function addAttribute(tagstring, attrname, attrvalue) {
	tagstring = tagstring + " " + attrname + "='" + attrvalue + "'";
	return tagstring;
}

function closetag(str) {
	return str + ">";
}

var gProductRecs = new Array(40);
var gProductRecCount = 0;

function addProductRec(title, subtitle, description, image, url, price, upgradeprice, shipping)
{
	gProductRecs[gProductRecCount] = new makeProductInfo(title, subtitle, description, image, url, price, upgradeprice, shipping);
	gProductRecCount++;
}


function viewaslist(featurednames, includegraphics, includeupgradeprice) {
	var featuredarray = featurednames.split(",");
	document.write("<table width='100%' cellpadding='2' cellspacing='0'>");
	var featureindex;
	var itemindex;
	var displayWholesalePrices = false;
	for (featureindex=0; featureindex < featuredarray.length; featureindex++) {
		for (itemindex=0; itemindex < gProductRecCount; itemindex++ ) {
			if (gProductRecs[itemindex].title == featuredarray[featureindex]) {
				gProductRecs[itemindex].displayListView(itemindex, includegraphics, includeupgradeprice, displayWholesalePrices);
			}
		}
	}
	document.write("</table>");
}

// viewaslist examples:
// parameters: featurednames, includegraphics, includeupgradeprice
// viewaslist("Harrison on Harrison,So Long 2nd Street", true, false);

function wholesaleList(featurednames) {
	var featuredarray = featurednames.split(",");
	document.write("<table width='100%' cellpadding='1' cellspacing='0'>");
	var featureindex;
	var itemindex;
	var displayWholesalePrices = true;
	var includegraphics = false;
	var includeupgradeprice = false;
	for (featureindex=0; featureindex < featuredarray.length; featureindex++) {
		for (itemindex=0; itemindex < gProductRecCount; itemindex++ ) {
			if (gProductRecs[itemindex].title == featuredarray[featureindex]) {
				gProductRecs[itemindex].displayListView(itemindex, includegraphics, includeupgradeprice, displayWholesalePrices);
			}
		}
	}
	document.write("</table>");
}


// template
// addProductRec(  title, subtitle, description, image, url, price, upgradeprice, shipping  );

// <font color='red'>NEW VERSION 2.4:</font> 
// removed shipping values 06-07-09 PJO, previously="0.00" for new PayPal shipping profile charges

addProductRec(  "Life Force", "Music CD", "Solos and duos for cello and violin featuring Wendy Sutter and Tim Fain.  Joel Harrison's first CD of all non-improvised music. <br /><em>&quot;In an era where everything’s been done and done again, Joel Harrison has found his own completely original yet totally unpredictable voice with these spare-textured, almost sacred-sounding utterances. Another great cd added to his thoroughly unorthodox catalogue.&quot;<br />- Frank J. Oteri: American Music Center</em>", "LifeForceCover100x90.jpg", "lifeforce.html", "15.00", "", ""  );
addProductRec(  "Urban Myths", "Music CD", "A wildly diverse improviser/composer/arranger with a penchant for unorthodox instrumental combinations, guitarist Joel Harrison has sustained one of the most unpredictable discographies of the last decade with his chimerical mix of jazz, blues, chamber music, African and Indian folk music, Appalachian tunes and old school country songs. On URBAN MYTHS, Joel puts his focus on the electric jazz that influenced him growing up in the 1970's. By virtue of Harrison's singular writing and a phenomenal performance by seasoned veterans, URBAN MYTHS is a major achievement and one of the most interesting records of the year, regardless of genre.", "UrbanMyths_101x100.jpg", "urbanmyths.html", "15.00", "", ""  );
addProductRec(  "The Wheel", "Music CD", "A six movement suite for string quartet and jazz quintet. A true union of the jazz and classical music traditions, with compositional influences from Appalachia and West Africa.", "thewheel-joelharrison-100w.jpg", "thewheel.html", "12.00", "", ""  );
addProductRec(  "Passing Train", "Music CD", "All new songs. &#147;Harrison is onto something both innovative and compelling and deserves a much wider audience.&#148; &#151; Don Heckman, LA Times", "passingtrain2008-100.jpg", "passingtrain.html", "12.00", "", ""  );
addProductRec(  "Harbor", "Music CD", "Guitarist Joel Harrison released Harbor on Highnote in April 2007. This recording was commissioned by the French American Jazz Exchange and Chamber Music America and includes French/Vietnamese guitarist Nguy&ecirc;n L&ecirc;, and saxophonist David Binney. As with all Harrison's music the compositions have a wide stylistic reach -- the focus for this recording is the sonic world of two guitars: Harrison, L&ecirc; (as well as Binney) all share a passion for the crossroads of jazz, rock, Indian, and African music where lyricism meets noise, Indian raga meets jazz harmony, and the after effects of electric Miles meets Messiaen and the Middle East.", "Harbor-100w.jpg", "harbor.html", "12.00", "", ""  );
addProductRec(  "Harrison on Harrison", "Music CD", "This project is a singularly original journey into the music of George Harrison. Joel reinvents George's songs, with stunning improvisational, textural, harmonic, and rhythmic twists. His band, which includes Jazz icons such as David Liebman, Uri Caine, and David Binney inhabit the arrangements with remarkable exuberance, pathos, and creativity.", "HarrisonOnHarrison100px.jpg", "harrisononharrison.html", "12.00", "", ""  );
addProductRec(  "So Long 2nd Street", "Music CD", "Once again Harrison and Free Country II travel along the seams of Jazz, Country, Blues, and Spirituals, using country classics, hymns, and folk tunes as a gateway to creative music making. Harrison has included his own compositions on this release, side by side with gems by Merle Haggard, Jimmy Webb, the Stanley Brothers, as well as timeless traditional tunes. Featuring Dave Binney.", "SoLong2ndStreet100px.jpg", "solong2ndstreet.html", "8.00", "", ""  );
addProductRec(  "Free Country", "Music CD", "Free Country is a collection of old Country and Appalachian tunes arranged in unusual, even radical, ways. Simply put, this body of work is my sonic view of the experiment known as America -- not the billboard, but the underbelly. Featuring Norah Jones and Uri Caine.", "FreeCountry100px.jpg", "freecountry.html", "8.00", "", ""  );
addProductRec(  "Transience", "Music CD", "Joel Harrison's ensemble shows off it's vitality and edgy expressionist sound here, featuring bassoonist Paul Hanson and pianist Jeff Chimenti (keyboardist for Bob Weir and The Dead).", "Transience100px.jpg", "transience.html", "12.00", "", ""  );
addProductRec(  "Range of Motion", "Music CD", "Blurs the lines between the historical categories of jazz... Intense, moody stuff that will lose jazz lovers lacking at least a decade of refining. -- Dave McElfresh: Jazz Now.", "RangeOfMotion100px.jpg", "rangeofmotion.html", "12.00", "", ""  );
addProductRec(  "3+3=7", "Music CD", "A colorful, multi-textured jazz blend, layered with elements of rock, world music, avant-garde and new classical music. Band members ramrod and muse, bash and romance, grate and croon. -- Dan Oullete: Downbeat.", "ThreePlusThree100px.jpg", "threeplusthree.html", "12.00", "", ""  );
addProductRec(  "Film Music", "Music CD", "Joel Harrison has composed music for numerous cable tv and independent documentary films for companies such as HBO, A&amp;E, Court TV, and The Learning Channel. Harrison scored the HBO film Southern Comfort which has won numerous awards, including Grand Jury Prize at Sundance, 1st place at San Francisco and Berlin Film festivals, etc. The film received rave reviews in the New York Times, LA Times, and many other publications. Two of his A&amp;E shows were rated as having close to the highest viewership of the year (1999 and 2000). He also recorded a Jazz soundtrack for Court TV's American Babylon, which included Joey Baron on drums and Greg Tardy on saxophone.", "FilmMusicVol1-100.jpg", "filmmusic.html", "", "", ""  );
addProductRec(  "Native Lands", "Music CD", "Native Lands is a collection of ethnic folk songs from around the world­arranged, performed and recorded largely with indigenous instruments and some modern aesthetics. Innovative arrangements from the traditional music of Tibet, India, Bulgaria, China, Bali, and Western Africa, and, original compositions inspired by the idioms of these lands, comprise this CD. Reflecting the charm and character of these places, the music instantly takes the listener to a journey of the past, to a world far away.", "NativeLands100px.jpg", "nativelands.html", "12.00", "", ""  );


// addProductRec( title, subtitle, description, image, url, price, upgradeprice, shipping );