
function exampleGetInputDocument() {

    var doc = document;

    programModified(doc, 'program-msgs');

    return doc;
}

function loadGameExample()
{
  var tmpDoc = exampleGetInputDocument();

  var a = tmpDoc.getElementById('rules');

  // rules
  tmpDoc.getElementById('rules').value = 
	"use 'http://www.ida.liu.se/hswrl/owl/geography.owl' as 'g'.\n\n" +
    
	"win(X) :- \n" +
	"\t move(X,Y), \n" +
	"\t neg(win(Y)). \n\n" +

	"move(e,f) :- dl(g#Europe(f)). \n\n" +

	"move(c,f) :- dl(neg(g#Finland(f))). \n\n" +

	"move(b,a). \n" +
	"move(a,b). \n" +
	"move(a,c). \n" +
	"move(c,d). \n" +
	"move(d,e).";

    // query
    tmpDoc.getElementById('query_form').value = 'win(c)';
    
}

function loadGameExampleOpen()
{
  var tmpDoc = exampleGetInputDocument();

  var a = tmpDoc.getElementById('rules');

  // rules
  tmpDoc.getElementById('rules').value = 
	"use 'http://www.ida.liu.se/hswrl/owl/geography.owl' as 'g'.\n\n" +
    
	"win(X) :- \n" +
	"\t move(X,Y), \n" +
	"\t neg(win(Y)). \n\n" +

	"move(e,f) :- dl(g#Europe(f)). \n\n" +

	"move(c,f) :- dl(neg(g#Finland(f))). \n\n" +

	"move(b,a). \n" +
	"move(a,b). \n" +
	"move(a,c). \n" +
	"move(c,d). \n" +
	"move(d,e).";

    // query
    tmpDoc.getElementById('query_form').value = 'win(X)';
    
}


function loadGameHistoryExample()
{
  var tmpDoc = exampleGetInputDocument();

  var a = tmpDoc.getElementById('rules');

  // rules
  tmpDoc.getElementById('rules').value = 
	"use 'http://www.ida.liu.se/hswrl/owl/geography.owl' as 'g'.\n\n" +
    
	"win(X) :- win(X,[]).\n\n" +

	"win(X,H) :- \n" +
	"\t move(X,Y,H), \n" +
	"\t neg(win(Y, [X|H])). \n\n" +

  	"move(A,B,H) :- \n" +
	"\t edge(A,B), \n" +
	"\t neg(member(B,H)). \n\n" +

	"edge(e,f) :- dl(g#Europe(f)). \n" +

	"edge(c,f) :- dl(neg(g#Finland(f))). \n\n" +

	"edge(b,a). \n" +
	"edge(a,b). \n" +
	"edge(a,c). \n" +
	"edge(c,d). \n" +
	"edge(d,e). \n\n" +

	"member(X,[X|T]). \n" +
	"member(X,[H|T]) :- member(X,T).\n";

    // query
    tmpDoc.getElementById('query_form').value = 'win(c,[d])';
    
}

function loadGameHistoryLimitExample()
{
  var tmpDoc = exampleGetInputDocument();

  var a = tmpDoc.getElementById('rules');

  // rules
  tmpDoc.getElementById('rules').value = 
	"use 'http://www.ida.liu.se/hswrl/owl/geography.owl' as 'g'.\n\n" +
    
	"win(X) :- win(X,[]).\n\n" +

	"win(X,H) :- \n" +
	"\t move(X,Y,H), \n" +
	"\t neg(win(Y, [X|H])). \n\n" +

  	"move(A,B,H) :- \n" +
	"\t edge(A,B), \n" +
	"\t restriction(B,R), \n" +
	"\t membern(B,H,N), \n" +
	"\t N<R. \n\n" +

	"edge(e,f) :- dl(g#Europe(f)). \n" +

	"edge(c,f) :- dl(neg(g#Finland(f))). \n\n" +

	"edge(b,a). \n" +
	"edge(a,b). \n" +
	"edge(a,c). \n" +
	"edge(c,d). \n" +
	"edge(d,e). \n\n" +

	"restriction(a,7). \n" +
	"restriction(b,6). \n" +
	"restriction(c,1). \n" +
	"restriction(d,1). \n" +
	"restriction(e,1). \n" +
	"restriction(f,1). \n\n" +

	"membern(E,[],0). \n" +
	"membern(E,[E|L],N1) :- membern(E,L,N), N1 is N+1.\n" +
        "membern(E,[G|L],N) :- E\=G, membern(E,L,N).\n";

    // query
    tmpDoc.getElementById('query_form').value = 'win(c,[d])';
    
}

function loadExistentialExample()
{
  var tmpDoc = exampleGetInputDocument();

  var a = tmpDoc.getElementById('rules');

  // rules
  tmpDoc.getElementById('rules').value = 
	"use 'http://www.ida.liu.se/hswrl/owl/geography.owl' as 'g'.\n\n" +
    
	"win(X) :- \n" +
	"\t move(X,Y), \n" +
	"\t neg(win(Y)). \n\n" +

	"move(e,f) :- dl(neg(g#Europe(X))), dl(g#Finland(X)). \n\n" +

	"move(c,f). \n\n" +

	"move(b,a). \n" +
	"move(a,b). \n" +
	"move(a,c). \n" +
	"move(c,d). \n" +
	"move(d,e).";

    // query
    tmpDoc.getElementById('query_form').value = 'move(e,f)';
    
}

function loadExistentialVariantExample()
{
  var tmpDoc = exampleGetInputDocument();

  var a = tmpDoc.getElementById('rules');

  // rules
  tmpDoc.getElementById('rules').value = 
	"use 'http://www.ida.liu.se/hswrl/owl/geography.owl' as 'g'.\n\n" +
    
	"win(X) :- \n" +
	"\t move(X,Y), \n" +
	"\t neg(win(Y)). \n\n" +

	"move(e,f) :- dl(g#Europe(X)), dl(g#Finland(X)). \n\n" +

	"move(c,f). \n\n" +

	"move(b,a). \n" +
	"move(a,b). \n" +
	"move(a,c). \n" +
	"move(c,d). \n" +
	"move(d,e).";

    // query
    tmpDoc.getElementById('query_form').value = 'move(e,f)';
    
}

function loadExampleCustomer()
{
  var tmpDoc = exampleGetInputDocument();

  // rules
  tmpDoc.getElementById('rules').value = 

	"use 'http://www.ida.liu.se/hswrl/owl/customer.owl' as 'cust'.\n\n" +

	"% this ontolology uses concepts from the FOAF ontology\n\n" +

	"discount(X, 25) :- \n" +
	"\t status(X, 'cust#gold'). \n\n" +

	"status(X, 'cust#gold') :- \n" +
	"\t totalPurchase(X, T), \n" +
	"\t greaterOrEqual(T, 5000). \n\n" +

	"status(X, 'cust#gold') :- \n" +
	"\t totalPurchase(X, T), \n" +
	"\t greaterOrEqual(T, 1000), \n" +
	"\t cust#KnowsManager(X). \n\n" +

	"totalPurchase('cust#john', 6000). \n" +
	"totalPurchase('cust#steven', 1600). \n" +
	"totalPurchase('cust#holly', 4600). \n";

  // query
  tmpDoc.getElementById('query').value = "discount('cust#holly', 25)";
}

