/**********************************************
* DOWNLOAD_ORDER.JS        VERSION 1.1        *
* This javascript file should be inserted on  *
* the bottom comments for the order summary   *
* page in the checkout process. It will make  *
* it so customers can download a product      *
* instantly if it is a downloadable product.  *
*                                             *
* ONLY EDIT WHAT YOU ARE INSTRUCTED TO EDIT   *
**********************************************/

/*
to insert this into an account's checkout process, upload this file and then put this code into the bottom comments of the order summary page:

<script language="javascript" src="https://secure.eznettools.net/D300003/X300003/download_order.js">
</script>
*/

var stock_num = new Array();
var link = new Array();


/*******************************************
*            BEGIN EDITING HERE            *
*  Make a stock_num[] and link[] entry for *
*  each downloadable product.              *
*******************************************/

var LinkText = "Download Now!";

stock_num[0] = "00000";
     link[0] = "http://www.shuoink.com/?00000";

stock_num[1] = "00001";
     link[1] = "http://www.shuoink.com/?00001";

stock_num[3] = "00003";
     link[3] = "http://www.shuoink.com/?00003";


/*******************************************
*       DO NOT EDIT AFTER THIS POINT       *
*******************************************/

// UPDATE: table_number is now calculated
// from the end of the document instead of
// from the beginning. Thus, the following
// line of code:
var table_number = (document.getElementsByTagName("table").length - 3);

var x = document.getElementsByTagName("table");
var y = x[table_number].getElementsByTagName("td");
var z = "";
var rows = y.length / 4;

for(i=0;i<rows;i++)
{
	z = y[i*4].innerHTML.split("&nbsp;");
	zz = z[1].split(" ");
	for(n=0;n<stock_num.length;n++)
	{
//		if(y[i*4].innerHTML.match(stock_num[n]))
		if(zz[1]==stock_num[n])
		{
			y[i*4+2].innerHTML += "<a href='" + link[n] + "'>" + LinkText + "</a>";
		}
	}

}