Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

contact form

  • Loading branch information...
commit 3ce4385d6eff503120f2cb854ab99a6691a59808 1 parent d385ce2
@midnightmonster midnightmonster authored
View
BIN  assets/bootstrap components.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  assets/bootstrap settings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  www/charter.html
@@ -38,7 +38,7 @@
<div class="hero-unit"><div class="sidekick">
<h1>Charter</h1>
<p>Need to charter a jet? Our broad range of charter partners enable us to create options that meet your travel needs, even at the last minute. </p>
- <p><a class="btn btn-primary btn-large">Contact Us &raquo;</a></p>
+ <p><a href="contact.html" class="btn btn-primary btn-large">Contact Us &raquo;</a></p>
</div></div>
<!-- /Hero Unit -->
<!-- One Column -->
View
128 www/contact.html
@@ -11,6 +11,35 @@
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
+ <link href="css/kafoof.bootstrap.css" rel="stylesheet">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
+ <script src="js/kafoof.min.js"></script>
+ <script>
+ var setupForm = function(k){
+ k.serializeDefinition('#form-definition');
+ var kv = Kafoof.validate();
+ kv.disable();
+ $(this).closest('form').submit(function(e){
+ if(!kv.run()) return false;
+ e.preventDefault();
+ $button = $(this).find('button').attr('disabled',true);
+ $.post(this.action,$(this).find(':input').serialize())
+ .success(function(){
+ $('.form-submit').toggle();
+ }).error(function(){
+ alert('Your message could not be sent. We apologize for the inconvenience.');
+ }).complete(function(){
+ $button.attr('disabled',false);
+ });
+ return false;
+ });
+ };
+ Kafoof.load('#contact-form',{topics:[
+ 'Acquiring a business jet',
+ 'Selling a business jet',
+ 'Business jet consultations'
+ ]},{}).render(setupForm);
+ </script>
</head>
<body>
@@ -36,72 +65,43 @@
<div class="container">
<!-- Hero Unit -->
- <div class="hero-unit"><div class="sidekick">
- <h1>Kitties are so cute</h1>
- <p>If you had your own plane, you could take your kitty on board with you. You wouldn't have to use a pet carrier or deal with the other hassles of travel with pets. Don't you wish you could take your kitty on your private jet?</p>
- <p><a class="btn btn-primary btn-large">Learn more &raquo;</a></p>
- </div></div>
- <!-- /Hero Unit -->
- <!-- One Column -->
- <h1>Example One-Column Section</h1>
- <p>The text goes pretty wide this way. Not going to be beautiful or easy to read in most cases. Did I mention that kitties are so cute? Oh the darling kitties!</p>
- <!-- /One Column -->
- <!-- Image on Right -->
- <div class="row">
- <div class="span7">
- <h1>Image on the right</h1>
- <ul>
- <li>When you do these images it's very important</li>
- <li>That you not leave the img src pointing to the assets folder</li>
- <li>Because that won't be accessible on the website</li>
- </ul>
- </div>
- <img class="span5" src="../assets/cit_cj2_ext02_hires.jpg" alt="">
- </div>
- <!-- /Image on Right -->
- <!-- Two Column -->
- <h1>Example Two-Column Section</h1>
- <div class="row">
- <div class="span6">
- <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
- </div>
- <div class="span6">
- <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
- </div>
- </div>
- <!-- /Two Column -->
- <!-- Image on Left -->
- <div class="row">
- <img class="span5" src="../assets/G001_high_resolution.jpg" alt="">
- <div class="span7">
- <h1>Image on the left</h1>
- <ul>
- <li>It's also important</li>
- <li>To scale these to a reasonable size when you save them in the www/img folder</li>
- <li>Right now I'm having the browser do it, and that's a big waste of bandwidth and memory</li>
- </ul>
- </div>
- </div>
- <!-- /Image on Left -->
- <!-- Three Column -->
- <div class="row">
- <div class="span4">
- <h2>Three</h2>
- <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
- <p><a class="btn" href="#">View details &raquo;</a></p>
+ <div class="hero-unit with-butler">
+ <div class="butler">
+ <p>jet<i>forward</i> Aviation<br>973 Summerleaf Drive<br>Suite 101<br>San Jose, CA 95120</p>
+ <p>Phone: 408.674.8708<br>Fax: 408.852.0303</p>
</div>
- <div class="span4">
- <h2>Columns</h2>
- <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
- <p><a class="btn" href="#">View details &raquo;</a></p>
- </div>
- <div class="span4">
- <h2>Are Nice</h2>
- <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
- <p><a class="btn" href="#">View details &raquo;</a></p>
+ <div class="sidekick"><form action="contact.php" method="post" style="margin:0" id="contact">
+ <h1 style="margin:0">Contact Us</h1>
+ <div id="contact-form"><textarea style="display:none">
+-- @contact -----------------------
+
+Let's talk about
+[______________________________[^]]
+
+Your message
++---------------------------------+
++ +
++ +
++---------------------------------+
+
+Your name Preferred phone
+[_______________] [_______________]
+
+Your email address
+[_________________________________]
+-----------------------------------
+* topic; from:topics; prompt:Choose...
++ message
+* name
+* phone
++ email; validate:EMAIL
+ </textarea></div>
+ <p class="form-submit"><button type="submit" class="btn btn-primary btn-large">Send Message</button><input type="hidden" name="form-definition" id="form-definition"></p>
+ <div class="form-submit alert" style="display:none">
+ <b>Thank you!</b> Your message has been sent.
</div>
- </div>
- <!-- /Three Column -->
+ </form></div></div>
+ <!-- /Hero Unit -->
</div> <!-- /container -->
<div class="footer">
<div class="container">
View
14 www/contact.php
@@ -0,0 +1,14 @@
+<?php
+if(empty($_POST['email'])) die('fail');
+require 'lib/SimpleEmail.php';
+require 'lib/preview_view.php';
+require 'lib/KafoofPreview.php';
+$preview = new KafoofPreview($_POST);
+ob_start();
+foreach($preview->sections() as $s) kafoof_section($s);
+$_POST['body'] = ob_get_clean();
+$mail = new SimpleEmail('contact.template');
+if(!$mail->send($_POST)) {
+ throw new Exception('Email send failed');
+}
+die('ok');
View
6 www/contact.template
@@ -0,0 +1,6 @@
+To: info@jetforwardaviation.com
+From: {{email}}
+Subject: Contact Form: {{topic}}
+Content-type: text/html
+
+<html><body>{{body}}</body></html>
View
BIN  www/css/Kafoof.err.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3  www/css/custom.css
@@ -52,7 +52,10 @@ div.navbar-fixed-top .nav {
}
div.hero-unit { background:#222 url(../img/hero-bw.jpg) right center no-repeat; padding:0 373px 0 0; color:#eee; margin:0 -4px 30px;}
+div.with-butler { background-image:none; }
div.sidekick { border-right:2px solid #841114; padding:40px; }
+div.butler { float:right; width:293px; padding:30px 40px; margin-right:-373px; }
+div.with-butler div.sidekick { padding:30px 40px; }
.hero-unit h1 { color:#c8bdb5; font-size:32px; margin:0 0 12px;}
h1, h2 {margin:18px 0 9px; }
View
48 www/css/kafoof.bootstrap.css
@@ -0,0 +1,48 @@
+
+input.K-textfield,input.K-password,textarea.K-textarea,select.K-select{color:#555555;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:15px;background:#ffffff;line-height:18px;height:18px;margin:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;padding:2px 0;border:none;width:100%;float:left;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;-webkit-transition:none;-moz-transition:none;-ms-transition:none;-o-transition:none;transition:none;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;-ms-box-sizing:content-box;box-sizing:content-box;}
+select.K-select{*height:22px;}
+span.K-border{border:solid 1px #cccccc;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding:2px 4px;background:#ffffff;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-webkit-transition:border linear 0.2s,box-shadow linear 0.2s;-moz-transition:border linear 0.2s,box-shadow linear 0.2s;-ms-transition:border linear 0.2s,box-shadow linear 0.2s;-o-transition:border linear 0.2s,box-shadow linear 0.2s;transition:border linear 0.2s,box-shadow linear 0.2s;}
+div.K-focus span.K-border{border-color:#eca852;border-color:rgba(236, 168, 82, 0.8);-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(236, 168, 82, 0.6);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(236, 168, 82, 0.6);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(236, 168, 82, 0.6);outline:0;}
+fieldset.K-fieldset{margin:22px -8px 0;padding:0 8px;border:none;}
+fieldset.K-fieldset legend{margin-bottom:11px;}
+fieldset.K-boxset legend{float:left;display:inline;color:#333333;*margin-left:-7px;font-size:15px;font-weight:normal;line-height:22px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;margin-bottom:4px;}
+span.K-legend-span{float:left;display:inline;margin-left:0px;}
+div.K-row{padding:0 8px 8px;margin:0 -8px 3px;}
+div.K-text{margin:0 0 -0.5em;}
+div.K-text p{margin:0 0 0.5em;}
+label.K-label-box-plus{overflow:hidden;zoom:1;}
+.K-boxes-col label{line-height:1.4;clear:left;float:none;text-align:left;width:auto;}
+input.K-textfield-plus{height:1.4em;line-height:1.4;}
+b.K-required{font-weight:inherit;color:red;padding-left:2px;}
+div.K-err{padding-left:22px;background:url(Kafoof.err.png) no-repeat left center;color:#f99;min-height:16px;line-height:1.25;margin:0 0 2px;cursor:pointer;}
+div.K-error-container{width:100%;display:none;}
+div.K-errors{margin-bottom:0.5em;}
+textarea.K-textarea{line-height:1.25;overflow-y:auto;height:auto;resize:vertical;}
+textarea.K-textarea-mono{font-family:Consolas,Inconsolata,monospace;}
+input.K-textfield,select.K-select,textarea.K-textarea,input.K-password{-webkit-transition:none;-ms-transition:none;-moz-transition:none;transition:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}
+input.K-textfield:focus,input.K-password:focus,select.K-select:focus,textarea.K-textarea:focus{-moz-outline:none;outline:none;-webkit-outline:none;-o-outline:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}
+div.K-row{float:left;clear:left;width:100%;}
+div.K-width{float:left;position:relative;display:inline;}
+div.K-width-label-top{padding-top:1.5em;}
+div.K-width-label-top label{position:absolute;left:0;top:0;height:1.5em;line-height:1.5em;white-space:nowrap;overflow:visible;float:none;padding:0;text-align:left;width:auto;font-weight:normal;}
+div.K-width-label-bottom{padding-bottom:1.5em;}
+div.K-width-label-bottom label{position:absolute;left:0;bottom:0;height:1.5em;line-height:1.5em;white-space:nowrap;overflow:visible;float:none;padding:0;text-align:left;width:auto;font-weight:normal;}
+span.K-border{display:block;overflow:hidden;zoom:1;}
+span.K-border-select{padding:4;}
+div.K-multi-wrap{background:#ccc;padding:10px;border:solid 2px #999;border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px;-o-border-radius:5px;overflow:hidden;zoom:1;}
+div.K-multi-set{float:left;width:100%;zoom:1;}
+div.K-multi-item{background:#fff;width:100%;padding:10px 0;margin-bottom:10px;border-radius:8px;-webkit-border-radius:8px;-moz-border-radius:8px;-o-border-radius:8px;box-shadow:1px 1px 5px rgba(0, 0, 0, 0.5);-webkit-box-shadow:1px 1px 5px rgba(0, 0, 0, 0.5);-moz-box-shadow:1px 1px 5px rgba(0, 0, 0, 0.5);-o-box-shadow:1px 1px 5px rgba(0, 0, 0, 0.5);}
+div.K-multi-item fieldset.K-multi-item{padding-left:10px;padding-right:10px;}
+div.K-multi-add{margin-bottom:0;}
+div.K-multi-add p{margin:0;padding:0 10px;}
+a.K-multi-del{float:right;line-height:1.5;clear:left;margin-top:-2.07em;}
+div.K-fieldset-wrap{overflow:hidden;position:relative;zoom:1;padding:0 8px;margin:0 -8px;}
+fieldset.K-fieldset{overflow:hidden;zoom:1;}
+fieldset.K-boxset{padding:0;margin:0;border:none;}
+div.K-boxes-col label{padding:4px 21px 4px 25px;border:solid 1px white;display:block;position:static;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;-webkit-transition:border linear 0.2s,box-shadow linear 0.2s;-moz-transition:border linear 0.2s,box-shadow linear 0.2s;-ms-transition:border linear 0.2s,box-shadow linear 0.2s;-o-transition:border linear 0.2s,box-shadow linear 0.2s;transition:border linear 0.2s,box-shadow linear 0.2s;}
+div.K-boxes-col label.K-focus{outline:0;border:solid 1px rgba(236, 168, 82, 0.8);-webkit-box-shadow:inset 0 0 8px rgba(236, 168, 82, 0.6);-moz-box-shadow:inset 0 0 8px rgba(236, 168, 82, 0.6);box-shadow:inset 0 0 8px rgba(236, 168, 82, 0.6);padding:4px 21px 4px 25px;}
+div.K-boxes-col div.K-boxes-sub{padding:0 0 0 26px;border:none;display:block;}
+div.K-boxes-col span.K-boxes{float:left;display:inline;margin:0 0 0 -24px;}
+
+.hero-unit label { color:#ccc; }
+.hero-unit
View
23 www/js/kafoof.min.js
@@ -0,0 +1,23 @@
+var JSON;if(!JSON){JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==="string"){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());/*
+ * ----------------------------------------------------------------------------
+ * Package: JS Date Format Patch
+ * Version: 0.9.9
+ * Date: 2010-09-26
+ * Author URL: http://miljenkobarbir.com/
+ * Repository: http://github.com/barbir/js-date-format
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2010 Miljenko Barbir
+ * Dual licensed under the MIT and GPL licenses.
+ * ----------------------------------------------------------------------------
+ */
+ Date.format=function(b,g){var e=Date.formatLogic;var d=(g.indexOf("a")!=-1)||(g.indexOf("A")!=-1);var f=new Array();f.d=b.getDate();f.dd=e.pad(f.d,2);f.ddd=e.i18n.shortDayNames[b.getDay()];f.dddd=e.i18n.dayNames[b.getDay()];f.M=b.getMonth()+1;f.MM=e.pad(f.M,2);f.MMM=e.i18n.shortMonthNames[f.M-1];f.MMMM=e.i18n.monthNames[f.M-1];f.yyyy=b.getFullYear();f.yyy=e.pad(f.yyyy,2)+"y";f.yy=e.pad(f.yyyy,2);f.y="y";f.H=b.getHours();f.hh=e.pad(d?e.convertTo12Hour(f.H):f.H,2);f.h=d?e.convertTo12Hour(f.H):f.H;f.HH=e.pad(f.H,2);f.m=b.getMinutes();f.mm=e.pad(f.m,2);f.s=b.getSeconds();f.ss=e.pad(f.s,2);f.z=b.getMilliseconds();f.zz=f.z+"z";f.zzz=e.pad(f.z,3);f.ap=f.H<12?"am":"pm";f.a=f.H<12?"am":"pm";f.AP=f.H<12?"AM":"PM";f.A=f.H<12?"AM":"PM";var c=0;var a="";while(c<g.length){token=g.charAt(c);while((c+1<g.length)&&f[token+g.charAt(c+1)]!=null){token+=g.charAt(++c)}if(f[token]!=null){a+=f[token]}else{a+=token}c++}return a};Date.formatLogic={pad:function(f,e){var a=1;var c="";if(e<1){return""}for(var d=0;d<e;d++){a*=10;c+="0"}var b=f;b=c+f;b=b.substring(b.length-e);return b},convertTo12Hour:function(a){return a%12==0?12:a%12},i18n:{dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}};Date.prototype.toFormattedString=function(a){return Date.format(this,a)};Date.parseFormatted=function(g,f){var b=new Date(2000,0,1);var c=new Array();c.d="([0-9][0-9]?)";c.dd="([0-9][0-9])";c.M="([0-9][0-9]?)";c.MM="([0-9][0-9])";c.yyyy="([0-9][0-9][0-9][0-9])";c.yyy="([0-9][0-9])[y]";c.yy="([0-9][0-9])";c.H="([0-9][0-9]?)";c.hh="([0-9][0-9])";c.h="([0-9][0-9]?)";c.HH="([0-9][0-9])";c.m="([0-9][0-9]?)";c.mm="([0-9][0-9])";c.s="([0-9][0-9]?)";c.ss="([0-9][0-9])";c.z="([0-9][0-9]?[0-9]?)";c.zz="([0-9][0-9]?[0-9]?)[z]";c.zzz="([0-9][0-9][0-9])";c.ap="([ap][m])";c.a="([ap][m])";c.AP="([AP][M])";c.A="([AP][M])";var h=Date.parseLogic;var d=0;var e="";var j=new Array("");while(d<f.length){token=f.charAt(d);while((d+1<f.length)&&c[token+f.charAt(d+1)]!=null){token+=f.charAt(++d)}if(c[token]!=null){e+=c[token];j[j.length]=token}else{e+=token}d++}var a=RegExp(e);matches=g.match(a);if(matches==null||matches.length!=j.length){return null}for(var d=0;d<j.length;d++){if(j[d]!=""){switch(j[d]){case"yyyy":case"yyy":b.setYear(h.parseInt(matches[d]));break;case"yy":b.setYear(2000+h.parseInt(matches[d]));break;case"MM":case"M":b.setMonth(h.parseInt(matches[d])-1);break;case"dd":case"d":b.setDate(h.parseInt(matches[d]));break;case"hh":case"h":case"HH":case"H":b.setHours(h.parseInt(matches[d]));break;case"mm":case"m":b.setMinutes(h.parseInt(matches[d]));break;case"ss":case"s":b.setSeconds(h.parseInt(matches[d]));break;case"zzz":case"zz":case"z":b.setMilliseconds(h.parseInt(matches[d]));break;case"AP":case"A":case"ap":case"a":if((matches[d]=="PM"||matches[d]=="pm")&&(b.getHours()<12)){b.setHours(b.getHours()+12)}if((matches[d]=="AM"||matches[d]=="am")&&(b.getHours()==12)){b.setHours(0)}break}}}return b};Date.parseLogic={unpad:function(b){var a=b;while(a.length>1){if(a[0]=="0"){a=a.substring(1,a.length)}else{break}}return a},parseInt:function(a){return parseInt(this.unpad(a))}};Date.prototype.fromFormattedString=function(a,b){this.setTime(Date.parseFormatted(a,b).getTime());return this};
+/*
+ * ----------------------------------------------------------------------------
+ * Package: Kafoof
+ * Author: Joshua Paine <joshua@letterblock.com>
+ * Author URL: http://letterblock.com/
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2010-2012 LetterBlock LLC. All rights reserved.
+ * ----------------------------------------------------------------------------
+ */
+if(!self.LB){self.LB={}}LB.Delayed=function(a){this.q=[];this.paused=!a;return this};LB.Delayed.prototype.play=function(){var a;while((a=this.q.shift())){a()}this.paused=false};LB.Delayed.prototype.pause=function(){this.paused=true};LB.Delayed.prototype.wrap=function(c,a){var b=this;return function(){var d=arguments;if(b.paused){b.q.push(function(){a.apply(c,d)})}else{a.apply(c,d)}return c?c:a}};if(!self.jQuery){throw"Kafoof requires jQuery."}if(!self.LB||!self.LB.Delayed){throw"Kafoof requires LB.Delayed."}self.Kafoof=(function(A){var P=function(af){var h,ag;if(A.isPlainObject(af)){h=0;for(ag in af){if(ag==="sec"||ag==="usec"){++h}else{return false}}return h===2?new Date(af.sec*1000+af.usec):false}if(A.isNumeric(af)){return new Date(1000*af)}return false};var ad;ad=function(af){if(af.textContent){return af.textContent}if(af.innerText){return af.innerText}var ag="",h;var ah=af.childNodes;for(h=0;h<ah.length;h++){if(ah[h].nodeType===3){ag+=ah[h].nodeValue}if(ah[h].nodeType===1){ag+=ad(ah[h])}}return ag};var Z=function(h){return typeof h==="undefined"?"":h.html||String(h).replace(/[<"&]/g,function(af){return{"<":"&lt;",'"':"&quot;","&":"&amp;"}[af]})};var ab=function(af,h,ag){return Z(h).replace(/\{\{([^\}]+)\}\}/g,function(ai,ah){return Z(K(af.values,ag,ah)||af.vars[ah.replace(/^\$/,"")]||"")})};var m=function(h){var af="",ag;for(ag in h){if(h.hasOwnProperty(ag)){af+=ag+":"+h[ag]+"; "}}return af};var T=function(ah,ag,ai){var aj="<"+ah,af;for(af in ag){if(ag.hasOwnProperty(af)&&ag[af]!==false){var h={c:"class"}[af]||af;aj+=ag[af]===true?(" "+h):(" "+h+'="'+Z(ag[af])+'"')}}aj+=">";if(ai===false){return aj}if(ai){aj+=ai}aj+="</"+ah+">";return aj};var d=function(ag,af){var h=af?ag/(af):ag;return(self.Kafoof.percentFudge*h).toFixed(5)+"%"};var I=function(h,ai){if(!h){h=[]}var ag=[],af,ah;af=Math.ceil(h.length/ai);for(ah=0;ah<ai;ah++){ag.push(h.slice(ah*af,ah*af+af))}return ag};var X;X=function(h){if(!h){h=++X.textCounter}return("Kn-"+h).replace(/[\.\]\[]/g,"-").replace(/[^a-z0-9_\-]/gi,"")};X.textCounter=0;var k=function(af){var ag=0;var h=af.length;af.pull=function(){if(ag<h){return af[ag++]}return null};return af};var z=function(ai){var af,ag,ah;var aj=ai.substr(0,300);if(aj.indexOf("\r\n")!==-1){af=ai.split("\r\n")}else{if(aj.indexOf("\n")!==-1){af=ai.split("\n")}else{if(aj.indexOf("\r")!==-1){af=ai.split("\r")}}}for(ag=0;ag<af.length;ag++){af[ag]=af[ag].replace(/\s\s*$/,"")}ag=0;var h=0;ah={pullHeader:function(){var ak;while(!(ak=/^(\s*)(-{2,} )(.*)( -{2,})$/.exec(af[ag++]))){if(ag>=af.length){return null}}h=ak[1].length;return k(ak.slice(1))},pullBoxLine:function(){var ak,al;if(ag>=af.length){return null}ak=af[ag++].substr(h);if(/^-+$/.test(ak)){return null}al=ak.match(/(\s+|\+-+\+|\+ +\+|(\([Xx]\)|\[[Xx](\.\.\.)?\])\.*([0-9]{1,2}-col|inline)\.*|\[[xX ]\]|\([xX \*]\)|\[_*\[[+\^]\]\]|\[[_\*]*\]|\{[^}]+\}|<<@[^>]+>>|<@[^>]+>|::@.+?::|[^\s]+)/g);return al?k(al):{blank:true}},pullFieldDefinition:function(){var ak,al;if(ag>=af.length){return null}ak=af[ag++].replace(/^\s+/,"");al=/^([*+xX~])\s*([^;\s]+)[;\s]*(.*)$/.exec(ak);return al?k(al.slice(1)):null},line:function(){return ag+1}};return ah};var J=function(h){if(!h){h=[]}var ag=h.push,af,ah;h.push=function(){for(af=0;af<arguments.length;af++){ah=arguments[af];if(!h.length||(ah.type!=="space"&&ah.type!=="text")||!h[h.length-1].isTextEater){ag.call(h,ah)}else{h[h.length-1].value+=ah.value;h[h.length-1].width+=ah.width}}return h.length};h.width=function(){if(!this.length){return 0}var ai=this[this.length-1];return ai.left+ai.width};h.getByLeft=function(aj){var ai=0;while(ai<this.length&&this[ai].left<aj){ai++}return(ai<this.length&&this[ai].left===aj)?this[ai]:null};return h};var w={align:function(ag){var af=ag[1].length,h=ag[3].length;if(af===3){return"left"}if(h===3){return"right"}if(Math.abs(af-h)<4){return"center"}return(af<h)?"left":"right"},name:function(af){var ah=af[2],h={},ag;if((ag=ah.split(/,\s*@/)).length===2){h.title=ag[0];h.name="@"+ag[1]}else{if(ah.indexOf("@")===0){h.name=ah}else{h.title=ah}}return h}};var p=function(af,h){var ag=function(ah,ai){this.type=af;this.width=ai.length;this.left=ah.width();this.source=ai;this.isField=true;if(h){h.apply(this,arguments)}};ag.prototype.aDefs={};return ag};var x=function(h){return function(){this.inputType=h;var af=/[0-9]+-col|inline/.exec(this.source);this.cols=af?parseInt(af[0],10)?parseInt(af[0],10):0:1}};var S=p("textfield");S.prototype.aDefs={max:true,"private":true,"default":true,dateFormat:true};var F=p("password");F.prototype.aDefs={"private":true};var V=p("iradio",function(){this.value="";this.checked=/[xX\*]/.test(this.source)});var f=p("iboxes",function(){this.value="";this.checked=/[xX\*]/.test(this.source)});var G=p("boxes",x("radio"));G.prototype.aDefs={from:true,"default":true};var ae=p("boxes",x("checkbox"));ae.prototype.aDefs={from:true,"default":true};var M=p("boxesplus",x("checkbox"));M.prototype.aDefs={from:true,newprompt:true,"default":true};var l=p("select");l.prototype.aDefs={from:true,prompt:true};var a=p("selectplus");a.prototype.aDefs={from:true,prompt:true,newprompt:true};var H=p("textarea",function(){this.rows=1;this.monospace=this.source.match(/MONO/)});var r=p("time",function(){this.hourSet=this.source.match(/^\{(00|1[3-9]|2[0-3])\:/)?"military":"civilian";this.minuteIncrement=parseInt(/\:([0-9]{2})/.exec(this.source)[1],10)});r.prototype.military=["00:mm","01:mm","02:mm","03:mm","04:mm","05:mm","06:mm","07:mm","08:mm","09:mm","10:mm","11:mm","12:mm","13:mm","14:mm","15:mm","16:mm","17:mm","18:mm","19:mm","20:mm","21:mm","22:mm","23:mm"];r.prototype.civilian=["12:mm AM","01:mm AM","02:mm AM","03:mm AM","04:mm AM","05:mm AM","06:mm AM","07:mm AM","08:mm AM","09:mm AM","10:mm AM","11:mm AM","12:mm PM","01:mm PM","02:mm PM","03:mm PM","04:mm PM","05:mm PM","06:mm PM","07:mm PM","08:mm PM","09:mm PM","10:mm PM","11:mm PM"];var v=p("include",function(){this.toInclude=/@[^>]+/.exec(this.source)[0]});var c=p("import",function(){this.toImport=/@[^>]+/.exec(this.source)[0]});var R=p("multiinclude",function(){this.toInclude=/@[a-zA-Z0-9_]+/.exec(this.source)[0];this.includeTitle=(/, *(.*)::$/.exec(this.source)||[null,""])[1].replace(/\s\s*$/,"")});R.prototype.aDefs={title:true,delprompt:true,newprompt:true};var E=function(h){this.type="space";this.width=1;this.left=h.width();this.value=" "};var ac=function(h,af){this.type="gap";this.width=af.length;this.left=h.width()};var t=function(h,af){this.type="text";this.width=af.length;this.left=h.width();this.value=af.replace(/~~*$/,"")};var D=function(){this.type="hidden"};t.prototype.complete=function(h,ah){var af;for(af=0;af<h.length;af++){var ag=h[af].getByLeft(this.left);if(!ag||(ag.type&&ag.type==="gap")){continue}if(ah&&ag.type!=="text"){throw JSON.stringify({err:"Field element not allowed",obj:this,next:ag})}if(ag.type==="text"){this.value+=" "+ag.value;this.width=this.width>ag.width?this.width:ag.width}else{if(ag.isField){ag.label=this.value;ag.labelWidth=this.width;ag.labelPosition="top";return ag.complete(h.slice(af+1))}}}this.value=this.value.replace(/\s\s*$/,"");return this};t.prototype.isTextEater=true;V.prototype.complete=f.prototype.complete=function(h,ai){this.inline=true;var af;this.value=this.value.replace(/\s\s*/,"");if(!ai){ai=[]}if(ai.length){var ah=ai[ai.length-1];if(ah.width>this.width){this.width=ah.width}}ai.push(this);for(af=0;af<h.length;af++){var ag=h[af].getByLeft(this.left);if(!ag||ag.type==="gap"){ag=h[af].getByLeft(this.left+4)}if(!ag||ag.type==="gap"){break}if(ag.type==="text"){this.value+=" "+ag.value;if((ag.width+ag.left)>(this.width+this.left)){this.width=ag.width+ag.left-this.left}}else{if(ag.type===this.type){return ag.complete(h.slice(af+1),ai)}else{if(ag.isField){throw ag.type+" element not allowed immediately below "+this.type}}}}this.options=[];this["default"]=[];for(af=0;af<ai.length;af++){if(ai[af].checked){this["default"].push(ai[af].value)}this.options.push(ai[af].value)}this.cols=1;this.inputType=this.type==="iradio"?"radio":"checkbox";this.type="boxes";return this};V.prototype.isTextEater=true;f.prototype.isTextEater=true;H.prototype.complete=function(h){var af;for(af=0;af<h.length;af++){var ag=h[af].getByLeft(this.left);if(!ag){break}if(ag.type==="text"){ag.complete(h.slice(af+1),true);this.label=ag.value;this.labelWidth=ag.width;this.labelPosition="bottom";return this}else{if(ag.type==="textarea"){this.rows++}else{if(ag.isField){throw ag.type+" element not allowed immediately below textarea"}else{console.log(ag)}}}}return this};S.prototype.complete=F.prototype.complete=G.prototype.complete=ae.prototype.complete=M.prototype.complete=l.prototype.complete=a.prototype.complete=r.prototype.complete=c.prototype.complete=v.prototype.complete=R.prototype.complete=function(h){if(!h.length){return this}var af=h[0].getByLeft(this.left);if(!af){return this}if(af.isField){throw af.type+" element not allowed immediately below "+this.type}if(af.type==="text"){af.complete(h.slice(1),true);this.label=af.value;this.labelWidth=af.width;this.labelPosition="bottom"}return this};var U=function(ah){var ag;if(ah.noBoxRows){ah.noBoxRows=false;return null}while((ag=ah.pullBoxLine())&&ag.blank){}if(!ag){return null}var al=[],am,aj;while(ag&&!ag.blank){am=new J();while((aj=ag.pull())){if(" "===aj){am.push(new E(am));continue}if(/^ {2,}$/.test(aj)){am.push(new ac(am,aj));continue}if(/^\[_*\]$/.test(aj)){am.push(new S(am,aj));continue}if(/^\[\*+\]$/.test(aj)){am.push(new F(am,aj));continue}if(/^\([Xx]\)\S/.test(aj)){am.push(new G(am,aj));continue}if(/^\[[Xx]\]\S/.test(aj)){am.push(new ae(am,aj));continue}if(/^\[[Xx]...\]\S/.test(aj)){am.push(new M(am,aj));continue}if(/^\([xX \*]\)$/.test(aj)){am.push(new V(am,aj));continue}if(/^\[[xX ]\]$/.test(aj)){am.push(new f(am,aj));continue}if(/^\[_*\[\^\]\]$/.test(aj)){am.push(new l(am,aj));continue}if(/^\[_*\[\+\]\]$/.test(aj)){am.push(new a(am,aj));continue}if(/^\{[0-9]{2}:/.test(aj)){am.push(new r(am,aj));continue}if(/^<@/.test(aj)){am.push(new v(am,aj));continue}if(/^<<@/.test(aj)){am.push(new c(am,aj));continue}if(/^::@/.test(aj)){am.push(new R(am,aj));continue}if(/^\+(MONO)?[\- ]+\+$/.test(aj)){am.push(new H(am,aj));continue}am.push(new t(am,aj))}al.push(am);ag=ah.pullBoxLine()}if(!ag){ah.noBoxRows=true}var h=al[0];al=al.slice(1);var ak=[];for(var af=0;af<h.length;af++){var ai=h[af];if(ai.isField||ai.type=="text"){ak.push(ai.complete(al))}}return J(ak)};var L=function(aq){var ak,al,an,ai,at,ao,ah,aj,ap;if(!(ak=aq.pullHeader())){return null}al=w.name(ak);al.type="fieldset";al.sub=!!ak[0];al.width=(ak[1]+ak[2]+ak[3]).length;al.align=w.align(ak);al.fields=[];al.fields.hidden=[];al.rows=[];while((at=U(aq))){for(ai=0;ai<at.length;ai++){if(at[ai].isField){al.fields.push(at[ai])}}al.rows.push(at)}ai=0;while((an=aq.pullFieldDefinition())){ap=an.pull();if("~"===ap){al.fields.splice(ai,0,new D());if(!al.fields.hidden){al.fields.hidden=[]}al.fields.hidden.push(al.fields[ai])}if(ai>=al.fields.length){throw ("Too many field definitions ("+(ai+1)+"). Line "+aq.line())}ao=al.fields[ai];ao.required=ap==="+"||ap==="X";ao.immutable=ap==="x"||ap==="X";ao.dataName=an.pull();if((ah=an.pull())){var am=[];var h=function(av,aw){var au=am.length;am[au]=aw;return'"'+au+'"'};var ar=function(av,au){return am[1*au]};ah=ah.replace(/"([^"]*)"/g,h).replace(/'([^']*)'/g,h);ah=ah.split(/\s*;\s*/);for(var ag=0;ag<ah.length;ag++){var af=ah[ag].split(/\s*:\s*/);if(af.length>2){throw ("Messed up definition. Line "+aq.line())}if(af[0]!="validate"&&!ao.aDefs[af[0]]){continue}if(af.length==1){ao[af[0]]=true}else{ao[af[0]]=af[1].replace(/"(\d+)"/g,ar)}}}ao.validate=ao.validate?ao.validate.split(/,\s*/):[];if(ao.max){ao.validate.unshift("MAXLENGTH")}if(ao.required){ao.validate.unshift("REQUIRED")}ao.validate=ao.validate.length?ao.validate.join(","):false;ai++}if(ai!=al.fields.length){throw ("Not enough field definitions ("+ai+" for "+al.fields.length+"). Line "+aq.line())}return al};var B=function(h,af){var ag=h?h.slice(0):[];if(af||af===0){Array.prototype.push.apply(ag,String(af).split("."))}return ag};var b=function(h){return h.join(".")};var aa=function(h){return h.replace(/[\[\]]+$/,"").split(/[\[\]]+/)};var y=function(ag,h){ag=B(ag,h);var ah=ag.shift();for(var af=0;af<ag.length;af++){ah+=("["+ag[af]+"]")}return ah};var e=(function(){var h=0;return function(){return"Kid"+(h++)}})();var K=function(h,ah,af,ak){ak||(ak="");var aj=h||{};ah=B(ah,af);for(var ag=0;ag<ah.length;ag++){if(!aj.hasOwnProperty(ah[ag])){return ak}aj=aj[ah[ag]];var ai=typeof aj;if("undefined"==ai||"function"==ai||null===aj){return ak}if(!aj){return""}}return aj};var Q=function(h,af){if(self.Kafoof.constants[af]){return self.Kafoof.constants[af]()}return h.vars[af.replace(/^\$/,"")]||[]};var N=function(h,af){if((h.type!="fieldset"&&h.required&&h.label)||(h.type=="fieldset"&&h.fields.length==1&&h.fields[0].required&&!h.fields[0].label)){return af+'<b class="K-required">'+self.Kafoof.requiredText+"</b>"}return af};var g=function(ak,ai,al,ah){var ag=0,h,aj='<div class="K-error-container"></div>';for(var af=0;af<ak.length;af++){h=ak[af];aj+=h.render({width:d(h.width,ai.width),"margin-left":d(h.left-ag,ai.width)},ah,al);ag=h.left+h.width}return T("div",{c:"K-row"+(ak.isLast?" K-row-last":"")},aj)};var C=function(ag,af,ak){var aj="";for(var h=0;h<ag.rows.length;h++){var ai=ag.rows[h];ai.isLast=(h==ag.rows.length-1);aj+=g(ai,ag,ak,af)}if(ag.fields.hidden){var ah=ag.fields.hidden;for(h=0;h<ah.length;h++){aj+=ah[h].render(null,af,ak)}}return aj};var s=function(af,h,ag){if(!ag){ag=[]}return T("div",{c:"K-fieldset-wrap"},T("fieldset",{c:"K-fieldset"+(af.name?" K-name-"+af.name.replace(/^@/,""):"")},(af.title?T("legend",{},T("span",{c:"K-legend-span"},N(af,Z(af.title)))):"")+C(af,h,ag)))};t.prototype.render=function(af,ag,ai){var h={c:X()+" K-width K-text",style:m(af)};var ah=ab(ag,this.value,ai);return T("div",h,/^<(p|div)[ >]/.test(ah)?ah:'<p class="K-text">'+ah+"</p>")};D.prototype.render=function(h,af,ai){var ag=K(af.values,ai,this.dataName);var ah=e();return ag?T("input",{type:"hidden",name:y(ai,this.dataName),value:ag,id:ah},false):""};S.prototype.render=function(af,ah,al){var aj=K(ah.values,al,this.dataName,this["default"]);if(this.dateFormat){var ag=P(aj);if(ag){aj=ag.toFormattedString(this.dateFormat)}}var h={c:X(this.dataName)+" K-width K-width-label-"+this.labelPosition,style:m(af),"data-K-validate":this.validate};var ai={type:"text",c:"K-"+this.type,name:y(al,this.dataName),value:aj,id:ak,maxlength:(this.max?this.max:false),autocomplete:this["private"]?"off":false,"data-date-format":this.dateFormat?this.dateFormat:false};var ak=e();return T("div",h,T("label",{"for":ak},N(this,Z(this.label)))+'<span class="K-border">'+T("input",ai,false)+"</span>")};F.prototype.render=function(af,ag,ai){var h={c:X(this.dataName)+" K-width K-width-label-"+this.labelPosition,style:m(af),"data-K-validate":this.validate};var ah=e();return T("div",h,T("label",{"for":ah},N(this,Z(this.label)))+'<span class="K-border">'+T("input",{type:"password",c:"K-"+this.type,name:y(ai,this.dataName),id:ah,autocomplete:this["private"]?"off":false},false)+"</span>")};V.prototype.render=G.prototype.render=function(af,ag,ai){if(!this.options){this.options=Q(ag,this.from||this.dataName)}var ah="";if(this["default"]&&this["default"].length){ah=this.options.length==1?1:this["default"]}var h=K(ag.values,ai,this.dataName,ah);h=h?[h]:[];return T("div",{c:X(this.dataName)+" K-width",style:m(af),"data-K-validate":this.validate},T("fieldset",{c:"K-fieldset K-boxset"},(this.label?T("legend",{},N(this,Z(this.label))):"")+'<div class="K-cols-wrap">'+M.prototype.renderColumns.call(this,h,ai)+"</div>"))};f.prototype.render=ae.prototype.render=function(af,ag,ai){if(!this.options){this.options=Q(ag,this.from||this.dataName)}var ah="";if(this["default"]&&this["default"].length){ah=this.options.length==1?1:this["default"]}var h=K(ag.values,ai,this.dataName,ah)||[];if(!A.isArray(h)){h=[h]}if(h.length==1&&this.options.length==1&&h[0]=="0"){h=[]}return T("div",{c:X(this.dataName)+" K-width",style:m(af),"data-K-validate":this.validate},T("fieldset",{c:"K-fieldset K-boxset"},(this.label?T("legend",{},N(this,Z(this.label))):"")+'<div class="K-cols-wrap">'+M.prototype.renderColumns.call(this,h,ai)+"</div>"))};M.prototype.render=function(af,ag,ah){if(!this.options){this.options=Q(ag,this.from||this.dataName)}var h=K(ag.values,ah,this.dataName)||[];h.push({add:true});return T("div",{c:X(this.dataName)+" K-width",style:m(af),"data-K-validate":this.validate},T("fieldset",{c:"K-fieldset K-boxset"},(this.label?T("legend",{},N(this,Z(this.label))):"")+'<div class="K-cols-wrap">'+this.renderColumns(h,ah)+"</div>"))};var q=function(h,af){return function(al){var ak,ah=al;while((ah=ah.parentNode)&&!/K-cols-wrap/.exec(ah.className)){}var ag=ah.getElementsByTagName("input");var aj=[],ai;for(ak=0;ak<ag.length;ak++){ai=ag[ak];if("checkbox"==ai.type){if(ai.checked){aj.push(ai.value)}}else{if("text"==ai.type){if(ai.value){aj.push(ai.value)}}}}ag=ai=al=null;aj.push("",{add:true});ah.innerHTML=h.renderColumns(aj,af);ag=ah.getElementsByTagName("input");setTimeout(function(){for(var am=0;am<ag.length;am++){if("text"==ag[am].type&&!ag[am].value){ag[am].focus()}}},10);return false}};M.prototype.renderColumns=function(ar,ah){var al="";if(!this.cols){alert("0 cols not yet implemented for boxes");this.cols=1}if(!Kafoof.extern.boxesExpand){Kafoof.extern.boxesExpand=function(au){if(!au){au=this}var av=au.parentNode.parentNode.parentNode;if(au.checked){A(">div.K-boxes-sub",av).show().each(function(){A(">label>span",this).children("input:checkbox, input:radio").removeAttr("disabled");A(">div.K-boxes-group>label>span",this).children("input:checkbox, input:radio").removeAttr("disabled").each(Kafoof.extern.boxesExpand)})}else{A(">div.K-boxes-sub",av).hide().find("input:checkbox, input:radio").attr("disabled","disabled")}}}var h=y(ah,this.dataName)+(this.inputType=="radio"||(this.options.length==1&&this.inline)?"":"[]");var ai=[];var at={},aq,af,ap,ao=false;var an=this;var aj=function(aF,aC,aw){var aD=[],aA=false,aB=null,au;for(var ax=0;ax<aF.length;ax++){aA=false;var aE=aF[ax];if(!aE){continue}au=e();if(!aC&&aF.length==1&&!aE.value&&an.inline){aE={title:aE,value:"1"};aB="1";aA=ar.length>0;al+=T("input",{type:"hidden",name:h,value:0});ao="K-boxes-solo"}else{aB=A.isPlainObject(aE)?(typeof aE.value==="undefined"?false:aE.value):aE;if(aB!==false){aA=(ar.indexOf(aB)!==-1);at[aB]=true}}aw||(aw={});aw.active=aA||(aC>0&&aw.active);var az=aE.sub&&A.isArray(aE.sub);var av=az?aj(aE.sub,aC+1,aw):null;var ay=T("label",{"for":au,c:ao},T("span",{c:"K-boxes"},T("input",{type:an.inputType,value:aB,id:au,name:(aB===false&&an.inputType!="radio")?false:h,checked:aA||((aB===false)&&aw.active),disabled:!!aC&&!aw.active,onclick:az?"Kafoof.extern.boxesExpand(this);":""}))+T("span",{title:aE.desc||false},Z(aE.title||aB)));if(az){aD.push(T("div",{c:"K-boxes-group"},ay+T("div",{c:"K-boxes-sub",style:aw.active?false:"display:none"},av.join(""))))}else{if(aB!==false){aD.push(ay)}}}return aD};var ai=aj(this.options,0);if(M==this.constructor){for(var ag=0;ag<ar.length;ag++){aq=ar[ag];af=e();if(aq.add){var ak=e();self.Kafoof.extern[ak]=q(this,ah);ai.push(T("label",{},T("a",{c:"K-add",href:"#",onclick:"return Kafoof.extern['"+ak+"'](this);"},this.newprompt||"Add another...")))}else{if(!at[aq]){ai.push(T("label",{"for":af,c:"K-label-box-plus"},T("input",{c:"K-textfield K-textfield-plus",value:aq,id:af,name:h},false)))}}}}var am=I(ai,this.cols);for(i=0;i<am.length;i++){al+=T("div",{c:"K-boxes-col K-width K-col-"+(i+1),style:"width:"+d(1/this.cols)+(i===0?";clear:left":"")},am[i].join(""))}return al};var o=function(af){var h=null;if("input"==af.tagName.toLowerCase()){h=af}while(af&&!af.className.match(/K-cols-wrap/)){af=af.parentNode}setTimeout(function(){if(!af){throw"Hey, what happened to the container?"}A("a.K-add",af).focus()},10)};c.prototype.render=function(h,af,ag){return C(af.subroutines[this.toImport]||af.routines[this.toImport],af,B(ag,this.dataName))};v.prototype.render=function(h,af,ag){return s(af.subroutines[this.toInclude]||af.routines[this.toInclude],af,B(ag,this.dataName))};var j={};var W=function(af,h){A(af).children("div.K-multi-add")[h?"hide":"show"]("fast")};var n=function(af,h){return function(an,ai){var ag=A(an).parents("div.K-multi-set").first();var ak=ag.get(0);var aj=1*ag.attr("data-K-min")+ag.children("div.K-multi-item").length-1;var ah=B(aa(ag.attr("data-K-namePrefix")),aj);var am=document.createElement("div");var al=ak.getElementsByTagName("div");al=al[al.length-1];ak.insertBefore(am,al);am.className="K-multi-item";if(self.navigator.userAgent.match(/mobile/i)||(A.browser.msie&&parseInt(A.browser.version,10)<8)){am.innerHTML=af.renderItem(h,ah);if(!ai){A(am).find(":input").get(0).focus()}}else{am.style.display="none";am.innerHTML=af.renderItem(h,ah);A(am).slideDown("fast",function(){if(!ai){A(am).find(":input").get(0).focus()}})}if(ai){ai.item=am}W(ak,aj>=af.max);return false}};var u=function(ah){var af=A(ah);var aj=af.attr("data-K-namePrefix");var ag=1*af.attr("data-K-min");var h=1*af.attr("data-K-max");var ai=new RegExp("^("+aj.replace(/\[([^\]]+)\]/g,function(ak,al){if(al.match(/^[0-9]+$/)){return"\\[[0-9]+\\]"}return"\\["+al+"\\]"})+")\\[[0-9]+\\]","g");af.children("div.K-multi-item").each(function(){if(A(this).hasClass("K-multi-add")){return}A(":input",this).attr("name",function(ak,al){return al.replace(ai,"$1["+ag+"]")});A("div.K-multi-set, fieldset.K-multi-item",this).attr("data-K-namePrefix",function(ak,al){return al.replace(ai,"$1["+ag+"]")});++ag});W(ah,ag>h);af.trigger("kafoof-renumber")};R.prototype.render=function(ai,ah,al){var an=B([],this.dataName);var ag=/^\[([0-9]+)-([0-9]*)\]$/.exec(an.pop());if(!ag){throw'MultiInclude data name "'+this.dataName+"\" doesn't include a valid range"}this.min=1*ag[1];this.max=ag[2]?1*ag[2]:100;this.dataSetName=b(an);var h=e();self.Kafoof.extern[h]=j[this.dataSetName]=n(this,{routines:ah.routines,subroutines:ah.subroutines,values:{},vars:ah.vars});var am="",af;var ak=K(ah.values,al,this.dataSetName);if(ak&&ak.length){for(af=this.min;af<ak.length;af++){am+='<div class="K-multi-item">'+this.renderItem(ah,B(al,this.dataSetName+"."+af))+"</div>"}}var aj=(af>this.max);var ao={c:X(this.dataName)+" K-width",style:m(ai),"data-K-validate":this.validate};if(this.label){ao.c+=" K-width-label-"+this.labelPosition}return T("div",ao,(this.label?T("label",{},N(this,Z(this.label))):"")+'<div class="K-multi-wrap">'+T("div",{c:"K-multi-set"+(aj?" K-multi-full":""),"data-K-min":this.min,"data-K-max":this.max,"data-K-namePrefix":y(al,this.dataSetName)},am+T("div",{c:"K-multi-item K-multi-add",style:aj?"display:none":false},T("p",{},T("a",{c:"K-add-link-"+this.dataSetName,href:"#",onclick:"return Kafoof.extern['"+h+"'](this);"},this.newprompt||"Add another..."))))+"</div>")};R.prototype.renderItem=function(af,ag){var h="return Kafoof.extern.delMulti(this)";return T("fieldset",{c:"K-fieldset K-multi-item K-name-"+this.toInclude.replace(/^@/,""),"data-K-title":this.title?this.title:false,"data-K-namePrefix":y(ag),"data-K-defaultTitle":this.includeTitle||false},T("legend",{},T("span",{c:"K-legend-span"},this.includeTitle?this.includeTitle:"&nbsp;"))+T("a",{c:"K-multi-del",href:"#",onclick:h},this.delprompt||"Remove")+C(af.subroutines[this.toInclude]||af.routines[this.toInclude],af,ag))};a.prototype.render=l.prototype.render=function(ai,ah,aj){var ak=T("option",{value:""},this.prompt||"...");var al=this.value?this.value:K(ah.values,aj,this.dataName);if(!this.options&&!this.from){throw"'from' not set on select field named "+this.dataName}var ap=this.options?this.options:Q(ah,this.from||this.dataName);var am,ao,ag,an,h=e(),af=false;for(ag=0;ag<ap.length;ag++){ao=ap[ag];am=ao.value||ao;af=af||al==am;ak+=T("option",{value:am,selected:al==am,title:ao.desc||false},ao.title||am)}if(this.type=="selectplus"){if(!af&&al){ak+=T("option",{value:al,selected:true},al)}ak+=T("option",{c:"K-selectplus-other",id:h+"-new"},this.newprompt||"Other...")}an={c:X(this.dataName)+" K-width K-width-label-"+this.labelPosition,style:m(ai),"data-K-validate":this.validate};return T("div",an,T("label",{"for":h},N(this,Z(this.label)))+'<span class="K-border K-border-select">'+T("select",{c:"K-select"+(this.type=="selectplus"?" K-selectplus":""),name:y(aj,this.dataName),id:h},ak)+(this.type=="selectplus"?T("input",{c:"K-textfield K-textfield-other",id:h+"-other",style:"display:none"}):"")+"</span>")};H.prototype.render=function(af,ag,aj){var ah=K(ag.values,aj,this.dataName);var h={c:X(this.dataName)+" K-width K-width-label-"+this.labelPosition,style:m(af),"data-K-validate":this.validate};var ai=e();return T("div",h,T("label",{"for":ai},N(this,Z(this.label)))+'<span class="K-border">'+T("textarea",{rows:this.rows,cols:40,c:"K-"+this.type+(this.monospace?" K-"+this.type+"-mono":""),name:y(aj,this.dataName),id:ai},Z(ah))+"</span>")};r.prototype.render=function(ah,ai,ak){var h=[];for(var ag=0;ag<this.military.length;ag++){h.push({value:this.military[ag].replace("mm","00"),title:this[this.hourSet][ag].replace("mm","00")});if(!this.minuteIncrement){continue}var af=0;while((af+=this.minuteIncrement)<60){var aj=(af<10)?"0"+af:""+af;h.push({value:this.military[ag].replace("mm",aj),title:this[this.hourSet][ag].replace("mm",aj)})}}this.options=h;return l.prototype.render.apply(this,arguments)};var O=function(aj){var ai=this;ai.routines=[];ai.subroutines=[];ai.vars=null;ai.values=null;var af=new LB.Delayed();var ak=function(ap){if(!ap){if(self.console){console.log("No definitions found in "+aj)}af.play();return false}try{var al=new z(ap),am,an;while((am=L(al))){am.kobj=ai;an=ai[am.sub?"subroutines":"routines"];if(am.title){an[am.title]=am}if(am.name){an[am.name]=am}an.push(am)}}catch(ao){if(self.console){console.log("Kafoof: "+ao)}throw (ao)}if(self.console){console.log(ah.getDefinition())}af.play()};var ag=function(am,an){var al=function(ap){if(!this.Ktitle){this.Ktitle=A(this).attr("data-K-title")}if(!this.Ktitle){return true}if(!this.KdefaultTitle){this.KdefaultTitle=A(this).attr("data-K-defaultTitle")||"&nbsp;"}var ar=A(this).attr("data-K-namePrefix");var ao=false;var aq=this.Ktitle.replace(/\(([^\)]+)\)/,function(au,at){var ax=ar+"["+at.split(".").join("][")+"]";var av=":text[name='"+ax+"'], textarea[name='"+ax+"'], select[name='"+ax+"']>option:selected, :radio[name='"+ax+"']:checked";var aw=A(av).val();if(aw){ao=true}return aw||""});aq=Z(ao?Z(aq):this.KdefaultTitle);if(!this.KprevTitle||this.KprevTitle!=aq){A("legend>span",this).first().html(aq)}this.KprevTitle=aq;return true};A(am).html(an).delegate("select.K-selectplus","change click keypress",function(at){if(this.selectedIndex!=this.options.length-1){return true}var ao,ap,au,aq,ar;ao=this;ap=this.parentNode.getElementsByTagName("input")[0];au=function(){ao.style.display="none";ap.style.display="";ap.focus();A(ap).bind("blur",ar)};aq=function(){A(ap).unbind("blur",ar);ap.style.display="none";ao.style.display=""};ar=function(ax){if(!this.value){ao.selectedIndex=0}else{var aw=false;for(var av=0;av<ao.options.length;av++){if(ao.options[av].value==this.value){aw=true;ao.selectedIndex=av;break}}if(!aw){A("#"+this.id.replace(/-other/,"-new")).before(A("<option />").text(this.value).attr("value",this.value));ao.selectedIndex=ao.options.length-2}}aq()};au()}).delegate("input, textarea, select","focus",function(ao){A(this).parents("div.K-boxes-col label, div.K-width").first().addClass("K-focus")}).delegate("input, textarea, select","blur",function(ao){A(this).parents("div.K-boxes-col label, div.K-width").first().removeClass("K-focus")}).delegate("input.K-textfield-plus","blur",function(ao){if(!this.value){this.parentNode.parentNode.removeChild(this.parentNode)}}).delegate("input.K-textfield","keypress",function(aq){if(13==aq.which){var ao=(this.id.indexOf("-other")!=-1);var ap=("undefined"!=(typeof A(this).closest("form").data("enterSubmit")));if(ao||!ap){aq.preventDefault()}if(ao){A(this).blur()}}}).delegate("input.K-textfield-plus","keypress",function(ao){if(13==ao.which){o(this);ao.preventDefault()}}).delegate("input.K-textfield-plus","keydown",function(ao){if(27==ao.which||(8==ao.which&&!this.value)){o(this);ao.preventDefault()}}).delegate("fieldset.K-multi-item","blur",al).find("fieldset.K-multi-item").each(al).end()};var h=[];var ah={vars:function(al){ai.vars=al;return ah},values:function(al){ai.values=al;return ah},getDefinition:function(){return{routines:ai.routines,subroutines:ai.subroutines}},addMulti:function(am){var al=[];A(h.join(", ")).find(".K-add-link-"+am).each(function(){var an={};j[am](this,an);if(an.item){al.push(an.item)}});return A(al)},interpolate:function(al){return ab(ai,al)}};ah.serializeDefinition=af.wrap(ah,function(an){var am=this.getDefinition();var al=function(ao,ap){delete ap.kobj};if(am.routines){A.each(am.routines,al)}if(am.subroutines){A.each(am.subroutines,al)}A(an).val(JSON.stringify(am))});ah.render=af.wrap(ah,function(al,am){if(!am&&typeof al=="function"){am=al;al=null}al||(al=aj);A(function(){var ao="";for(var an=0;an<ai.routines.length;an++){ao+=s(ai.routines[an],ai)}h.push(al);ag(al,ao);if(am){A(al).each(function(){am.call(this,ah)})}})});ah.renderFieldset=af.wrap(ah,function(al,am,an){if(!an&&typeof am=="function"){an=am;am=null}am||(am=aj);A(function(){var ao=ai.routines[al]||ai.subroutines[al];if(!ao){throw"Fieldset with name or title '"+al+"' not found."+(ai.routines["@"+al]?" Maybe you meant '"+("@"+al)+"'?":"")}h.push(am);ag(am,s(ao,ai));if(an){A(am).each(function(){an.call(this,ah)})}})});if(/^\s*--/.test(aj)){ak(aj)}else{if(aj.find||/^[#\.]/.test(aj)){A(function(){ak(A(aj).find("textarea").val())})}else{A.get(aj,function(am,al,an){ak(an.responseText)})}}return ah};var Y={load:function(ag,af,h){return(new O(ag)).vars(af).values(h)},getListBuilder:function(af){var h=null;return function(){if(h){return h}var ag=af.split(";");var ah=[];for(var ai=0;ai<ag.length;ai++){var aj={};var ak=ag[ai].split(":");aj.value=ak[0];if(ak[1]){aj.title=ak[1]}if(ak[2]){aj.desc=ak[2]}ah[ai]=aj}af=null;return(h=ah)}},extern:{delMulti:function(h){A(h).parents("div.K-multi-item").first().each(function(){var af=A(this).parents("div.K-multi-set").get(0);if(self.navigator.userAgent.match(/mobile/i)){this.parentNode.removeChild(this);u(af)}else{A(this).slideUp("fast",function(){this.parentNode.removeChild(this);u(af)})}});return false}},util:{h:Z,innerText:ad,isHtmlObj:function(ag){var af=false;for(var h in ag){if(!ag.hasOwnProperty(h)){continue}if(h!="html"){return false}if("string"==typeof ag[h]){af=true}}return af},focus:function(h){A(":input",h||this).first().focus()}}};return Y})(jQuery);self.Kafoof.percentFudge=99.9;self.Kafoof.requiredText="*";self.Kafoof.constants={STATES:self.Kafoof.getListBuilder("AA:Armed Forces Americas;AE:Armed Forces Europe;AK:Alaska;AL:Alabama;AP:Armed Forces Pacific;AR:Arkansas;AS:American Samoa;AZ:Arizona;CA:California;CO:Colorado;CT:Connecticut;DC:District of Columbia;DE:Delaware;FL:Florida;FM:Federated Micronesia;GA:Georgia;GU:Guam;HI:Hawaii;IA:Iowa;ID:Idaho;IL:Illinois;IN:Indiana;KS:Kansas;KY:Kentucky;LA:Louisiana;MA:Massachusetts;MD:Maryland;ME:Maine;MH:Marshall Islands;MI:Michigan;MN:Minnesota;MO:Missouri;MP:N. Mariana Islands;MS:Mississippi;MT:Montana;NC:North Carolina;ND:North Dakota;NE:Nebraska;NH:New Hampshire;NJ:New Jersey;NM:New Mexico;NV:Nevada;NY:New York;OH:Ohio;OK:Oklahoma;OR:Oregon;PA:Pennsylvania;PR:Puerto Rico;PW:Palau;RI:Rhode Island;SC:South Carolina;SD:South Dakota;TN:Tennessee;TX:Texas;UT:Utah;VA:Virginia;VI:US Virgin Islands;VT:Vermont;WA:Washington;WI:Wisconsin;WV:West Virginia;WY:Wyoming"),CC_MONTHS:function(){return["01","02","03","04","05","06","07","08","09","10","11","12"]},CC_YEARS:function(){var a=(new Date()).getFullYear(),b=-1,c=[];while(++b<10){c.push(a+b)}return c},EMPTY_SET:function(){return[]}};if(!Array.prototype.indexOf){Array.prototype.indexOf=function(b){var a=this.length;var c=Number(arguments[1])||0;c=(c<0)?Math.ceil(c):Math.floor(c);if(c<0){c+=a}for(;c<a;c++){if(c in this&&this[c]===b){return c}}return -1}}self.Kafoof.validate=(function(a){return function(g,e){if(g&&!e&&typeof g!="string"){e=g;g=null}if(!g){g="form"}if(!e){e={}}if(!e.tests){e.tests=e.methods||{}}var c=function(l,k){var j="K-err K-err-"+(/(^| )Kn-(\S+)/.exec(a("#"+l).parents("div.K-width").attr("class"))||[0,0,""])[2];return'<div class="'+j+'" onclick="document.getElementById(\''+l+"').focus()\">"+Kafoof.util.h(k)+"</div>"};var b=function(l){var j={};var k=function(q,n){var m,p,o;for(m in q){p=n?n+"["+m+"]":m;if(("string"==typeof q[m])||Kafoof.util.isHtmlObj(q[m])){j[p]=q[m]}else{if("object"==typeof q[m]){k(q[m],p)}}}};k(l);return j};var h=function(m){var k,l,j;m=b(m);for(l in m){k=a('[name="'+l+'"]',this).get(0);if(!k){continue}j=a(k).parents("div.K-row").children("div.K-error-container").first();if(!j.find("div.K-errors").get(0)){j.html('<div class="K-errors"></div>')}j.find("div.K-errors").html(j.find("div.K-errors").html()+c(k.id,m[l]));j.css("display","block")}};var d=function(l){l||(l={});var k=b(l.errors||{});var m=null;var j=null;a(this).find("div.K-row").filter(":visible").each(function(){var n=a(this);var t=n.find("div.K-error-container").first();var u=[];n.find(">div.K-width").filter(":visible").each(function(){$width=a(this);var B=$width.attr("data-K-validate");if(!B){return}B=B.split(/,/);var w=$width.children("label").get(0)||$width.children("fieldset").children("legend").get(0);if(!w&&$width.find("input[type=checkbox]").length==1){w=$width.find("label").get(0)}if(!w&&$width.closest("fieldset.K-fieldset").filter(function(){a(this).find("div.K-row>div.K-width").filter(function(){return a(this).find("p.K-text").length==0}).length==1})){w=$width.closest("fieldset.K-fieldset").children("legend").get(0)}w=Kafoof.util.innerText(w);if(B[0]=="REQUIRED"){w=w.substr(0,w.length-Kafoof.requiredText.length)}var z=$width.find(":text[name], :password[name], textarea[name], select[name]>option:selected, :checked[name]").filter(":enabled").val();var v={},C;var y=$width.find(">div.K-multi-wrap>div.K-multi-set").get(0)||$width.find(":input[id]").get(0);while((!v.error||v["continue"])&&(C=B.pop())){var x=e.tests[C]||self.Kafoof.validate.tests[C];v=x?x.call(y,z||"",w):{error:"No validate method '"+C+"' for "+w};if(v.error){u.push({msg:v.error,fid:(y?y.id:null)})}if(v.value||v.value===""){if(y.tagName.toUpperCase()!="DIV"){z=v.value;$width.find(":text, :password, textarea").filter(":enabled").first().val(z)}}}if(y&&(!v.error||v["continue"])){var A=k[y.name.replace("/[\d+]$","")]||null;if(A){u.push({msg:A,fid:y.id})}}});var o;if((o=n.find(">div.K-width>span>:password").filter(":visible").last().get(0))){var r=o.form.elements[o.name];if(r&&r.length==2&&r[1]==o&&r[0].value!=r[1].value){u.push({msg:"Password fields must match.",fid:o.id})}}var q="";for(var p=0;p<u.length;p++){var s=u[p];if(s.fid&&!m){m=s.fid}q+=c(s.fid,s.msg)}t.html(q?'<div class="K-errors">'+q+"</div>":"").css("display",q?"block":"none");if(q&&!j){j=t}});if(j){a(window).scrollTop(j.offset().top-5)}if(m){document.getElementById(m).focus()}if(e.callback){e.callback.call(this,!m)}return !j&&!m};a(function(){a(g).bind("submit",d);if(e.errors){a(g).each(function(){var j=this;a(function(){h.call(j,e.errors)})})}});var f={run:function(j){var k=true;a(g).each(function(){k=d.call(this,j)&&k});return k},disable:function(){a(g).unbind("submit",d)},enable:function(){f.disable();a(g).bind("submit",d)},displayErrors:function(j){a(g).each(function(){h.call(this,j)})}};return f}})(jQuery);self.Kafoof.validate.rxTest=function(b,a){return function(d,c){if(!d||b.test(d)){return{value:null}}return{error:a.replace("%s",c)}}};self.Kafoof.validate.tests={REQUIRED:function(b,a){if(this.tagName.toUpperCase()=="DIV"){if(!$(this).find("fieldset").length){return{error:(a||"Set")+" must not be empty."}}return{value:null}}if(!b){return{error:a+" is required."}}return{value:null}},MAXLENGTH:function(c,b){var a=$(this).attr("maxlength");if(!a||c.length<=1*a){return{value:null}}else{return{error:b+" cannot be longer than "+a+" characters."}}},ALPHA:Kafoof.validate.rxTest(/^[a-zA-Z]+$/,"%s may only contain letters."),NUM:Kafoof.validate.rxTest(/^\d+$/,"%s may only contain numbers."),ALPHANUM:Kafoof.validate.rxTest(/^[a-zA-Z\d]+$/,"%s may only contain letters and numbers."),EMAIL:Kafoof.validate.rxTest(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i,"%s must be a valid email address."),TIN:function(b,a){if(b){var c=b.replace(/\D+/g,"");if(!/^[\s-]*(\d[\s-]*){9}$/.test(b)){return{error:a+" must contain nine digits with optional dash seperators."}}if("123456789"==c||/^(\d)\1{8}$/.test(c)){return{error:a+" is not valid."}}}return{value:b.replace(/\s+/g,"").replace(/\-+/g,"-")}},CREDIT_CARD:function(b,a){var c=function c(d){d=d.split("").reverse();var f=0,e;for(e=0;e<d.length;e++){d[e]=1*d[e];f+=e%2?2*d[e]-(d[e]>4?9:0):d[e]}return(f%10)==0};b=b.replace(/\D+/g,"");if(b){if(b.length>16){return{error:a+" should be no more than 16 digits long.",value:b}}if(b.length<13){return{error:a+" should contain no fewer than 13 digits.",value:b}}if(!c(b)){return{error:"Please double-check your card number.",value:b}}}return{value:b}},DOLLARS:function(b,a){if(b&&!/^\$?(\.[0-9]{2}|[0-9]+(,[0-9]{3})*(\.[0-9]{1,2})?)$/.test(b)){return{error:a+" must be a dollar amount like 1,000 or 500.00."}}return{value:null}},NA_PHONE:function(c,a){if(!c){return{value:null}}var b=c?c.replace(/\D/g,"").replace(/^[01]+/,""):"";if(b.length!=10){return{error:a+" should be in 10 digit format."}}return{value:b.substr(0,3)+"-"+b.substr(3,3)+"-"+b.substr(6)}},NA_POSTCODE:function(b,a){var c;if(!b||/^[0-9]{5}([ \-+]?[0-9]{4})?$/.test(b)){return{value:b.replace(/[ +]/,"-")}}else{if(c=/^([a-z]\d[a-z]) ?(\d[a-z]\d)$/i.exec(b)){return{value:(c[1]+" "+c[2]).toUpperCase()}}else{return{error:a+" must be a valid U.S. ZIP code or Canadian postal code."}}}},ZIPCODE:function(b,a){if(b&&!/^[0-9]{5}([ \-+]?[0-9]{4})?$/.test(b)){return{error:a+" must be a valid U.S. ZIP code like 23456 or 23456-1234."}}return{value:b.replace(/[ +]/,"-")}},WEB:function(c,a){if(!c){return{value:null}}var b={error:a+" must be a valid web address."};var e={proto:/^(https?)[:\/]{1,5}/i,domain:/^(?:[a-z0-9\-]+\.)+[a-z0-9\-]{2,6}/i,port:/^:[1-9][0-9]*/},d={};d.proto=(e.proto.exec(c)||["","http"])[1].toLowerCase();c=c.replace(e.proto,"");d.domain=(e.domain.exec(c)||[""])[0].toLowerCase();if(!d.domain){return b}c=c.replace(e.domain,"");d.port=(e.port.exec(c)||[""])[0];c=c.replace(e.port,"");d.path=c||"/";if(d.path&&!/^[#?\/]/.test(d.path)){return b}return{value:d.proto+"://"+d.domain+d.port+d.path}},RECENT_YEAR:function(c,a){if(!c){return{value:null}}var b={error:a+" must be a recent four-digit year."};if(!/^(19|20)?\d{2}$/.test(c)){return b}if(/^[789]\d$/.test(c)){c="19"+c}else{if(2000+parseInt(c,10)<=(new Date()).getFullYear()){c=""+(2000+parseInt(c,10))}}if(!/^\d{4}$/.test(c)){return b}if(parseInt(c,10)>(new Date()).getFullYear()){return{error:a+" must be in the past."}}return{value:c}},"YYYY-MM-DD":function(c,a){var b;if(!c){return{}}if(!(b=/^(\d{4})[.\-\/](\d{1,2})[.\-\/](\d{1,2})$/.exec(c))){return{error:a+" must be a date in YYYY-MM-DD format."}}return{value:(b[1]+"-0"+b[2]+"-0"+b[3]).replace(/-0(\d\d)/g,"-$1")}}};
View
98 www/lib/KafoofPreview.php
@@ -0,0 +1,98 @@
+<?php
+class KafoofPreview {
+ protected $definition, $post;
+ public function __construct($post,$definition=null) {
+ if(!$definition && !empty($post['form-definition'])) $definition = $post['form-definition'];
+ $this->definition = is_string($definition) ? json_decode($definition) : $definition;
+ $this->post = $post;
+ }
+ public function sections($post=null){
+ if(!$post) $post = $this->post;
+ if(!$this->definition) return "<p><b>Error:</b> Unable to render form preview.</p>";
+ $def = unserialize(serialize($this->definition));
+ $filled = array();
+ $all = array_merge($def->routines,$def->subroutines);
+ foreach($def->routines as $section) {
+ $filled[] = $this->processSection($section,$post,$all);
+ }
+ return $filled;
+ }
+ protected function processSection($section,$context,$all) {
+ $sout = new \stdClass();
+ if(!empty($section->title)) $sout->title = $section->title;
+ $sout->rows = array();
+ $width = $section->width;
+ foreach($section->rows as $i=>$row){
+ $rrow = array_reverse($row);
+ $r = array();
+ $left = $width;
+ foreach($rrow as $field){
+ # TODO: branch for text, multi, include
+ $f = new \stdClass();
+ $f->width = sprintf('%.4F%%',$field->width/$width*100);
+ if($field->left+$field->width < $left) {
+ $f->pad = sprintf('%.4F%%',($left-$field->left-$field->width)/$width*100);
+ }
+ $left = $field->left;
+ if('text'==$field->type) {
+ $f->type = 'text';
+ $f->value = strpos($field->value,'}}')===false ? $field->value : '';
+ } elseif('import'==$field->type) {
+ $values = $this->getValue($field->dataName,$context);
+ $values = $values ? array($values) : array(array());
+ $moreRows = $this->subSection($field->toImport,$values,$all);
+ $sout->rows = array_merge($sout->rows,$moreRows[0]->rows);
+ break;
+ } elseif('include'==$field->type || 'multiinclude'==$field->type) {
+ $f->type = 'include';
+ $f->label = empty($field->label) ? null : $field->label;
+ $values = $this->getValue($field->dataName,$context);
+ if('include'==$field->type) $values = array($values);
+ $f->sets = $this->subSection($field->toInclude,$values,$all);
+ } else {
+ $f->type = 'field';
+ $f->label = $field->label;
+ $f->value = $this->getValue($field->dataName,$context);
+ if(is_array($f->value)) $f->value = implode(', ',$f->value);
+ }
+ $r[] = $f;
+ }
+ if($r){ // should always be $r, except for <<import>>
+ if($row[0]->left > 0) {
+ $f = new \stdClass();
+ $f->type = 'space';
+ $f->width = sprintf('%.4F%%',$row[0]->left/$width*100);
+ $r[] = $f;
+ }
+ $r = array_reverse($r);
+ $sout->rows[] = $r;
+ }
+ }
+ return $sout;
+ }
+ protected function subSection($name,$values,$all) {
+ foreach($all as $section) if($name==$section->name) break;
+ if($section->name != $name) return null;
+ $out = array();
+ foreach($values as $i=>$context){
+ $out[$i] = $this->processSection($section,$context,$all);
+ }
+ return $out;
+ }
+ protected function getValue($dataName,$context) {
+ $parts = explode('.',$dataName);
+ foreach($parts as $part){
+ if(preg_match('#^\[(\d+)-(\d+)\]$#',$part,$matches)) {
+ $output = array();
+ for($i = (int)$matches[1]; $i <= (int)$matches[2]; $i++){
+ if(isset($context[$i])) $output[$i] = $context[$i];
+ else return $output;
+ }
+ }
+ if(is_numeric($part)) $part = (int)$part;
+ if(empty($context[$part])) return null;
+ $context = $context[$part];
+ }
+ return $context;
+ }
+}
View
86 www/lib/SimpleEmail.php
@@ -0,0 +1,86 @@
+<?php
+class SimpleTemplate
+{
+ var $data, $str;
+ function __construct($path=null,$data=null)
+ {
+ $this->data = $data;
+ if($path)
+ {
+ if($path{0}!='/') $path = $_SERVER['DOCUMENT_ROOT'] . '/' . $path;
+ if(!($this->str = file_get_contents($path))) user_error("SimpleTemplate couldn't find file: $path",E_ERROR);
+ }
+ }
+
+ function render($data = null, $str = '')
+ {
+ if($data) $this->data = $data;
+ if(!$str && $this->str) $str = $this->str;
+ return preg_replace_callback('/\{\{([\S]+?)\}\}/',array($this,'callback'),$str);
+ }
+
+ protected function callback($res)
+ {
+ $datum = empty($this->data[$res[1]]) ? '' : $this->data[$res[1]];
+ return is_array($datum) ? implode(', ',$datum) : $datum;
+ }
+}
+
+class SimpleEmail extends SimpleTemplate
+{
+ public $lastHeaders;
+ function send($data = null, $str = '')
+ {
+ if(!$data) $data = $this->data;
+ if(!$str) $str = $this->str;
+ $str = preg_split("/\r?\n\r?\n/", $str, 2);
+
+ // handle headers, preventing injection
+ $headers = $str[0];
+ $safedata = $data;
+ foreach($data as $key=>$val) if(is_string($val) && strpos($val,"\n")!==false) $safedata[$key] = '';
+ $headers = $this->render($safedata,$headers);
+ $headers = preg_split("/\r?\n/",$headers);
+ $headout = array();
+ $this->lastHeaders = array();
+ $to = $subject = '';
+ foreach($headers as $line)
+ {
+ $header = explode(":",$line,2);
+ if(strtolower($header[0])=='to') $to = $header[1];
+ elseif(strtolower($header[0])=='subject') $subject = $header[1];
+ else $headout[] = $line;
+ $this->lastHeaders[strtolower($header[0])] = trim($header[1]);
+ }
+ $body = $this->render($data,$str[1]);
+ if(empty($this->lastHeaders['message-id'])) {
+ $msgid = '<'.md5($to.$body).'@'.$_SERVER['HTTP_HOST'].'>';
+ $this->lastHeaders['message-id'] = $msgid;
+ $headout[] = "Message-ID: $msgid";
+ }
+ return mail($to,$subject,$body,implode("\r\n",$headout));
+ }
+}
+
+if (get_magic_quotes_gpc()) {
+ function undoMagicQuotes($array, $topLevel=true) {
+ $newArray = array();
+ foreach($array as $key => $value) {
+ if (!$topLevel) {
+ $key = stripslashes($key);
+ }
+ if (is_array($value)) {
+ $newArray[$key] = undoMagicQuotes($value, false);
+ }
+ else {
+ $newArray[$key] = stripslashes($value);
+ }
+ }
+ return $newArray;
+ }
+ $_GET = undoMagicQuotes($_GET);
+ $_POST = undoMagicQuotes($_POST);
+ $_COOKIE = undoMagicQuotes($_COOKIE);
+ $_REQUEST = undoMagicQuotes($_REQUEST);
+}
+?>
View
67 www/lib/preview_view.php
@@ -0,0 +1,67 @@
+<?php
+function h($str){
+ return htmlspecialchars($str);
+}
+function kafoof_section($s){
+ ?>
+<div style="margin-bottom:10px; border:solid 1px #ccc; -moz-border-radius:4px; border-radius:4px;">
+<table cellpadding="0" cellspacing="0" border="0" style="font-family:inherit;width:100%; max-width:900px;">
+ <? if(@$s->title): ?>
+ <tr><td colspan="3"><h3 style="font-family:inherit;margin:0;padding:0;"><?=h($s->title)?></h3></td></tr>
+ <tr><td colspan="3" style="font-family:inherit;height:7px; line-height:7px; font-size:5px;">&nbsp;</td></tr>
+ <? else: ?>
+ <tr><td colspan="3" style="font-family:inherit;height:10px; line-height:10px; font-size:5px;">&nbsp;</td></tr>
+ <? endif; ?>
+ <tr>
+ <td style="font-family:inherit;width:10px">&nbsp;</td>
+ <td>
+ <? foreach($s->rows as $row): ?>
+ <table cellpadding="0" cellspacing="0" border="0" style="font-family:inherit;width:100%;">
+ <thead>
+ <tr>
+ <? foreach($row as $f): ?>
+ <? if('text'==@$f->type): ?>
+ <td rowspan="2" style="font-family:inherit;font-weight:normal; text-align:left; vertical-align:top;">
+ <?=h(@$f->value)?>
+ </td>
+ <? else: ?>
+ <th colspan="<?=empty($f->pad) ? 1: 2 ?>" style="font-family:inherit;text-align:left; vertical-align:top; font-weight:normal">
+ <?=h(@$f->label)?>
+ </th>
+ <? endif; ?>
+ <? endforeach; ?>
+ </tr>
+ </thead>
+ <tbody>
+ <? $cols = 0 ?>
+ <tr>
+ <? foreach($row as $f): ?>
+ <? $cols++; ?>
+ <? if('text'==@$f->type): ?>
+ <? elseif('field'==@$f->type): ?>
+ <td style="font-family:inherit;text-align:left; vertical-align:top; font-weight:normal; color:#00438a;width:<?=h(@$f->width)?>;border-bottom:dotted 1px #aaa;">
+ <?=empty($f->value) ? '&nbsp;' : nl2br(h($f->value)) ?>
+ </td>
+ <? if(!empty($f->pad)): ?>
+ <? $cols++; ?>
+ <td style="font-family:inherit;width:<?=$f->pad?>"></td>
+ <? endif; ?>
+ <? elseif('include'==@$f->type): ?>
+ <td style="font-family:inherit;vertical-align:top">
+ <? foreach(@$f->sets as $sub) kafoof_section($sub); ?>
+ </td>
+ <? endif; ?>
+ <? endforeach; ?>
+ </tr>
+ <tr><td colspan="<?=$cols?>" style="font-family:inherit;height:10px; line-height:10px; font-size:5px;">&nbsp;</td></tr>
+ </tbody>
+ </table>
+ <? endforeach; ?>
+ </td>
+ <td style="font-family:inherit;width:10px">&nbsp;</td>
+ </tr>
+</table>
+</div>
+ <?php
+}
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.