// your amazon secret access key
var secretAccessKey = "2Ychg6Qmbejoy+XF2Kn2kszn0ozHe2H0x3Ct57T8";

// set this to true in order to show the signed url
var debug = false;

var Base64 = (function() {
  function encode_base64(data) {
    var out = "", c1, c2, c3, e1, e2, e3, e4;
    for (var i = 0; i < data.length; ) {
       c1 = data.charCodeAt(i++);
       c2 = data.charCodeAt(i++);
       c3 = data.charCodeAt(i++);
       e1 = c1 >> 2;
       e2 = ((c1 & 3) << 4) + (c2 >> 4);
       e3 = ((c2 & 15) << 2) + (c3 >> 6);
       e4 = c3 & 63;
       if (isNaN(c2))
         e3 = e4 = 64;
       else if (isNaN(c3))
         e4 = 64;
       out += tab.charAt(e1) + tab.charAt(e2) + tab.charAt(e3) + tab.charAt(e4);
    }
    return out;
  }

  function decode_base64(data) {
    var out = "", c1, c2, c3, e1, e2, e3, e4;
    for (var i = 0; i < data.length; ) {
      e1 = tab.indexOf(data.charAt(i++));
      e2 = tab.indexOf(data.charAt(i++));
      e3 = tab.indexOf(data.charAt(i++));
      e4 = tab.indexOf(data.charAt(i++));
      c1 = (e1 << 2) + (e2 >> 4);
      c2 = ((e2 & 15) << 4) + (e3 >> 2);
      c3 = ((e3 & 3) << 6) + e4;
      out += String.fromCharCode(c1);
      if (e3 != 64)
        out += String.fromCharCode(c2);
      if (e4 != 64)
        out += String.fromCharCode(c3);
    }
    return out;
  }

  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  return { encode:encode_base64, decode:decode_base64 };
})();

/* string_to_array: convert a string to a character (byte) array */

function string_to_array(str) {
  var len = str.length;
  var res = new Array(len);
  for(var i = 0; i < len; i++)
    res[i] = str.charCodeAt(i);
  return res;
}

/* array_to_hex_string: convert a byte array to a hexadecimal string */

function array_to_hex_string(ary) {
  var res = "";
  for(var i = 0; i < ary.length; i++)
    res += SHA256_hexchars[ary[i] >> 4] + SHA256_hexchars[ary[i] & 0x0f];
  return res;
}

/******************************************************************************/

/* The following are the SHA256 routines */

/*
   SHA256_init: initialize the internal state of the hash function. Call this
   function before calling the SHA256_write function.
*/

function SHA256_init() {
  SHA256_H = new Array(0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
    0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19);
  SHA256_buf = new Array();
  SHA256_len = 0;
}

/*
   SHA256_write: add a message fragment to the hash function's internal state.
   'msg' may be given as string or as byte array and may have arbitrary length.

*/

function SHA256_write(msg) {
  if (typeof(msg) == "string")
    SHA256_buf = SHA256_buf.concat(string_to_array(msg));
  else
    SHA256_buf = SHA256_buf.concat(msg);
  for(var i = 0; i + 64 <= SHA256_buf.length; i += 64)
    SHA256_Hash_Byte_Block(SHA256_H, SHA256_buf.slice(i, i + 64));
  SHA256_buf = SHA256_buf.slice(i);
  SHA256_len += msg.length;
}

/*
   SHA256_finalize: finalize the hash value calculation. Call this function
   after the last call to SHA256_write. An array of 32 bytes (= 256 bits)
   is returned.
*/

function SHA256_finalize() {
  SHA256_buf[SHA256_buf.length] = 0x80;

  if (SHA256_buf.length > 64 - 8) {
    for(var i = SHA256_buf.length; i < 64; i++)
      SHA256_buf[i] = 0;
    SHA256_Hash_Byte_Block(SHA256_H, SHA256_buf);
    SHA256_buf.length = 0;
  }

  for(var i = SHA256_buf.length; i < 64 - 5; i++)
    SHA256_buf[i] = 0;
  SHA256_buf[59] = (SHA256_len >>> 29) & 0xff;
  SHA256_buf[60] = (SHA256_len >>> 21) & 0xff;
  SHA256_buf[61] = (SHA256_len >>> 13) & 0xff;
  SHA256_buf[62] = (SHA256_len >>> 5) & 0xff;
  SHA256_buf[63] = (SHA256_len << 3) & 0xff;
  SHA256_Hash_Byte_Block(SHA256_H, SHA256_buf);

  var res = new Array(32);
  for(var i = 0; i < 8; i++) {
    res[4 * i + 0] = SHA256_H[i] >>> 24;
    res[4 * i + 1] = (SHA256_H[i] >> 16) & 0xff;
    res[4 * i + 2] = (SHA256_H[i] >> 8) & 0xff;
    res[4 * i + 3] = SHA256_H[i] & 0xff;
  }

  delete SHA256_H;
  delete SHA256_buf;
  delete SHA256_len;
  return res;
}

/*
   SHA256_hash: calculate the hash value of the string or byte array 'msg'
   and return it as hexadecimal string. This shortcut function may be more
   convenient than calling SHA256_init, SHA256_write, SHA256_finalize
   and array_to_hex_string explicitly.
*/

function SHA256_hash(msg) {
  var res;
  SHA256_init();
  SHA256_write(msg);
  res = SHA256_finalize();
  return array_to_hex_string(res);
}

/******************************************************************************/

/* The following are the HMAC-SHA256 routines */

/*
   HMAC_SHA256_init: initialize the MAC's internal state. The MAC key 'key'
   may be given as string or as byte array and may have arbitrary length.
*/

function HMAC_SHA256_init(key) {
  if (typeof(key) == "string")
    HMAC_SHA256_key = string_to_array(key);
  else
    HMAC_SHA256_key = new Array().concat(key);

  if (HMAC_SHA256_key.length > 64) {
    SHA256_init();
    SHA256_write(HMAC_SHA256_key);
    HMAC_SHA256_key = SHA256_finalize();
  }

  for(var i = HMAC_SHA256_key.length; i < 64; i++)
    HMAC_SHA256_key[i] = 0;
  for(var i = 0; i < 64; i++)
    HMAC_SHA256_key[i] ^=  0x36;
  SHA256_init();
  SHA256_write(HMAC_SHA256_key);
}

/*
   HMAC_SHA256_write: process a message fragment. 'msg' may be given as
   string or as byte array and may have arbitrary length.
*/

function HMAC_SHA256_write(msg) {
  SHA256_write(msg);
}

/*
   HMAC_SHA256_finalize: finalize the HMAC calculation. An array of 32 bytes
   (= 256 bits) is returned.
*/

function HMAC_SHA256_finalize() {
  var md = SHA256_finalize();
  for(var i = 0; i < 64; i++)
    HMAC_SHA256_key[i] ^= 0x36 ^ 0x5c;
  SHA256_init();
  SHA256_write(HMAC_SHA256_key);
  SHA256_write(md);
  for(var i = 0; i < 64; i++)
    HMAC_SHA256_key[i] = 0;
  delete HMAC_SHA256_key;
  return SHA256_finalize();
}

/*
   HMAC_SHA256_MAC: calculate the HMAC value of message 'msg' under key 'key'
   (both may be of type string or byte array); return the MAC as hexadecimal
   string. This shortcut function may be more convenient than calling
   HMAC_SHA256_init, HMAC_SHA256_write, HMAC_SHA256_finalize and
   array_to_hex_string explicitly.
*/

function HMAC_SHA256_MAC(key, msg) {
  var res;
  HMAC_SHA256_init(key);
  HMAC_SHA256_write(msg);
  res = HMAC_SHA256_finalize();
  return array_to_hex_string(res);
}

/******************************************************************************/

/* The following lookup tables and functions are for internal use only! */

SHA256_hexchars = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  'a', 'b', 'c', 'd', 'e', 'f');

SHA256_K = new Array(
  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
  0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
  0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
  0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
  0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
  0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
);

function SHA256_sigma0(x) {
  return ((x >>> 7) | (x << 25)) ^ ((x >>> 18) | (x << 14)) ^ (x >>> 3);
}

function SHA256_sigma1(x) {
  return ((x >>> 17) | (x << 15)) ^ ((x >>> 19) | (x << 13)) ^ (x >>> 10);
}

function SHA256_Sigma0(x) {
  return ((x >>> 2) | (x << 30)) ^ ((x >>> 13) | (x << 19)) ^
    ((x >>> 22) | (x << 10));
}

function SHA256_Sigma1(x) {
  return ((x >>> 6) | (x << 26)) ^ ((x >>> 11) | (x << 21)) ^
    ((x >>> 25) | (x << 7));
}

function SHA256_Ch(x, y, z) {
  return z ^ (x & (y ^ z));
}

function SHA256_Maj(x, y, z) {
  return (x & y) ^ (z & (x ^ y));
}

function SHA256_Hash_Word_Block(H, W) {
  for(var i = 16; i < 64; i++)
    W[i] = (SHA256_sigma1(W[i - 2]) +  W[i - 7] +
      SHA256_sigma0(W[i - 15]) + W[i - 16]) & 0xffffffff;
  var state = new Array().concat(H);
  for(var i = 0; i < 64; i++) {
    var T1 = state[7] + SHA256_Sigma1(state[4]) +
      SHA256_Ch(state[4], state[5], state[6]) + SHA256_K[i] + W[i];
    var T2 = SHA256_Sigma0(state[0]) + SHA256_Maj(state[0], state[1], state[2]);
    state.pop();
    state.unshift((T1 + T2) & 0xffffffff);
    state[4] = (state[4] + T1) & 0xffffffff;
  }
  for(var i = 0; i < 8; i++)
    H[i] = (H[i] + state[i]) & 0xffffffff;
}

function SHA256_Hash_Byte_Block(H, w) {
  var W = new Array(16);
  for(var i = 0; i < 16; i++)
    W[i] = w[4 * i + 0] << 24 | w[4 * i + 1] << 16 |
      w[4 * i + 2] << 8 | w[4 * i + 3];
  SHA256_Hash_Word_Block(H, W);
}

var AWSQS = (function() {

	/* ------ privates ------ */

	function array_to_string( ary ) {
		var str = "";
		for( var i = 0; i < ary.length; i++ ) {
			str += String.fromCharCode( ary[i] );
		}
		return str;
	}

	// uses http://point-at-infinity.org/jssha256/
	function local_HMAC_SHA256_MAC( strKey, strMsg ) {
	  HMAC_SHA256_init( strKey );
	  HMAC_SHA256_write( strMsg );
	  var aHash = HMAC_SHA256_finalize();
	  return array_to_string( aHash );
	}

	function fnTranslate( str, aTranslate ) {
		for ( var i = 0; i < aTranslate.length; i++ ) {
			str = str.replace( aTranslate[i][0], aTranslate[i][1] );
		}
		return str;
	}

	function encodeURIComponentAWS( str ) {
		return fnTranslate( encodeURIComponent( str ),
			[ [/!/g, "%21"], [/'/g, "%27"], [/\(/g, "%28"], [/\)/g, "%29"], [/\*/g, "%2A"] ] );
	}

	function toZString( dt ) {
		// "Sun, 10 May 2009 18:45:50 UTC" to "2009-05-10T18:45:50Z":
		//  note: ff toUTCString returns "Sun, 17 May 2009 23:31:11 GMT" - !
		return dt.toUTCString().replace( /.{3}, (\d{1,2}) .{3} (\d{4}) (\d{2}:\d{2}:\d{2}) .{3}/,
			function(strMatch, strDay, strYear, strTime) {
				var strDate = (dt.getUTCDate()).toString().replace( /^(\d)$/, "0$1" );
				var strMonth = (dt.getUTCMonth()+1).toString().replace( /^(\d)$/, "0$1" );
				return strYear + "-" + strMonth + "-" + strDate + "T" + strTime + "Z";
			});
	}

	function timestamp() { return toZString( new Date() ); }

	// given methond ( "POST" or "GET" ), AWS query (in GET form) and "secret access key",
	// return object with Timestamp and Signature
	function fnSignature( strMethod, strQuery, strKey ) {
		var bEncode = strMethod == "GET";

		var strTimestamp = timestamp();
		strQuery += "&Timestamp=" + ( bEncode ? strTimestamp : encodeURIComponentAWS( strTimestamp ) );

		var strToSign = strQuery.replace( /(https?:\/\/)([^\/]*)(\/.*)\?(.*)/i,
			function( strMatch, strScheme, strHost, strUri, strParams ) {
				var aParams = strParams.split("&").sort();
					if ( bEncode ) {
						for ( var i = 0; i < aParams.length; i++ ) {
							var aKV = aParams[i].split("=");
							for ( var j = 0; j < aKV.length; j++ ) {
								aKV[j] = encodeURIComponentAWS( aKV[j] );
							}
							aParams[i] = aKV.join("=");
						}
					}
				strParams = aParams.join("&");
				strHost = strHost.toLowerCase();
				return ([ strMethod, strHost, strUri, strParams ]).join("\n");
			});

		// Base64 from http://ecmanaut.blogspot.com/2007/11/javascript-base64-singleton.html
		var strSignature = Base64.encode( local_HMAC_SHA256_MAC( strKey, strToSign ) );
		if ( bEncode ) {
			strSignature = encodeURIComponentAWS( strSignature );
		}

		return { Timestamp: strTimestamp, Signature: strSignature };
	}


	/* ------ form helpers ------ */

	function encodeKV( strKey, strVal )  {
		var strK = encodeURIComponentAWS( strKey );
		var strV = encodeURIComponentAWS( strVal );
		return strK + "=" + strV;
	}

	function getKV( elem )  {
		return encodeKV( elem.name, elem.value );
	}

	// getQuery collects up all field values to be POSTed from form,
	// constructs _uri_encoded_ GET style query with form's action
	// _all_ fields must be collected, even if empty (except those not sent).
	// 2009.06.12, fn: all except for the _signature_ & _timestamp_ fields, if present !
	function getQuery( oForm )  {
		var aQuery = [];

		var colElements = oForm.elements;
		for ( var i = 0; i < colElements.length; i++ )  {
			var elem = colElements[i];
			var strType = elem.type ? elem.type.toLowerCase() : "";
			var strTag = elem.tagName.toLowerCase();

			switch( true ) {

				case elem.name == "Signature":
				case elem.name == "Timestamp":
					// SKIP!
					break;

				case strType == "hidden":
				case strType == "text":
				case strType == "checkbox" && elem.checked:
				case strType == "radio" && elem.checked:
				case strTag == "textarea":

					aQuery.push( getKV( elem ) );
					break;

				case strTag == "select":
					var bDone = false;
					for ( var j = 0; j < elem.options.length; j++ ) {
						if ( !bDone && elem.options[j].selected ) {
							aQuery.push( encodeKV( elem.name, elem.options[j].value ) );
							bDone = true;
						}
					}
					if ( !bDone ) { // or are empty selects not POSTed ?
						aQuery.push( encodeKV( elem.name, "" ) );
					}
					break;

				default:
					// nothin'
			}
		}
		return oForm.action + "?" + aQuery.join("&");
	}

	function setHidden( oForm, strName, strValue ) {
		var elem = oForm.elements[ strName ];
		if ( !elem ) {
			elem = document.createElement("input");
			elem.type = "hidden";
			elem.name = strName;
			oForm.appendChild(elem);
		}
		elem.value = strValue;
	}


	/* ------ publics ------ */

	//  get timestamp & signature for form
	function fnFormSignature( oForm, strKey ) {
		return fnSignature( oForm.method.toUpperCase(), getQuery( oForm ), strKey );
	}

	//  get timestamp & signature for query
	function fnQuerySignature( strQuery, strKey ) {
		return fnSignature( "GET", strQuery, strKey );
	}

	// sign form with key: add signature & timestamp
	function fnSignForm( oForm, strKey ) {
		var oSign = fnFormSignature( oForm, strKey );
		setHidden( oForm, "Timestamp", oSign.Timestamp );
		setHidden( oForm, "Signature", oSign.Signature );
	}

	// sign query with key: add signature & timestamp
	function fnSignQuery( strQuery, strKey ) {
		var oSign = fnQuerySignature( strQuery, strKey );
		return strQuery + "&Timestamp=" + oSign.Timestamp + "&Signature=" + oSign.Signature;
	}


	/* ------ expose publics here ------ */
	return {
				signForm: fnSignForm,
				signQuery: fnSignQuery,
				getFormSignature: fnFormSignature,
				getQuerySignature: fnQuerySignature,
				getSignature: fnSignature
			};
})();



// Basic DOM shortcut functions
	function getEl(x){return document.getElementById(x)}
	function ctn(x){ if (x == "Too low to display") { x = "Discounted"; } return document.createTextNode(x) }
	function cel(x){ return document.createElement(x) }

	function JSONscriptRequest(fullUrl) {
	  if(debug)
		alert("Before signature: " + 	fullUrl);	
	  this.fullUrl = fullUrl;
	  this.secretAccessKey = secretAccessKey;
	  //this.fullUrl = AWSQS.signQuery(fullUrl, secretAccessKey);
	  //if(debug)	alert("After signature: " + this.fullUrl);
	  this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
	  this.headLoc = document.getElementsByTagName("head").item(0);
	  this.scriptId = 'azScriptId' + JSONscriptRequest.scriptCounter++;
	}
	JSONscriptRequest.scriptCounter = 1;
	JSONscriptRequest.prototype.buildScriptTag = function () {
	  this.scriptObj = document.createElement("script");
	  this.scriptObj.setAttribute("type", "text/javascript");
	  var url = this.fullUrl + this.noCacheIE;
	  url = AWSQS.signQuery(url, this.secretAccessKey);
	   //this.fullUrl = AWSQS.signQuery(fullUrl, secretAccessKey);
	  if(debug)	
		alert("After signature: " + url);
	  this.scriptObj.setAttribute("src", url);
	  this.scriptObj.setAttribute("id", this.scriptId);
	}
	JSONscriptRequest.prototype.removeScriptTag = function () {
	  this.headLoc.removeChild(this.scriptObj);
	}
	JSONscriptRequest.prototype.addScriptTag = function () {
	  this.headLoc.appendChild(this.scriptObj);
	}
	
	var keywordIndex = 0;

	var amzJSONcatSearchCallback = function(nameKeyword, tmpData){
		//alert("callback " + nameKeyword + " " + tmpData);
		
		if (tmpData.ItemSet.Item.length > 1){
			var tBody = document.createElement("tbody");
			var trRow = document.createElement("tr");
			var tdImageCol = document.createElement("td");
			tdImageCol.setAttribute("id", "image" + keywordIndex);
			tdImageCol.style.width = "75px";
			
			var tdSecondCol = document.createElement("td");
			var innerTable = document.createElement("table");
			var innerTbody = document.createElement("tbody");
			innerTable.setAttribute("width", "100%");
			innerTable.setAttribute("cellpadding", "0");
			innerTable.setAttribute("cellspacing", "0");
			
			var innerTr = document.createElement("tr");
			var innerFirstTd = document.createElement("td");
			innerFirstTd.setAttribute("valign", "top");
			innerFirstTd.setAttribute("id", "title");
			innerFirstTd.style.cssText = "font-weight: bold; width: 60%;";
			
			var innerSecondTd = document.createElement("td");
			innerSecondTd.setAttribute("valign", "top");
			innerSecondTd.style.width = "20%";
			
			var priceSpan = document.createElement("span");
			priceSpan.setAttribute("id", "price" + keywordIndex);
			priceSpan.style.cssText = "font-weight: bold; color:#2361a1;";
			innerSecondTd.appendChild(priceSpan);
			
			innerTr.appendChild(innerFirstTd);
			innerTr.appendChild(innerSecondTd);
			
			var innerSecondTr = document.createElement("tr");
			var innerThirdTd = document.createElement("td");
			innerThirdTd.setAttribute("valign", "top");
			innerThirdTd.setAttribute("id", "desc" + keywordIndex);
			innerThirdTd.style.cssText = "line-height: 1em;";
			innerThirdTd.setAttribute("colspan", "2");
			innerSecondTr.appendChild(innerThirdTd);
			
			innerTbody.appendChild(innerTr);
			innerTbody.appendChild(innerSecondTr);
			innerTable.appendChild(innerTbody);
			
			tdSecondCol.appendChild(innerTable);
			
			trRow.appendChild(tdImageCol);
			trRow.appendChild(tdSecondCol);
			
			var splitChar = "--";
			var splitPos = nameKeyword.indexOf(splitChar);
			var name = nameKeyword.substring(0, splitPos);
			var currentKeyword = nameKeyword.substring(splitPos + splitChar.length);
			
			if (typeof(name) == "undefined" || name == "")
				name = "searchResults";
	
			if (typeof(getEl(name).firstChild) != "undefined" && getEl(name).firstChild != null && getEl(name).firstChild.nodeType != 3) {
				getEl(name).firstChild.appendChild(trRow);
			}
			else {
				tBody.appendChild(trRow);
				getEl(name).appendChild(tBody);
			}
			
			var tmpItem = tmpData.ItemSet.Item[0];

			if(tmpItem.thumburl){
				var ig = cel('img');
				ig.setAttribute('src',tmpItem.thumburl);
				ig.setAttribute('alt',tmpItem.title);
				var imgHeight = tmpItem.thumbdims[0];
				var imgWidth = tmpItem.thumbdims[1];
				var maxHeight = 60;
				if (imgHeight > maxHeight)
				{
					var scale = maxHeight / imgHeight;
					imgHeight = imgHeight * scale;
					imgWidth = imgWidth * scale;
				}
				ig.style.cssText = "border:0px;height:"+imgHeight+"px;width:"+imgWidth+"px;float:left;margin-right:8px";
				tdImageCol.appendChild(ig);
			}

			var a = cel('a');
			a.setAttribute('href',tmpItem.url);
			a.appendChild(ctn(currentKeyword));
			innerFirstTd.appendChild(a);

			if((tmpItem.price)||(tmpItem.lowestnewprice)||(tmpItem.lowestusedprice)){
				if(tmpItem.price){
					var a = cel('a');
					a.setAttribute('href',tmpItem.url);
					a.appendChild(ctn(tmpItem.price));
					priceSpan.appendChild(a);
				}else if(tmpItem.lowestnewprice){
					var a = cel('a');
					a.setAttribute('href',tmpItem.url);
					a.appendChild(ctn(tmpItem.lowestnewprice));
					priceSpan.appendChild(a);
				}else if(tmpItem.lowestusedprice){
					var a = cel('a');
					a.setAttribute('href',tmpItem.url);
					a.appendChild(ctn(tmpItem.lowestusedprice));
					priceSpan.appendChild(a);
				}
			}

			if (tmpItem.desc) {
				var desc = new String(tmpItem.desc);
				desc = desc.substring(0, 120) + "...";
				innerThirdTd.appendChild(ctn(desc));
			}
		}
	}
	
	function CallAmazonAPI(parameter) {
		if(isArrayObject()) {
			for(var index = 0; index < keyword.length; index++) {
				var request = 'http://xml-us.amznxslt.com/onca/xml?Service=AWSECommerceService&SubscriptionId=1XMKGCCQRJTQ2X6A1N82&AssociateTag=digicametrac-20&Tag=digicametrac-20&Operation=ItemSearch&Style=http://www.digitalcameratracker.com/ajsonCategorySearch.xsl&ContentType=text/javascript&ItemPage=1&SearchIndex=Electronics&ResponseGroup=Medium&Condition=All&Keywords=' + keyword[index] + '&CallBack=amzJSONcatSearchCallback&Parameter=' + parameter + '--' + keyword[index];
				aObj = new JSONscriptRequest(request);
				aObj.buildScriptTag();
				aObj.addScriptTag();
			}
		}
		else {
			var request = 'http://xml-us.amznxslt.com/onca/xml?Service=AWSECommerceService&SubscriptionId=1XMKGCCQRJTQ2X6A1N82&AssociateTag=digicametrac-20&Tag=digicametrac-20&Operation=ItemSearch&Style=http://www.digitalcameratracker.com/ajsonCategorySearch.xsl&ContentType=text/javascript&ItemPage=1&SearchIndex=Electronics&ResponseGroup=Medium&Condition=All&Keywords=' + keyword + '&CallBack=amzJSONcatSearchCallback&Parameter=' + parameter + '--' + keyword;
			aObj = new JSONscriptRequest(request);
			aObj.buildScriptTag();
			aObj.addScriptTag();
		}
	}
	
	function isArrayObject(){
		return typeof(keyword)== "object" && keyword.length && typeof(keyword.length)=="number";
	}