/**
  NextDB.net JavaScript API
  build: 4/1/2011
  docs: http://nextdb.net/docs/  
  contact: info@nextdb.net
  � 2009-2011 NextDB LLC All rights reserved.
  US and international patents pending.
*/
(function(){if((window.net&&window.net.nextdb)||window.nextdb){return }if(!window.net){window.net={}}if(!window.nextdb){window.nextdb={}}if(!window.nextdb.admin){window.nextdb.admin={}}if(!window.nextdb.html){window.nextdb.html={}}if(!window.net.nextdb){window.net.nextdb=window.nextdb}var A=window.nextdb;A.html.Calendar=function(g,c){var a=a;var E=g||new Date();var c=c||{border:"rgb(200, 200, 200)",font:"rgb(8, 8, 8)",background:"rgb(255, 255, 255)",selectedBackground:"rgb(0, 88, 0)",selectedFont:"rgb(255, 255, 255)",mouseoverBackground:"rgb(200, 200, 200)",mouseoverFont:"rgb(0, 0, 0)"};var k=["January","February","March","April","May","June","July","August","September","October","November","December"];var V=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var G=[31,28,31,30,31,30,31,31,30,31,30,31];if(D()){G[1]=29}this.date=function(){return E};var F=new RegExp(/\s/g);this.input=S("input");if(g){this.input.value=A.Util.convertToServerDateFormat(g)}this.selectType="BUTTON";this.body=S("div");var P=this.body;var B=this.input;P.style.backgroundColor=c.background;P.style.color=c.font;P.style.position="absolute";P.style.zIndex="100000";P.style.display="none";P.style.width="150px";P.style.border="3px solid "+c.border;P.style.textAlign="center";P.style.padding="4px";P.style.fontFamily="arial";P.style.fontSize="8pt";var I=S("div");I.style.position="relative";I.style.height="24px";var T=S("span");T.style.position="absolute";T.style.left="6px";T.style.color=c.font;T.style.fontFamily="verdana";T.style.fontSize="8pt";T.style.fontWeight="bold";T.style.textAlign="center";T.innerHTML="&lt;&lt;";T.onclick=e;T.id="nextdb:cal-back-arrow";var Y=S("span");Y.innerHTML="&gt;&gt;";Y.style.position="absolute";Y.style.fontFamily="verdana";Y.style.color=c.font;Y.style.fontSize="8pt";Y.style.fontWeight="bold";Y.style.left="120px";Y.style.textAlign="center";Y.onclick=O;Y.id="nextdb:cal-forward-arrow";var b=S("span");b.style.position="absolute";b.style.left="30px";b.style.minWidth="80px";b.style.fontFamily="arial";b.style.fontWeight="bold";b.style.fontSize="8pt";b.style.color=c.font;b.style.backgroundColor=c.background;b.style.textAlign="center";b.innerHTML=k[E.getMonth()]+" "+E.getFullYear();b.id="nextdb:cal-month-view";I.appendChild(T);I.appendChild(b);I.appendChild(Y);P.appendChild(I);var m=S("td");m.style.width="10px";m.style.height="8px";m.style.padding="3px";m.style.fontSize="7pt";m.style.border="1px solid "+c.border;m.style.textAlign="center";m.style.cursor="hand";var n=S("table");var X=S("tBody");var R=S("tr");for(f=0;f<7;f++){var Q=m.cloneNode(false);Q.innerHTML=V[f].substr(0,1);R.appendChild(Q)}X.appendChild(R);P.style.align="center";n.appendChild(X);P.appendChild(n);var l=S("table");M();P.appendChild(l);var W=S("select");W.onchange=C;W.style.color=c.font;W.style.width="40px";W.style.backgroundColor=c.background;W.style.fontSize="8pt";for(var f=0;f<24;f++){var Z=S("option");Z.style.backgroundColor=c.background;if((f==E.getHours())){Z.selected="true"}Z.value=f;if(f==0){Z.text="12 AM"}else{if(f<12){Z.text=f+" AM"}else{if(f==12){Z.text="12 PM"}else{Z.text=Math.abs(12-f)+" PM"}}}if(document.all){W.add(Z,f)}else{W.appendChild(Z)}}P.appendChild(W);var h=S("select");h.onchange=H;h.style.color=c.font;h.style.width="40px";h.style.backgroundColor=c.background;h.style.fontFamily="arial";h.style.fontSize="8pt";for(var f=0;f<60;f++){var Z=S("option");if((f==E.getMinutes())){Z.selected="true"}Z.value=f<10?"0"+f:f;Z.text=Z.value;Z.style.backgroundColor=c.background;if(document.all){h.add(Z,f)}else{h.appendChild(Z)}}P.appendChild(h);var K=S("input");K.type="button";K.onclick=N;K.value="set";K.style.fontFamily="arial";K.style.fontSize="8pt";P.appendChild(K);function M(){if(U("nextdb:cal-table")){l.removeChild(U("nextdb:cal-table"))}var w=S("tBody");w.id="nextdb:cal-table";var u=S("tr");w.appendChild(u);var r=new Date(E.getFullYear(),E.getMonth());r.setDate(1);var p=r.getDay();var o=1;for(var s=0;s<7;s++){var v=m.cloneNode(false);if(s<p){v.innerHTML="&nbsp;"}else{if(E.getDate()==o){v.innerHTML=o;v.style.backgroundColor=c.selectedBackground;v.style.color=c.selectedFont}else{v.innerHTML=o}v.onmouseover=d;v.onmouseout=J;v.onclick=j;o++}u.appendChild(v)}var u=S("tr");w.appendChild(u);var q=0;var t=G[E.getMonth()]-o;for(var s=0;s<=t;s++){var v=m.cloneNode(false);if(E.getDate()==o){v.innerHTML=o;v.style.backgroundColor=c.selectedBackground;v.style.color=c.selectedFont}else{v.innerHTML=o}v.onmouseover=d;v.onmouseout=J;v.onclick=j;u.appendChild(v);o++;q++;if(q==7){q=0;u=S("tr");w.appendChild(u)}}l.appendChild(w)}function d(i){if(document.all){var o=window.event.srcElement}else{var o=i.target}if(o.style.backgroundColor.replace(F,"")!=c.selectedBackground.replace(F,"")){o.style.backgroundColor=c.mouseoverBackground;o.style.color=c.mouseoverFont}}function J(i){if(document.all){var o=window.event.srcElement}else{var o=i.target}if(o.style.backgroundColor.replace(F,"")!=c.selectedBackground.replace(F,"")){o.style.backgroundColor=c.background;o.style.color=c.font}}function j(q){if(document.all){var r=window.event.srcElement}else{var r=q.target}var p=U("nextdb:cal-table").getElementsByTagName("td");for(var o=0;o<p.length;o++){p[o].style.backgroundColor=c.background;p[o].style.color=c.font}E.setDate(r.innerHTML);N();r.style.backgroundColor=c.selectedBackground;r.style.color=c.selectedFont}function L(){E.setYear(yearSelect[yearSelect.selectedIndex].value);if(D()){G[1]=29}M()}function e(){E.setMonth(E.getMonth()-1);M();U("nextdb:cal-month-view").innerHTML=k[E.getMonth()]+" "+E.getFullYear()}function O(){E.setMonth(E.getMonth()+1);M();U("nextdb:cal-month-view").innerHTML=k[E.getMonth()]+" "+E.getFullYear()}function C(){E.setHours(W[W.selectedIndex].value)}function H(){E.setMinutes(h[h.selectedIndex].value)}function N(){P.style.display="none";var i=A.Util.convertToServerDateFormat(E);B.value=i;if(B.callback){B.callback(i)}}function D(){if((E.getFullYear()%4)==0){if((E.getFullYear()%100==0)&&(E.getFullYear()%400)!=0){return false}else{return true}}else{return false}}function U(i){return document.getElementById(i)}function S(i){if(document.all){var o=document.createElement("<"+i+">")}else{var o=document.createElement(i)}return o}};A.html.Calendar.prototype.getElement=function(){this.input.type="text";var B=this;this.input.onfocus=function(){B.input.parentNode.appendChild(B.body);B.body.style.display="block"};return this.input};A.html.Calendar.prototype.setCallback=function(B){this.input.callback=B};A.html.Calendar.prototype.setSelectType=function(B){if(!B||B!="BUTTON"||B!="DAYCLICK"){alert("invalid value in setting Calendar.setSelectType() \n\n entered : "+B);return }this.selectType=B};A.Column=function(D,E,F,C,G,B){if(E!="TEXT"&&E!="LONGTEXT"&&E!="DATE"&&E!="INTEGER"&&E!="LONGINTEGER"&&E!="PASSWORD"&&E!="DECIMAL"&&E!="BINARY"&&E!="LONGBINARY"){alert("invalid xdb.Column typeuse TEXT, LONGTEXT, INTEGER, LONGINTEGER, DECIMAL, BINARY, LONGBINARY");return }this.name=D;this.type=E;this.unique=F;this.defaultValue=C;this.nullable=G;this.owner=B};A.Column.prototype.toString=function(){return this.name};A.Connection=function(B,D){if(arguments.length>=2){this.companyName=B;this.schema=D}else{if(arguments.length==1){try{this.companyName=B.companyName;this.schema=B.databaseName}catch(C){alert("bad connection parameters")}}}};A.Connection.prototype.setURL=function(B){A.CONSTANTS.url=B};A.Connection.prototype.setTimeout=function(B){A.CONSTANTS.requestTimeout=B};A.Connection.prototype.getURL=function(B,D){var C=A.CONSTANTS.url+"/"+this.companyName+"/"+this.schema+"/"+B+"?"+D;return C};A.Connection.prototype.createRelationship=function(D,B,F,E){var C=this.getURL("RELATE_ROWS",A.CONSTANTS.generalCallback);C+="&relationshipName="+D;C+="&pk1="+A.Util.escape(B);C+="&pk2="+A.Util.escape(F);A.Request.send(C,E,true)};A.Connection.prototype.removeRelationship=function(D,B,F,E){var C=this.getURL("REMOVE_RELATIONSHIP",A.CONSTANTS.generalCallback);C+="&relationshipName="+D;C+="&pk1="+A.Util.escape(B);C+="&pk2="+A.Util.escape(F);A.Request.send(C,E,true)};A.Connection.prototype.getUploadURL=function(D,B){var C=A.CONSTANTS.uploadUrl+"/"+this.companyName+"/"+this.schema+"/post?table="+B+"&uploadID="+D;return C};A.Connection.prototype.describeTable=function(B,D){var C=this.getURL("DESCRIBE_TABLE",A.CONSTANTS.describeTablesCallback);if(!B){alert("nextdb.Connection.prototype.describeTable\n\nplease supply table name")}C+="&name="+B;A.Request.send(C,D)};A.Connection.prototype.describeQuery=function(C,D){if(!C){alert("nextdb.Connection.prototype.describeQueries\n\nplease supply query name");return }var B=this.getURL("DESCRIBE_QUERY",A.CONSTANTS.describeQueryCallback);B+="&name="+C;A.Request.send(B,D)};A.Connection.prototype.uploadProgress=function(C,D){var B=this.getURL("PROGRESS",A.CONSTANTS.uploadProgressCallback);B+="&uploadID="+C;A.Request.send(B,D)};A.Connection.prototype.executeQuery=function(D,F){var B="EXECUTE_QUERY";if(D.admin){B="ADMIN_QUERY"}var C=this.getURL(B,A.CONSTANTS.queryCallback);if(D.admin){C+="&table="+D.name}else{C+="&name="+D.name}if(D.pageSize!=null){C+="&pageSize="+D.pageSize}if(D.startAfter!=null){C+="&startAfterPK="+A.Util.escape(D.startAfter)}if(D.startAfterValue!=null){C+="&startAfterValue="+A.Util.escape((D.startAfterValue))}if(D.orderBy!=null){C+="&orderBy="+D.orderBy}if(D.map){for(var E in D.map){if(D.map.hasOwnProperty(E)){C+=("&"+A.Util.escape("${"+E+"}")+"="+A.Util.escape(D.map[E])+"")}}}A.Request.send(C,F)};A.Connection.prototype.executeInsert=function(C,E){var B=this.getURL("INSERT",A.CONSTANTS.insertCallback);B+="&_table="+C.table;for(var D in C.map){if(C.map.hasOwnProperty(D)){B+=("&"+D+"="+A.Util.escape((C.map[D])))}}if(C.relationshipName&&C.rowId){B+="&_relationshipName="+C.relationshipName;B+="&_FK="+A.Util.escape(C.rowId)}if(C.permalinkHandler){A.Request.send(B,E,true,C.permalinkHandler)}else{A.Request.send(B,E,true)}};A.Connection.prototype.executeUpdate=function(E,D){var B=this.getURL("UPDATE",A.CONSTANTS.updateCallback);B+="&_table="+E.table;B+="&_PK="+A.Util.escape(E.rowId);if(E.map){for(var C in E.map){if(E.map.hasOwnProperty(C)){B+=("&"+C+"="+A.Util.escape(E.map[C]))}}}A.Request.send(B,D,true)};A.Connection.prototype.describeQueries=function(C){var B=this.getURL("DESCRIBE_QUERY",A.CONSTANTS.describeQueriesCallback);A.Request.send(B,C)};A.Connection.prototype.executeDelete=function(B,D){var C=this.getURL("DELETE",A.CONSTANTS.generalCallback);C+="&table="+B.tableName;C+="&PK="+A.Util.escape(B.rowId);A.Request.send(C,D)};A.Connection.prototype.executeGenericRequest=function(B,D,F){var C=this.getURL(B,A.CONSTANTS.generalDataCallback);if(D){for(var E in D){if(D.hasOwnProperty(E)){C+=("&"+E+"="+A.Util.escape(D[E]))}}}A.Request.send(C,F)};A.CONSTANTS={};A.CONSTANTS.logging=1;A.CONSTANTS.requestTimeout=90;A.CONSTANTS.url="http://www.nextdb.net/nextdb/service";A.CONSTANTS.uploadUrl="http://www.nextdb.net/nextdb/upload";A.CONSTANTS.captchaUrl="http://www.nextdb.net/nextdb/captcha";A.CONSTANTS.generalCallback="callback=nextdb.Request.generalCallback";A.CONSTANTS.generalDataCallback="callback=nextdb.Request.generalDataCallback";A.CONSTANTS.queryCallback="callback=nextdb.Request.queryCallback";A.CONSTANTS.insertCallback="_callback=nextdb.Request.insertCallback";A.CONSTANTS.updateCallback="_callback=nextdb.Request.updateCallback";A.CONSTANTS.describeTablesCallback="callback=nextdb.Request.describeTablesCallback";A.CONSTANTS.pingCallback="callback=nextdb.Request.pingCallback";A.CONSTANTS.uploadProgressCallback="callback=nextdb.Request.uploadProgressCallback";A.CONSTANTS.describeQueryCallback="callback=nextdb.Request.describeQueryCallback";A.Delete=function(B,C){this.tableName=B;this.rowId=C};A.Delete.prototype.setTableName=function(B){this.tableName=B};A.Delete.prototype.setRowId=function(B){this.rowId=B};A.Error=function(){this.code=0;this.message="";this.causedBy="";var B=this;this.exceptionClass="";this.toString=function(){return B.code+" : "+B.message+" : "+B.causedBy};var B=this;this.getMessage=function(){if(B.code==120&&B.causedBy){return"The column "+B.causedBy+" is unique and the value you entered is already taken.  Please try again."}else{return B.message}}};A.html.FileUpload=function(H,P,D,B,E){this.table=P;this.div=document.createElement("div");this.rowSet;this.conn=H;this.callbackStart=D;this.callbackFinish=B;this.formId="XDBForm"+Math.round(Math.random()*100000000000);this.progress=E;this.uploadID;this.formFieldId="XDBFormField"+Math.round(Math.random()*100000000000);var L=this;var C=document.createElement("form");this.form=C;C.action="";C.method="post";C.id=this.formId;C.name="upLoadForm";C.onsubmit=O;C.enctype="multipart/form-data";C.encoding="multipart/form-data";var I=document.createElement("input");I.type="file";I.name="form[file]";I.id=L.formFieldId;I.onchange=function(){N.click()};C.appendChild(I);this.addClassName=function(Q){I.className=Q;C.className=Q};var N=document.createElement("input");N.type="submit";N.style.display="none";C.appendChild(N);var G;function O(){M();L.callbackStart();return A.html.AIM.submit(C,{onStart:F,onComplete:J},L.div)}function M(){var Q=Math.round(Math.random()*100000000000);L.uploadID=Q;G=L.conn.getUploadURL(Q,L.table);document.getElementById(L.formId).action=G}function F(){K();return true}function K(){if(!L.progress){return }L.conn.uploadProgress(L.uploadID,function(R,Q){if(Q){return Q}else{if(!R.rx){setTimeout(K,100);return }if(R.rx<R.totalRX){L.progress(R);setTimeout(K,100)}else{L.progress(R);return }}})}function J(Q){var R=(G.replace(/post/,"view"));L.callbackFinish(R);return }};A.html.FileUpload.prototype.getElement=function(){return this.form};A.html.AIM={frame:function(E){var D="f"+Math.floor(Math.random()*99999);var C=document.createElement("div");C.innerHTML=C.innerHTML+'<iframe style="display:none;" id="'+D+'" name="'+D+'" onload="nextdb.html.AIM.loaded(\''+D+"');\"></iframe>";C.id="div_"+D;document.body.appendChild(C);var B=document.getElementById(D);self.frames[D].name=D;if(E&&typeof (E.onComplete)=="function"){B.onComplete=E.onComplete}return D},form:function(C,B){C.setAttribute("target",B)},submit:function(B,C){A.html.AIM.form(B,A.html.AIM.frame(C));if(C&&typeof (C.onStart)=="function"){return C.onStart()}else{return true}},loaded:function(D){try{var B=document.getElementById(D);if(typeof (B.onComplete)=="function"){B.onComplete(D)}}catch(C){alert(C)}}};A.html.Form=function(){this.form;this.columns;this._interceptor;this._columnAliases;this._hiddenColumns=[];this._omitFields=[];this._orderFields=[];this._defaultValues={};this._options={};this._expandable=[];this._confirmFields=[];this._obscureFields=[];this._cancelCallback=null;this._afterRenderCallback=null;this._validation={};this._layout=1;this._whileLoading=null;this._timeoutMessage=null;this._timeoutDuration=null;this._fail=false};A.html.Form.BOX_LAYOUT=1;A.html.Form.HORIZONTAL_LAYOUT=2;A.html.Form.VERTICAL_LAYOUT=3;A.html.Form.prototype.interceptor=function(B){this._interceptor=B;return this};A.html.Form.prototype.fail=function(){this._fail=true;return this};A.html.Form.prototype.columnAliases=function(B){this._columnAliases=B;return this};A.html.Form.prototype.cancelCallback=function(B){this._cancelCallback=B;return this};A.html.Form.prototype.afterRenderCallback=function(B){this._afterRenderCallback=B;return this};A.html.Form.prototype.layout=function(B){this._layout=B;return this};A.html.Form.prototype.whileLoading=function(B){this._whileLoading=B;return this};A.html.Form.prototype.timeoutMessage=function(B){this._timeoutMessage=B;return this};A.html.Form.prototype.expandFields=function(B){this._expandable=B;return this};A.html.Form.prototype.omitFields=function(B){this._omitFields=B;return this};A.html.Form.prototype.orderFields=function(B){this._orderFields=B;return this};A.html.Form.prototype.confirmFields=function(B){this._confirmFields=B;return this};A.html.Form.prototype.setMessageId=function(B){this.errorId=B;return this};A.html.Form.prototype.message=function(D,B){var C=document.getElementById(this.errorId);if(B){C.style.color=B}else{C.style.color="#cc0000"}C.innerHTML=D;return this};A.html.Form.prototype.obscureFields=function(B){this._obscureFields=B;return this};A.html.Form.prototype.options=function(B){this._options=B;return this};A.html.Form.prototype.defaultValues=function(B){this._defaultValues=B;return this};A.html.Form.prototype.validation=function(B){this._validation=B;return this};A.html.Form.prototype.destroy=function(){if(document.getElementById(this.objectId)){A.Util.purge(document.getElementById(this.objectId));document.getElementById(this.objectId).parentNode.removeChild(document.getElementById(this.objectId))}return this};A.html.Form.prototype.render=function(B){};A.html.Form.prototype.doAction=function(){};A.html.Form.prototype.build=function(){for(var n=0;n<this._expandable.length;n++){if(this.columns[this._expandable[n].toString()]){this.columns[this._expandable[n].toString()].expandable=true}}for(var n=0;n<this._obscureFields.length;n++){if(this.columns[this._obscureFields[n].toString()]){this.columns[this._obscureFields[n].toString()].dataType="PASSWORD"}}for(var n=0;n<this._omitFields.length;n++){if(this.columns[this._omitFields[n].toString()]){delete this.columns[this._omitFields[n].toString()]}}for(var L in this._defaultValues){if(this.columns[L]){this.columns[L].defaultValue=this._defaultValues[L]}}for(var K in this._options){if(this.columns[K]){this.columns[K].options=this._options[K]}}for(var W in this._validation){if(this.columns[W]){this.columns[W].validate=this._validation[W]}}if(this._orderFields.length>0){var f={};for(var n=0;n<this._orderFields.length;n++){var s=this._orderFields[n];for(var W in this.columns){if(W==s){f[W]=this.columns[W];break}}}this.columns=f}var e=this;function o(){var i="";for(var c in e.columns){if(e.columns[c].validate&&e.columns[c].node){var t=e.columns[c].validate.regex.test(e.columns[c].node.value);if(e.columns[c].node2){if(e.columns[c].node2.value!=e.columns[c].node.value){i+=" "+(e.columns[c].node.name).replace(/_/g," ")+" fields must match, ";e.columns[c].node.style.border=h;e.columns[c].node2.style.border=h;continue}else{if(!t){e.columns[c].node2.style.border=h}else{e.columns[c].node2.style.border=""}}}if(!t){var b=(e.columns[c].node.name).replace(/_/g," ");var u=e.columns[c].validate.message.replace("?",b);i+=u+", ";e.columns[c].node.style.border=h}else{e.columns[c].node.style.border=""}}}if(i!=""){i=i.substring(0,i.length-2);e.message(i)}else{e.message("");e.doAction()}}function D(t,b){var c;var i=new A.html.FileUpload(e.conn,e.table,function(){c=d.value;d.value="loading...";t.firstChild.style.display="none";t.appendChild(X("div"));d.disabled=true},function(u){d.value=c;d.disabled=false;t.innerHTML="<input type='hidden' name='"+b+"' value='"+u+"'><img src='http://www.nextdb.net/img/file.png'> File loaded and ready for "+e.type},function(u){var w=u.rx;var x=u.totalRX;var v=(Math.round((w/x)*100))+"%";t.lastChild.innerHTML=v;if(v=="100%"){d.value=c}});return i}var X=A.Util.createElement;var V="&nbsp;";var h="1px solid #CC0000";var a=X("form");var J=X("table");J.className="form";a.appendChild(J);a.id=this.objectId;var O=X("tBody");J.appendChild(O);var P=X("tr");var F=X("td");if(this._layout==A.html.Form.BOX_LAYOUT){F.colSpan="2"}else{if(this._layout==A.html.Form.HORIZONTAL_LAYOUT){F.colSpan="5"}}if(this.errorId){F.id=this.errorId}F.innerHTML="&nbsp;";F.style.margin="4px";F.style.padding="4px";P.appendChild(F);O.appendChild(P);var R=true;var H;function Z(i,c){if(e._layout==A.html.Form.BOX_LAYOUT){var b=X("tr");b.appendChild(i);b.appendChild(c);O.appendChild(b)}else{if(e._layout==A.html.Form.HORIZONTAL_LAYOUT){if(R){H=X("tr");H.appendChild(i);H.appendChild(c);O.appendChild(H);R=false}else{H.appendChild(i);H.appendChild(c)}}else{if(e._layout==A.html.Form.VERTICAL_LAYOUT){var u=X("tr");var t=X("tr");u.appendChild(i);t.appendChild(c);O.appendChild(u);O.appendChild(t)}}}}for(var E in this.columns){var Q=X("td");var N=X("td");if(this._columnAliases){Q.innerHTML=this._columnAliases[E.toString()]?this._columnAliases[E.toString()]:E.replace(/_/g," ")}else{Q.innerHTML=E.replace(/_/g," ")}if(this.columns[E].dataType=="LONGBINARY"){var M=document.createElement("div");M.name=E;N.appendChild(M);var q=D(N,E);M.appendChild(q.form);Z(Q,N);this.columns[E].node=M}else{if(this.columns[E].dataType=="DATE"){var p=new A.html.Calendar();var C=p.getElement();C.type="text";C.name=E;Q.innerHTML+="<br>[click to open]";C.value=this.columns[E].defaultValue||"";N.appendChild(C);Z(Q,N);this.columns[E].node=C}else{if(this.columns[E].dataType=="TEXT"||this.columns[E].dataType=="HIDDEN"||this.columns[E].dataType=="PASSWORD"||this.columns[E].dataType=="LONGINTEGER"||this.columns[E].dataType=="DECIMAL"){if(this.columns[E].options){var j=X("select");j.name=E;for(var K in this.columns[E].options){var g=X("option");g.value=this.columns[E].options[K];g.text=this.columns[E].options[K];if(document.all){j.add(g)}else{j.appendChild(g)}}N.appendChild(j);Z(Q,N);this.columns[E].node=j}else{if(this.columns[E].expandable){var C=X("textarea");C.value=this.columns[E].defaultValue||"";C.name=E;N.appendChild(C);Z(Q,N);this.columns[E].node=C}else{var C=X("input");if(this.columns[E].password||this.columns[E].dataType=="PASSWORD"){C.type="password"}else{C.type="text"}C.name=E;C.value=this.columns[E].defaultValue||"";N.appendChild(C);Z(Q,N);this.columns[E].node=C;for(var n=0;n<this._confirmFields.length;n++){if(this._confirmFields[n]==E){var U=C.cloneNode(true);U.name="_"+U.name;U.value="";var m=X("td");var l=X("td");m.innerHTML="confirm "+E.replace(/_/g," ");l.appendChild(U);Z(m,l);this.columns[E].node2=U}}}}}}}}if(this.captcha){var I=X("td");var G=X("td");var B=X("td");var k=X("td");G.innerHTML="<img onclick='nextdb.Util.sourceCaptchaImg(this,\""+this.captchaStyle.fg+'","'+this.captchaStyle.bg+"\")' id='nextdb-captcha' src='"+A.CONSTANTS.captchaUrl+"?fg="+(this.captchaStyle.fg.replace("#",""))+"&bg="+(this.captchaStyle.bg.replace("#",""))+"&width=175&height=80&cruft="+Math.random()+"'><br/>";I.innerHTML="word verification:<br>[click image to reload]";var C=X("input");this.columns.captcha={};this.columns.captcha.node=C;this.columns.captcha.validate=A.validate.REQUIRED;C.type="text";C.name="captcha";k.appendChild(C);B.innerHTML="type the characters <br>you see in the picture";Z(I,G);Z(B,k)}var T=X("td");var S=X("td");var d=X("input");this.inputButtonSubmit=d;var r=X("input");var Y=X("input");d.type="button";r.type="button";Y.type="reset";d.value="submit";if(this._cancelCallback!=null&&(typeof this._cancelCallback=="function")){A.Util.addEvent(r,"click",this._cancelCallback)}r.value="cancel";Y.value="reset";S.appendChild(d);S.appendChild(Y);S.appendChild(r);Z(T,S);A.Util.addEvent(d,"click",o);return a};A.html.InsertForm=function(C,B){this.objectId=Math.round(Math.abs(Math.random()*10000000));this.errorId="nextdb-form-msg-"+this.objectId;this.type="INSERT";this.conn=C;this.tableName=B;this.linkId;this.callback;this.captchaStyle={bg:"#FFFFFF",fg:"#333333"};return this};A.html.InsertForm.prototype=new A.html.Form;A.html.InsertForm.prototype.insertAndLink=function(C,B){this.relationshipName=B;this.linkId=C;return this};A.html.InsertForm.prototype.setRelationship=function(B){if(B.type=="Relationship"){this.linkId=B.rowId;this.relationshipName=B.relationshipName}else{if(arguments.length==2){this.linkId=arguments[0];this.relationshipName=arguments[1]}else{alert("development time bug:\n\n invalid params to insert.setRelationship()")}}return this};A.html.InsertForm.prototype.insertCallback=function(B){this.callback=B;return this};A.html.InsertForm.prototype.captchaColors=function(B){if(!B.fg||!B.bg){alert('invalid call to captchaColors\n\n please use this object literal format: {bg:"#FFFFFF",fg:"#333333"}');return }this.captchaStyle=B;return this};A.html.InsertForm.prototype.describeTable=function(){var B=this;this.conn.describeTable(this.tableName,function(F,D){if(D){if(B._timeoutMessage){B.div.innerHTML=B._timeoutMessage;return }else{alert(D);return }}else{B.columns={};var G=F[0];for(var E=0;E<G.columns.length;E++){if(G.columns[E].owner==null){var C=G.columns[E].type=="INTEGER"?A.validate.NUMERIC:A.validate.REQUIRED;B.columns[G.columns[E].name]={dataType:G.columns[E].type,validate:C}}}if(G.captcha=="true"){B.captcha=true}}B.div.innerHTML="";B.div.appendChild(B.build());if(B._afterRenderCallback){B._afterRenderCallback()}})};A.html.InsertForm.prototype.doAction=function(){var D=this;var C=D.inputButtonSubmit.value;D.inputButtonSubmit.value="sending...";D.inputButtonSubmit.disabled=true;var B=new A.Insert(this.tableName);var E=A.Util.parseForm(document.getElementById(this.objectId));if(this.relationshipName&&this.linkId){B.setRelationship(this.linkId,this.relationshipName)}if(this._interceptor){this._interceptor(E,B)}B.setParameters(E);if(D._fail){D.inputButtonSubmit.value=C;D.inputButtonSubmit.disabled=false;D._fail=false;return false}if((typeof this.callback=="function")){this.conn.executeInsert(B,function(F,G){D.inputButtonSubmit.value="submit";D.inputButtonSubmit.disabled=false;D.callback(F,G)})}else{this.conn.executeInsert(B,function(G,F){D.inputButtonSubmit.value="submit";D.inputButtonSubmit.disabled=false;if(F){var H;if(F.code==120){H="field "+F.causedBy+" must be unique, the value you entered is already taken"}else{if(F.code==130){H="field "+F.causedBy+" threw a data format exception, please check data format"}else{if(F.code==110){H="incorrect security CAPTCHA word";D.columns.captcha.node.style.border="1px solid #cc0000"}else{H=F.message}}}D.message("insert failed. "+H,"red")}else{D.message("insert succeeded","green");if(document.getElementById("nextdb-captcha"+D.objectId)){A.Util.sourceCaptchaImg(document.getElementById("nextdb-captcha"+D.objectId))}}})}};A.html.InsertForm.prototype.render=function(B){this.div=B;B.innerHTML=this._whileLoading!=null?this._whileLoading:"";this.describeTable()};A.html.UpdateForm=function(C,B){this.objectId=Math.round(Math.abs(Math.random()*10000000));this.errorId="nextdb-form-msg-"+this.objectId;this.type="UPDATE";this.conn=C;this.callback;this.tableName=B;return this};A.html.UpdateForm.prototype=new A.html.Form;A.html.UpdateForm.prototype.setRowId=function(B){this.rowId=B;return this};A.html.UpdateForm.prototype.updateCallback=function(B){this.callback=B;return this};A.html.UpdateForm.prototype.describeTable=function(){var B=this;this.conn.describeTable(this.tableName,function(F,D){if(D){if(B._timeoutMessage){B.div.innerHTML=B._timeoutMessage;return }else{alert(D);return }}else{B.columns={};var G=F[0];for(var E=0;E<G.columns.length;E++){if(G.columns[E].owner==null){var C=G.columns[E].type=="INTEGER"?A.validate.NUMERIC:A.validate.REQUIRED;B.columns[G.columns[E].name]={dataType:G.columns[E].type,validate:C}}}B.div.appendChild(B.build());if(B._afterRenderCallback){B._afterRenderCallback()}}})};A.html.UpdateForm.prototype.doAction=function(B){if(!this.rowId){alert("you must pass in a valid updatePK to the UpdateForm in order to identify the row you wish to update.");return }var D=this;D.inputButtonSubmit.value="sending...";D.inputButtonSubmit.disabled=true;var C=new A.Update(this.tableName);C.setRowId(this.rowId);var E=A.Util.parseForm(document.getElementById(this.objectId));if(this.interceptor){this.interceptor(E,C)}C.setParameters(E);if((typeof this.callback=="function")){this.conn.executeUpdate(C,function(F,G){D.inputButtonSubmit.value="submit";D.inputButtonSubmit.disabled=false;D.callback(F,G)})}else{this.conn.executeUpdate(C,function(F){D.inputButtonSubmit.value="submit";D.inputButtonSubmit.disabled=false;if(F){var G;if(F.code==120){G="field "+F.causedBy+" must be unique, the value you entered is already taken"}else{if(F.code==130){G="field "+F.causedBy+" threw a data format exception, please check data format"}else{G=F.message}}error="update failed. "+G;D.message(error,"red")}else{D.message("update succeeded","green")}if(this.callback){this.callback(F)}})}};A.html.UpdateForm.prototype.render=function(B){this.div=B;B.innerHTML=this._whileLoading!=null?this._whileLoading:"";this.describeTable();return this};A.html.QueryForm=function(B,C){this.objectId=Math.round(Math.abs(Math.random()*10000000));this.errorId="nextdb-form-msg-"+this.objectId;this.type="QUERY";this.conn=B;this.queryName=C;this.callback;return this};A.html.QueryForm.prototype=new A.html.Form;A.html.QueryForm.prototype.queryCallback=function(B){this.callback=B;return this};A.html.QueryForm.prototype.describeQuery=function(){var B=this;this.conn.describeQuery(this.queryName,function(F,E){if(E){if(B._timeoutMessage){B.div.innerHTML=B._timeoutMessage;return }else{alert(E);return }}else{B.columns={};for(var D in F[B.queryName.toString()].whereParameters){B.columns[D.toString()]={};var C=F[B.queryName.toString()].whereParameters[D.toString()];if(C.indexOf("SURID")==0){B.columns[D.toString()].dataType="TEXT"}else{if(C=="INTEGER"){B.columns[D.toString()].dataType="LONGINTEGER"}else{B.columns[D.toString()].dataType=C}}if(C=="INTEGER"){B.columns[D.toString()].validate=A.validate.NUMERIC}else{B.columns[D.toString()].validate=A.validate.REQUIRED}}}B.div.innerHTML="";B.div.appendChild(B.build());if(B._afterRenderCallback){B._afterRenderCallback()}})};A.html.QueryForm.prototype.doAction=function(){var C=this;C.inputButtonSubmit.value="sending...";C.inputButtonSubmit.disabled=true;var B=new A.Query(this.queryName);var D=A.Util.parseForm(document.getElementById(this.objectId));if(this.interceptor){this.interceptor(D,B)}B.setParameters(D);if((typeof this.callback=="function")){this.conn.executeQuery(B,function(E,F){C.inputButtonSubmit.value="submit";C.inputButtonSubmit.disabled=false;C.callback(E,F)})}else{this.conn.executeQuery(B,function(){})}};A.html.QueryForm.prototype.render=function(B){this.div=B;B.innerHTML=this._whileLoading!=null?this._whileLoading:"";this.describeQuery()};A.Insert=function(B){this.table=B;this.map={};this.relationshipName;this.rowId;this.permalinkHandler};A.Insert.prototype.setParameters=function(B){this.map=B};A.Insert.prototype.setPermalinkHandler=function(B){this.permalinkHandler=B};A.Insert.prototype.setRelationship=function(B){if(B.type=="Relationship"){this.rowId=B.rowId;this.relationshipName=B.relationshipName}else{if(arguments.length==2){this.rowId=arguments[0];this.relationshipName=arguments[1]}else{alert("development time bug:\n\n invalid params to insert.setRelationship()")}}};A.Relationship=function(B,C){this.type="Relationship";this.relationshipName=B;this.rowId=C};A.Query=function(B){this.name=B;this.map;this.startAfterValue="now";this.admin=false;this.startAfter=0;this.pageSize=10000;this.orderBy=null};A.Query.prototype.setParameters=function(B){this.map=B};A.Query.prototype.setStartAfter=function(B){this.startAfter=B};A.Query.prototype.setStartAfterValue=function(B){this.startAfterValue=(B)};A.Query.prototype.setPageSize=function(B){this.pageSize=B};A.html.Reflector=function(){Array.prototype.___isArray=true;var K=0;var C="";var I=false;var G=-1;var F=this;this.reflect=function(P){K++;if(I){G++;if(typeof (P)==="number"||typeof (P)==="string"){D(H()+((typeof (P)==="number")?B(P):M(P)));K--;return }}for(var Q in P){var O;if(P[Q]==null||P[Q]==undefined){D(L("object "+Q+"= null"));continue}if(typeof (P[Q])==="object"){if((P[Q].___isArray)){I=true;D(L("array ")+Q+" ("+P[Q].length+")");for(var N=0;N<P[Q].length;N++){F.reflect(P[Q][N])}I=false;G=-1}else{D(L("object ")+Q);F.reflect(P[Q])}}else{if(typeof (P[Q])==="string"){D(L("string ")+Q+H()+M(P[Q]))}else{if(typeof (P[Q])==="number"){D(L("number ")+Q+H()+B(P[Q]))}}}}K--};this.getHTML=function(){return"<style>span{font-size:9pt} pre{font-size:9pt} .s { color: green } .t { color: blue } .n { color: red } .r { color: #DD7777; font-weight:bold } .literal { color: #5555FF }</style><pre>"+C+"</pre>"};this.show=function(){var N;if(document.getElementById("nextdb:reflector")){N=document.getElementById("nextdb:reflector");N.innerHTML+="<style>span{font-size:9pt} pre{font-size:9pt} .s { color: green } .t { color: blue } .n { color: red } .r { color: #DD7777; font-weight:bold } .literal { color: #5555FF }</style>";N.innerHTML+="<pre>"+C+"</pre>"}else{N=document.createElement("div");N.style.position="relative";N.style.width="768px";N.style.padding="8px";N.style.backgroundColor="#ffffff";N.style.fontSize="14pt";N.style.border="1px inset #cccccc";N.id="nextdb:reflector";document.body.appendChild(N);N.innerHTML+="<style>span{font-size:9pt} pre{font-size:9pt} .s { color: green } .t { color: blue } .n { color: red } .r { color: #DD7777; font-weight:bold } .literal { color: #5555FF }</style>";N.innerHTML+="<pre>"+C+"</pre>"}};function M(N){return"<span class='s'>\""+N+'"</span>'}function H(){return"<span class='r'>=</span>"}function L(N){return"<img src='http://www.nextdb.net/admin/img/arrow.png'><span class='t'>"+N+"</span>"}function B(N){return"<span class='n'>"+N+"</span>"}function J(){var O="";for(var N=0;N<K;N++){O+="\t"}return O}function D(N){if(G!=-1){C+=J()+"["+G+"]"+N+"\n"}else{C+=J()+N+"\n"}}function E(N){N.target.parent.style.display="none"}};A.Request=function(){};A.Request.scriptId=1;A.Request.callbackFunctions=[];A.Request.additionalCallbackFunctions=[];A.Request.checkExceptions=function(C){var B=undefined;if(C.hasOwnProperty("ApplicationException")){B=new A.Error();B.message=C.ApplicationException.message;B.exceptionClass=C.ApplicationException.exceptionClass;if(B.message=="request cannot be completed because user is not logged in."){A.Util.createCookie("timeout","true",1);window.location="./index.html";return }B.causedBy=C.ApplicationException.causedBy;if(C.ApplicationException.code==null){B.code=-1}else{B.code=parseInt(C.ApplicationException.code)}}if(C.hasOwnProperty("InternalException")){B=new A.Error();B.message=C.InternalException.message;B.exceptionClass=C.InternalException.exceptionClass;B.causedBy=C.InternalException.causedBy;if(C.InternalException.code==null){B.code=-1}else{B.code=parseInt(C.InternalException.code)}}return B};A.Request.queryCallback=function(C){var B=A.Request.checkExceptions(C);A.Request.callbackFunctions[C.id](C.rs,B,C.datatypes);A.Request.clearCallback(C.id)};A.Request.describeQueryCallback=function(C){var B=A.Request.checkExceptions(C);A.Request.callbackFunctions[C.id](C,B);A.Request.clearCallback(C.id)};A.Request.insertCallback=function(D){var B=A.Request.checkExceptions(D);var C=null;if(D.hasOwnProperty("generatedPK")){C=D.generatedPK}if(A.Request.additionalCallbackFunctions[D.id]){A.Request.additionalCallbackFunctions[D.id](D.permalink)}A.Request.callbackFunctions[D.id](C,B);A.Request.clearCallback(D.id)};A.Request.updateCallback=function(C){var B=A.Request.checkExceptions(C);A.Request.callbackFunctions[C.id](B);A.Request.clearCallback(C.id)};A.Request.describeTablesCallback=function(H){var B=A.Request.checkExceptions(H);var E=[];if(H.Tables){for(var D=0;D<H.Tables.length;D++){var G=new A.Table(H.Tables[D].name);G.captcha=H.Tables[D].captcha;var C=H.Tables[D].Columns;for(var I=0;I<C.length;I++){var F=new A.Column(C[I].name,C[I].type,C[I].unique,C[I].defaultValue,C[I].nullable,C[I].owner);G.addColumn(F)}E[D]=G}}A.Request.callbackFunctions[H.id](E,B);A.Request.clearCallback(H.id)};A.Request.uploadProgressCallback=function(C){var B=A.Request.checkExceptions(C);A.Request.callbackFunctions[C.id](C,B);A.Request.clearCallback(C.id)};A.Request.generalCallback=function(C){var B=A.Request.checkExceptions(C);A.Request.callbackFunctions[C.id](B);A.Request.clearCallback(C.id)};A.Request.generalDataCallback=function(C){var B=A.Request.checkExceptions(C);A.Request.callbackFunctions[C.id](C,B);A.Request.clearCallback(C.id)};A.Request.send=function(D,R,K,C){var F=A.Request.scriptId++;A.Request.callbackFunctions[F]=R;if(C){A.Request.additionalCallbackFunctions[F]=C}if(D.length<2000){var L=document.createElement("script");L.setAttribute("type","text/javascript");if(K){L.setAttribute("src",D+"&_id="+F)}else{L.setAttribute("src",D+"&id="+F)}L.setAttribute("id",F);document.getElementsByTagName("head").item(0).appendChild(L);setTimeout("nextdb.Request.checkTimeout("+F+")",A.CONSTANTS.requestTimeout*1000)}else{var N=D.substring(0,D.indexOf("?")+1);var M=D.substring(D.indexOf("?")+1);var B=Math.ceil(Math.random()*10000000);var O=1500;var H=1;while(N.length+M.length>O){H++;if(N.length+(M.length/H)<O){break}}var J=[];var P=Math.ceil(M.length/H);for(var I=0;I<H;I++){var E=Math.round(I*P);var G=Math.round((I*P)+P);if(I+1==H){var Q=(A.Util.escape((M.substring(E))))}else{var Q=(A.Util.escape((M.substring(E,G))))}var D=N+"rId="+B+"&chunkNum="+(I)+"&chunkCallback=nextdb.Request.multiPartCallback&numChunks="+H+"&chunk="+Q;J.push(D)}for(var I=0;I<J.length;I++){var L=document.createElement("script");L.setAttribute("type","text/javascript");L.setAttribute("id",F);L.rid=B;L.cn=I;if(K){L.setAttribute("src",J[I]+"&_id="+F)}else{L.setAttribute("src",J[I]+"&id="+F)}document.getElementsByTagName("head").item(0).appendChild(L)}setTimeout("nextdb.Request.checkTimeout("+F+")",A.CONSTANTS.requestTimeout*1000)}};A.Request.multiPartCallback=function(D){var B=document.getElementsByTagName("script");for(var C=0;C<B.length;C++){if(document.getElementsByTagName("script")[C].rid==D.reqId&&document.getElementsByTagName("script")[C].cn==D.chunkNum){document.getElementsByTagName("head").item(0).removeChild(document.getElementsByTagName("script")[C])}}};A.Request.clearCallback=function(B){if(B){A.Request.callbackFunctions[B]=null;document.getElementsByTagName("head").item(0).removeChild(document.getElementById(B))}};A.Request.checkTimeout=function(E){if(A.Request.callbackFunctions[E]){if(!A.Request.timeoutError){A.Request.timeoutError=new A.Error();A.Request.timeoutError.message="This request has timed out.  The server might be having problems.  Please try again later.";A.Request.timeoutError.code=408}var C=A.Request.callbackFunctions[E].toString();var B=(C.substring(C.indexOf("(")+1,C.indexOf(")")));var D=(B.split(",")).length;if(D==1){A.Request.callbackFunctions[E](A.Request.timeoutError)}else{if(D==2){A.Request.callbackFunctions[E](null,A.Request.timeoutError)}else{if(D==3){A.Request.callbackFunctions[E](null,null,A.Request.timeoutError)}else{if(D==4){A.Request.callbackFunctions[E](null,null,null,A.Request.timeoutError)}}}}A.Request.callbackFunctions[E]=null;A.Request.clearCallback(E)}};A.Request.timeoutError=undefined;A.Table=function(B){this.name=B;this.captcha=false;this.columns=[]};A.Table.prototype.addColumn=function(B){this.columns.push(B)};A.Table.prototype.removeColumn=function(C){var D=[];for(var B=0;B<this.columns.length;B++){if(this.columns[B].name!=C){D.push(this.columns[B])}}this.columns=D};A.Table.prototype.getColumns=function(){return this.columns};A.Table.prototype.test=function(){alert(this.name)};A.Update=function(B){this.table=B;this.map;this.rowId};A.Update.prototype.setParameters=function(B){this.map=B};A.Update.prototype.setRowId=function(B){this.rowId=B};A.Util=function(){};A.Util.fitTextArea=function(B){return ;var C=B.target||window.event.srcElement;if(document.all){C.style.overflow="visible";return }while(C.rows>1&&C.scrollHeight<C.offsetHeight){C.rows--}while(C.scrollHeight>C.offsetHeight){C.rows++}return };A.Util.addEvent=function(D,C,B){if(D.attachEvent){D["e"+C+B]=B;D[C+B]=function(){D["e"+C+B](window.event)};D.attachEvent("on"+C,D[C+B])}else{D.addEventListener(C,B,false)}};A.Util.removeEvent=function(D,C,B){if(D.detachEvent){D.detachEvent("on"+C,D[C+B]);D[C+B]=null}else{D.removeEventListener(C,B,false)}};A.Util.shareDataModel=function(B){return"http://www.nextdb.net/nextdb/service/"+B.companyName+"/"+B.schema+"/EXPORT"};A.Util.monthNames=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"];A.Util.shortDateFormat=function(C){var B=((C.getHours()+"").length==1?"0"+C.getHours():C.getHours());var D=((C.getMinutes()+"").length==1?"0"+C.getMinutes():C.getMinutes());return A.Util.monthNames[C.getMonth()]+" "+C.getDate()+",  "+C.getFullYear()+" "+B+":"+D};A.Util.convertToServerDateFormat=function(B){var D=B.getFullYear()+"-"+(B.getMonth()+1)+"-"+B.getDate()+" "+B.getHours()+":"+B.getMinutes()+":"+B.getSeconds()+".000 "+C();return D;function C(){var G=B.toString();var I="";var F;var H=G.indexOf("(");if(H>-1){I=G.substring(++H,G.indexOf(")"))}else{var E=/([A-Z\/]+) \d{4}$/;if((F=G.match(E))){I=F[1]}else{G=dateObject.toLocaleString();E=/ ([A-Z\/]+)$/;if((F=G.match(E))){I=F[1]}}}return(I=="AM"||I=="PM")?"":I}};A.Util.convertFromServerDateFormat=function(F){try{var D=F.split(" ");var G=D[0].split("-");var C=D[1].split(":");var B=new Date();B.setUTCFullYear(G[0]);var E=B.setUTCMonth(parseInt(G[1],10)-1);B.setUTCDate(G[2],10);B.setUTCHours(C[0]);B.setUTCMinutes(C[1]);B.setUTCSeconds(C[2]);return B}catch(H){throw ("invalid date string from server : "+F)}};A.Util.convertFromLocalServerDateFormat=function(F){try{var D=F.split(" ");var G=D[0].split("-");var C=D[1].split(":");var B=new Date();B.setFullYear(G[0]);var E=B.setMonth(parseInt(G[1],10)-1);B.setDate(G[2],10);B.setHours(C[0]);B.setMinutes(C[1]);B.setSeconds(C[2]);return B}catch(H){throw ("invalid date string from server : "+F)}};A.Util.isServerDateFormat=function(C){var B=/^(19|20)\d\d[-](0[1-9]|[1-9]|1[012])[-](0[1-9]|[1-9]|[12][0-9]|3[01]).*GMT$/;if(B.test(C)==false){return false}return true};A.Util.printAll=function(E){var C=E.attributes,D,B,F;if(C){B=C.length;for(D=0;D<B;D+=1){F=C[D];if(F.name=="id"){A.Util.p(F.value)}}}C=E.childNodes;if(C){B=C.length;for(D=0;D<B;D+=1){A.Util.printAll(E.childNodes[D])}}};A.Util.validateEmail=function(B){var C=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;if(C.test(B)==false){return false}return true};A.Util.googleAPI=null;A.Util.visualizeQuery=function(C,D){if(A.Util.googleAPI==null){A.Util.googleAPI=document.createElement("script");A.Util.googleAPI.setAttribute("type","text/javascript");A.Util.googleAPI.setAttribute("src","http://www.google.com/jsapi");document.getElementsByTagName("head").item(0).appendChild(A.Util.googleAPI);A.Util.googleAPI.onload=function(){A.Util.visualizeQuery(C,D)}}else{var B=function(){var J=new google.visualization.DataTable();J.addRows(C.length);for(var H in C[0]){for(var F in C[0][H]){J.addColumn("string",F)}}var G=0;for(var E=0;E<C.length;E++){for(var H in C[E]){for(var F in C[E][H]){J.setCell(E,G,""+C[E][H][F]);G++}G=0}}var I=new google.visualization.Table(D);I.draw(J,{showRowNumber:true})};google.load("visualization","1",{packages:["table"],callback:B})}};A.Util.parseForm=function(C){var D={};if(!C||!C.hasChildNodes()){alert("illegal argument to nextdb.Util.parseForm\n\nBe sure to pass in a valid HTML DOM node with child input elements to be parsed.");return }B(C);function B(G){E(G);if(G.hasChildNodes()){for(var F=0;F<G.childNodes.length;F++){B(G.childNodes[F])}}}function E(F){if(F.nodeName.toLowerCase()=="input"&&F.type.toLowerCase()=="text"){D[F.name]=F.value}else{if(F.nodeName.toLowerCase()=="input"&&F.type.toLowerCase()=="password"){D[F.name]=F.value}else{if(F.nodeName.toLowerCase()=="input"&&F.type.toLowerCase()=="hidden"){D[F.name]=F.value}else{if(F.nodeName.toLowerCase()=="input"&&F.type.toLowerCase()=="checkbox"){D[F.name]=F.checked}else{if(F.nodeName.toLowerCase()=="input"&&F.type.toLowerCase()=="radio"){D[F.name]=F.checked}else{if(F.nodeName.toLowerCase()=="textarea"){D[F.name]=F.value}else{if(F.nodeName.toLowerCase()=="select"&&F.name&&F.name!=""){D[F.name]=F[F.selectedIndex].value}}}}}}}}return D};A.Util.c=function(){if(document.getElementById("nextdb:console")){document.getElementById("nextdb:console").innerHTML=""}};A.Util.escape=function(F){F=F+"";var K="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~";var C="!*'();:@&=+$,/?%#[]";var I=K+C;var H="0123456789ABCDEFabcdef";function J(L){return"%"+H.charAt(L>>4)+H.charAt(L&15)}var D="";for(var E=0;E<F.length;E++){var B=F.charAt(E);if(K.indexOf(B)!=-1){D=D+B}else{var G=F.charCodeAt(E);if(G<128){D=D+J(G)}if(G>127&&G<2048){D=D+J((G>>6)|192);D=D+J((G&63)|128)}if(G>2047&&G<65536){D=D+J((G>>12)|224);D=D+J(((G>>6)&63)|128);D=D+J((G&63)|128)}if(G>65535){D=D+J((G>>18)|240);D=D+J(((G>>12)&63)|128);D=D+J(((G>>6)&63)|128);D=D+J((G&63)|128)}}}return D};A.Util.escapeBraces=function(B){for(var C in B){B[C]=B[C].replace(/\]/g,">").replace(/\[/g,"<")}return B};A.Util.escapeBrakets=function(B){return B.replace(/\>/g,"&gt;").replace(/\</g,"&lt;")};A.Util.yellowerize=function(B){B.onfocus=function(C){if(document.all){window.event.srcElement.style.backgroundColor="#ffffcc"}else{C.target.style.backgroundColor="#ffffcc"}};B.onblur=function(C){if(document.all){window.event.srcElement.style.backgroundColor="#eeeeee"}else{C.target.style.backgroundColor="#eeeeee"}}};A.Util.trim=function(B){return B.replace(/^\s+|\s+$/g,"")};A.Util.byId=function(B){return document.getElementById(B)};A.Util.sourceCaptchaImg=function(C,B,E){var D=A.CONSTANTS.captchaUrl+"?width=175&height=80";if(B){D+="&fg="+B.replace("#","")}if(E){D+="&bg="+E.replace("#","")}D+="&cruft="+Math.random();C.src=D};A.Util.createCookie=function(D,E,F){if(F){var C=new Date();C.setTime(C.getTime()+(F*24*60*60*1000));var B="; expires="+C.toGMTString()}else{var B=""}document.cookie=D+"="+E+B+"; path=/"};A.Util.readCookie=function(C){var E=C+"=";var B=document.cookie.split(";");for(var D=0;D<B.length;D++){var F=B[D];while(F.charAt(0)==" "){F=F.substring(1,F.length)}if(F.indexOf(E)==0){return F.substring(E.length,F.length)}}return null};A.Util.eraseCookie=function(B){A.Util.createCookie(B,"",-1)};A.Util.print=function(B,C){A.Util.p(B,C)};A.Util.parseDate=function(B){return A.Util.convertFromServerDateFormat(B)};A.Util.getCaptchaURL=function(B){B.src=A.CONSTANTS.captchaUrl+"?width=175&height=80&cruft="+Math.random()};A.Util.uc=function(){if(document.getElementById("nextdb:usage-console")){document.getElementById("nextdb:usage-console").innerHTML=""}};A.Util.up=function(B,D){if(document.getElementById("nextdb:usage-console")){document.getElementById("nextdb:usage-console").innerHTML+="<br/>"+B}else{var C=document.createElement("div");C.style.position="absolute";C.style.top="10px";C.style.left="10px";C.style.scrolling="on";C.style.width="600px";C.style.height="300px";C.style.overflow="auto";C.style.zIndex="300";C.style.padding="10px";C.style.border="4px solid #cccccc";C.style.fontSize="9pt";C.style.fontFamily="verdana";C.style.border="3px inset #008F00";C.style.color="#CCFF66";C.style.backgroundColor="#ffffff";C.id="nextdb:usage-console";document.body.appendChild(C);C.innerHTML+="<br/>"+B}document.getElementById("nextdb:usage-console").style.display="block";document.getElementById("nextdb:usage-console").onclick=function(){document.getElementById("nextdb:usage-console").style.display="none"}};A.Util.createElement=function(B){if(document.all){return document.createElement("<"+B+">")}else{return document.createElement(B)}};A.validate={};A.validate.EMAIL={regex:/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,message:"valid email required"};A.validate.REQUIRED={regex:/./,message:"? required"};A.validate.NUMERIC={regex:/^\d+$/,message:"? must be numeric"};A.validate.STRONG_PASSWORD={regex:/(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/,message:"? must be at least 8 mixed case alphanumeric characters"};A.validate.OPTIONAL={regex:null,message:""}})();
