/*
 * Ext JS Library 2.0.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){

    // create the Data Store
    var store = new Ext.data.Store({
        // load using HTTP
        url: '/company/patents/index.xml',

        // the return will be XML, so lets set up a reader
		
		/* xml row
		 * 
		 * <row>
  <product_family>5000 - Intrusion Defense</product_family>
  <product_sub_family>10 - Intrusion Defense</product_sub_family>
  <series>400 - Third Party</series>
  <category>100 - Resale</category>
  <product_part_number>DSIMBA7-ME</product_part_number>
  <product_description>DRAGON SECURITY COMMAND CONSOLE - ME</product_description>
  <replacement_product_part_number></replacement_product_part_number>
  <replacement_product_strategy></replacement_product_strategy>
  <end_of_sales_life_date>2007-02-01</end_of_sales_life_date>
  <end_of_service_life_date>2012-02-01</end_of_service_life_date>
</row>
		 * 
		 * 
		 * 
		 * 
		 */
        reader: new Ext.data.XmlReader({
               // records will have an "Item" tag
               record: 'row'
           }, [ {
          name : 'type', sortType : 'string'
    },{
         name : 'id',   sortType : 'string'
    }
	])
    });







    // create the grid
    var grid = new Ext.grid.GridPanel({
        store: store,
        columns: [
            
			{header: "ID", dataIndex: 'id', sortable: true, hidden: false}
		],
		title: '<h3 style="color:#aa103f">Enterasys Patents</h3>',
        renderTo:'patent-grid',
        width:105,
        autoHeight : true,
		loadMask:{
			msg:'Loading...'
		},
		listeners: {
          cellclick:  function (o, row, cell, e) {
            allocationHandler( o, row, cell, e);
          }}

    });

    store.load();
	
	
	  function allocationHandler( o, row, cell, e) {
    		var dataIndex = o.getColumnModel().getDataIndex(cell);
	  		var record = o.getStore().getAt(row);
		    var cli_id = record.get( "id" );


  /*  if ( dataIndex == "allocation" ) {
      var record = o.getStore().getAt(row);
      var cli_id = record.get( "cli_id" );
      popupWindow.showDialog( cli_id );
    } */
	
	// alert("Hi There: " + dataIndex + ", " + record + ", " + cli_id); 5029164
	window.open('http://patft.uspto.gov/netacgi/nph-Parser?TERM1='  + cli_id + '&Sect1=PTO1&Sect2=HITOFF&d=PALL&p=1&u=%2Fnetahtml%2FPTO%2Fsrchnum.htm&r=0&f=S&l=50');
  }



	
	
});

