function ansWizTax(){

      var href;
      var ele_cont;
      var ele = document.getElementById('ans_wiz');
      var dictionary = {};

      var foo = ele.getElementsByTagName('a');

            for(var i = 0; i< foo.length; i++){
	            var temp = [];

	            href = foo[i].getAttribute('href');
	            ele_cont = foo[i].innerHTML;
      		
	            var x = ele_cont.split('-');
	            var key = x[0].replace(/^\s+|\s+$/g, '');
	            var title =  x.slice(1).join('-').replace(/^\s+|\s+$/g, '');

	            temp[0] = title;
	            temp[1] = href;

	            var y = dictionary[key];
	            if(y == null){
		            y = [];
		            dictionary[key] = y;
	            }
	            y.push(temp);
	            dictionary[key] = y;
            }
		listBuilder(dictionary);
		addEvt(ele);
}


function listBuilder(dictionary){
      var ele = document.getElementById('tempContent');
      var finalHtml = '<ul>';
      
      for(key in dictionary){
            var content = dictionary[key];

             
            finalHtml += '<li><h4 style="cursor:pointer; cursor:hand;" onclick="itemSelected(this);"><span>' + key + '</span></h4><ul>';
            
            for(c in content){ 
                  var link = content[c]; 
                  var tag = '<li><a href="' + link[1] + '">' + link[0] + '</a></li>';
                  finalHtml += tag; 
            }
           finalHtml += '</ul></li>'; 
      }
      
      finalHtml += '</ul>';
      document.getElementById('ans_wiz').innerHTML = finalHtml;
}


function addEvt(ele){
      var tmp = ele.getElementsByTagName('h4');
      
      for(i = 0; i<tmp.length; i++){
            if(i<2){
                  tmp[i].nextSibling.className = "item_selected";
                  tmp[i].style.backgroundImage = 'url(/help/img/arrow_sel.gif)';
            }
            else{
                  tmp[i].style.backgroundImage = 'url(/help/img/arrow_unsel.gif)';  
            }   
                                   
      }
            
}

ansWizTax();
