/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

/**
 * jQuery.query - Query String Modification and Creation for jQuery
 * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
 * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
 * Date: 2009/8/13
 *
 * @author Blair Mitchelmore
 * @version 2.1.7
 *
 **/
new function(settings) {
  // Various Settings
  var $separator = settings.separator || '&';
  var $spaces = settings.spaces === false ? false : true;
  var $suffix = settings.suffix === false ? '' : '[]';
  var $prefix = settings.prefix === false ? false : true;
  var $hash = $prefix ? settings.hash === true ? "#" : "?" : "";
  var $numbers = settings.numbers === false ? false : true;

  jQuery.query = new function() {
    var is = function(o, t) {
      return o != undefined && o !== null && (!!t ? o.constructor == t : true);
    };
    var parse = function(path) {
      var m, rx = /\[([^[]*)\]/g, match = /^([^[]+)(\[.*\])?$/.exec(path), base = match[1], tokens = [];
      while (m = rx.exec(match[2])) tokens.push(m[1]);
      return [base, tokens];
    };
    var set = function(target, tokens, value) {
      var o, token = tokens.shift();
      if (typeof target != 'object') target = null;
      if (token === "") {
        if (!target) target = [];
        if (is(target, Array)) {
          target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
        } else if (is(target, Object)) {
          var i = 0;
          while (target[i++] != null);
          target[--i] = tokens.length == 0 ? value : set(target[i], tokens.slice(0), value);
        } else {
          target = [];
          target.push(tokens.length == 0 ? value : set(null, tokens.slice(0), value));
        }
      } else if (token && token.match(/^\s*[0-9]+\s*$/)) {
        var index = parseInt(token, 10);
        if (!target) target = [];
        target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
      } else if (token) {
        var index = token.replace(/^\s*|\s*$/g, "");
        if (!target) target = {};
        if (is(target, Array)) {
          var temp = {};
          for (var i = 0; i < target.length; ++i) {
            temp[i] = target[i];
          }
          target = temp;
        }
        target[index] = tokens.length == 0 ? value : set(target[index], tokens.slice(0), value);
      } else {
        return value;
      }
      return target;
    };

    var queryObject = function(a) {
      var self = this;
      self.keys = {};

      if (a.queryObject) {
        jQuery.each(a.get(), function(key, val) {
          self.SET(key, val);
        });
      } else {
        jQuery.each(arguments, function() {
          var q = "" + this;
          q = q.replace(/^[?#]/,''); // remove any leading ? || #
          q = q.replace(/[;&]$/,''); // remove any trailing & || ;
          if ($spaces) q = q.replace(/[+]/g,' '); // replace +'s with spaces

          jQuery.each(q.split(/[&;]/), function(){
            var key = decodeURIComponent(this.split('=')[0] || "");
            var val = decodeURIComponent(this.split('=')[1] || "");

            if (!key) return;

            if ($numbers) {
              if (/^[+-]?[0-9]+\.[0-9]*$/.test(val)) // simple float regex
                val = parseFloat(val);
              else if (/^[+-]?[0-9]+$/.test(val)) // simple int regex
                val = parseInt(val, 10);
            }

            val = (!val && val !== 0) ? true : val;

            if (val !== false && val !== true && typeof val != 'number')
              val = val;

            self.SET(key, val);
          });
        });
      }
      return self;
    };

    queryObject.prototype = {
      queryObject: true,
      has: function(key, type) {
        var value = this.get(key);
        return is(value, type);
      },
      GET: function(key) {
        if (!is(key)) return this.keys;
        var parsed = parse(key), base = parsed[0], tokens = parsed[1];
        var target = this.keys[base];
        while (target != null && tokens.length != 0) {
          target = target[tokens.shift()];
        }
        return typeof target == 'number' ? target : target || "";
      },
      get: function(key) {
        var target = this.GET(key);
        if (is(target, Object))
          return jQuery.extend(true, {}, target);
        else if (is(target, Array))
          return target.slice(0);
        return target;
      },
      SET: function(key, val) {
        var value = !is(val) ? null : val;
        var parsed = parse(key), base = parsed[0], tokens = parsed[1];
        var target = this.keys[base];
        this.keys[base] = set(target, tokens.slice(0), value);
        return this;
      },
      set: function(key, val) {
        return this.copy().SET(key, val);
      },
      REMOVE: function(key) {
        return this.SET(key, null).COMPACT();
      },
      remove: function(key) {
        return this.copy().REMOVE(key);
      },
      EMPTY: function() {
        var self = this;
        jQuery.each(self.keys, function(key, value) {
          delete self.keys[key];
        });
        return self;
      },
      load: function(url) {
        var hash = url.replace(/^.*?[#](.+?)(?:\?.+)?$/, "$1");
        var search = url.replace(/^.*?[?](.+?)(?:#.+)?$/, "$1");
        return new queryObject(url.length == search.length ? '' : search, url.length == hash.length ? '' : hash);
      },
      empty: function() {
        return this.copy().EMPTY();
      },
      copy: function() {
        return new queryObject(this);
      },
      COMPACT: function() {
        function build(orig) {
          var obj = typeof orig == "object" ? is(orig, Array) ? [] : {} : orig;
          if (typeof orig == 'object') {
            function add(o, key, value) {
              if (is(o, Array))
                o.push(value);
              else
                o[key] = value;
            }
            jQuery.each(orig, function(key, value) {
              if (!is(value)) return true;
              add(obj, key, build(value));
            });
          }
          return obj;
        }
        this.keys = build(this.keys);
        return this;
      },
      compact: function() {
        return this.copy().COMPACT();
      },
      toString: function() {
        var i = 0, queryString = [], chunks = [], self = this;
        var encode = function(str) {
          str = str + "";
          if ($spaces) str = str.replace(/ /g, "+");
          return encodeURIComponent(str);
        };
        var addFields = function(arr, key, value) {
          if (!is(value) || value === false) return;
          var o = [encode(key)];
          if (value !== true) {
            o.push("=");
            o.push(encode(value));
          }
          arr.push(o.join(""));
        };
        var build = function(obj, base) {
          var newKey = function(key) {
            return !base || base == "" ? [key].join("") : [base, "[", key, "]"].join("");
          };
          jQuery.each(obj, function(key, value) {
            if (typeof value == 'object')
              build(value, newKey(key));
            else
              addFields(chunks, newKey(key), value);
          });
        };

        build(this.keys);

        if (chunks.length > 0) queryString.push($hash);
        queryString.push(chunks.join($separator));

        return queryString.join("");
      }
    };

    return new queryObject(location.search, location.hash);
  };
}(jQuery.query || {}); // Pass in jQuery.query as settings object

/**
 * jQuery Validation Plugin 1.8.1
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2011 Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function(c){c.extend(c.fn,{validate:function(a){if(this.length){var b=c.data(this[0],"validator");if(b)return b;b=new c.validator(a,this[0]);c.data(this[0],"validator",b);if(b.settings.onsubmit){this.find("input, button").filter(".cancel").click(function(){b.cancelSubmit=true});b.settings.submitHandler&&this.find("input, button").filter(":submit").click(function(){b.submitButton=this});this.submit(function(d){function e(){if(b.settings.submitHandler){if(b.submitButton)var f=c("<input type='hidden'/>").attr("name",
b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);b.settings.submitHandler.call(b,b.currentForm);b.submitButton&&f.remove();return false}return true}b.settings.debug&&d.preventDefault();if(b.cancelSubmit){b.cancelSubmit=false;return e()}if(b.form()){if(b.pendingRequest){b.formSubmitted=true;return false}return e()}else{b.focusInvalid();return false}})}return b}else a&&a.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing")},valid:function(){if(c(this[0]).is("form"))return this.validate().form();
else{var a=true,b=c(this[0].form).validate();this.each(function(){a&=b.element(this)});return a}},removeAttrs:function(a){var b={},d=this;c.each(a.split(/\s/),function(e,f){b[f]=d.attr(f);d.removeAttr(f)});return b},rules:function(a,b){var d=this[0];if(a){var e=c.data(d.form,"validator").settings,f=e.rules,g=c.validator.staticRules(d);switch(a){case "add":c.extend(g,c.validator.normalizeRule(b));f[d.name]=g;if(b.messages)e.messages[d.name]=c.extend(e.messages[d.name],b.messages);break;case "remove":if(!b){delete f[d.name];
return g}var h={};c.each(b.split(/\s/),function(j,i){h[i]=g[i];delete g[i]});return h}}d=c.validator.normalizeRules(c.extend({},c.validator.metadataRules(d),c.validator.classRules(d),c.validator.attributeRules(d),c.validator.staticRules(d)),d);if(d.required){e=d.required;delete d.required;d=c.extend({required:e},d)}return d}});c.extend(c.expr[":"],{blank:function(a){return!c.trim(""+a.value)},filled:function(a){return!!c.trim(""+a.value)},unchecked:function(a){return!a.checked}});c.validator=function(a,
b){this.settings=c.extend(true,{},c.validator.defaults,a);this.currentForm=b;this.init()};c.validator.format=function(a,b){if(arguments.length==1)return function(){var d=c.makeArray(arguments);d.unshift(a);return c.validator.format.apply(this,d)};if(arguments.length>2&&b.constructor!=Array)b=c.makeArray(arguments).slice(1);if(b.constructor!=Array)b=[b];c.each(b,function(d,e){a=a.replace(RegExp("\\{"+d+"\\}","g"),e)});return a};c.extend(c.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",
validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:c([]),errorLabelContainer:c([]),onsubmit:true,ignore:[],ignoreTitle:false,onfocusin:function(a){this.lastActive=a;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass);this.addWrapper(this.errorsFor(a)).hide()}},onfocusout:function(a){if(!this.checkable(a)&&(a.name in this.submitted||!this.optional(a)))this.element(a)},
onkeyup:function(a){if(a.name in this.submitted||a==this.lastElement)this.element(a)},onclick:function(a){if(a.name in this.submitted)this.element(a);else a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).addClass(b).removeClass(d):c(a).addClass(b).removeClass(d)},unhighlight:function(a,b,d){a.type==="radio"?this.findByName(a.name).removeClass(b).addClass(d):c(a).removeClass(b).addClass(d)}},setDefaults:function(a){c.extend(c.validator.defaults,
a)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:c.validator.format("Please enter no more than {0} characters."),
minlength:c.validator.format("Please enter at least {0} characters."),rangelength:c.validator.format("Please enter a value between {0} and {1} characters long."),range:c.validator.format("Please enter a value between {0} and {1}."),max:c.validator.format("Please enter a value less than or equal to {0}."),min:c.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){function a(e){var f=c.data(this[0].form,"validator");e="on"+e.type.replace(/^validate/,
"");f.settings[e]&&f.settings[e].call(f,this[0])}this.labelContainer=c(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||c(this.currentForm);this.containers=c(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var b=this.groups={};c.each(this.settings.groups,function(e,f){c.each(f.split(/\s/),function(g,h){b[h]=e})});var d=this.settings.rules;
c.each(d,function(e,f){d[e]=c.validator.normalizeRule(f)});c(this.currentForm).validateDelegate(":text, :password, :file, select, textarea","focusin focusout keyup",a).validateDelegate(":radio, :checkbox, select, option","click",a);this.settings.invalidHandler&&c(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){this.checkForm();c.extend(this.submitted,this.errorMap);this.invalid=c.extend({},this.errorMap);this.valid()||c(this.currentForm).triggerHandler("invalid-form",
[this]);this.showErrors();return this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(a){this.lastElement=a=this.clean(a);this.prepareElement(a);this.currentElements=c(a);var b=this.check(a);if(b)delete this.invalid[a.name];else this.invalid[a.name]=true;if(!this.numberOfInvalids())this.toHide=this.toHide.add(this.containers);this.showErrors();return b},showErrors:function(a){if(a){c.extend(this.errorMap,
a);this.errorList=[];for(var b in a)this.errorList.push({message:a[b],element:this.findByName(b)[0]});this.successList=c.grep(this.successList,function(d){return!(d.name in a)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){c.fn.resetForm&&c(this.currentForm).resetForm();this.submitted={};this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},
objectLength:function(a){var b=0,d;for(d in a)b++;return b},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return this.size()==0},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{c(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(a){}},findLastActive:function(){var a=this.lastActive;return a&&c.grep(this.errorList,function(b){return b.element.name==
a.name}).length==1&&a},elements:function(){var a=this,b={};return c(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in b||!a.objectLength(c(this).rules()))return false;return b[this.name]=true})},clean:function(a){return c(a)[0]},errors:function(){return c(this.settings.errorElement+"."+this.settings.errorClass,
this.errorContext)},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=c([]);this.toHide=c([]);this.currentElements=c([])},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers)},prepareElement:function(a){this.reset();this.toHide=this.errorsFor(a)},check:function(a){a=this.clean(a);if(this.checkable(a))a=this.findByName(a.name).not(this.settings.ignore)[0];var b=c(a).rules(),d=false,e;for(e in b){var f={method:e,parameters:b[e]};try{var g=
c.validator.methods[e].call(this,a.value.replace(/\r/g,""),a,f.parameters);if(g=="dependency-mismatch")d=true;else{d=false;if(g=="pending"){this.toHide=this.toHide.not(this.errorsFor(a));return}if(!g){this.formatAndAdd(a,f);return false}}}catch(h){this.settings.debug&&window.console&&console.log("exception occured when checking element "+a.id+", check the '"+f.method+"' method",h);throw h;}}if(!d){this.objectLength(b)&&this.successList.push(a);return true}},customMetaMessage:function(a,b){if(c.metadata){var d=
this.settings.meta?c(a).metadata()[this.settings.meta]:c(a).metadata();return d&&d.messages&&d.messages[b]}},customMessage:function(a,b){var d=this.settings.messages[a];return d&&(d.constructor==String?d:d[b])},findDefined:function(){for(var a=0;a<arguments.length;a++)if(arguments[a]!==undefined)return arguments[a]},defaultMessage:function(a,b){return this.findDefined(this.customMessage(a.name,b),this.customMetaMessage(a,b),!this.settings.ignoreTitle&&a.title||undefined,c.validator.messages[b],"<strong>Warning: No message defined for "+
a.name+"</strong>")},formatAndAdd:function(a,b){var d=this.defaultMessage(a,b.method),e=/\$?\{(\d+)\}/g;if(typeof d=="function")d=d.call(this,b.parameters,a);else if(e.test(d))d=jQuery.format(d.replace(e,"{$1}"),b.parameters);this.errorList.push({message:d,element:a});this.errorMap[a.name]=d;this.submitted[a.name]=d},addWrapper:function(a){if(this.settings.wrapper)a=a.add(a.parent(this.settings.wrapper));return a},defaultShowErrors:function(){for(var a=0;this.errorList[a];a++){var b=this.errorList[a];
this.settings.highlight&&this.settings.highlight.call(this,b.element,this.settings.errorClass,this.settings.validClass);this.showLabel(b.element,b.message)}if(this.errorList.length)this.toShow=this.toShow.add(this.containers);if(this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight){a=0;for(b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass)}this.toHide=this.toHide.not(this.toShow);
this.hideErrors();this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return c(this.errorList).map(function(){return this.element})},showLabel:function(a,b){var d=this.errorsFor(a);if(d.length){d.removeClass().addClass(this.settings.errorClass);d.attr("generated")&&d.html(b)}else{d=c("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(a),generated:true}).addClass(this.settings.errorClass).html(b||
"");if(this.settings.wrapper)d=d.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();this.labelContainer.append(d).length||(this.settings.errorPlacement?this.settings.errorPlacement(d,c(a)):d.insertAfter(a))}if(!b&&this.settings.success){d.text("");typeof this.settings.success=="string"?d.addClass(this.settings.success):this.settings.success(d)}this.toShow=this.toShow.add(d)},errorsFor:function(a){var b=this.idOrName(a);return this.errors().filter(function(){return c(this).attr("for")==b})},
idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(a){var b=this.currentForm;return c(document.getElementsByName(a)).map(function(d,e){return e.form==b&&e.name==a&&e||null})},getLength:function(a,b){switch(b.nodeName.toLowerCase()){case "select":return c("option:selected",b).length;case "input":if(this.checkable(b))return this.findByName(b.name).filter(":checked").length}return a.length},
depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):true},dependTypes:{"boolean":function(a){return a},string:function(a,b){return!!c(a,b.form).length},"function":function(a,b){return a(b)}},optional:function(a){return!c.validator.methods.required.call(this,c.trim(a.value),a)&&"dependency-mismatch"},startRequest:function(a){if(!this.pending[a.name]){this.pendingRequest++;this.pending[a.name]=true}},stopRequest:function(a,b){this.pendingRequest--;if(this.pendingRequest<
0)this.pendingRequest=0;delete this.pending[a.name];if(b&&this.pendingRequest==0&&this.formSubmitted&&this.form()){c(this.currentForm).submit();this.formSubmitted=false}else if(!b&&this.pendingRequest==0&&this.formSubmitted){c(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false}},previousValue:function(a){return c.data(a,"previousValue")||c.data(a,"previousValue",{old:null,valid:true,message:this.defaultMessage(a,"remote")})}},classRuleSettings:{required:{required:true},
email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(a,b){a.constructor==String?this.classRuleSettings[a]=b:c.extend(this.classRuleSettings,a)},classRules:function(a){var b={};(a=c(a).attr("class"))&&c.each(a.split(" "),function(){this in c.validator.classRuleSettings&&c.extend(b,c.validator.classRuleSettings[this])});return b},attributeRules:function(a){var b=
{};a=c(a);for(var d in c.validator.methods){var e=a.attr(d);if(e)b[d]=e}b.maxlength&&/-1|2147483647|524288/.test(b.maxlength)&&delete b.maxlength;return b},metadataRules:function(a){if(!c.metadata)return{};var b=c.data(a.form,"validator").settings.meta;return b?c(a).metadata()[b]:c(a).metadata()},staticRules:function(a){var b={},d=c.data(a.form,"validator");if(d.settings.rules)b=c.validator.normalizeRule(d.settings.rules[a.name])||{};return b},normalizeRules:function(a,b){c.each(a,function(d,e){if(e===
false)delete a[d];else if(e.param||e.depends){var f=true;switch(typeof e.depends){case "string":f=!!c(e.depends,b.form).length;break;case "function":f=e.depends.call(b,b)}if(f)a[d]=e.param!==undefined?e.param:true;else delete a[d]}});c.each(a,function(d,e){a[d]=c.isFunction(e)?e(b):e});c.each(["minlength","maxlength","min","max"],function(){if(a[this])a[this]=Number(a[this])});c.each(["rangelength","range"],function(){if(a[this])a[this]=[Number(a[this][0]),Number(a[this][1])]});if(c.validator.autoCreateRanges){if(a.min&&
a.max){a.range=[a.min,a.max];delete a.min;delete a.max}if(a.minlength&&a.maxlength){a.rangelength=[a.minlength,a.maxlength];delete a.minlength;delete a.maxlength}}a.messages&&delete a.messages;return a},normalizeRule:function(a){if(typeof a=="string"){var b={};c.each(a.split(/\s/),function(){b[this]=true});a=b}return a},addMethod:function(a,b,d){c.validator.methods[a]=b;c.validator.messages[a]=d!=undefined?d:c.validator.messages[a];b.length<3&&c.validator.addClassRules(a,c.validator.normalizeRule(a))},
methods:{required:function(a,b,d){if(!this.depend(d,b))return"dependency-mismatch";switch(b.nodeName.toLowerCase()){case "select":return(a=c(b).val())&&a.length>0;case "input":if(this.checkable(b))return this.getLength(a,b)>0;default:return c.trim(a).length>0}},remote:function(a,b,d){if(this.optional(b))return"dependency-mismatch";var e=this.previousValue(b);this.settings.messages[b.name]||(this.settings.messages[b.name]={});e.originalMessage=this.settings.messages[b.name].remote;this.settings.messages[b.name].remote=
e.message;d=typeof d=="string"&&{url:d}||d;if(this.pending[b.name])return"pending";if(e.old===a)return e.valid;e.old=a;var f=this;this.startRequest(b);var g={};g[b.name]=a;c.ajax(c.extend(true,{url:d,mode:"abort",port:"validate"+b.name,dataType:"json",data:g,success:function(h){f.settings.messages[b.name].remote=e.originalMessage;var j=h===true;if(j){var i=f.formSubmitted;f.prepareElement(b);f.formSubmitted=i;f.successList.push(b);f.showErrors()}else{i={};h=h||f.defaultMessage(b,"remote");i[b.name]=
e.message=c.isFunction(h)?h(a):h;f.showErrors(i)}e.valid=j;f.stopRequest(b,j)}},d));return"pending"},minlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)>=d},maxlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)<=d},rangelength:function(a,b,d){a=this.getLength(c.trim(a),b);return this.optional(b)||a>=d[0]&&a<=d[1]},min:function(a,b,d){return this.optional(b)||a>=d},max:function(a,b,d){return this.optional(b)||a<=d},range:function(a,b,d){return this.optional(b)||
a>=d[0]&&a<=d[1]},email:function(a,b){return this.optional(b)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(a)},
url:function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},
date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a))},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9-]+/.test(a))return false;var d=0,e=0,f=false;a=a.replace(/\D/g,"");for(var g=a.length-1;g>=
0;g--){e=a.charAt(g);e=parseInt(e,10);if(f)if((e*=2)>9)e-=9;d+=e;f=!f}return d%10==0},accept:function(a,b,d){d=typeof d=="string"?d.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(b)||a.match(RegExp(".("+d+")$","i"))},equalTo:function(a,b,d){d=c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){c(b).valid()});return a==d.val()}}});c.format=c.validator.format})(jQuery);
(function(c){var a={};if(c.ajaxPrefilter)c.ajaxPrefilter(function(d,e,f){e=d.port;if(d.mode=="abort"){a[e]&&a[e].abort();a[e]=f}});else{var b=c.ajax;c.ajax=function(d){var e=("port"in d?d:c.ajaxSettings).port;if(("mode"in d?d:c.ajaxSettings).mode=="abort"){a[e]&&a[e].abort();return a[e]=b.apply(this,arguments)}return b.apply(this,arguments)}}})(jQuery);
(function(c){!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.handle.call(this,e)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)},handler:function(e){arguments[0]=c.event.fix(e);arguments[0].type=b;return c.event.handle.apply(this,arguments)}}});c.extend(c.fn,{validateDelegate:function(a,
b,d){return this.bind(b,function(e){var f=c(e.target);if(f.is(a))return d.apply(f,arguments)})}})})(jQuery);

/**
 * jQuery ti.add_bookmark plug-in 0.2
 *
 * http://www.trilogyinteractive.com
 *
 * Copyright (c) 2009 Trilogy Interactive
 *
**/

/**
 * Adds a bookmark based on the user's browser type
 *
 * @usage $.add_bookmark(url, page_title)
 *
**/

jQuery.add_bookmark = function(url,page_title) {

  if (jQuery.browser.mozilla){
    window.sidebar.addPanel(page_title, url,'');
  } else if ( jQuery.browser.opera ) {
    var a = document.createElement('A');
    a.rel = 'sidebar';
    a.target = '_search';
    a.title = page_title;
    a.href = url; a.click();
  } else if ( jQuery.browser.msie ) {
    window.external.AddFavorite(url, page_title);
  } else {
    alert("Your web browser appears to not support adding a bookmark via Javascript. Please manually add one via your browser's bookmark menu.");
  }

};

jQuery.fn.boxes = function(options) {
  
  switch (typeof options){
    case 'object':
    case 'undefined':
      elements = this;
      mask = '';
      
      settings = jQuery.extend({
        mask_background_color: '#000',
        mask_opacity:          0.8,
        position:              'center'
      }, options);
    
      init();
      break;
    case 'string':
      var target = this;
      run_command( options );
      break;
  }
  
  function init(){
    move_to_body();
    build_mask();
    init_styling();
    open_target = false;
    bind_events();
  }
  
  function move_to_body(){
    elements = jQuery( elements ).detach().appendTo("body"); 
  }
  
  function build_mask(){
    
    mask = jQuery("<div id='boxes-mask' style='display: none;' />").appendTo("body");
    jQuery(mask).css({
      position:         'absolute',
      zIndex:           1000,
      backgroundColor:  settings.mask_background_color,
      opacity:          settings.mask_opacity,
      top:              0,
      left:             0,
      height:           jQuery(document).height(),
      width:            jQuery(document).width()
    });
  }
  
  function init_styling(){
    
    jQuery(elements).css({
      position: 'absolute',
      zIndex:   1001
    }).hide();
    
  }
  
  function bind_events(){
    jQuery.each(elements,function(){
      var id = $(this).attr('id');
      
      jQuery("a[href='#" + id + "_open']").click(function(){
        var box_id = $(this).attr('href').split('_')[0].substr(1);
        jQuery("#" + box_id).boxes('open');
        return false;
      });
      
      jQuery("a[href='#" + id + "_close']").click(function(){
        var box_id = $(this).attr('href').split('_')[0].substr(1);
        jQuery("#" + box_id).boxes('close');
        return false;
      });
      
    });
    
    jQuery(window).resize( reposition );
    jQuery(window).scroll( reposition );
    
  }

  function reposition(){
    
    jQuery(mask).css({
      height:           jQuery(document).height(),
      width:            jQuery(window).width()
    });    
    
    if (open_target){

      if ( settings.position == 'top' )
        target_top = $(window).scrollTop() + (jQuery(window).height() / 10)
      else if ( settings.position == 'center' )
        target_top = $(window).scrollTop() + ( jQuery(window).height() / 2 ) - ( jQuery(open_target).height() / 2 )
      else
        target_top = $(window).scrollTop() + settings.position
        
        console.log( jQuery(window).width() / 2 );
        
      jQuery(open_target).css({
        top:      target_top,
        left:     ( jQuery(window).width() / 2 ) - ( jQuery(open_target).width() / 2 )
      });
      
    }
    
  }

  // commands
  
  function run_command( command ){
    switch( command ){
      case 'close':
        close(target);
        break;
      case 'open':
        open(target);
        break;
    }
  }
  
  function open(target){

    if ( settings.position == 'top' )
      target_top = $(window).scrollTop() + (jQuery(window).height() / 10)
    else if ( settings.position == 'center' )
      target_top = $(window).scrollTop() + ( jQuery(window).height() / 2 ) - ( jQuery(target).height() / 2 )
    else
      target_top = $(window).scrollTop() + settings.position
      
    jQuery(mask).show();
    jQuery(target).css({
      top:      target_top,
      left:     ( jQuery(window).width() / 2 ) - ( jQuery(target).width() / 2 )
    }).show();
    
    open_target = target;
  };
  
  function close(target){
    jQuery(target).hide();
    jQuery(mask).hide();
    
    open_target = false;
  };
  
};

/**
 * jQuery ti.fontsize plug-in 0.2
 *
 * http://www.trilogyinteractive.com
 *
 * Copyright (c) 2009 Trilogy Interactive
 *
**/

/**
 * Applies a fontsize class to a given DOM element and enables controls for the same
 *
 * @example $('body').fontsize()
 * @desc Enables fontsize behavior on the body DOM element using the default settings
 *
 * @example $('#content').fontsize()
 * @desc Enables fontsize behavior on the DOM element with id=content using the default settings
 *
 * @example $('body).fontsize( sizes: ['small','big'], initial_size: 'big' )
 * @desc Enables fontsize behavior on the body DOM element with two sizes and the initial size of big
 *
 * @option sizes (Array) - list of all sizes to support, this will be used to identify the controls
 * @option initial_size (String) - what size to use when loading the document
 * @option controls_selector (String) - selector to location the control container to enable additional CSS based display behavior
 * @option href_prefix (String) - combined with each size to identify a particular control
 * @option use_cookie (Boolean) - set to false to disable persistent behavior between page loads
 * @option cookie_name (String) - name of the cookie to store setting
 * @option cookie_duration (Integer) - number of days before setting should expire
 *
 * @example_html controls should be defined with an href anchor of the href_prefix and size name:
 *   <a href="#fontsize_small>Small</a>
 *   <a href="#fontsize_medium>Medium</a>
 *   <a href="#fontsize_large>Large</a>
**/

jQuery.fn.fontsize = function(options) {

  el = this;

  settings = jQuery.extend({
    sizes:             ['small','medium','large'],
    initial_size:      'small',
    href_prefix:       'fontsize',
    controls_selector: '#fontsize_links',
    use_cookie:        true,
    cookie_name:       'font_size',
    cookie_duration:   365
  }, options);

  // determine the current_size and set as appropriate
  if ( settings.use_cookie && $.cookie( settings.cookie_name ) ){
    current_size = $.cookie( settings.cookie_name );
  } else {
    current_size = settings.initial_size;
  }

  jQuery( settings.controls_selector ).addClass( current_size );
  jQuery( el ).addClass( current_size );


  // build control binds
  jQuery.each( settings.sizes, function(){
    var new_size = '' + this;

    jQuery("a[href=#" + [settings.href_prefix,this].join('_') + "]").click( function(){

      // modify the controls
      jQuery( settings.controls_selector ).removeClass( current_size );
      jQuery( settings.controls_selector ).addClass( new_size );

      // modify the DOM element
      jQuery( el ).removeClass( current_size );
      jQuery( el ).addClass( new_size );

      // persist data if needed
      if (settings.use_cookie) $.cookie( settings.cookie_name, new_size, { expires: settings.cookie_duration, path: '/'} );

      // setup new state
      current_size = new_size;

      return false;
    });
  });

  return this;
};

jQuery.fn.ga_track = function(options) {

  var els = this;
  var settings = jQuery.extend({
    category:       'General',
    action:         'Download',
    label:          false,
    opt_value:      false,
    tracker:        pageTracker,
    suppress_click: false
  }, options);
  
  els.each( function(){

    $(this).bind('click',function(){

      if (!settings.label){
        if ( $(this).attr('href') )
          label = $(this).attr('href');
        else if ( $(this).attr('title') )
          label = $(this).attr('title');
        else
          label = "None";
      } else {
        label = settings.label
      }

      settings.tracker._trackEvent(
        settings.category,
        settings.action,
        label
      );

      return !settings.suppress_click;

    });
  });

  return this;
};

/**
 * jQuery ti.random-class plug-in 0.1
 *
 * http://www.trilogyinteractive.com
 *
 * Copyright (c) 2009 Trilogy Interactive
 *
**/

/**
 * Applies a randomly select class to a given DOM element from a provided list of classes
 *
 * @example $('body').random_class(['red','green','blue','yellow'])
 * @desc Randomly selects one of the four classes and assigns it to the body tag
 *
 * @example $('#content').random_class(['red','green','blue','yellow'])
 * @desc Randomly selects one of the four classes and assigns it to the DOM element with ID of content
 *
 * @example $('body').random_class(['red','green','blue','yellow'], { use_cookie: false })
 * @desc Randomly selects one of the four classes and assigns it to the body tag, but does not save it to a cookie
 *
 * @classes (Array) - required list of classes to be radomly selected from
 *
 * @option use_cookie (Boolean) - set to false to disable persistent behavior between page loads
 * @option cookie_name (String) - name of the cookie to store class in
 *
**/

jQuery.fn.random_class = function(classes,options) {

  el = this;

  settings = jQuery.extend({
    use_cookie:  true,
    cookie_name: 'random_class'
  }, options);

  if (!classes.length) alert("No classes defined for jquery.am.random_class");

  if ( settings.use_cookie && $.cookie( settings.cookie_name ) ){
    random_class = $.cookie( settings.cookie_name );
  } else {
    var i = Math.floor(Math.random() * classes.length );
    random_class = classes[i];

    if ( settings.use_cookie ) $.cookie( settings.cookie_name, random_class, { path: '/'} );
  }

  jQuery( el ).addClass( random_class );

  return this;
};

/**
 * jQuery ti.restore_form_values plug-in 0.2
 *
 * http://www.trilogyinteractive.com
 *
 * Copyright (c) 2011 Trilogy Interactive
 *
**/

jQuery.fn.restore_form_values = function(options) {

  var form = this;
  var settings = jQuery.extend({
    error_class: 'error'
  }, options);

  init(form.find(":text"));
  init(form.find("input[type='email']"));
  init(form.find("input[type='number']"));
  init(form.find("textarea"));

  function init( fields ){

    fields.each( function(){
      var field = $(this);
      if ( field.attr('restore') ){

        field.data('restore_form_values',{
          initial: field.attr('value'),
          restore: field.attr('restore'),
          blank:   field.attr('blank') || ''
        });

        field.bind('focus',function(){
          var field = $(this);
          var current = field.val();
          var field_data = field.data('restore_form_values');

          if (settings.error_class) field.removeClass( settings.error_class );

          if      (current == field_data['initial']) field.val( field_data['blank'] );
          else if (current == field_data['restore']) field.val( field_data['blank'] );
        });

        field.bind('blur',function(){
          var field = $(this);
          var current = field.val();
          var field_data = field.data('restore_form_values');

          if (current == field_data['blank']) field.val(field_data['restore']);
        });

      }
    });

  }

  return this;
};

jQuery.fn.rotator = function(options) {

  var el = this;

  if ( !jQuery.ui ){
    alert("jquery-ui must be loaded for rotator to work");
    return false;
  } else if ( !jQuery.ui.tabs ){
    alert("jquery-ui-tabs must be loaded for rotator to work");
    return false;
  }

  settings = jQuery.extend({
    // control options
    previous_button: false,
    next_button:     false,
    youtube_detect:  true,
    interval:        8000,

    // jquery.ui.tabs setting defaults
    tabs: {
      selected:      0,
      fx:            { opacity: 'toggle' }
    }
  }, options);

  $( el ).tabs( settings['tabs'] );

  var last_tab_index = $(el).tabs('length') -1;

  if ( settings.youtube_detect ){

    if( $( el ).find( "object").length ){
      // youtube content found, do not enable rotation
    } else {
      // no youtube content found, enable rotations for every 8000ms
      $( el ).tabs('rotate', settings.interval, false );
    }

  } else {
    $( el ).tabs('rotate', settings.interval, false );
  }

  // attach event to back button to go back one pane and turn off animations
  if ( settings.previous_button ) {
    $( settings.previous_button ).click(function() {
      var tabs = $(el);

      var current_tab = tabs.tabs( "option", "selected" );
      current_tab--;
      if (current_tab <= -1) current_tab = last_tab_index;

      tabs.tabs('select', current_tab);
      tabs.tabs('rotate', 0, false );
      return false;
    });
  }

  // attach event to next button to go forward one pane and turn off animations
  if ( settings.next_button ) {
    $( settings.next_button ).click(function() {
      var tabs = $(el);

      var current_tab = tabs.tabs( "option", "selected" );
      current_tab++;
      if ( current_tab > last_tab_index ) current_tab = 0;

      tabs.tabs('select', current_tab);
      tabs.tabs('rotate', 0, false );
      return false;
    });
  }

  // disable rotation if any panels are clicked
  $( el ).find("div").click(function(){
    $(el).tabs('rotate', 0, false );
  });

}

/**
 * jQuery ti.sc_extract plug-in 0.1
 *
 * http://www.trilogyinteractive.com
 *
 * Copyright (c) 2011 Trilogy Interactive
 *
**/

/**
 * Parses URL parameters and sets form fields with their value
 *
 * @usage $.sc_extract()
 *
 * By default sc_extract looks for a URL paramater named "sc" and sets any form field with the name "SourceCode" to that value
 *
 * @option param - changes the URL paramater used to set the value
 * @option field - a jQuery selector used to find the field
 * @option default_value - a value used when there is no value for the specified URL param
 *
**/

jQuery.sc_extract = function(options) {

  var settings = jQuery.extend({
    param:   'sc',
    field:   "input[name='SourceCode']",
    default_value: ''
  }, options);

  var value = $.query.get( settings.param );        // get URL parameter via the $.query API

  if ( value && value !== true) {                   // if there was a value and it was not a boolean
    $(settings.field).val( value );                   // set the field
  } else if ( settings.default_value ) {            // if there was no value, but a default value in the options
    $(settings.field).val( settings.default_value );  // set the field
  }

};

/**
 * jQuery ti.splashbox plug-in 0.3
 *
 * http://www.triogyinteractive.com
 *
 * Copyright (c) 2010 Trilogy Interactive
 *
**/

/**
 * Redirects from a splash page to a designated target_url after a set number of visits
 *
 * @usage $.splashpage(target_url, options_hash)
 *
 * @example $.splashpage('http://www.example.com/home')
 * @desc Redirects visitors to http://www.example.com/home if they have visited more than once
 *
 * @example $.splashpage('/home')
 * @desc Redirects visitors to /home of the current domain if they have visited more than once
 *
 * @example $.splashpage('/home', { redirect_after: 3 } )
 * @desc Redirects visitors to /home of the current domain if they have visited more than three times
 *
 * @option redirect_after (Integer) - number of visits before redirect is triggered
 * @option cookie_name (String) - name of the cookie to store visit count
 * @option cookie_duration (Integer) - number of days until cookie expires if not visited after which the redirect stops
 * @option visit_reset (Boolean) - if true, the duration for the cookie will be reset each time the splash page redirects
 * @option testing (Boolean) - if true, shows redirect behavior in the console but does not actually redirect
 *
**/

jQuery.fn.splashbox = function(options) {

  if ( typeof options == 'object' ){
    init( this, options );
  } else if ( typeof options == 'string' ){
    switch ( options ){
      case 'close':
      case 'hide':
        hide();
        break;
      case 'open':
      case 'show':
        show();
        break;
    }
  }

  function init( el, options) {

    components = {
      splash_box: el
    };

    settings = jQuery.extend({
      mask_background_color: '#000',
      mask_opacity:          0.8,

      position:        'top',
      skip_after:      1,
      cookie_name:     'splash_box_visits',
      cookie_duration: 30,
      visit_reset:     false,
      testing:         false,
      auto_show:       true,
      click_to_show:   ".splash-show",
      click_to_hide:   ".splash-skip"
    }, options);

    state = {
      open: false
    };

    jQuery(components.splash_box).hide();

    jQuery("body").append("<div id='splash-mask' style='display: none;' />");
    components.splash_mask = jQuery("#splash-mask");

    var number_of_visits = $.cookie( settings.cookie_name );

    if ( settings.auto_show && number_of_visits >= settings.skip_after ){

      // this will reset the duration for the cookie only if the plugin is configured to do so
      if ( settings.visit_reset ) $.cookie( settings.cookie_name, number_of_visits, { expires: settings.cookie_duration, path: '/'} );
      if ( settings.testing ) console.log( "skipping splashbox" );

      return true;

    } else {

      if ( number_of_visits )
        $.cookie( settings.cookie_name, ((number_of_visits*1) + 1 ), { expires: settings.cookie_duration, path: '/'} );
      else
        $.cookie( settings.cookie_name, 1, { expires: settings.cookie_duration, path: '/'} );

      build();
      if ( settings.auto_show ) show();

      return false;

    }

  }

  function build(){

    var page_size = get_page_size();

    jQuery(components.splash_mask).css({
      position:         'absolute',
      zIndex:           1000,
      backgroundColor:  settings.mask_background_color,
      opacity:          settings.mask_opacity,
      top:              0,
      left:             0
    });

    jQuery(components.splash_box).css({
      zIndex:  1001
    });

    jQuery(components.splash_box).find( settings.click_to_hide ).click( function(){
      hide();
      return false;
    });

    jQuery( settings.click_to_show ).click( function(){
      show();
      return false;
    });

    jQuery(window).resize( reposition );
    jQuery(window).scroll( reposition );

  }

  function reposition(){
    if ( state.open ){

      var page_size = get_page_size();
      var page_scroll = get_page_scroll();

      jQuery(components.splash_mask).css({
        width:  page_size[0],
        height: page_size[1]
      })

      if ( is_numeric( settings.position ) )
        top_pixles = page_scroll[1] + settings.position
      else if ( settings.position == 'center' )
        top_pixles = page_scroll[1] + (page_size[3] / 2) - ($(components.splash_box).height() / 2)
      else
        top_pixles = page_scroll[1] + (page_size[3] / 10)

      jQuery(components.splash_box).css({
        position:         'absolute',
        top:  top_pixles,
        left: page_scroll[0] + (page_size[2] / 2) - ($(components.splash_box).width() / 2)
      });

    }
  }

  function show(){

    jQuery('embed, object, select').css({ 'visibility' : 'hidden' });
    jQuery(components.splash_box).find('embed, object, select').css({ 'visibility' : 'visible' });

    var page_size = get_page_size();
    var page_scroll = get_page_scroll();

    jQuery(components.splash_mask).css({
      width:  page_size[0],
      height: page_size[1]
    }).fadeIn();

    if ( is_numeric( settings.position ) )
      top_pixles = page_scroll[1] + settings.position
    else if ( settings.position == 'center' )
      top_pixles = page_scroll[1] + (page_size[3] / 2) - ($(components.splash_box).height() / 2)
    else
      top_pixles = page_scroll[1] + (page_size[3] / 10)

    jQuery(components.splash_box).css({
      position:         'absolute',
      top:  top_pixles,
      left: page_scroll[0] + (page_size[2] / 2) - ($(components.splash_box).width() / 2)
    }).fadeIn();

    state.open = true;

  }

  function hide(){
    jQuery('embed, object, select').css({ 'visibility' : 'visible' });

    state.open = false;
    jQuery(components.splash_box).fadeOut();
    jQuery(components.splash_mask).fadeOut();
  }

  // ** utility methods **

  // @return Array Return an array with page width, height and window width, height
  // from quicksmode.com
  function get_page_size() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
      xScroll = window.innerWidth + window.scrollMaxX;
      yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
      xScroll = document.body.scrollWidth;
      yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
      xScroll = document.body.offsetWidth;
      yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer
      if(document.documentElement.clientWidth){
        windowWidth = document.documentElement.clientWidth;
      } else {
        windowWidth = self.innerWidth;
      }
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight;
    }
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
      pageHeight = windowHeight;
    } else {
      pageHeight = yScroll;
    }
    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){
      pageWidth = xScroll;
    } else {
      pageWidth = windowWidth;
    }
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
    return arrayPageSize;
  };

  // @return Array Return an array with x,y page scroll values.
  // from quicksmode.com
  function get_page_scroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {   // Explorer 6 Strict
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;
    }
    arrayPageScroll = new Array(xScroll,yScroll);
    return arrayPageScroll;
  };

}

/**
 * jQuery ti.splashbox plug-in 0.2
 *
 * http://www.triogyinteractive.com
 *
 * Copyright (c) 2010 Trilogy Interactive
 *
**/

/**
 * Redirects from a splash page to a designated target_url after a set number of visits
 *
 * @usage $.splashpage(target_url, options_hash)
 *
 * @example $.splashpage('http://www.example.com/home')
 * @desc Redirects visitors to http://www.example.com/home if they have visited more than once
 *
 * @example $.splashpage('/home')
 * @desc Redirects visitors to /home of the current domain if they have visited more than once
 *
 * @example $.splashpage('/home', { redirect_after: 3 } )
 * @desc Redirects visitors to /home of the current domain if they have visited more than three times
 *
 * @option redirect_after (Integer) - number of visits before redirect is triggered
 * @option cookie_name (String) - name of the cookie to store visit count
 * @option cookie_duration (Integer) - number of days until cookie expires if not visited after which the redirect stops
 * @option visit_reset (Boolean) - if true, the duration for the cookie will be reset each time the splash page redirects
 * @option testing (Boolean) - if true, shows redirect behavior in the console but does not actually redirect
 *
**/

jQuery.fn.splashboxes = function(options) {

  var components = {
    splash_boxes: this
  };

  var settings = jQuery.extend({
    mask_id:               'splash-mask',
    mask_background_color: '#000',
    mask_opacity:          0.8,

    position:        'top',
    skip_after:      1,
    cookie_name:     'splash_box_visits',
    cookie_duration: 30,
    visit_reset:     false,
    testing:         false,
    auto_show:       true,
    click_to_show:   ".splash-show",
    click_to_hide:   ".splash-hide"
  }, options);

  var state = {
    open: false
  };

  jQuery( components.splash_boxes ).hide();

//   if ( !jQuery("#" + settings.mask_id) )
  jQuery("body").append("<div id='" + settings.mask_id + "' style='display: none;' />");
  components.splash_mask = $("#" + settings.mask_id);

  build();

  function build(){

    var page_size = get_page_size();

    jQuery(components.splash_mask).css({
      position:         'absolute',
      zIndex:           1000,
      backgroundColor:  settings.mask_background_color,
      opacity:          settings.mask_opacity,
      top:              0,
      left:             0
    });

    jQuery(components.splash_boxes).css({
      zIndex:  1001
    });

    jQuery(components.splash_boxes).find( settings.click_to_hide ).click( function(){
      hide( $(this).attr('href').split('#')[1] );
      return false;
    });

    jQuery( settings.click_to_show ).click( function(){
      show( $(this).attr('href').split('#')[1] );
      return false;
    });

    jQuery(window).resize( reposition );
    jQuery(window).scroll( reposition );

  }

  function reposition(){
    if ( state.open ){

      var page_size = get_page_size();
      var page_scroll = get_page_scroll();

      jQuery(components.splash_mask).css({
        width:  page_size[0],
        height: page_size[1]
      })

      if (settings.position == 'center')
        top_pixles = page_scroll[1] + (page_size[3] / 2) - (jQuery(components.splash_boxes).height() / 2)
      else
        top_pixles = page_scroll[1] + (page_size[3] / 10)

      jQuery(components.splash_boxes).css({
        position:         'absolute',
        top:  top_pixles,
        left: page_scroll[0] + (page_size[2] / 2) - (jQuery(components.splash_boxes).width() / 2)
      });

    }
  }

  function show(id){

    jQuery('embed, object, select').css({ 'visibility' : 'hidden' });

    var page_size = get_page_size();
    var page_scroll = get_page_scroll();

    jQuery(components.splash_mask).css({
      width:  page_size[0],
      height: page_size[1]
    }).fadeIn();

    if (settings.position == 'center')
      top_pixles = page_scroll[1] + (page_size[3] / 2) - (jQuery(components.splash_boxes).height() / 2)
    else
      top_pixles = page_scroll[1] + (page_size[3] / 10)

    jQuery("#" + id).css({
      position:         'absolute',
      top:  top_pixles,
      left: page_scroll[0] + (page_size[2] / 2) - (jQuery(components.splash_boxes).width() / 2)
    }).fadeIn();

    state.open = true;

  }

  function hide(id){
    jQuery('embed, object, select').css({ 'visibility' : 'visible' });

    state.open = false;
    jQuery("#" + id).fadeOut();
    jQuery(components.splash_mask).fadeOut();
  }
//
  // ** utility methods **

  // @return Array Return an array with page width, height and window width, height
  // from quicksmode.com
  function get_page_size() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
      xScroll = window.innerWidth + window.scrollMaxX;
      yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
      xScroll = document.body.scrollWidth;
      yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
      xScroll = document.body.offsetWidth;
      yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer
      if(document.documentElement.clientWidth){
        windowWidth = document.documentElement.clientWidth;
      } else {
        windowWidth = self.innerWidth;
      }
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight;
    }
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
      pageHeight = windowHeight;
    } else {
      pageHeight = yScroll;
    }
    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){
      pageWidth = xScroll;
    } else {
      pageWidth = windowWidth;
    }
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
    return arrayPageSize;
  };

  // @return Array Return an array with x,y page scroll values.
  // from quicksmode.com
  function get_page_scroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {   // Explorer 6 Strict
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;
    }
    arrayPageScroll = new Array(xScroll,yScroll);
    return arrayPageScroll;
  };

}

/**
 * jQuery ti.splashpage plug-in 0.2
 *
 * http://www.trilogyinteractive.com
 *
 * Copyright (c) 2009 Trilogy Interactive
 *
**/

/**
 * Redirects from a splash page to a designated target_url after a set number of visits
 *
 * @usage $.splashpage(target_url, options_hash)
 *
 * @example $.splashpage('http://www.example.com/home')
 * @desc Redirects visitors to http://www.example.com/home if they have visited more than once
 *
 * @example $.splashpage('/home')
 * @desc Redirects visitors to /home of the current domain if they have visited more than once
 *
 * @example $.splashpage('/home', { redirect_after: 3 } )
 * @desc Redirects visitors to /home of the current domain if they have visited more than three times
 *
 * @option redirect_after (Integer) - number of visits before redirect is triggered
 * @option cookie_name (String) - name of the cookie to store visit count
 * @option cookie_duration (Integer) - number of days until cookie expires if not visited after which the redirect stops
 * @option visit_reset (Boolean) - if true, the duration for the cookie will be reset each time the splash page redirects
 * @option testing (Boolean) - if true, shows redirect behavior in the console but does not actually redirect
 *
**/

jQuery.splashpage = function(target_url,options) {

  settings = jQuery.extend({
    redirect_after:  1,
    cookie_name:     'splash_page_visits',
    cookie_duration: 30,
    visit_reset:     false,
    testing:         false
  }, options);

  number_of_visits = $.cookie( settings.cookie_name );

  if ( number_of_visits >= settings.redirect_after ){

    // this will reset the duration for the cookie only if the plugin is configured to do so
    if ( settings.visit_reset ) $.cookie( settings.cookie_name, number_of_visits, { expires: settings.cookie_duration, path: '/'} );

    if ( settings.testing )
      console.log( "redirecting to " + target_url );
    else{
      jQuery.document_redirect = true;
      window.location = target_url;
    }

    return true;

  } else {

    if ( number_of_visits )
      $.cookie( settings.cookie_name, ((number_of_visits*1) + 1 ), { expires: settings.cookie_duration, path: '/'} );
    else
      $.cookie( settings.cookie_name, 1, { expires: settings.cookie_duration, path: '/'} );

    return false;

  }

}

function JumpURL(selection) {
  var tempIndex, selectedURL;
  tempIndex = selection.selectedIndex;
  selectedURL = selection.options[tempIndex].value;
  window.location.href = selectedURL;
}

startList = function() {
  if (document.all&&document.getElementById) {
    navRoot = document.getElementById("menu");
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.nodeName=="LI") {
        node.onmouseover=function() {
          this.className+=" over";
        }
        node.onmouseout=function() {
          this.className=this.className.replace(" over", "");
        }
      }
    }
  }
}

function is_numeric(value){
  return !isNaN( parseFloat( value ) )
}

/*
 * ti.firebug-logger 0.1
 *
 * http://www.trilogyinteractive.com
 *
 * Copyright (c) 2009 Trilogy Interactive
 *
 */

// If firebug is not running in the browser, this code will create a console object that can receive
// log method calls, but does nothing with them. This prevents js errors from being thrown on
// browsers without firebug.

if (typeof console == 'undefined'){
  console = {
    log: function( message ){
      // alert(message);
    }
  }
}

$.validator.addMethod("phone_number", function(value, element) {
 return this.optional(element) || /^\d{3}[.-]{0,1}\d{3}[.-]{0,1}(\d{4})$/.test(value);
}, "Use xxx-xxx-xxxx format");
 
$.validator.addMethod("zip_code", function(value, element) {
 return this.optional(element) || /^(\d{5})(-\d{4})?$/.test(value);
}, "Must be a valid zip code");


