copy sdk to doc site when packaging; add more documentation about javascript sdk
diff --git a/asterix-doc/pom.xml b/asterix-doc/pom.xml
index 8675dcc..ac03d02 100644
--- a/asterix-doc/pom.xml
+++ b/asterix-doc/pom.xml
@@ -1,35 +1,68 @@
-<!--
- ! Copyright 2009-2013 by The Regents of the University of California
- ! Licensed under the Apache License, Version 2.0 (the "License");
- ! you may not use this file except in compliance with the License.
- ! you may obtain a copy of the License from
- ! 
- !     http://www.apache.org/licenses/LICENSE-2.0
- ! 
- ! Unless required by applicable law or agreed to in writing, software
- ! distributed under the License is distributed on an "AS IS" BASIS,
- ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ! See the License for the specific language governing permissions and
- ! limitations under the License.
- !-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <artifactId>asterix</artifactId>
-    <groupId>edu.uci.ics.asterix</groupId>
-    <version>0.8.4-SNAPSHOT</version>
-  </parent>
-  <artifactId>asterix-doc</artifactId>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-site-plugin</artifactId>
-        <version>3.3</version>
-        <configuration>
-          <generateReports>false</generateReports>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
+<!-- ! Copyright 2009-2013 by The Regents of the University of California 
+	! Licensed under the Apache License, Version 2.0 (the "License"); ! you may 
+	not use this file except in compliance with the License. ! you may obtain 
+	a copy of the License from ! ! http://www.apache.org/licenses/LICENSE-2.0 
+	! ! Unless required by applicable law or agreed to in writing, software ! 
+	distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT 
+	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the 
+	License for the specific language governing permissions and ! limitations 
+	under the License. ! -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<artifactId>asterix</artifactId>
+		<groupId>edu.uci.ics.asterix</groupId>
+		<version>0.8.4-SNAPSHOT</version>
+	</parent>
+	<artifactId>asterix-doc</artifactId>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-site-plugin</artifactId>
+				<version>3.3</version>
+				<configuration>
+					<generateReports>false</generateReports>
+				</configuration>
+				<executions>
+					<execution>
+						<phase>package</phase>
+						<goals>
+							<goal>site</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-resources-plugin</artifactId>
+				<version>2.6</version>
+				<executions>
+					<execution>
+						<phase>package</phase>
+						<goals>
+							<goal>copy-resources</goal>
+						</goals>
+						<inherited>false</inherited>
+						<configuration>
+							<outputDirectory>${project.build.directory}/site/download</outputDirectory>
+							<resources>
+								<resource>
+									<directory>../asterix-examples/src/main/resources/</directory>
+									<includes>
+										<include>asterix-sdk-stable.js</include>
+									</includes>
+								</resource>
+							</resources>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> 
+				<executions> <execution> <phase>package</phase> <goals> <goal>assembly</goal> 
+				</goals> <inherited>false</inherited> <configuration> <descriptor>src/assembly/assembly.xml</descriptor> 
+				</configuration> </execution> </executions> </plugin> -->
+		</plugins>
+	</build>
 </project>
diff --git a/asterix-doc/src/site/markdown/aql/js-sdk.md b/asterix-doc/src/site/markdown/aql/js-sdk.md
index 85a13bb..ead0c68 100644
--- a/asterix-doc/src/site/markdown/aql/js-sdk.md
+++ b/asterix-doc/src/site/markdown/aql/js-sdk.md
@@ -1,24 +1,529 @@
 # AsterixDB Javascript SDK #
 
-## Installing/Including ##
-... TODO ...
+## Obtaining and Including ##
+[Download](../download/asterix-sdk-stable.js) the javascript SDK.
 
-## Learning the javascript SDK--by example ##
-In this section, we explore how to form AQL queries using the javascript SDK.
-... TODO ...
+The AsterixDB javascript SDK can be included (like any other javascript library)
+by adding the following line in the appropriate HTML file:
+
+	<script src="path/to/asterix-sdk-stable.js"></script>
+
+## Interactive Demos
+- Cherry demo
+- All of the examples in following section can be viewed by running the interactive demo.
+
+## The javascript SDK: by example ##
+In this section, we explore how to form AQL queries using the javascript SDK. The queries from
+[AsterixDB 101: An ADM and AQL Primer](primer.html) are used as examples here. For each AQL statement, 
+the equivalent javascript expression is shown below it, followed by the results of executing the query.
 
 ### Query 0-A - Exact-Match Lookup ###
+###### AQL
+	use dataverse TinySocial;
 
-        use dataverse TinySocial;
+	for $user in dataset FacebookUsers
+    where $user.id = 8
+    return $user;
 
-        for $user in dataset FacebookUsers
-        where $user.id = 8
-        return $user;
+###### JS
 
-... TODO ...
+	var expression0a = new FLWOGRExpression()
+		.ForClause("$user", new AExpression("dataset FacebookUsers"))
+        .WhereClause(new AExpression("$user.id = 8"))
+        .ReturnClause("$user");
 
-        var expression0a = new FLWOGRExpression()
-            .ForClause("$user", new AExpression("dataset FacebookUsers"))
-            .WhereClause(new AExpression("$user.id = 8"))
-            .ReturnClause("$user");
+###### Results
 
+	{ "id": { int32: 8 } , "alias": "Nila", "name": "NilaMilliron", "user-since": { datetime: 1199182200000}, "friend-ids": { unorderedlist: [{ int32: 3 } ]}, "employment": { orderedlist: [{ "organization-name": "Plexlane", "start-date": { date: 1267315200000}, "end-date": null } ]} }
+
+### Query 0-B - Range Scan ###
+###### AQL
+	use dataverse TinySocial;
+
+    for $user in dataset FacebookUsers
+    where $user.id >= 2 and $user.id <= 4
+    return $user;
+
+###### JS
+
+	var expression0b = new FLWOGRExpression()
+    	.ForClause("$user", new AExpression("dataset FacebookUsers"))
+		.WhereClause().and(new AExpression("$user.id >= 2"), new AExpression("$user.id <= 4"))
+		.ReturnClause("$user");
+
+###### Results
+
+	{ "id": { int32: 2 } , "alias": "Isbel", "name": "IsbelDull", "user-since": { datetime: 1295691000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 4 } ]}, "employment": { orderedlist: [{ "organization-name": "Hexviafind", "start-date": { date: 1272326400000}, "end-date": null } ]} }
+	{ "id": { int32: 3 } , "alias": "Emory", "name": "EmoryUnk", "user-since": { datetime: 1341915000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 8 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "geomedia", "start-date": { date: 1276732800000}, "end-date": { date: 1264464000000} } ]} }
+	{ "id": { int32: 4 } , "alias": "Nicholas", "name": "NicholasStroh", "user-since": { datetime: 1293444600000}, "friend-ids": { unorderedlist: [{ int32: 2 } ]}, "employment": { orderedlist: [{ "organization-name": "Zamcorporation", "start-date": { date: 1275955200000}, "end-date": null } ]} }
+
+### Query 1 - Other Query Filters ###
+###### AQL
+	use dataverse TinySocial;
+
+    for $user in dataset FacebookUsers
+    where $user.user-since >= datetime('2010-07-22T00:00:00')
+    and $user.user-since <= datetime('2012-07-29T23:59:59')
+    return $user;
+
+###### JS
+
+	var expression1 = new FLWOGRExpression()
+		.ForClause("$user", new AExpression("dataset FacebookUsers"))
+        .WhereClause().and(
+			new AExpression("$user.user-since >= datetime('2010-07-22T00:00:00')"),
+			new AExpression("$user.user-since <= datetime('2012-07-29T23:59:59')")
+        ).ReturnClause("$user");
+
+###### Results
+
+	{ "id": { int32: 2 } , "alias": "Isbel", "name": "IsbelDull", "user-since": { datetime: 1295691000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 4 } ]}, "employment": { orderedlist: [{ "organization-name": "Hexviafind", "start-date": { date: 1272326400000}, "end-date": null } ]} }
+	{ "id": { int32: 10 } , "alias": "Bram", "name": "BramHatch", "user-since": { datetime: 1287223800000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "physcane", "start-date": { date: 1181001600000}, "end-date": { date: 1320451200000} } ]} }
+	{ "id": { int32: 3 } , "alias": "Emory", "name": "EmoryUnk", "user-since": { datetime: 1341915000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 8 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "geomedia", "start-date": { date: 1276732800000}, "end-date": { date: 1264464000000} } ]} }
+	{ "id": { int32: 4 } , "alias": "Nicholas", "name": "NicholasStroh", "user-since": { datetime: 1293444600000}, "friend-ids": { unorderedlist: [{ int32: 2 } ]}, "employment": { orderedlist: [{ "organization-name": "Zamcorporation", "start-date": { date: 1275955200000}, "end-date": null } ]} }
+
+### Query 2-A - Equijoin ###
+###### AQL
+	use dataverse TinySocial;
+
+    for $user in dataset FacebookUsers
+    for $message in dataset FacebookMessages
+    where $message.author-id = $user.id
+    return {
+        "uname": $user.name,
+        "message": $message.message
+    };
+
+###### JS
+
+	var expression2a = new FLWOGRExpression()
+		.ForClause ("$user", new AExpression("dataset FacebookUsers"))
+		.ForClause ("$message", new AExpression("dataset FacebookMessages"))
+		.WhereClause(new AExpression("$message.author-id = $user.id"))
+		.ReturnClause({
+			"uname" : "$user.name",
+			"message" : "$message.message"
+		});
+
+###### Results
+
+	{ "uname": "MargaritaStoddard", "message": " dislike iphone its touch-screen is horrible" }
+	{ "uname": "MargaritaStoddard", "message": " like verizon the 3G is awesome:)" }
+	{ "uname": "MargaritaStoddard", "message": " can't stand motorola the touch-screen is terrible" }
+	{ "uname": "MargaritaStoddard", "message": " can't stand at&t the network is horrible:(" }
+	{ "uname": "MargaritaStoddard", "message": " can't stand at&t its plan is terrible" }
+	{ "uname": "IsbelDull", "message": " like samsung the plan is amazing" }
+	{ "uname": "IsbelDull", "message": " like t-mobile its platform is mind-blowing" }
+	{ "uname": "WoodrowNehling", "message": " love at&t its 3G is good:)" }
+	{ "uname": "BramHatch", "message": " dislike iphone the voice-command is bad:(" }
+	{ "uname": "BramHatch", "message": " can't stand t-mobile its voicemail-service is OMG:(" }
+	{ "uname": "EmoryUnk", "message": " love sprint its shortcut-menu is awesome:)" }
+	{ "uname": "EmoryUnk", "message": " love verizon its wireless is good" }
+	{ "uname": "WillisWynne", "message": " love sprint the customization is mind-blowing" }
+	{ "uname": "SuzannaTillson", "message": " like iphone the voicemail-service is awesome" }
+	{ "uname": "VonKemble", "message": " dislike sprint the speed is horrible" }
+
+### Query 2-B - Index join ###
+###### AQL
+	use dataverse TinySocial;
+
+    for $user in dataset FacebookUsers
+    for $message in dataset FacebookMessages
+    where $message.author-id /*+ indexnl */  = $user.id
+    return {
+        "uname": $user.name,
+        "message": $message.message
+    };
+
+###### JS
+
+	var expression2b = new FLWOGRExpression()
+		.ForClause ("$user", new AExpression("dataset FacebookUsers"))
+		.ForClause ("$message", new AExpression("dataset FacebookMessages"))
+		.WhereClause(new AExpression("$message.author-id /*+ indexnl */  = $user.id"))
+		.ReturnClause({
+			"uname" : "$user.name",
+			"message" : "$message.message"
+		});
+
+###### Results
+
+	{ "uname": "MargaritaStoddard", "message": " dislike iphone its touch-screen is horrible" }
+	{ "uname": "MargaritaStoddard", "message": " like verizon the 3G is awesome:)" }
+	{ "uname": "MargaritaStoddard", "message": " can't stand motorola the touch-screen is terrible" }
+	{ "uname": "MargaritaStoddard", "message": " can't stand at&t the network is horrible:(" }
+	{ "uname": "MargaritaStoddard", "message": " can't stand at&t its plan is terrible" }
+	{ "uname": "IsbelDull", "message": " like samsung the plan is amazing" }
+	{ "uname": "IsbelDull", "message": " like t-mobile its platform is mind-blowing" }
+	{ "uname": "WoodrowNehling", "message": " love at&t its 3G is good:)" }
+	{ "uname": "BramHatch", "message": " dislike iphone the voice-command is bad:(" }
+	{ "uname": "BramHatch", "message": " can't stand t-mobile its voicemail-service is OMG:(" }
+	{ "uname": "EmoryUnk", "message": " love sprint its shortcut-menu is awesome:)" }
+	{ "uname": "EmoryUnk", "message": " love verizon its wireless is good" }
+	{ "uname": "WillisWynne", "message": " love sprint the customization is mind-blowing" }
+	{ "uname": "SuzannaTillson", "message": " like iphone the voicemail-service is awesome" }
+	{ "uname": "VonKemble", "message": " dislike sprint the speed is horrible" }
+
+### Query 3 - Nested Outer Join ###
+###### AQL
+	use dataverse TinySocial;
+
+    for $user in dataset FacebookUsers
+    return {
+        "uname": $user.name,
+        "messages": for $message in dataset FacebookMessages
+                    where $message.author-id = $user.id
+                    return $message.message
+    };
+
+###### JS
+
+	var expression3messages = new FLWOGRExpression()
+        .ForClause("$message", new AExpression("dataset FacebookMessages"))
+        .WhereClause(new AExpression("$message.author-id = $user.id"))
+        .ReturnClause("$message.message");
+
+    var expression3 = new FLWOGRExpression()
+        .ForClause ("$user", new AExpression("dataset FacebookUsers"))
+        .ReturnClause({
+            "uname": "$user.name",
+            "messages" : expression3messages
+        });
+
+###### Results
+
+	{ "uname": "MargaritaStoddard", "messages": { orderedlist: [" dislike iphone its touch-screen is horrible", " like verizon the 3G is awesome:)", " can't stand motorola the touch-screen is terrible", " can't stand at&t the network is horrible:(", " can't stand at&t its plan is terrible" ]} }
+	{ "uname": "IsbelDull", "messages": { orderedlist: [" like samsung the plan is amazing", " like t-mobile its platform is mind-blowing" ]} }
+	{ "uname": "NilaMilliron", "messages": { orderedlist: [ ]} }
+	{ "uname": "WoodrowNehling", "messages": { orderedlist: [" love at&t its 3G is good:)" ]} }
+	{ "uname": "BramHatch", "messages": { orderedlist: [" dislike iphone the voice-command is bad:(", " can't stand t-mobile its voicemail-service is OMG:(" ]} }
+	{ "uname": "EmoryUnk", "messages": { orderedlist: [" love sprint its shortcut-menu is awesome:)", " love verizon its wireless is good" ]} }
+	{ "uname": "WillisWynne", "messages": { orderedlist: [" love sprint the customization is mind-blowing" ]} }
+	{ "uname": "SuzannaTillson", "messages": { orderedlist: [" like iphone the voicemail-service is awesome" ]} }
+	{ "uname": "NicholasStroh", "messages": { orderedlist: [ ]} }
+	{ "uname": "VonKemble", "messages": { orderedlist: [" dislike sprint the speed is horrible" ]} }
+
+### Query 4 - Theta Join ###
+###### AQL
+	use dataverse TinySocial;
+
+    for $t in dataset TweetMessages
+    return {
+        "message": $t.message-text,
+        "nearby-messages": for $t2 in dataset TweetMessages
+                           where spatial-distance($t.sender-location, $t2.sender-location) <= 1
+                           return { "msgtxt":$t2.message-text}
+    };
+
+###### JS
+
+	var expression4messages = new FLWOGRExpression()
+        .ForClause( "$t2", new AExpression("dataset TweetMessages"))
+        .WhereClause( new AExpression("spatial-distance($t.sender-location, $t2.sender-location) <= 1"))
+        .ReturnClause({ "msgtxt" : "$t2.message-text" });
+
+    var expression4 = new FLWOGRExpression()
+        .ForClause( "$t", new AExpression("dataset TweetMessages"))
+        .ReturnClause({
+            "message" : "$t.message-text",
+            "nearby-messages" : expression4messages
+        });
+
+###### Results
+
+	{ "message": " hate verizon its voice-clarity is OMG:(", "nearby-messages": { orderedlist: [{ "msgtxt": " hate verizon its voice-clarity is OMG:(" }, { "msgtxt": " like motorola the speed is good:)" } ]} }
+	{ "message": " like iphone the voice-clarity is good:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like iphone the voice-clarity is good:)" } ]} }
+	{ "message": " like samsung the platform is good", "nearby-messages": { orderedlist: [{ "msgtxt": " like samsung the platform is good" } ]} }
+	{ "message": " love t-mobile its customization is good:)", "nearby-messages": { orderedlist: [{ "msgtxt": " love t-mobile its customization is good:)" } ]} }
+	{ "message": " like samsung the voice-command is amazing:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like samsung the voice-command is amazing:)" } ]} }
+	{ "message": " like motorola the speed is good:)", "nearby-messages": { orderedlist: [{ "msgtxt": " hate verizon its voice-clarity is OMG:(" }, { "msgtxt": " like motorola the speed is good:)" } ]} }
+	{ "message": " love verizon its voicemail-service is awesome", "nearby-messages": { orderedlist: [{ "msgtxt": " love verizon its voicemail-service is awesome" } ]} }
+	{ "message": " can't stand motorola its speed is terrible:(", "nearby-messages": { orderedlist: [{ "msgtxt": " can't stand motorola its speed is terrible:(" } ]} }
+	{ "message": " like t-mobile the shortcut-menu is awesome:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like t-mobile the shortcut-menu is awesome:)" } ]} }
+	{ "message": " can't stand iphone its platform is terrible", "nearby-messages": { orderedlist: [{ "msgtxt": " can't stand iphone its platform is terrible" } ]} }
+	{ "message": " like verizon its shortcut-menu is awesome:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like verizon its shortcut-menu is awesome:)" } ]} }
+	{ "message": " like sprint the voice-command is mind-blowing:)", "nearby-messages": { orderedlist: [{ "msgtxt": " like sprint the voice-command is mind-blowing:)" } ]} }
+
+### Query 5 - Fuzzy Join ###
+###### AQL
+use dataverse TinySocial;
+
+    set simfunction "edit-distance";
+    set simthreshold "3";
+
+    for $fbu in dataset FacebookUsers
+    return {
+        "id": $fbu.id,
+        "name": $fbu.name,
+        "similar-users": for $t in dataset TweetMessages
+                         let $tu := $t.user
+                         where $tu.name ~= $fbu.name
+                        return {
+                            "twitter-screenname": $tu.screen-name,
+                            "twitter-name": $tu.name
+                        }
+    };
+
+###### JS
+
+	var similarUsersExpression = new FLWOGRExpression()
+        .ForClause("$t", new AExpression("dataset TweetMessages"))
+        .LetClause ("$tu", new AExpression("$t.user"))
+        .WhereClause(new AExpression("$tu.name ~= $fbu.name"))
+        .ReturnClause({
+            "twitter-screenname": "$tu.screen-name",
+            "twitter-name": "$tu.name"
+        });
+
+    var expression5 = new FLWOGRExpression()
+        .ForClause ("$fbu", new AExpression("dataset FacebookUsers"))
+        .ReturnClause(
+            {
+                "id" : "$fbu.id",
+                "name" : "$fbu.name",
+                "similar-users" : similarUsersExpression
+            }
+        );
+
+###### Results
+
+	{ "id": { int32: 1 } , "name": "MargaritaStoddard", "similar-users": { orderedlist: [ ]} }
+	{ "id": { int32: 2 } , "name": "IsbelDull", "similar-users": { orderedlist: [ ]} }
+	{ "id": { int32: 8 } , "name": "NilaMilliron", "similar-users": { orderedlist: [{ "twitter-screenname": "NilaMilliron_tw", "twitter-name": "Nila Milliron" } ]} }
+	{ "id": { int32: 9 } , "name": "WoodrowNehling", "similar-users": { orderedlist: [ ]} }
+	{ "id": { int32: 10 } , "name": "BramHatch", "similar-users": { orderedlist: [ ]} }
+	{ "id": { int32: 3 } , "name": "EmoryUnk", "similar-users": { orderedlist: [ ]} }
+	{ "id": { int32: 6 } , "name": "WillisWynne", "similar-users": { orderedlist: [ ]} }
+	{ "id": { int32: 7 } , "name": "SuzannaTillson", "similar-users": { orderedlist: [ ]} }
+	{ "id": { int32: 4 } , "name": "NicholasStroh", "similar-users": { orderedlist: [ ]} }
+	{ "id": { int32: 5 } , "name": "VonKemble", "similar-users": { orderedlist: [ ]} }
+
+### Query 6 - Existential Quantification ###
+###### AQL
+
+	use dataverse TinySocial;
+
+    for $fbu in dataset FacebookUsers
+    where (some $e in $fbu.employment satisfies is-null($e.end-date))
+    return $fbu;
+
+###### JS
+
+	var expression6 = new FLWOGRExpression()
+        .ForClause ("$fbu", new AQLClause().set("dataset FacebookUsers"))
+        .WhereClause(
+            new QuantifiedExpression (
+                "some" ,
+                {"$e" : new AExpression("$fbu.employment") },
+                new FunctionExpression("is-null", new AExpression("$e.end-date"))
+            )
+        )
+        .ReturnClause("$fbu");
+
+###### Results
+
+	{ "id": { int32: 1 } , "alias": "Margarita", "name": "MargaritaStoddard", "user-since": { datetime: 1345457400000}, "friend-ids": { unorderedlist: [{ int32: 2 } , { int32: 3 } , { int32: 6 } , { int32: 10 } ]}, "employment": { orderedlist: [{ "organization-name": "Codetechno", "start-date": { date: 1154822400000}, "end-date": null } ]} }
+	{ "id": { int32: 2 } , "alias": "Isbel", "name": "IsbelDull", "user-since": { datetime: 1295691000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 4 } ]}, "employment": { orderedlist: [{ "organization-name": "Hexviafind", "start-date": { date: 1272326400000}, "end-date": null } ]} }
+	{ "id": { int32: 8 } , "alias": "Nila", "name": "NilaMilliron", "user-since": { datetime: 1199182200000}, "friend-ids": { unorderedlist: [{ int32: 3 } ]}, "employment": { orderedlist: [{ "organization-name": "Plexlane", "start-date": { date: 1267315200000}, "end-date": null } ]} }
+	{ "id": { int32: 6 } , "alias": "Willis", "name": "WillisWynne", "user-since": { datetime: 1105956600000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 3 } , { int32: 7 } ]}, "employment": { orderedlist: [{ "organization-name": "jaydax", "start-date": { date: 1242345600000}, "end-date": null } ]} }
+	{ "id": { int32: 7 } , "alias": "Suzanna", "name": "SuzannaTillson", "user-since": { datetime: 1344334200000}, "friend-ids": { unorderedlist: [{ int32: 6 } ]}, "employment": { orderedlist: [{ "organization-name": "Labzatron", "start-date": { date: 1303171200000}, "end-date": null } ]} }
+	{ "id": { int32: 4 } , "alias": "Nicholas", "name": "NicholasStroh", "user-since": { datetime: 1293444600000}, "friend-ids": { unorderedlist: [{ int32: 2 } ]}, "employment": { orderedlist: [{ "organization-name": "Zamcorporation", "start-date": { date: 1275955200000}, "end-date": null } ]} }
+	{ "id": { int32: 5 } , "alias": "Von", "name": "VonKemble", "user-since": { datetime: 1262686200000}, "friend-ids": { unorderedlist: [{ int32: 3 } , { int32: 6 } , { int32: 10 } ]}, "employment": { orderedlist: [{ "organization-name": "Kongreen", "start-date": { date: 1290816000000}, "end-date": null } ]} }
+
+### Query 7 - Universal Quantification ###
+###### AQL
+
+	use dataverse TinySocial;
+
+    for $fbu in dataset FacebookUsers
+    where (every $e in $fbu.employment satisfies not(is-null($e.end-date)))
+    return $fbu;
+
+###### JS
+
+	var expression7 = new FLWOGRExpression()
+        .ForClause("$fbu", new AExpression("dataset FacebookUsers"))
+        .WhereClause(
+            new QuantifiedExpression (
+                "every" ,
+                {"$e" : new AExpression("$fbu.employment") },
+                new FunctionExpression("not", new FunctionExpression("is-null", new AExpression("$e.end-date")))
+            )
+        )
+        .ReturnClause("$fbu");
+
+###### Results
+
+	{ "id": { int32: 9 } , "alias": "Woodrow", "name": "WoodrowNehling", "user-since": { datetime: 1127211000000}, "friend-ids": { unorderedlist: [{ int32: 3 } , { int32: 10 } ]}, "employment": { orderedlist: [{ "organization-name": "Zuncan", "start-date": { date: 1050969600000}, "end-date": { date: 1260662400000} } ]} }
+	{ "id": { int32: 10 } , "alias": "Bram", "name": "BramHatch", "user-since": { datetime: 1287223800000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "physcane", "start-date": { date: 1181001600000}, "end-date": { date: 1320451200000} } ]} }
+	{ "id": { int32: 3 } , "alias": "Emory", "name": "EmoryUnk", "user-since": { datetime: 1341915000000}, "friend-ids": { unorderedlist: [{ int32: 1 } , { int32: 5 } , { int32: 8 } , { int32: 9 } ]}, "employment": { orderedlist: [{ "organization-name": "geomedia", "start-date": { date: 1276732800000}, "end-date": { date: 1264464000000} } ]} }
+
+### Query 8 - Simple Aggregation ###
+###### AQL
+
+	use dataverse TinySocial;
+
+    count(for $fbu in dataset FacebookUsers return $fbu);
+
+###### JS
+
+	var expression8 = new FunctionExpression(
+        "count",
+        new FLWOGRExpression()
+            .ForClause("$fbu", new AExpression("dataset FacebookUsers"))
+            .ReturnClause("$fbu")
+    );
+
+###### Results
+
+	{ int64: 10 }
+
+### Query 9-A - Grouping and Aggregation ###
+###### AQL
+
+	use dataverse TinySocial;
+
+    for $t in dataset TweetMessages
+    group by $uid := $t.user.screen-name with $t
+    return {
+        "user": $uid,
+        "count": count($t)
+    };
+
+###### JS
+
+	var expression9a = new FLWOGRExpression()
+        .ForClause("$t", new AExpression("dataset TweetMessages"))
+        .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t")
+        .ReturnClause(
+            {
+                "user" : "$uid",
+                "count" : new FunctionExpression("count", new AExpression("$t"))
+            }
+        );
+
+###### Results
+
+	{ "user": "ColineGeyer@63", "count": { int64: 3 } }
+	{ "user": "OliJackson_512", "count": { int64: 1 } }
+	{ "user": "NilaMilliron_tw", "count": { int64: 1 } }
+	{ "user": "ChangEwing_573", "count": { int64: 1 } }
+	{ "user": "NathanGiesen@211", "count": { int64: 6 } }
+
+### Query 9-B - (Hash-Based) Grouping and Aggregation ###
+###### AQL
+
+	use dataverse TinySocial;
+
+    for $t in dataset TweetMessages
+    /*+ hash*/
+    group by $uid := $t.user.screen-name with $t
+    return {
+        "user": $uid,
+        "count": count($t)
+    };
+
+###### JS
+
+	var expression9b = new FLWOGRExpression()
+        .ForClause("$t", new AExpression("dataset TweetMessages"))
+        .AQLClause("/*+ hash*/")
+        .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t")
+        .ReturnClause(
+            {
+                "user" : "$uid",
+                "count" : new FunctionExpression("count", new AExpression("$t"))
+            }
+        );
+
+###### Results
+
+	{ "user": "ColineGeyer@63", "count": { int64: 3 } }
+	{ "user": "OliJackson_512", "count": { int64: 1 } }
+	{ "user": "NilaMilliron_tw", "count": { int64: 1 } }
+	{ "user": "ChangEwing_573", "count": { int64: 1 } }
+	{ "user": "NathanGiesen@211", "count": { int64: 6 } }
+
+### Query 10 - Grouping and Limits ###
+###### AQL
+
+	use dataverse TinySocial;
+
+    for $t in dataset TweetMessages
+    group by $uid := $t.user.screen-name with $t
+    let $c := count($t)
+    order by $c desc
+    limit 3
+    return {
+        "user": $uid,
+        "count": $c
+    };
+
+
+###### JS
+
+	var expression10 = new FLWOGRExpression()
+        .ForClause("$t", new AExpression("dataset TweetMessages"))
+        .GroupClause("$uid", new AExpression("$t.user.screen-name"), "with", "$t")
+        .LetClause("$c", new FunctionExpression("count", new AExpression("$t")))
+        .OrderbyClause( new AExpression("$c"), "desc" )
+        .LimitClause(new AExpression("3"))
+        .ReturnClause(
+            {
+                "user" : "$uid",
+                "count" : "$c"
+            }
+        );
+
+###### Results
+
+	{ "user": "NathanGiesen@211", "count": { int64: 6 } }
+	{ "user": "ColineGeyer@63", "count": { int64: 3 } }
+	{ "user": "NilaMilliron_tw", "count": { int64: 1 } }
+
+### Query 11 - Left Outer Fuzzy Join ###
+###### AQL
+
+	use dataverse TinySocial;
+
+    set simfunction "jaccard";
+    set simthreshold "0.3";
+
+    for $t in dataset TweetMessages
+    return {
+        "tweet": $t,
+        "similar-tweets": for $t2 in dataset TweetMessages
+        where  $t2.referred-topics ~= $t.referred-topics
+        and $t2.tweetid != $t.tweetid
+        return $t2.referred-topics
+    };
+
+###### JS
+
+	var expression11 = new FLWOGRExpression()
+        .ForClause( "$t", new AExpression("dataset TweetMessages"))
+        .ReturnClause({
+            "tweet"         : new AExpression("$t"),
+            "similar-tweets": new FLWOGRExpression()
+                                .ForClause( "$t2", new AExpression("dataset TweetMessages"))
+                                .WhereClause().and(
+                                    new AExpression("$t2.referred-topics ~= $t.referred-topics"),
+                                    new AExpression("$t2.tweetid != $t.tweetid")
+                                 )
+                                .ReturnClause("$t2.referred-topics")
+        });
+
+###### Results
+
+	{ "tweet": { "tweetid": "10", "user": { "screen-name": "ColineGeyer@63", "lang": "en", "friends_count": { int32: 121 } , "statuses_count": { int32: 362 } , "name": "Coline Geyer", "followers_count": { int32: 17159 } }, "sender-location": { point: [29.15, 76.53]}, "send-time": { datetime: 1201342200000}, "referred-topics": { unorderedlist: ["verizon", "voice-clarity" ]}, "message-text": " hate verizon its voice-clarity is OMG:(" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["iphone", "voice-clarity" ]}, { unorderedlist: ["verizon", "shortcut-menu" ]}, { unorderedlist: ["verizon", "voicemail-service" ]} ]} }
+	{ "tweet": { "tweetid": "6", "user": { "screen-name": "ColineGeyer@63", "lang": "en", "friends_count": { int32: 121 } , "statuses_count": { int32: 362 } , "name": "Coline Geyer", "followers_count": { int32: 17159 } }, "sender-location": { point: [47.51, 83.99]}, "send-time": { datetime: 1273227000000}, "referred-topics": { unorderedlist: ["iphone", "voice-clarity" ]}, "message-text": " like iphone the voice-clarity is good:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["verizon", "voice-clarity" ]}, { unorderedlist: ["iphone", "platform" ]} ]} }
+	{ "tweet": { "tweetid": "7", "user": { "screen-name": "ChangEwing_573", "lang": "en", "friends_count": { int32: 182 } , "statuses_count": { int32: 394 } , "name": "Chang Ewing", "followers_count": { int32: 32136 } }, "sender-location": { point: [36.21, 72.6]}, "send-time": { datetime: 1314267000000}, "referred-topics": { unorderedlist: ["samsung", "platform" ]}, "message-text": " like samsung the platform is good" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["iphone", "platform" ]}, { unorderedlist: ["samsung", "voice-command" ]} ]} }
+	{ "tweet": { "tweetid": "1", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [47.44, 80.65]}, "send-time": { datetime: 1209204600000}, "referred-topics": { unorderedlist: ["t-mobile", "customization" ]}, "message-text": " love t-mobile its customization is good:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["t-mobile", "shortcut-menu" ]} ]} }
+	{ "tweet": { "tweetid": "12", "user": { "screen-name": "OliJackson_512", "lang": "en", "friends_count": { int32: 445 } , "statuses_count": { int32: 164 } , "name": "Oli Jackson", "followers_count": { int32: 22649 } }, "sender-location": { point: [24.82, 94.63]}, "send-time": { datetime: 1266055800000}, "referred-topics": { unorderedlist: ["samsung", "voice-command" ]}, "message-text": " like samsung the voice-command is amazing:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["samsung", "platform" ]}, { unorderedlist: ["sprint", "voice-command" ]} ]} }
+	{ "tweet": { "tweetid": "3", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [29.72, 75.8]}, "send-time": { datetime: 1162635000000}, "referred-topics": { unorderedlist: ["motorola", "speed" ]}, "message-text": " like motorola the speed is good:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["motorola", "speed" ]} ]} }
+	{ "tweet": { "tweetid": "9", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [36.86, 74.62]}, "send-time": { datetime: 1342865400000}, "referred-topics": { unorderedlist: ["verizon", "voicemail-service" ]}, "message-text": " love verizon its voicemail-service is awesome" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["verizon", "voice-clarity" ]}, { unorderedlist: ["verizon", "shortcut-menu" ]} ]} }
+	{ "tweet": { "tweetid": "5", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [40.09, 92.69]}, "send-time": { datetime: 1154686200000}, "referred-topics": { unorderedlist: ["motorola", "speed" ]}, "message-text": " can't stand motorola its speed is terrible:(" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["motorola", "speed" ]} ]} }
+	{ "tweet": { "tweetid": "8", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [46.05, 93.34]}, "send-time": { datetime: 1129284600000}, "referred-topics": { unorderedlist: ["t-mobile", "shortcut-menu" ]}, "message-text": " like t-mobile the shortcut-menu is awesome:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["verizon", "shortcut-menu" ]}, { unorderedlist: ["t-mobile", "customization" ]} ]} }
+	{ "tweet": { "tweetid": "11", "user": { "screen-name": "NilaMilliron_tw", "lang": "en", "friends_count": { int32: 445 } , "statuses_count": { int32: 164 } , "name": "Nila Milliron", "followers_count": { int32: 22649 } }, "sender-location": { point: [37.59, 68.42]}, "send-time": { datetime: 1205057400000}, "referred-topics": { unorderedlist: ["iphone", "platform" ]}, "message-text": " can't stand iphone its platform is terrible" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["iphone", "voice-clarity" ]}, { unorderedlist: ["samsung", "platform" ]} ]} }
+	{ "tweet": { "tweetid": "2", "user": { "screen-name": "ColineGeyer@63", "lang": "en", "friends_count": { int32: 121 } , "statuses_count": { int32: 362 } , "name": "Coline Geyer", "followers_count": { int32: 17159 } }, "sender-location": { point: [32.84, 67.14]}, "send-time": { datetime: 1273745400000}, "referred-topics": { unorderedlist: ["verizon", "shortcut-menu" ]}, "message-text": " like verizon its shortcut-menu is awesome:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["t-mobile", "shortcut-menu" ]}, { unorderedlist: ["verizon", "voice-clarity" ]}, { unorderedlist: ["verizon", "voicemail-service" ]} ]} }
+	{ "tweet": { "tweetid": "4", "user": { "screen-name": "NathanGiesen@211", "lang": "en", "friends_count": { int32: 39339 } , "statuses_count": { int32: 473 } , "name": "Nathan Giesen", "followers_count": { int32: 49416 } }, "sender-location": { point: [39.28, 70.48]}, "send-time": { datetime: 1324894200000}, "referred-topics": { unorderedlist: ["sprint", "voice-command" ]}, "message-text": " like sprint the voice-command is mind-blowing:)" }, "similar-tweets": { orderedlist: [{ unorderedlist: ["samsung", "voice-command" ]} ]} }
diff --git a/asterix-examples/pom.xml b/asterix-examples/pom.xml
new file mode 100644
index 0000000..1268908
--- /dev/null
+++ b/asterix-examples/pom.xml
@@ -0,0 +1,19 @@
+<!-- ! Copyright 2009-2013 by The Regents of the University of California 
+	! Licensed under the Apache License, Version 2.0 (the "License"); ! you may 
+	not use this file except in compliance with the License. ! you may obtain 
+	a copy of the License from ! ! http://www.apache.org/licenses/LICENSE-2.0 
+	! ! Unless required by applicable law or agreed to in writing, software ! 
+	distributed under the License is distributed on an "AS IS" BASIS, ! WITHOUT 
+	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! See the 
+	License for the specific language governing permissions and ! limitations 
+	under the License. ! -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<artifactId>asterix</artifactId>
+		<groupId>edu.uci.ics.asterix</groupId>
+		<version>0.8.4-SNAPSHOT</version>
+	</parent>
+	<artifactId>asterix-examples</artifactId>
+</project> 
diff --git a/asterix-examples/src/main/resources/asterix-sdk-stable.js b/asterix-examples/src/main/resources/asterix-sdk-stable.js
new file mode 100755
index 0000000..3e5aa8d
--- /dev/null
+++ b/asterix-examples/src/main/resources/asterix-sdk-stable.js
@@ -0,0 +1,1045 @@
+/**
+* Asterix SDK - Beta Version
+* @author Eugenia Gabrielov <genia.likes.science@gmail.com>
+* 
+* This is a Javascript helper file for generating AQL queries for AsterixDB (https://code.google.com/p/asterixdb/) 
+*/
+
+/**
+* AsterixDBConnection
+* 
+* This is a handler for connections to a local AsterixDB REST API Endpoint. 
+* This initialization takes as input a configuraiton object, and initializes
+* same basic functionality. 
+*/
+function AsterixDBConnection(configuration) {
+    // Initialize AsterixDBConnection properties
+    this._properties = {};
+    
+    // Set dataverse as null for now, this needs to be set by the user.
+    this._properties["dataverse"] = "";
+    
+    // By default, we will wait for calls to the REST API to complete. The query method
+    // sends a different setting when executed asynchronously. Calls that do not specify a mode
+    // will be executed synchronously.
+    this._properties["mode"] = "synchronous";
+    
+    // These are the default error behaviors for Asterix and ajax errors, respectively. 
+    // They can be overridden by calling initializing your AsterixDBConnection like so:
+    // adb = new AsterixDBConnection({
+    //                                  "error" : function(data) {
+    //                                              // override here...
+    //                                  });
+    // and similarly for ajax_error, just pass in the configuration as a json object.
+    this._properties["error"] = function(data) {
+        alert("Asterix REST API Error:\n" + data["error-code"][0] + "\n" + data["error-code"][1]);
+    };
+    
+    this._properties["ajax_error"] = function(message) {
+        alert("[Ajax Error]\n" + message);
+    };
+
+    // This is the default path to the local Asterix REST API. Can be overwritten for remote configurations
+    // or for demo setup purposes (such as with a proxy handler with Python or PHP.
+    this._properties["endpoint_root"] = "http://localhost:19002/";
+    
+    // If we have passed in a configuration, we will update the internal properties
+    // using that configuration. You can do things such as include a new endpoint_root,
+    // a new error function, a new dataverse, etc. You can even store extra info.
+    //
+    // NOTE Long-term, this should have more strict limits.
+    var configuration = configuration || {};
+
+    for (var key in configuration) {
+        this._properties[key] = configuration[key];
+    }
+    
+    return this;
+}
+
+
+/**
+* dataverse
+*
+* Sets dataverse for execution for the AsterixDBConnection.
+*/
+AsterixDBConnection.prototype.dataverse = function(dataverseName) {
+    this._properties["dataverse"] = dataverseName;
+    
+    return this;
+};
+
+
+/**
+* query (http://asterix.ics.uci.edu/documentation/api.html#QueryApi)
+* 
+* @param statements, statements of an AQL query
+* @param successFn, a function to execute if this query is run successfully
+* @param mode, a string either "synchronous" or "asynchronous", depending on preferred
+*               execution mode. 
+*/
+AsterixDBConnection.prototype.query = function(statements, successFn, mode) {
+ 
+    if ( typeof statements === 'string') {
+        statements = [ statements ];
+    }
+    
+    var m = typeof mode ? mode : "synchronous";
+    
+    // DEBUG
+    //alert(statements.join("\n"));
+     
+    var query = "use dataverse " + this._properties["dataverse"] + ";\n" + statements.join("\n");
+    
+    this._api(
+        {
+            "query" : query,
+            "mode"  : m
+        },
+        successFn, 
+        "query"
+    );
+
+    return this;
+};
+
+/**
+* query_status (http://asterix.ics.uci.edu/documentation/api.html#QueryStatusApi)
+* 
+* @param handle, a json object of the form {"handle" : handleObject}, where
+*                   the handle object is an opaque handle previously returned
+*                   from an asynchronous call.
+* @param successFn, a function to call on successful execution of this API call.
+*/
+AsterixDBConnection.prototype.query_status = function(handle, successFn) {
+    this._api(
+        handle,
+        successFn,
+        "query/status"
+    );
+
+    return this;
+};
+
+
+/**
+* query_result (http://asterix.ics.uci.edu/documentation/api.html#AsynchronousResultApi)
+* 
+* handle, a json object of the form {"handle" : handleObject}, where
+*           the handle object is an opaque handle previously returned
+*           from an asynchronous call.
+* successFn, a function to call on successful execution of this API call.
+*/
+AsterixDBConnection.prototype.query_result = function(handle, successFn) {
+    this._api(
+        handle,
+        successFn,
+        "query/result"
+    ); 
+
+    return this;
+};
+
+
+/**
+* ddl (http://asterix.ics.uci.edu/documentation/api.html#DdlApi)
+* 
+* @param statements, statements to run through ddl api
+* @param successFn, a function to execute if they are successful
+*/
+AsterixDBConnection.prototype.ddl = function(statements, successFn) {
+    if ( typeof statements === 'string') {
+        statements = [ statements ];
+    }
+    
+    this._api(
+        {
+            "ddl" :  "use dataverse " + this._properties["dataverse"] + ";\n" + statements.join("\n")
+        },
+        successFn,
+        "ddl"
+    );
+}
+
+
+/**
+* update (http://asterix.ics.uci.edu/documentation/api.html#UpdateApi)
+*
+* @param statements, statement(s) for an update API call
+* @param successFn, a function to run if this is executed successfully.
+* 
+* This is an AsterixDBConnection handler for the update API. It passes statements provided
+* to the internal API endpoint handler.
+*/
+AsterixDBConnection.prototype.update = function(statements, successFn) {
+    if ( typeof statements === 'string') {
+        statements = [ statements ];
+    }
+    
+    // DEBUG
+    // alert(statements.join("\n"));
+    
+    this._api(
+        {
+            "statements" : "use dataverse " + this._properties["dataverse"] + ";\n" + statements.join("\n")
+        },
+        successFn,
+        "update"
+    );
+}
+
+
+/**
+* meta
+* @param statements, a string or a list of strings representing an Asterix query object
+* @param successFn, a function to execute if call succeeds
+*
+* Queries without a dataverse. This is a work-around for an Asterix REST API behavior
+* that sometiems throws an error. This is handy for Asterix Metadata queries.
+*/
+AsterixDBConnection.prototype.meta = function(statements, successFn) {
+
+    if ( typeof statements === 'string') {
+        statements = [ statements ];
+    }
+    
+    var query = statements.join("\n");
+    
+    this._api(
+        {
+            "query" : query,
+            "mode"  : "synchronous"
+        },
+        successFn, 
+        "query"
+    );
+
+    return this;
+}
+
+
+/**
+* _api
+*
+* @param json, the data to be passed with the request
+* @param onSuccess, the success function to be run if this succeeds
+* @param endpoint, a string representing one of the Asterix API endpoints 
+* 
+* Documentation of endpoints is here:
+* http://asterix.ics.uci.edu/documentation/api.html
+*
+* This is treated as an internal method for making the actual call to the API.
+*/
+AsterixDBConnection.prototype._api = function(json, onSuccess, endpoint) {
+
+    // The success function is called if the response is successful and returns data,
+    // or is just OK.
+    var success_fn = onSuccess;
+    
+    // This is the error function. Called if something breaks either on the Asterix side
+    // or in the Ajax call.
+    var error_fn = this._properties["error"];
+    var ajax_error_fn = this._properties["ajax_error"];
+    
+    // This is the target endpoint from the REST api, called as a string.
+    var endpoint_url = this._properties["endpoint_root"] + endpoint;    
+
+    // This SDK does not rely on jQuery, but utilizes its Ajax capabilities when present.
+    if (window.jQuery) {
+        $.ajax({
+        
+            // The Asterix API does not accept post requests.
+            type        : 'GET',
+            
+            // This is the endpoint url provided by combining the default
+            // or reconfigured endpoint root along with the appropriate api endpoint
+            // such as "query" or "update".
+            url         : endpoint_url,
+            
+            // This is the data in the format specified on the API documentation.
+            data        : json,
+            
+            // We send out the json datatype to make sure our data is parsed correctly. 
+            dataType    : "json",
+            
+            // The success option calls a function on success, which in this case means
+            // something was returned from the API. However, this does not mean the call succeeded
+            // on the REST API side, it just means we got something back. This also contains the
+            // error return codes, which need to be handled before we call th success function.
+            success     : function(data) {
+
+                // Check Asterix Response for errors
+                // See http://asterix.ics.uci.edu/documentation/api.html#ErrorCodes
+                if (data["error-code"]) { 
+                    error_fn(data);
+                    
+                // Otherwise, run our provided success function
+                } else {
+                    success_fn(data);
+                }
+            },
+            
+            // This is the function that gets called if there is an ajax-related (non-Asterix)
+            // error. Network errors, empty response bodies, syntax errors, and a number of others
+            // can pop up. 
+            error       : function(data) {
+
+                // Some of the Asterix API endpoints return empty responses on success.
+                // However, the ajax function treats these as errors while reporting a
+                // 200 OK code with no payload. So we will check for that, otherwise 
+                // alert of an error. An example response is as follows:
+                // {"readyState":4,"responseText":"","status":200,"statusText":"OK"}
+                if (data["status"] == 200 && data["responseText"] == "") {
+                    success_fn(data);
+                } else {
+                    alert("[Ajax Error]\n" + JSON.stringify(data));
+                }
+            }
+        });
+        
+    } else {
+    
+        // NOTE: This section is in progress; currently API requires jQuery.
+    
+        // First, we encode the parameters of the query to create a new url.
+        api_endpoint = endpoint_url + "?" + Object.keys(json).map(function(k) {
+            return encodeURIComponent(k) + '=' + encodeURIComponent(json[k])
+        }).join('&');
+       
+        // Now, create an XMLHttp object to carry our request. We will call the
+        // UI callback function on ready.
+        var xmlhttp;
+        xmlhttp = new XMLHttpRequest();
+        xmlhttp.open("GET", endpoint_url, true);
+        xmlhttp.send(null);
+        
+        xmlhttp.onreadystatechange = function(){
+            if (xmlhttp.readyState == 4) {
+                if (xmlhttp.status === 200) {
+                    alert(xmlhttp.responseText);
+                    //success.call(null, xmlHttp.responseText);
+                } else {
+                    //error.call(null, xmlHttp.responseText);
+                }
+            } else {
+                // Still processing
+            }
+        };
+    }
+    return this;
+};
+
+// Asterix Expressions - Base
+function AExpression () {
+
+    this._properties = {};
+    this._success = function() {};
+
+    if (arguments.length == 1) {
+        this._properties["value"] = arguments[0];    
+    }
+
+    return this;
+}
+
+
+AExpression.prototype.bind = function(options) {
+    var options = options || {};
+
+    if (options.hasOwnProperty("success")) {
+        this._success = options["success"];
+    }
+
+    if (options.hasOwnProperty("return")) {
+        this._properties["return"] = " return " + options["return"].val();
+    }
+};
+
+
+AExpression.prototype.run = function(successFn) {
+    return this;
+};
+
+
+AExpression.prototype.val = function() { 
+
+    var value = "";
+
+    // If there is a dataverse defined, provide it.
+    if (this._properties.hasOwnProperty("dataverse")) {
+        value += "use dataverse " + this._properties["dataverse"] + ";\n";
+    };
+
+    if (this._properties.hasOwnProperty("value")) {
+        value += this._properties["value"].toString();
+    }
+
+    return value;
+};
+
+
+// @param expressionValue [String]
+AExpression.prototype.set = function(expressionValue) {
+    this._properties["value"] = expressionValue; 
+    return this;
+};
+
+
+// AQL Statements
+// SingleStatement ::= DataverseDeclaration
+//                  | FunctionDeclaration
+//                  | CreateStatement
+//                  | DropStatement
+//                  | LoadStatement
+//                  | SetStatement
+//                  | InsertStatement
+//                  | DeleteStatement
+//                  | Query
+function InsertStatement(quantifiedName, query) {
+    AExpression.call(this);
+    
+    var innerQuery = "";
+    if (query instanceof AExpression) {
+        innerQuery = query.val();
+    } else if (typeof query == "object" && Object.getPrototypeOf( query ) === Object.prototype ) {
+        
+        var insertStatements = [];
+        for (querykey in query) {
+            if (query[querykey] instanceof AExpression) {
+                insertStatements.push('"' + querykey + '" : ' + query[querykey].val());
+            } else if (typeof query[querykey] == "string") {
+                insertStatements.push('"' + querykey + '" : ' + query[querykey]);
+            } else {
+                insertStatements.push('"' + querykey + '" : ' + query[querykey].toString());
+            }
+        }
+        
+        innerQuery = "{" + insertStatements.join(', ') + "}";
+    }
+    
+    var statement = "insert into dataset " + quantifiedName + "(" + innerQuery + ");";
+    
+    AExpression.prototype.set.call(this, statement);
+
+    return this;
+}
+
+InsertStatement.prototype = Object.create(AExpression.prototype);
+InsertStatement.prototype.constructor = InsertStatement;
+
+
+// Delete Statement
+// DeleteStatement ::= "delete" Variable "from" "dataset" QualifiedName ( "where" Expression )?
+function DeleteStatement (variable, quantifiedName, whereExpression) {
+    AExpression.call(this);
+    
+    var statement = "delete " + variable + " from dataset " + quantifiedName;
+    
+    if (whereExpression instanceof AExpression) {
+        statement += " where " + whereExpression.val();
+    }
+    
+    AExpression.prototype.set.call(this, statement);
+    
+    return this;
+}
+
+DeleteStatement.prototype = Object.create(AExpression.prototype);
+DeleteStatement.prototype.constructor = DeleteStatement;
+
+// SetStatement
+//
+// Grammar
+// "set" Identifier StringLiteral
+function SetStatement (identifier, stringLiteral) {
+    AExpression.call(this);
+
+    var statement = "set " + identifier + ' "' + stringLiteral + '";';
+
+    AExpression.prototype.set.call(this, statement);
+
+    return this;
+}
+
+SetStatement.prototype = Object.create(AExpression.prototype);
+SetStatement.prototype.constructor = SetStatement;
+
+
+// Other Expressions
+
+// FunctionExpression
+// Parent: AsterixExpression
+// 
+// @param   options [Various], 
+// @key     function [String], a function to be applid to the expression
+// @key     expression [AsterixExpression or AQLClause] an AsterixExpression/Clause to which the fn will be applied
+function FunctionExpression() {
+    
+    // Initialize superclass
+    AExpression.call(this);
+    
+    this._properties["function"] = "";
+    this._properties["expressions"] = [];
+
+    // Check for fn/expression input
+    if (arguments.length >= 2 && typeof arguments[0] == "string") {
+        
+        this._properties["function"] = arguments[0];
+
+        for (i = 1; i < arguments.length; i++) {
+            if (arguments[i] instanceof AExpression || arguments[i] instanceof AQLClause) {
+                this._properties["expressions"].push(arguments[i]);
+            } else {
+                this._properties["expressions"].push(new AExpression(arguments[i]));
+            }
+        }
+    } 
+
+    // Return FunctionCallExpression object
+    return this;
+}
+
+
+FunctionExpression.prototype = Object.create(AExpression.prototype);
+FunctionExpression.prototype.constructor = FunctionExpression;
+   
+
+FunctionExpression.prototype.val = function () {
+    var fn_args = [];
+    for (var i = 0; i < this._properties["expressions"].length; i++) {
+        fn_args.push(this._properties["expressions"][i].val());
+    }
+
+    return this._properties["function"] + "(" + fn_args.join(", ") + ")";
+};
+
+
+// FLWOGRExpression
+//
+// FLWOGRExpression ::= ( ForClause | LetClause ) ( Clause )* "return" Expression
+function FLWOGRExpression (options) {
+    // Initialize superclass
+    AExpression.call(this);
+
+    this._properties["clauses"] = [];
+    this._properties["minSize"] = 0;
+
+    // Bind options and return
+    this.bind(options);
+    return this;
+}
+
+
+FLWOGRExpression.prototype = Object.create(AExpression.prototype);
+FLWOGRExpression.prototype.constructor = FLWOGRExpression;
+
+
+FLWOGRExpression.prototype.bind = function(options) {
+    AExpression.prototype.bind.call(this, options);
+
+    var options = options || {};
+
+    if (options instanceof SetStatement) {
+         this._properties["clauses"].push(options);
+         this._properties["minSize"] += 1;
+    }
+
+    if (this._properties["clauses"].length <= this._properties["minSize"]) {
+        // Needs to start with for or let clause
+        if (options instanceof ForClause || options instanceof LetClause) {
+            this._properties["clauses"].push(options);
+        }
+    } else {
+        if (options instanceof AQLClause) {
+            this._properties["clauses"].push(options);
+        }
+    }
+
+    return this;
+};
+
+
+FLWOGRExpression.prototype.val = function() {
+    var value = AExpression.prototype.val.call(this);
+
+    var clauseValues = [];
+    for (var c in this._properties["clauses"]) {
+        clauseValues.push(this._properties["clauses"][c].val());
+    }
+
+    return value + clauseValues.join("\n");// + ";";
+};
+
+// Pretty Expression Shorthand
+
+FLWOGRExpression.prototype.ReturnClause = function(expression) {
+    return this.bind(new ReturnClause(expression));
+};
+
+FLWOGRExpression.prototype.ForClause = function() {
+    return this.bind(new ForClause(Array.prototype.slice.call(arguments)));
+};
+
+FLWOGRExpression.prototype.LetClause = function() {
+    return this.bind(new LetClause(Array.prototype.slice.call(arguments)));
+};
+
+FLWOGRExpression.prototype.WhereClause = function() {
+    return this.bind(new WhereClause(Array.prototype.slice.call(arguments)));
+};
+
+FLWOGRExpression.prototype.and = function() {
+    var args = Array.prototype.slice.call(arguments);
+    args.push(true);
+    return this.bind(new WhereClause().and(args));
+};
+
+FLWOGRExpression.prototype.or = function() {
+    var args = Array.prototype.slice.call(arguments);
+    args.push(true);
+    return this.bind(new WhereClause().or(args));
+};
+
+FLWOGRExpression.prototype.OrderbyClause = function() {
+    return this.bind(new OrderbyClause(Array.prototype.slice.call(arguments)));
+};
+
+
+FLWOGRExpression.prototype.GroupClause = function() {
+    return this.bind(new GroupClause(Array.prototype.slice.call(arguments)));
+};
+
+FLWOGRExpression.prototype.LimitClause = function() {
+    return this.bind(new LimitClause(Array.prototype.slice.call(arguments)));
+};
+
+FLWOGRExpression.prototype.DistinctClause = function() {
+    return this.bind(new DistinctClause(Array.prototype.slice.call(arguments)));
+};
+
+FLWOGRExpression.prototype.AQLClause = function() {
+    return this.bind(new AQLClause(Array.prototype.slice.call(arguments)));
+};
+
+
+// AQLClause
+//
+// Base Clause  ::= ForClause | LetClause | WhereClause | OrderbyClause | GroupClause | LimitClause | DistinctClause
+function AQLClause() {
+    this._properties = {};
+    this._properties["clause"] = "";
+    this._properties["stack"] = [];
+    if (typeof arguments[0] == 'string') {
+        this._properties["clause"] = arguments[0];
+    }
+    return this;
+}
+
+AQLClause.prototype.val = function() {
+    var value = this._properties["clause"];
+ 
+    return value;
+};
+
+AQLClause.prototype.bind = function(options) {
+
+    if (options instanceof AQLClause) {
+        this._properties["clause"] += " " + options.val();
+    }
+
+    return this;
+};
+
+AQLClause.prototype.set = function(value) {
+    this._properties["clause"] = value;
+    return this;
+};
+
+
+// ForClause
+//
+// Grammar:
+// "for" Variable ( "at" Variable )? "in" ( Expression )
+//
+// @param for_variable [String], REQUIRED, first variable in clause 
+// @param at_variable [String], NOT REQUIRED, first variable in clause
+// @param expression [AsterixExpression], REQUIRED, expression to evaluate
+function ForClause(for_variable, at_variable, expression) {
+    AQLClause.call(this);
+  
+    var parameters = [];
+    if (arguments[0] instanceof Array) {
+        parameters = arguments[0];
+    } else {
+        parameters = arguments;
+    }
+  
+    this._properties["clause"] = "for " + parameters[0];
+    
+    if (parameters.length == 3) {
+        this._properties["clause"] += " at " + parameters[1];
+        this._properties["clause"] += " in " + parameters[2].val();
+    } else if (parameters.length == 2) {
+        this._properties["clause"] += " in " + parameters[1].val();
+    }
+    
+    return this;
+}
+
+ForClause.prototype = Object.create(AQLClause.prototype);
+ForClause.prototype.constructor = ForClause;
+
+
+// LetClause
+//
+// Grammar:
+// LetClause      ::= "let" Variable ":=" Expression
+//
+// @param let_variable [String]
+// @param expression [AExpression]
+function LetClause(let_variable, expression) {
+    AQLClause.call(this);
+    
+    var parameters = [];
+    if (arguments[0] instanceof Array) {
+        parameters = arguments[0];
+    } else {
+        parameters = arguments;
+    }
+    
+    this._properties["clause"] = "let " + parameters[0] + " := ";
+    this._properties["clause"] += parameters[1].val();
+    
+    return this; 
+}
+
+LetClause.prototype = Object.create(AQLClause.prototype);
+LetClause.prototype.constructor = LetClause;
+
+
+// ReturnClause
+//
+// Grammar:
+// return [AQLExpression]
+function ReturnClause(expression) {
+    AQLClause.call(this);
+
+    this._properties["clause"] = "return ";
+    
+    if (expression instanceof AExpression || expression instanceof AQLClause) {
+        this._properties["clause"] += expression.val();
+    
+    } else if ( typeof expression == "object" && Object.getPrototypeOf( expression ) === Object.prototype ) {
+        
+        this._properties["clause"] += "\n{\n";
+        var returnStatements = [];
+        for (returnValue in expression) {
+           
+            if (expression[returnValue] instanceof AExpression) { 
+                returnStatements.push('"' + returnValue + '" ' + " : " + expression[returnValue].val());            
+            } else if (typeof expression[returnValue] == "string") {          
+                returnStatements.push('"' + returnValue + '" ' + " : " + expression[returnValue]);   
+            }
+        }
+        this._properties["clause"] += returnStatements.join(",\n");
+        this._properties["clause"] += "\n}";  
+    
+    } else {
+        this._properties["clause"] += new AQLClause().set(expression).val();
+    }
+
+    return this;
+}
+
+
+ReturnClause.prototype = Object.create(AQLClause.prototype);
+ReturnClause.prototype.constructor = ReturnClause;
+
+
+// WhereClause
+//
+// Grammar: 
+// ::= "where" Expression
+// 
+// @param expression [BooleanExpression], pushes this expression onto the stack
+function WhereClause(expression) {
+    AQLClause.call(this);
+    
+    this._properties["stack"] = [];
+
+    if (expression instanceof Array) {
+        this.bind(expression[0]);
+    } else {
+        this.bind(expression);
+    }
+    
+    return this;
+}
+
+
+WhereClause.prototype = Object.create(AQLClause.prototype);
+WhereClause.prototype.constructor = WhereClause;
+
+
+WhereClause.prototype.bind = function(expression) {
+    if (expression instanceof AExpression) {
+        this._properties["stack"].push(expression);
+    }
+    return this;
+};
+
+
+WhereClause.prototype.val = function() {
+    var value = "";  
+    
+    if (this._properties["stack"].length == 0) {
+        return value;
+    }
+
+    var count = this._properties["stack"].length - 1;
+    while (count >= 0) {
+        value += this._properties["stack"][count].val() + " ";
+        count -= 1;
+    }
+    
+    return "where " + value;
+};
+
+
+WhereClause.prototype.and = function() {
+    
+    var parameters = [];
+    if (arguments[0] instanceof Array) {
+        parameters = arguments[0];
+    } else {
+        parameters = arguments;
+    }
+    
+    var andClauses = [];  
+    for (var expression in parameters) {
+        
+        if (parameters[expression] instanceof AExpression) {
+            andClauses.push(parameters[expression].val());
+        }
+    }
+    
+    if (andClauses.length > 0) {
+        this._properties["stack"].push(new AExpression().set(andClauses.join(" and ")));
+    }
+    
+    return this;
+};
+
+
+WhereClause.prototype.or = function() {
+
+    var parameters = [];
+    if (arguments[0] instanceof Array) {
+        parameters = arguments[0];
+    } else {
+        parameters = arguments;
+    }
+
+    var orClauses = [];  
+    for (var expression in parameters) {
+        
+        if (parameters[expression] instanceof AExpression) {
+            orClauses.push(parameters[expression].val());
+        }
+    }
+    
+    if (andClauses.length > 0) {
+        this._properties["stack"].push(new AExpression().set(orClauses.join(" and ")));
+    }
+    
+    return this;
+};
+
+// LimitClause
+// Grammar:
+// LimitClause    ::= "limit" Expression ( "offset" Expression )?
+// 
+// @param   limitExpression [REQUIRED, AQLExpression]
+// @param   offsetExpression [OPTIONAL, AQLExpression]
+function LimitClause(limitExpression, offsetExpression) {
+
+    AQLClause.call(this);
+    
+    var parameters = [];
+    if (arguments[0] instanceof Array) {
+        parameters = arguments[0];
+    } else {
+        parameters = arguments;
+    }
+  
+    // limitExpression required
+    this._properties["clause"] = "limit " + parameters[0].val();
+
+    // Optional: Offset
+    if (parameters.length == 2) {
+        this._properties["clause"] += " offset " + parameters[1].val();
+    }
+
+    return this;
+}
+
+LimitClause.prototype = Object.create(AQLClause.prototype);
+LimitClause.prototype.constructor = LimitClause;
+
+
+// OrderbyClause
+//
+// Grammar:
+// OrderbyClause  ::= "order" "by" Expression ( ( "asc" ) | ( "desc" ) )? ( "," Expression ( ( "asc" ) | ( "desc" ) )? )*
+//
+// @params AQLExpressions and asc/desc strings, in any quantity. At least one required. 
+function OrderbyClause() {
+    
+    AQLClause.call(this);
+
+    // At least one argument expression is required, and first should be expression
+    if (arguments.length == 0) {
+        this._properties["clause"] = null;
+        return this;    
+    }
+    
+    var parameters = [];
+    if (arguments[0] instanceof Array) {
+        parameters = arguments[0];
+    } else {
+        parameters = arguments;
+    }
+
+    var expc = 0;
+    var expressions = [];    
+
+    while (expc < parameters.length) {
+      
+        var expression = "";
+
+        if (parameters[expc] instanceof AExpression) {
+            expression += parameters[expc].val();
+        }
+
+        var next = expc + 1;
+        if (next < parameters.length && (parameters[next] == "asc" || parameters[next] == "desc")) {
+            expc++;
+            expression += " " + parameters[expc];
+        }
+        
+        expressions.push(expression);
+      
+        expc++;
+    }
+
+    this._properties["clause"] = "order by " + expressions.join(", ");
+    return this;
+}
+
+OrderbyClause.prototype = Object.create(AQLClause.prototype);
+OrderbyClause.prototype.constructor = OrderbyClause;
+
+
+// GroupClause
+//
+// Grammar:
+// GroupClause    ::= "group" "by" ( Variable ":=" )? Expression ( "," ( Variable ":=" )? Expression )* ( "decor" Variable ":=" Expression ( "," "decor" Variable ":=" Expression )* )? "with" VariableRef ( "," VariableRef )*
+function GroupClause() {
+    AQLClause.call(this);
+
+    if (arguments.length == 0) {
+        this._properties["clause"] = null;
+        return this;    
+    } 
+    
+    var parameters = [];
+    if (arguments[0] instanceof Array) {
+        parameters = arguments[0];
+    } else {
+        parameters = arguments;
+    }
+
+    var expc = 0;
+    var expressions = [];
+    var variableRefs = [];
+    var isDecor = false;
+    
+    while (expc < parameters.length) {
+
+        if (parameters[expc] instanceof AExpression) {
+
+            isDecor = false;
+            expressions.push(parameters[expc].val());
+
+        } else if (typeof parameters[expc] == "string") {       
+            
+            // Special keywords, decor & with
+            if (parameters[expc] == "decor") {
+                isDecor = true;
+            } else if (parameters[expc] == "with") {
+                isDecor = false;
+                expc++;
+                while (expc < parameters.length) {
+                    variableRefs.push(parameters[expc]);
+                    expc++;
+                }
+            
+            // Variables and variable refs
+            } else {
+                
+                var nextc = expc + 1;
+                var expression = "";
+            
+                if (isDecor) {
+                    expression += "decor "; 
+                    isDecor = false;
+                }
+
+                expression += parameters[expc] + " := " + parameters[nextc].val();
+                expressions.push(expression);
+                expc++;
+            }
+        }
+
+        expc++;
+    }
+
+    this._properties["clause"] = "group by " + expressions.join(", ") + " with " + variableRefs.join(", ");
+    return this;
+}
+
+GroupClause.prototype = Object.create(AQLClause.prototype);
+GroupClause.prototype.constructor = GroupClause;
+
+
+// Quantified Expression
+// 
+// Grammar
+// QuantifiedExpression ::= ( ( "some" ) | ( "every" ) ) Variable "in" Expression ( "," Variable "in" Expression )* "satisfies" Expression
+// 
+// @param String some/every
+// @param [AExpression]
+// @param [Aexpression] satisfiesExpression
+function QuantifiedExpression (keyword, expressions, satisfiesExpression) {
+    AExpression.call(this);
+
+    var expression = keyword + " ";
+    var varsInExpressions = [];
+
+    for (var varInExpression in expressions) {
+        varsInExpressions.push(varInExpression + " in " + expressions[varInExpression].val()); 
+    } 
+    expression += varsInExpressions.join(", ") + " satisfies " + satisfiesExpression.val();
+    
+    AExpression.prototype.set.call(this, expression);
+
+    return this;
+}
+
+QuantifiedExpression.prototype = Object.create(AExpression.prototype);
+QuantifiedExpression.prototype.constructor = QuantifiedExpression;
+
+QuantifiedExpression.prototype.val = function() {
+    var value = AExpression.prototype.val.call(this);
+    return "(" + value + ")";    
+};
diff --git a/pom.xml b/pom.xml
index 1585923..e966057 100644
--- a/pom.xml
+++ b/pom.xml
@@ -157,15 +157,16 @@
 		<module>asterix-runtime</module>
 		<module>asterix-om</module>
 		<module>asterix-aql</module>
-                <module>asterix-external-data</module>
-                <module>asterix-metadata</module>
-                <module>asterix-test-framework</module>
-                <module>asterix-maven-plugins</module>
-                <module>asterix-server</module>
-                <module>asterix-installer</module>
-                <module>asterix-events</module>
-                <module>asterix-doc</module>
-                <module>asterix-fuzzyjoin</module>
+        <module>asterix-external-data</module>
+        <module>asterix-examples</module>
+        <module>asterix-metadata</module>
+        <module>asterix-test-framework</module>
+        <module>asterix-maven-plugins</module>
+        <module>asterix-server</module>
+        <module>asterix-installer</module>
+        <module>asterix-events</module>
+        <module>asterix-doc</module>
+        <module>asterix-fuzzyjoin</module>
         </modules>
 
 	<repositories>