function sparqlView(container) {

    //The necessary vars for a View...
    this.name="SPARQL";        //Display name of this view.
    this.queryStates=[];          //All Queries currently in this view.
    this.container=container; //HTML DOM parent node for this view.
    //this.container.setAttribute('ondblclick','tableDoubleClick(event)')
    //qs.addQuery()
    
    this.container.setAttribute('id','SPARQLText')    	
    this.textForm=document.createElement('form');
    this.textArea=document.createElement('textarea');
    this.textArea.setAttribute('id','SPARQLTextArea')
    this.textArea.rows=8;
    this.textArea.cols=80;
    this.myButton=document.createElement('input');
    this.myButton.setAttribute('type','Button');
    this.myButton.setAttribute('value','Submit SPARQL');
    this.textForm.appendChild(this.textArea);
    this.textForm.appendChild(this.myButton);
    this.container.appendChild(this.textForm);

    //Javascript is strange:
    var thisSPARQLView = this;
    this.myButton.onclick = function () {
        return thisSPARQLView.qSPARQLText();
    }

    this.drawQuery = function(q) {
 		    this.textArea.value=queryToSPARQL(q);
 		    this.queryStates[q.id]=1;
    }
    
    this.undrawQuery = function(q) {
        this.textArea.value=""
        this.queryStates[q.id]=0;
	  }
    
    this.addQuery = function (q) {
        this.queryStates[q.id]=0;
    } //this.addQuery

    this.removeQuery = function (q) {
    	if (this.queryStates[q.id]==1) this.undrawQuery(q);
    	delete this.queryStates[q.id];
        return;
    }

	this.qSPARQLText = function () {
		var txt=document.getElementById('SPARQLTextArea').value;
		//alert(txt);
		var q=SPARQLToQuery(txt);
		qs.addQuery(q);
	    sortables_init(); //make table headers sortable
	}    
} // sparqlView
