var prod={
	onload: function() {
		switch (view) {
			case 'prodList':
				this.setTableSortable();
				if (activateSubId_list != '') {
					var subId_ar=activateSubId_list.split(',');
					for (var i=0;i<subId_ar.length;i++) {
						this.clk(get_object(subId_ar[i]));
					}
				}
				if (highlightIt != 0)
					this.highlightItem(highlightIt);
			break;
		}
	},
	clk: function(o) {
		switch (o.id.split('_')[0]) {
			case 'ictMain':
				var ictId=parseInt(o.id.split('_')[1]);
				window.location.href='index.cfm?pg='+pg+'&ic='+ictId;
			break;
			case 'ictSub':
				var parentId=parseInt(o.id.split('_')[1]);
				var ictId=parseInt(o.id.split('_')[2]);
				var level=parseInt(o.id.split('_')[3]);
				//hide possible active subHolder at current level
				if (eval('this.ictActive_'+level) && get_object('ictSubHolder_'+eval('this.ictActive_'+level)))
					get_object('ictSubHolder_'+eval('this.ictActive_'+level)).style.display='none';
				//set active for clicked level 
				eval('this.ictActive_'+level+'=ictId;');
				this.setTr(ictId,level);
				this.setSubs(parentId,ictId);
			break;
			case 'ict':
				var ic=o.id.split('_')[1];
				window.location.href='index.cfm?pg=4&ic='+ic;
			break;
		}
	},
	setTr: function(ictId,level) {
		var items=get_object('tbody_itm').children;
		var ictId_level,showThis;
		var j;
		for (var i=0;i<items.length;i++) {
			belongsToActiveUpperLevel=true;
			//loop upper levels (not self) and check if tr belongs to that
			for (j=1;j<level;j++) {
				ictId_level=parseInt(items[i].id.split('_')[j]);
				if (ictId_level != eval('this.ictActive_'+j))
					belongsToActiveUpperLevel=false;
			}
			ictId_level=parseInt(items[i].id.split('_')[level]);
			items[i].style.display=(belongsToActiveUpperLevel && (ictId == 0 || ictId == ictId_level))?'':'none';
		}
	},
	setSubs: function(parentId,ictId) {
		var items=get_object('ictSubHolderInner_'+parentId).children;
		var ictId_current,ictBase;
		for (var i=0;i<items.length;i++) {
			ictBase=items[i].id.split('_')[0];
			ictId_current=parseInt(items[i].id.split('_')[2]);
			items[i].className=(ictId == ictId_current)?ictBase+'_on':ictBase;
		}
		//check one level down
		if (get_object('ictSubHolder_'+ictId)) {
			get_object('ictSubHolder_'+ictId).style.display='block';
			this.setSubs(ictId,0);
		}
	},
	setTableSortable: function() {
		$("#table_itm").tablesorter({
			debug: false,
			headers: {
				0: { sorter: false },
				1: { sorter: 'text' },
				2: { sorter: 'digit' },
				3: { sorter: 'digit' },
				4: { sorter: 'text' }
			},
			sortList: [[2,0]],
			widgets: ['zebra']
		});
//		$("#table_itm").trigger("applyWidgets");
	},
	mov: function(o) {
		switch (o.id.split('_')[0]) {
			case 'ict':
				o.className='prodListCategory_over';
			break;
		}
	},
	mou: function(o) {
		switch (o.id.split('_')[0]) {
			case 'ict':
				o.className='prodListCategory';
			break;
		}
	},
	highlightItem: function(itmId) {
		var tr_ar=get_object('tbody_itm').children;
		var itmId_current;
		for (var i=0;i<tr_ar.length;i++) {
			itmId_current=parseInt(tr_ar[i].id.split('_')[3]);
			if (itmId_current == itmId) {
				var td_ar=tr_ar[i].children;
				for (var j=0;j<td_ar.length;j++) {
					td_ar[j].style.backgroundColor='#fffa7b';
				}
			}
		}
	}
}

