function populate()
{

    alert("yes so far so good");
    
    StoreHeader.test("test", cbtest);
    } 
    
    function cbtest(res)
    {
    alert(res);
    }
function addOption(selectbox,text,value )
{
        var optn = document.createElement("OPTION");
        optn.text = text;
        optn.value = value;
        selectbox.options.add(optn);
}


function populatecats()
{
    var brand = document.getElementById("ddBrand").value;
    
     var field = document.getElementById("ddCategory");
        var i;
         for(i=field.options.length-1;i>=0;i--)
         {
           field.remove(i);
         }
         
    addOption(field, "loading...", "0");
    
    
    shop.getcatsforbrand(brand, callback_populatecats);
}



function callback_populatecats(res)
{
      
      var field = document.getElementById("ddCategory");
        var i;
         for(i=field.options.length-1;i>=0;i--)
         {
           field.remove(i);
         }
     
		addOption(field, "by category...", "0");
		for(var i=0; i<res.value.Rows.length; i++)
		{
		    var name = res.value.Rows[i].Name;
		  
		 		    addOption(field, name, res.value.Rows[i].ID);
		 	
		}
}		
		
function populatecatsf()
{
    var brand = document.getElementById("ddBrand").value;
    
     var field = document.getElementById("ddCategory");
        var i;
         for(i=field.options.length-1;i>=0;i--)
         {
           field.remove(i);
         }
         
    addOption(field, "loading...", "0");
    
    
    _default.getcatsforbrand(brand, callback_populatecatsf);
}



function callback_populatecatsf(res)
{
      
      var field = document.getElementById("ddCategory");
        var i;
         for(i=field.options.length-1;i>=0;i--)
         {
           field.remove(i);
         }
     
		addOption(field, "Select a Category...", "0");
		for(var i=0; i<res.value.Rows.length; i++)
		{
		    var name = res.value.Rows[i].Name;
		  
		 		    addOption(field, name, res.value.Rows[i].ID);
		 	
		}
		
		
	
}
