/* ********** ***** ********** **

Included plugins:
	- jquery.birthday-picker.min.js
	- jquery.cookie.js

** ********** ***** ********** */

/*
 * jQuery Birthday Picker: v1.2 - 3/21/2011
 * http://abecoffman.com/stuff/birthdaypicker
 * 
 * Copyright (c) 2010 Abe Coffman
 * Dual licensed under the MIT and GPL licenses.
 * 
 */
(function(d){var a={"short":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"long":["January","February","March","April","May","June","July","August","September","October","November","December"]},b=new Date(),c=b.getFullYear(),f=b.getMonth()+1,e=b.getDate();d.fn.birthdaypicker=function(g){var h={maxAge:120,futureDates:false,maxYear:c,dateFormat:"middleEndian",monthFormat:"short",placeholder:true,legend:"",defaultDate:false,hiddenDate:true};return this.each(function(){if(g){d.extend(h,g)}var r=d("<fieldset class='birthday-picker'></fieldset>"),q=d("<select class='birth-year' name='birth[year]'></select>"),p=d("<select class='birth-month' name='birth[month]'></select>"),m=d("<select class='birth-day' name='birth[day]'></select>");if(h.legend){d("<legend>"+h.legend+"</legend>").appendTo(r)}var n; justinq=d("<div class='form-item'><label>Year</label></div>").append(q); justinp=d("<div class='form-item'><label>Month</label></div>").append(p); justinm=d("<div class='form-item'><label>Day</label></div>").append(m); if(h.dateFormat=="bigEndian"){n=c+"-"+f+"-"+e;r.append(justinq).append(justinp).append(justinm)}else{if(h.dateFormat=="littleEndian"){n=e+"-"+f+"-"+c;r.append(justinm).append(justinp).append(justinq)}else{r.append(justinp).append(justinm).append(justinq);n=f+"-"+e+"-"+c}}if(h.placeholder){d("<option value='0'>&nbsp;</option>").appendTo(q);d("<option value='0'>&nbsp;</option>").appendTo(p);d("<option value='0'>&nbsp;</option>").appendTo(m);n=null}if(h.defaultDate){n=h.defaultDate}if(h.hiddenDate){d("<input type='hidden' name='birthdate' />").val(n).appendTo(r)}var s=c;var t=c-h.maxAge;if(h.futureDates&&h.maxYear!=c){if(h.maxYear>1000){s=h.maxYear}else{s=c+h.maxYear}}while(s>=t){d("<option></option>").attr("value",s).text(s).appendTo(q);s--}for(var o=0;o<12;o++){d("<option></option>").attr("value",o+1).text(a[h.monthFormat][o]).appendTo(p)}for(var l=1;l<32;l++){d("<option></option>").attr("value",l).text(l).appendTo(m)}d(this).append(r);if(h.defaultDate){var i=new Date(h.defaultDate);q.val(i.getFullYear());p.val(i.getMonth()+1);m.val(i.getDate())}r.change(function(){var k=parseInt(p.children(":last").val()),y=parseInt(m.children(":last").val()),j=new Date(q.val(),p.val(),0),w=j.getDate();if(y>w){while(y>w){m.children(":last").remove();y--}}else{if(y<w){while(y<w){d("<option></option>").attr("value",y+1).text(y+1).appendTo(m);y++}}}if(!h.futureDates&&q.val()==u){if(k>x){while(k>x){p.children(":last").remove();k--}}if(p.val()==x){if(y>v){while(y>v){m.children(":last").remove();y--}}}}if(q.val()!=u&&k!=12){while(k<12){d("<option></option>").attr("value",k+1).text(a[h.monthFormat][k]).appendTo(p);k++}}var u=q.val(),x=p.val(),v=m.val();if((u*x*v)!=0){if(h.dateFormat=="bigEndian"){n=u+"-"+x+"-"+v}else{if(h.dateFormat=="littleEndian"){n=v+"-"+x+"-"+u}else{n=x+"-"+v+"-"+u}}d(this).children('input[type="hidden"]').val(n)}})})}})(jQuery);


/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 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
 *
 */
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

