﻿var iIcon          = tp+'Tree/I.png';
var lIcon          = tp+'Tree/L.png';
var lMinusIcon     = tp+'Tree/Lminus.png';
var lPlusIcon      = tp+'Tree/Lplus.png';
var tIcon          = tp+'Tree/T.png';
var tMinusIcon     = tp+'Tree/Tminus.png';
var tPlusIcon      = tp+'Tree/Tplus.png';
var blankIcon      = tp+'Tree/blank.png';

var defaultText    = 'Tree Item';
var defaultAction  = 'javascript:processClick();';

var selectedObj = null;

var ConveaTreeHandler = {
	idCounter : 0,
	idPrefix  : "----MODULETREE----",
	all       : {},
	behavior  : 'classic',
	getId     : function () { return this.idPrefix + this.idCounter++; },
	toggle    : function (oItem) { this.all[oItem.id.replace('-plus','')].toggle(); },
	select    : function (oItem) { this.all[oItem.id.replace('-icon','')].select(); },
	focus     : function (oItem) { this.all[oItem.id.replace('-anchor','')].focus(); },
	blur      : function (oItem) { this.all[oItem.id.replace('-anchor','')].blur(); }
};

function processClick()
{
	switch(selectedObj.type)
	{
		case -1: window.location.href="index.asp?page=category&id=2";  break;										
		case 9:  window.location.href="index.asp?page=catalog&id=" + selectedObj.record; break;					
		case 10: window.location.href="index.asp?page=category&id=" + selectedObj.record; break;							
	}		
}

function setCookie(key, value) 
{
	document.cookie = key + "=" + escape(value);
}

function getCookie(key) 
{	
	if (document.cookie.length) {
		var cookies = ' ' + document.cookie;
		var start = cookies.indexOf(' ' + key + '=');
		if (start == -1) { return null; }
		var end = cookies.indexOf(";", start);
		if (end == -1) { end = cookies.length; }
		end -= start;
		var cookie = cookies.substr(start,end);
		return unescape(cookie.substr(cookie.indexOf('=') + 1, cookie.length - cookie.indexOf('=') + 1));
	}
	else { return null; }
}
// JavaScript Document