function setupMenu(id, mode) {
         container = document.getElementById('level2');
         var list = [];
         if (mode == 'hide') {
            if (isOn == 1)
               return;
               
            currentId = 0;
            container.style.display = 'none';
         } else if (id > 0 && mode == 'show' && isOn == 0) {
            isOn = 1;
            currentId = id;
            while (container.firstChild) {
              container.removeChild(container.firstChild);
            }            
            
            container.style.display = 'block';
            eval ("list = level_"+id);

            if (list.length > 1) {
                
var c0 = document.createElement('TABLE'); 
c0.style.cssText = "margin-top: 6px; width: 100%; background-color: #FF8A00; border: 0px; border-collapse: collapse; border-spacing: 0px;";
c0.setAttribute("style","margin-top: 6px; width: 100%; background-color: #FF8A00; border: 0px; border-collapse: collapse; border-spacing: 0px;");
c0.setAttribute("cellSpacing","0");
c0.setAttribute("cellPadding","0");
var c1 = document.createElement('TBODY');
var c2 = document.createElement('TR');
var c3 = document.createElement('TD');

var d0 = document.createElement('TABLE'); 
//d0.style.cssText = "border-collapse: collapse; border-spacing: 0px;";
d0.setAttribute("cellSpacing","0");
d0.setAttribute("cellPadding","0");
var d1 = document.createElement('TBODY');
var d2 = document.createElement('TR');

var ids = 0;                
               for (i=0; i<(list.length - 1); i++) {
ids = ids + 1;
d3 = document.createElement('TD');
d3.setAttribute("id","prr_"+ids);
d3.setAttribute("width","1");
d4 = document.createElement("img");
d4.setAttribute("src","/s/i/s.gif");
d4.setAttribute("width","1");
d4.setAttribute("height","20");
d3.appendChild( d4 );
d2.appendChild( d3 );


d3 = document.createElement('TD');
d3.setAttribute("width","4");
d3.setAttribute("id","prv_"+ids);
d3.style.cssText = "padding: 2px 2px 2px 10px;";
d3.setAttribute("style","padding: 2px 2px 2px 10px;");
d4 = document.createElement("img");
d4.setAttribute("src","/s/i/b1.gif");
d4.setAttribute("id","img_"+ids);
d4.setAttribute("width","4");
d4.setAttribute("height","5");
d3.appendChild( d4 );
d2.appendChild( d3 );
                                   
d3 = document.createElement('TD');
d3.style.cssText = "padding: 2px 5px 2px 5px;";
d3.setAttribute("style","padding: 2px 5px 2px 5px;");
d3.setAttribute("align","left");
d4 = document.createElement("a");
d4.setAttribute("style","color: white;");
d4.setAttribute("id","ths_"+ids);
d4.onmouseover = function () {this.parentNode.style.background="#00559D"; var ss = this.getAttribute('ID'); ss = ss.replace('ths_', ''); document.getElementById('prr_'+ss).style.background="#00559D"; document.getElementById('prv_'+ss).style.background="#00559D"; document.getElementById('img_'+ss).setAttribute("src","/s/i/b1_.gif");};
d4.onmouseout = function () {this.parentNode.style.background="#FF8A00"; var ss = this.getAttribute('ID'); ss = ss.replace('ths_', ''); document.getElementById('prr_'+ss).style.background="#FF8A00"; document.getElementById('prv_'+ss).style.background="#FF8A00"; document.getElementById('img_'+ss).setAttribute("src","/s/i/b1.gif");};
d4.style.cssText = "color: white;";
d4.setAttribute("href", list[i][0]);
d5 = document.createTextNode(list[i][1]);
d4.appendChild( d5 );
d3.appendChild( d4 );
d2.appendChild( d3 );

               } 
d1.appendChild( d2 );
d0.appendChild( d1 );
c3.appendChild( d0 );
c2.appendChild( c3 );
c1.appendChild( c2 );
c0.appendChild( c1 );

container.appendChild( c0 );
               
               if (container.parentNode.offsetWidth > 0) {
                   container.style.width = (container.parentNode.offsetWidth - 0)+ 'px';
               } else {
                   container.style.width = '100%'
               }
            } else {
               container.innerHTML = '';
            }
         }
}

function clearMenu() {
    setupMenu(-1, 'hide');
}

function changePrice(courseObj) {
	 var course = courseObj.value;
	 var header = courseObj.options[courseObj.selectedIndex].text;
	 var priceObj;
	 var counter = 1;

	 document.getElementById('prtitle').innerHTML = header;
	 while (priceObj = document.getElementById('prd_'+counter)) {
		   idx = counter - 1;
		   prc = String(rprice[idx] * course/100.0);
		   priceObj.innerHTML = get_normal_digits(prc);
		   counter = counter + 1;
	 }
}

function changePrice2(courseObj) {
    var course = courseObj.value;

    var prc = String(rprice[0] * course/100.0);

    prc = get_normal_digits(prc) + ' ' + cname[courseObj.selectedIndex];

    if (document.getElementById('price1'))
	document.getElementById('price1').innerHTML = prc;
    
    if (document.getElementById('price2'))
	document.getElementById('price2').innerHTML = prc;

}

function get_normal_digits(tmp) {
	 tmp = tmp * 100;
	 tmp = Math.round(tmp);
	 tmp = tmp / 100;
	 tmp = tmp + '';
	 var aaa = tmp.split('.');
	 if (aaa.length == 1) {
		tmp = tmp + '.00';
	 } else {
	    if (aaa[1].length == 1) {
	 	   tmp = tmp + '0';
		}
     }
	 return tmp;
}

var sortcolumn;
var order = 1;

function sort_compare(a, b) {
    if (a[sortcolumn] > b[sortcolumn]) return order;
    if (a[sortcolumn] < b[sortcolumn]) return -order;
    return 0;
}

function sort_product_list(c) {
    if (!document || !document.getElementById || !rproduct || !rproduct[0]) return false;

    if (!rproduct[0][0]) {
	var i=0;
	var r;
	while (r = document.getElementById('rproduct'+i)) {
	    rproduct[i++][0] = r;
	}
    }

    if (sortcolumn === c)
	order = -order;
    else {
	order = 1;
	if (sortcolumn) document.getElementById('sarr' + sortcolumn).src = '/s/i/s.gif';
    }


    sortcolumn = c;
    document.getElementById('sarr' + sortcolumn).src = order > 0 ? '/s/i/bd.gif' : '/s/i/bu.gif';

    rproduct.sort(sort_compare);

    var tn = rproduct[0][0].parentNode;
    var cl = document.getElementById('plistcloser');
    for (var i=0; i<rproduct.length; i++) {
	tn.removeChild(rproduct[i][0]);
    }
    for (var i=0; i<rproduct.length; i++) {
	tn.insertBefore(rproduct[i][0], cl);
    }

    return false;
}
