// Make the table-cells clickable --------------------------------------------
addOnLoad('init_productsCompare()');

var pc_links = new Array();

function init_productsCompare() {
	var pc_cont = document.getElementById('products_compare');
	if( pc_cont ) {
		var pc_trs = pc_cont.getElementsByTagName('TR');
		
		// Fetch the hrefs from the A-tags in the first row of TDs
		var pc_as = pc_trs[1].getElementsByTagName('A');
		for( i = 0 ; i < pc_as.length ; ++i ) {
			pc_links[i] = pc_as[i].href;
		}
		
		// Add the onClick to the THs
		var pc_ths = pc_trs[0].getElementsByTagName('TH');
		for( i = 0 ; i < pc_ths.length ; ++i ) {
			pc_ths[i].rel = i;
			pc_ths[i].onclick = productsCompareGoUrl;
		}
		
		// Add the onClick to the TDs
		for( i = 1 ; i < pc_trs.length ; ++i) {
		    // the onClick event should not be added to the row that contains the direct order link as the user should not be redirected after direct order.
		    if(pc_trs[i].id != 'oneClickProductDirectOrderLink')
		    {
			    pc_tds = pc_trs[i].getElementsByTagName('TD');
			    for( j = 0 ; j < pc_tds.length ; ++j ) {
				    pc_tds[j].rel = j;
				    pc_tds[j].onclick = productsCompareGoUrl;
			    }
			}	
		}
	}
}

function productsCompareGoUrl() {
	window.location.href = pc_links[this.rel];
}
