﻿
; (function($) {

    var expr = (function() {
        if (!$.browser.msie) return false;
        var div = document.createElement('div');
        try { div.style.setExpression('width', '0+0'); }
        catch (e) { return false; }
        return true;
    })();

    function sz(el, p) {
        return parseInt($.css(el, p)) || 0;
    };
    function hex2(s) {
        var s = parseInt(s).toString(16);
        return (s.length < 2) ? '0' + s : s;
    };
    function gpc(node) {
        for (; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode) {
            var v = $.css(node, 'backgroundColor');
            if (v == 'rgba(0, 0, 0, 0)')
                continue; // webkit
            if (v.indexOf('rgb') >= 0) {
                var rgb = v.match(/\d+/g);
                return '#' + hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
            }
            if (v && v != 'transparent')
                return v;
        }
        return '#ffffff';
    };

    function getWidth(fx, i, width) {
        switch (fx) {
            case 'round': return Math.round(width * (1 - Math.cos(Math.asin(i / width))));
            case 'cool': return Math.round(width * (1 + Math.cos(Math.asin(i / width))));
            case 'sharp': return Math.round(width * (1 - Math.cos(Math.acos(i / width))));
            case 'bite': return Math.round(width * (Math.cos(Math.asin((width - i - 1) / width))));
            case 'slide': return Math.round(width * (Math.atan2(i, width / i)));
            case 'jut': return Math.round(width * (Math.atan2(width, (width - i - 1))));
            case 'curl': return Math.round(width * (Math.atan(i)));
            case 'tear': return Math.round(width * (Math.cos(i)));
            case 'wicked': return Math.round(width * (Math.tan(i)));
            case 'long': return Math.round(width * (Math.sqrt(i)));
            case 'sculpt': return Math.round(width * (Math.log((width - i - 1), width)));
            case 'dog': return (i & 1) ? (i + 1) : width;
            case 'dog2': return (i & 2) ? (i + 1) : width;
            case 'dog3': return (i & 3) ? (i + 1) : width;
            case 'fray': return (i % 2) * width;
            case 'notch': return width;
            case 'bevel': return i + 1;
        }
    };

    $.fn.corner = function(o) {
        // in 1.3+ we can fix mistakes with the ready state
        if (this.length == 0) {
            if (!$.isReady && this.selector) {
                var s = this.selector, c = this.context;
                $(function() {
                    $(s, c).corner(o);
                });
            }
            return this;
        }

        o = (o || "").toLowerCase();
        var keep = /keep/.test(o);                       // keep borders?
        var cc = ((o.match(/cc:(#[0-9a-f]+)/) || [])[1]);  // corner color
        var sc = ((o.match(/sc:(#[0-9a-f]+)/) || [])[1]);  // strip color
        var width = parseInt((o.match(/(\d+)px/) || [])[1]) || 10; // corner width
        var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
        var fx = ((o.match(re) || ['round'])[0]);
        var edges = { T: 0, B: 1 };
        var opts = {
            TL: /top|tl/.test(o), TR: /top|tr/.test(o),
            BL: /bottom|bl/.test(o), BR: /bottom|br/.test(o)
        };
        if (!opts.TL && !opts.TR && !opts.BL && !opts.BR)
            opts = { TL: 1, TR: 1, BL: 1, BR: 1 };
        var strip = document.createElement('div');
        strip.style.overflow = 'hidden';
        strip.style.height = '1px';
        strip.style.backgroundColor = sc || 'transparent';
        strip.style.borderStyle = 'solid';
        return this.each(function(index) {
            var pad = {
                T: parseInt($.css(this, 'paddingTop')) || 0, R: parseInt($.css(this, 'paddingRight')) || 0,
                B: parseInt($.css(this, 'paddingBottom')) || 0, L: parseInt($.css(this, 'paddingLeft')) || 0
            };

            if (typeof this.style.zoom != undefined) this.style.zoom = 1; // force 'hasLayout' in IE
            if (!keep) this.style.border = 'none';
            strip.style.borderColor = cc || gpc(this.parentNode);
            var cssHeight = $.curCSS(this, 'height');

            for (var j in edges) {
                var bot = edges[j];
                // only add stips if needed
                if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
                    strip.style.borderStyle = 'none ' + (opts[j + 'R'] ? 'solid' : 'none') + ' none ' + (opts[j + 'L'] ? 'solid' : 'none');
                    var d = document.createElement('div');
                    $(d).addClass('jquery-corner');
                    var ds = d.style;

                    bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

                    if (bot && cssHeight != 'auto') {
                        if ($.css(this, 'position') == 'static')
                            this.style.position = 'relative';
                        ds.position = 'absolute';
                        ds.bottom = ds.left = ds.padding = ds.margin = '0';
                        if (expr)
                            ds.setExpression('width', 'this.parentNode.offsetWidth');
                        else
                            ds.width = '100%';
                    }
                    else if (!bot && $.browser.msie) {
                        if ($.css(this, 'position') == 'static')
                            this.style.position = 'relative';
                        ds.position = 'absolute';
                        ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';

                        // fix ie6 problem when blocked element has a border width
                        if (expr) {
                            var bw = sz(this, 'borderLeftWidth') + sz(this, 'borderRightWidth');
                            ds.setExpression('width', 'this.parentNode.offsetWidth - ' + bw + '+ "px"');
                        }
                        else
                            ds.width = '100%';
                    }
                    else {
                        ds.position = 'relative';
                        ds.margin = !bot ? '-' + pad.T + 'px -' + pad.R + 'px ' + (pad.T - width) + 'px -' + pad.L + 'px' :
                                        (pad.B - width) + 'px -' + pad.R + 'px -' + pad.B + 'px -' + pad.L + 'px';
                    }

                    for (var i = 0; i < width; i++) {
                        var w = Math.max(0, getWidth(fx, i, width));
                        var e = strip.cloneNode(false);
                        e.style.borderWidth = '0 ' + (opts[j + 'R'] ? w : 0) + 'px 0 ' + (opts[j + 'L'] ? w : 0) + 'px';
                        bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
                    }
                }
            }
        });
    };

    $.fn.uncorner = function() {
        $('div.jquery-corner', this).remove();
        return this;
    };

})(jQuery);


/**
 * FontEffect - jQuery plugin for font effect
 *
 * @author Alessandro Uliana (fonteffect@iofo.it)
 *
 * Copyright (c) 2009 Alessandro Uliana
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Demo and examples on
 * http://www.iofo.it/jquery/fonteffect/
 *
 * @requires jQuery v1.3.2
 * @version: 1.0.0 - 30/3/2009

(function($){var FE={};FE.divcounter=0;FE.tabpos=["","0001021020212212","00010203041020304041424344142434","000102030405061020304050606162636465162636465666"];FE.font={serif:"Georgia, 'Times New Roman', 'Century Schoolbook L', serif",sans_serif:"Verdana, Helvetica, Arial, 'URW Gothic L', sans-serif",monospace:"'Courier New', Courier, 'DejaVu Sans Mono', monospace",fantasy:"Impact, Papyrus, fantasy",cursive:"'Comic Sans MS' cursive"};$.fn.FontEffect=function(o){var d=$.extend({outline:false,outlineColor1:"",outlineColor2:"",outlineWeight:1,mirror:false,mirrorColor:"#000",mirrorOffset:-10,mirrorHeight:50,mirrorDetail:1,mirrorTLength:50,mirrorTStart:0.2,shadow:false,shadowColor:"#aaa",shadowOffsetTop:5,shadowOffsetLeft:5,shadowBlur:1,shadowOpacity:0.1,gradient:false,gradientColor:"",gradientFromTop:true,gradientPosition:20,gradientLength:50,gradientSteps:20,proportional:false,hideText:false,debug:false},o);this.not(".JQFE").each(function(){if(!d.outline&&!d.shadow&&!d.mirror&&!d.gradient){d.outline=true;};if(d.outline){if(d.outlineColor1==""&&d.outlineColor2==""){d.outlineColor1=pickcontrast($(this).css("color"));};if(d.outlineColor2=="")d.outlineColor2=d.outlineColor1;};if(d.gradient&&d.gradientColor==""){d.gradientColor=pickcontrast($(this).css("color"));};var userdisplay=$(this).css("display");var userposition=$(this).css("position");$(this).css({display:"inline",position:((userposition=="absolute")?"absolute":"relative")});var h=$(this).height();var w=$(this).width()*1.04;var W=w+"px";var H=h+"px";var t=$(this).html();$(this).data("options",d).addClass("JQFE").css({width:W,height:H,display:userdisplay,position:(($(this).css("position")!="absolute")?"relative":"absolute"),zoom:1});var MyContainer=$("<div></div>").css({width:W,height:H,position:"relative"});MyContainer.append($("<div class='JQFEText'>"+t+"</div>").css({display:d.hideText?"none":"inline",width:W,height:H,position:"relative",zIndex:100}));var alldivsup=$("<div></div>").css({width:W,height:H,left:"0px",position:"absolute",top:parseInt($(this).css("paddingTop"))*0+"px",zIndex:110});var alldivsdown=$(alldivsup).clone().css({zIndex:90});FE.divounter+=4;$(this).html("");if(d.mirror){for(i=0;i<h*(d.mirrorHeight/100);i++){if(d.proportional){var css_top1=(h+d.mirrorOffset+i*d.mirrorDetail).pxToEm({scope:this});var css_height=d.mirrorDetail.pxToEm({scope:this});var css_top2=((h*-1)+i*(100/d.mirrorHeight)).pxToEm({scope:this});}
else{var css_top1=(h+d.mirrorOffset+i*d.mirrorDetail)+"px";var css_height=d.mirrorDetail+"px";var css_top2=((h*-1)+i*(100/d.mirrorHeight))+"px";};var css_opacity=d.mirrorTStart-(i*(d.mirrorTStart/((d.mirrorHeight/100)*d.mirrorTLength)));var appo=$("<div class='JQFEMirror'></div>").css({position:"absolute",top:css_top1,height:css_height,width:W,overflow:"hidden"}).append($("<div>"+t+"</div>").css({position:"absolute",color:d.mirrorColor,top:css_top2,opacity:css_opacity}));FE.divounter+=i*2;if(css_opacity<0.01)break;alldivsdown.append(appo);};};if(d.outline){var totdiv=(d.outlineWeight)*8;var to=FE.tabpos[d.outlineWeight];for(i=0;i<totdiv;i++){appo=$("<div class='JQFEOutline'>"+t+"</div>").css({position:"absolute",top:(to.charAt(i*2)-d.outlineWeight)+"px",left:(to.charAt(i*2+1)-d.outlineWeight)+"px",width:W,color:((i<totdiv/2+d.outlineWeight)?d.outlineColor1:d.outlineColor2),zIndex:((i>totdiv-totdiv/3)?20:30)});FE.divounter+=i;alldivsdown.append(appo);};};if(d.shadow){var totdiv=(d.shadowBlur)*8;var to=FE.tabpos[d.shadowBlur];for(i=0;i<totdiv;i++){appo=$("<div class='JQFEShadow'>"+t+"</div>").css({opacity:d.shadowOpacity,position:"absolute",top:(to.charAt(i*2)-d.shadowBlur)+d.shadowOffsetTop+"px",left:(to.charAt(i*2+1)-d.shadowBlur)+d.shadowOffsetLeft+"px",width:W,height:H,color:d.shadowColor,zIndex:10});FE.divounter+=i;alldivsdown.append(appo);};};if(d.gradient){var step=Math.round((h*(d.gradientLength*0.01))/d.gradientSteps);var postop=h*(d.gradientPosition*0.01);var opa=(1/d.gradientSteps);var gcolor=d.gradientColor;for(i=0;i<d.gradientSteps;i++){if(d.proportional){css_top1=(((i==0)?0:postop)+i*step).pxToEm({scope:this});css_height=(((i==0)?postop:0)+step).pxToEm({scope:this});css_top2=((((i==0)?0:postop)+i*step)*-1).pxToEm({scope:this});}
else{css_top1=(((i==0)?0:postop)+i*step)+"px";css_height=(((i==0)?postop:0)+step)+"px";css_top2=((((i==0)?0:postop)+i*step)*-1)+"px";};appo=$("<div class='JQFEGradient'></div>").css({position:"absolute",top:css_top1,height:css_height,left:"0px",width:W,overflow:"hidden"}).append($("<div>"+t+"</div>").css({width:"100%",position:"absolute",top:css_top2,color:gcolor,opacity:1-opa*i}));FE.divounter+=i*2;alldivsup.append(appo);};};MyContainer.append(alldivsdown);MyContainer.append(alldivsup);$(this).append(MyContainer);});function hex2rgb(hexcolor){hexcolor=hexcolor.substring(1);if(hexcolor.length==3)hexcolor=hexcolor.charAt(0)+hexcolor.charAt(0)+hexcolor.charAt(1)+hexcolor.charAt(1)+hexcolor.charAt(2)+hexcolor.charAt(2);var rgbcolor="rgb("+parseInt(hexcolor.substring(0,2),16)+", "+parseInt(hexcolor.substring(2,4),16)+", "+parseInt(hexcolor.substring(4,6),16)+")";return(rgbcolor);};function chkColorString(col){return(/(#([0-9A-Fa-f]{3,6})\b)|(rgb\(\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*,\s*\b([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b\s*\))|(rgb\(\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*,\s*(\d?\d%|100%)+\s*\))/.test(col));};function pickcontrast(col){if(chkColorString(col)){col=col.toUpperCase();if(col.charAt(0)=="#")col=hex2rgb(col);var appo=col.substring(4,col.length-1).split(", ");var g=255-parseInt(appo[0]);var b=255-parseInt(appo[1]);var r=255-parseInt(appo[2]);col="rgb("+r+", "+g+", "+b+")";};return(col);};return this;};$.fn.changeOptionsFE=function(newoptions){if(this){var oldoptions=$(this).data("options")||{};$.extend(oldoptions,newoptions);$(this).data("options",oldoptions);};};$.fn.redrawFE=function(newoptions){if(this){if(newoptions)$(this).changeOptionsFE(newoptions);$(this).removeFE();$(this).FontEffect($(this).data("options"));};};$.fn.removeFE=function(removeoptions){if(this&&$(this).hasClass("JQFE")){var t=$(this).find("div[class='JQFEText']").html();$(this).removeClass("JQFE");if(removeoptions)$(this).data("options",{});$(this).find("div[class^='JQFE']").remove();$(this).html(t);};};})(jQuery);Number.prototype.pxToEm=String.prototype.pxToEm=function(settings){settings=$.extend({scope:'body',reverse:false},settings);var pxVal=(this=='')?0:parseFloat(this);var scopeVal;var getWindowWidth=function(){var de=document.documentElement;return self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;};if(settings.scope=='body'&&$.browser.msie&&(parseFloat($('body').css('font-size'))/getWindowWidth()).toFixed(1)>0.0){var calcFontSize=function(){return(parseFloat($('body').css('font-size'))/getWindowWidth()).toFixed(3)*16;};scopeVal=calcFontSize();}
else { scopeVal = parseFloat($(settings.scope).css("font-size")); }; var result = (settings.reverse == true) ? (pxVal * scopeVal).toFixed(2) + 'px' : (pxVal / scopeVal).toFixed(2) + 'em'; return result;
};

 */

Date.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
Date.abbrDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
Date.monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
Date.abbrMonthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
Date.firstDayOfWeek = 0;

Date.format = 'mm/dd/yyyy';

Date.fullYearStart = '20';

(function() {
    function add(name, method) {
        if (!Date.prototype[name]) {
            Date.prototype[name] = method;
        }
    };

    /**
    * Checks if the year is a leap year.
    *
    * @example var dtm = new Date("01/12/2008");
    * dtm.isLeapYear();
    * @result true
    *
    * @name isLeapYear
    * @type Boolean
    * @cat Plugins/Methods/Date
    */
    add("isLeapYear", function() {
        var y = this.getFullYear();
        return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
    });

    add("isWeekend", function() {
        return this.getDay() == 0 || this.getDay() == 6;
    });

    add("isWeekDay", function() {
        return !this.isWeekend();
    });

 
    add("getDaysInMonth", function() {
        return [31, (this.isLeapYear() ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][this.getMonth()];
    });

    add("getDayName", function(abbreviated) {
        return abbreviated ? Date.abbrDayNames[this.getDay()] : Date.dayNames[this.getDay()];
    });

  
    add("getMonthName", function(abbreviated) {
        return abbreviated ? Date.abbrMonthNames[this.getMonth()] : Date.monthNames[this.getMonth()];
    });

    add("getDayOfYear", function() {
        var tmpdtm = new Date("1/1/" + this.getFullYear());
        return Math.floor((this.getTime() - tmpdtm.getTime()) / 86400000);
    });

    add("getWeekOfYear", function() {
        return Math.ceil(this.getDayOfYear() / 7);
    });

    add("setDayOfYear", function(day) {
        this.setMonth(0);
        this.setDate(day);
        return this;
    });

   
    add("addYears", function(num) {
        this.setFullYear(this.getFullYear() + num);
        return this;
    });

    add("addMonths", function(num) {
        var tmpdtm = this.getDate();

        this.setMonth(this.getMonth() + num);

        if (tmpdtm > this.getDate())
            this.addDays(-this.getDate());

        return this;
    });

    add("addDays", function(num) {
        //this.setDate(this.getDate() + num);
        this.setTime(this.getTime() + (num * 86400000));
        return this;
    });

   
    add("addHours", function(num) {
        this.setHours(this.getHours() + num);
        return this;
    });

    add("addMinutes", function(num) {
        this.setMinutes(this.getMinutes() + num);
        return this;
    });

    add("addSeconds", function(num) {
        this.setSeconds(this.getSeconds() + num);
        return this;
    });

   
    add("zeroTime", function() {
        this.setMilliseconds(0);
        this.setSeconds(0);
        this.setMinutes(0);
        this.setHours(0);
        return this;
    });

    add("asString", function(format) {
        var r = format || Date.format;
        if (r.split('mm').length > 1) { // ugly workaround to make sure we don't replace the m's in e.g. noveMber
            r = r.split('mmmm').join(this.getMonthName(false))
				.split('mmm').join(this.getMonthName(true))
				.split('mm').join(_zeroPad(this.getMonth() + 1))
        } else {
            r = r.split('m').join(this.getMonth() + 1);
        }
        r = r.split('yyyy').join(this.getFullYear())
			.split('yy').join((this.getFullYear() + '').substring(2))
			.split('dd').join(_zeroPad(this.getDate()))
			.split('d').join(this.getDate());
        return r;
    });

    Date.fromString = function(s) {
        var f = Date.format;

        var d = new Date('01/01/1972');

        if (s == '') return d;

        s = s.toLowerCase();
        var matcher = '';
        var order = [];
        var r = /(dd?d?|mm?m?|yy?yy?)+([^(m|d|y)])?/g;
        var results;
        while ((results = r.exec(f)) != null) {
            switch (results[1]) {
                case 'd':
                case 'dd':
                case 'm':
                case 'mm':
                case 'yy':
                case 'yyyy':
                    matcher += '(\\d+\\d?\\d?\\d?)+';
                    order.push(results[1].substr(0, 1));
                    break;
                case 'mmm':
                    matcher += '([a-z]{3})';
                    order.push('M');
                    break;
            }
            if (results[2]) {
                matcher += results[2];
            }

        }
        var dm = new RegExp(matcher);
        var result = s.match(dm);
        if (result == null) return d;
        for (var i = 0; i < order.length; i++) {
            var res = result[i + 1];
            switch (order[i]) {
                case 'd':
                    d.setDate(res);
                    break;
                case 'm':
                    d.setMonth(Number(res) - 1);
                    break;
                case 'M':
                    for (var j = 0; j < Date.abbrMonthNames.length; j++) {
                        if (Date.abbrMonthNames[j].toLowerCase() == res) break;
                    }
                    d.setMonth(j);
                    break;
                case 'y':
                    d.setYear(res);
                    break;
            }
        }

        return d;
    };

    // utility method
    var _zeroPad = function(num) {
        var s = '0' + num;
        return s.substring(s.length - 2)
        //return ('0'+num).substring(-2); // doesn't work on IE :(
    };

})();


(function($) {

    $.fn.extend({
    
        renderCalendar: function(s) {
            var dc = function(a) {
                return document.createElement(a);
            };

            s = $.extend({}, $.fn.datePicker.defaults, s);

            if (s.showHeader != $.dpConst.SHOW_HEADER_NONE) {
                var headRow = $(dc('tr'));
                for (var i = Date.firstDayOfWeek; i < Date.firstDayOfWeek + 7; i++) {
                    var weekday = i % 7;
                    var day = Date.dayNames[weekday];
                    var abbrDay = Date.abbrDayNames[weekday];
                    headRow.append(
						jQuery(dc('th')).attr({ 'scope': 'col', 'abbr': day, 'title': day, 'class': (weekday == 0 || weekday == 6 ? 'weekend' : 'weekday') }).html(s.showHeader == $.dpConst.SHOW_HEADER_SHORT ? abbrDay : day)
					);
                }
            };

            var calendarTable = $(dc('table'))
									.attr(
										{
										    'cellspacing': 2
										}
									)
									.addClass('jCalendar')
									.append(
										(s.showHeader != $.dpConst.SHOW_HEADER_NONE ?
											$(dc('thead'))
												.append(headRow)
											:
											dc('thead')
										)
									);
            var tbody = $(dc('tbody'));

            var today = (new Date()).zeroTime();
            today.setHours(12);

            var month = s.month == undefined ? today.getMonth() : s.month;
            var year = s.year || today.getFullYear();

            var currentDate = (new Date(year, month, 1, 12, 0, 0));


            var firstDayOffset = Date.firstDayOfWeek - currentDate.getDay() + 1;
            if (firstDayOffset > 1) firstDayOffset -= 7;
            var weeksToDraw = Math.ceil(((-1 * firstDayOffset + 1) + currentDate.getDaysInMonth()) / 7);
            currentDate.addDays(firstDayOffset - 1);

            var doHover = function(firstDayInBounds) {
                return function() {
                    if (s.hoverClass) {
                        var $this = $(this);
                        if (!s.selectWeek) {
                            $this.addClass(s.hoverClass);
                        } else if (firstDayInBounds && !$this.is('.disabled')) {
                            $this.parent().addClass('activeWeekHover');
                        }
                    }
                }
            };
            var unHover = function() {
                if (s.hoverClass) {
                    var $this = $(this);
                    $this.removeClass(s.hoverClass);
                    $this.parent().removeClass('activeWeekHover');
                }
            };

            var w = 0;
            while (w++ < weeksToDraw) {
                var r = jQuery(dc('tr'));
                var firstDayInBounds = s.dpController ? currentDate > s.dpController.startDate : false;
                for (var i = 0; i < 7; i++) {
                    var thisMonth = currentDate.getMonth() == month;
                    var d = $(dc('td'))
								.text(currentDate.getDate() + '')
								.addClass((thisMonth ? 'current-month ' : 'other-month ') +
													(currentDate.isWeekend() ? 'weekend ' : 'weekday ') +
													(thisMonth && currentDate.getTime() == today.getTime() ? 'today ' : '')
								)
								.data('datePickerDate', currentDate.asString())
								.hover(doHover(firstDayInBounds), unHover)
							;
                    r.append(d);
                    if (s.renderCallback) {
                        s.renderCallback(d, currentDate, month, year);
                    }
                    // addDays(1) fails in some locales due to daylight savings. See issue 39.
                    //currentDate.addDays(1);
                    // set the time to midday to avoid any weird timezone issues??
                    currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() + 1, 12, 0, 0);
                }
                tbody.append(r);
            }
            calendarTable.append(tbody);

            return this.each(
				function() {
				    $(this).empty().append(calendarTable);
				}
			);
        },
     
        datePicker: function(s) {
            if (!$.event._dpCache) $.event._dpCache = [];

            // initialise the date picker controller with the relevant settings...
            s = $.extend({}, $.fn.datePicker.defaults, s);

            return this.each(
				function() {
				    var $this = $(this);
				    var alreadyExists = true;

				    if (!this._dpId) {
				        this._dpId = $.event.guid++;
				        $.event._dpCache[this._dpId] = new DatePicker(this);
				        alreadyExists = false;
				    }

				    if (s.inline) {
				        s.createButton = false;
				        s.displayClose = false;
				        s.closeOnSelect = false;
				        $this.empty();
				    }

				    var controller = $.event._dpCache[this._dpId];

				    controller.init(s);

				    if (!alreadyExists && s.createButton) {
				        // create it!
				        controller.button = $('<ul id="Ul1" class="buttonc1go"><li class="dp-choose-date" >&nbsp;</li></ul>')
								.bind(
									'click',
									function() {
                                     
                                        if ($("#dp-popup").is(':visible'))
                                        {
									        $this.dpClose(this);   
                                        }
                                        else
                                        {  
                                   //   
                                            $this.dpDisplay(this);  //alert("click");
									        this.focus();
									   //     return false;   
                                        }
									}
								)
                       //         .css({"position": "absolute", "top": $this[0].offsetTop, "left": $this[0].offsetWidth});
                       ;

                       
				        $this.css({"align": "bottom"}).after(controller.button);
				    }

				    if (!alreadyExists && $this.is(':text')) {
				        $this
							.bind(
								'dateSelected',
								function(e, selectedDate, $td) {
								    this.value = selectedDate.asString();
								}
							).bind(
								'change',
								function() {
								    if (this.value == '') {
								        controller.clearSelected();
								    } else {
								        var d = Date.fromString(this.value);
								        if (d) {
								            controller.setSelected(d, true, true);
								        }
								    }
								}
							);
				        if (s.clickInput) {
				            $this.bind(
								'click',
								function() {
								    // The change event doesn't happen until the input loses focus so we need to manually trigger it...
								    $this.trigger('change');
								    $this.dpDisplay();
								}
							);
				        }
				        var d = Date.fromString(this.value);
				        if (this.value != '' && d) {
				            controller.setSelected(d, true, true);
				        }
				    }

				    $this.addClass('dp-applied');

				}
			)
        },
      
        dpSetDisabled: function(s) {
            return _w.call(this, 'setDisabled', s);
        },
      
        dpSetStartDate: function(d) {
            return _w.call(this, 'setStartDate', d);
        },
    
        dpSetEndDate: function(d) {
            return _w.call(this, 'setEndDate', d);
        },
    
        dpGetSelected: function() {
            var c = _getController(this[0]);
            if (c) {
                return c.getSelected();
            }
            return null;
        },
       
        dpSetSelected: function(d, v, m, e) {
            if (v == undefined) v = true;
            if (m == undefined) m = true;
            if (e == undefined) e = true;
            return _w.call(this, 'setSelected', Date.fromString(d), v, m, e);
        },
       
        dpSetDisplayedMonth: function(m, y) {
            return _w.call(this, 'setDisplayedMonth', Number(m), Number(y), true);
        },
       
        dpDisplay: function(e) {
            return _w.call(this, 'display', e);
        },
       
        dpSetRenderCallback: function(a) {
            return _w.call(this, 'setRenderCallback', a);
        },
      
        dpSetPosition: function(v, h) {
            return _w.call(this, 'setPosition', v, h);
        },
       
        dpSetOffset: function(v, h) {
            return _w.call(this, 'setOffset', v, h);
        },
       
        dpClose: function() {
            return _w.call(this, '_closeCalendar', false, this[0]);
        },
        // private function called on unload to clean up any expandos etc and prevent memory links...
        _dpDestroy: function() {
            // TODO - implement this?
        }
    });

    // private internal function to cut down on the amount of code needed where we forward
    // dp* methods on the jQuery object on to the relevant DatePicker controllers...
    var _w = function(f, a1, a2, a3, a4) {
        return this.each(
			function() {
			    var c = _getController(this);
			    if (c) {
			        c[f](a1, a2, a3, a4);
			    }
			}
		);
    };

    function DatePicker(ele) {
        this.ele = ele;

        // initial values...
        this.displayedMonth = null;
        this.displayedYear = null;
        this.startDate = null;
        this.endDate = null;
        this.showYearNavigation = null;
        this.closeOnSelect = null;
        this.displayClose = null;
        this.rememberViewedMonth = null;
        this.selectMultiple = null;
        this.numSelectable = null;
        this.numSelected = null;
        this.verticalPosition = null;
        this.horizontalPosition = null;
        this.verticalOffset = null;
        this.horizontalOffset = null;
        this.button = null;
        this.renderCallback = [];
        this.selectedDates = {};
        this.inline = null;
        this.context = '#dp-popup';
        this.settings = {};
    };
    $.extend(
		DatePicker.prototype,
		{
		    init: function(s) {
		        this.setStartDate(s.startDate);
		        this.setEndDate(s.endDate);
		        this.setDisplayedMonth(Number(s.month), Number(s.year));
		        this.setRenderCallback(s.renderCallback);
		        this.showYearNavigation = s.showYearNavigation;
		        this.closeOnSelect = s.closeOnSelect;
		        this.displayClose = s.displayClose;
		        this.rememberViewedMonth = s.rememberViewedMonth;
		        this.selectMultiple = s.selectMultiple;
		        this.numSelectable = s.selectMultiple ? s.numSelectable : 1;
		        this.numSelected = 0;
		        this.verticalPosition = s.verticalPosition;
		        this.horizontalPosition = s.horizontalPosition;
		        this.hoverClass = s.hoverClass;
		        this.setOffset(s.verticalOffset, s.horizontalOffset);
		        this.inline = s.inline;
		        this.settings = s;
		        if (this.inline) {
		            this.context = this.ele;
		            this.display();
		        }
		    },
		    setStartDate: function(d) {
		        if (d) {
		            this.startDate = Date.fromString(d);
		        }
		        if (!this.startDate) {
		            this.startDate = (new Date()).zeroTime().addYears(-1);
		        }
		        this.setDisplayedMonth(this.displayedMonth, this.displayedYear);
		    },
		    setEndDate: function(d) {
		        if (d) {
		            this.endDate = Date.fromString(d);
		        }
		        if (!this.endDate) {
		            this.endDate = (new Date('12/31/2999')); // using the JS Date.parse function which expects mm/dd/yyyy
		        }
		        if (this.endDate.getTime() < this.startDate.getTime()) {
		            this.endDate = this.startDate;
		        }
		        this.setDisplayedMonth(this.displayedMonth, this.displayedYear);
		    },
		    setPosition: function(v, h) {
		        this.verticalPosition = v;
		        this.horizontalPosition = h;
		    },
		    setOffset: function(v, h) {
		        this.verticalOffset = parseInt(v) || 0;
		        this.horizontalOffset = parseInt(h) || 0;
		    },
		    setDisabled: function(s) {
		        $e = $(this.ele);
		        $e[s ? 'addClass' : 'removeClass']('dp-disabled');
		        if (this.button) {
		            $but = $(this.button);
		            $but[s ? 'addClass' : 'removeClass']('dp-disabled');
		            $but.attr('title', s ? '' : $.dpText.TEXT_CHOOSE_DATE);
		        }
		        if ($e.is(':text')) {
		            $e.attr('disabled', s ? 'disabled' : '');
		        }
		    },
		    setDisplayedMonth: function(m, y, rerender) {
		        if (this.startDate == undefined || this.endDate == undefined) {
		            return;
		        }
		        var s = new Date(this.startDate.getTime());
		        s.setDate(1);
		        var e = new Date(this.endDate.getTime());
		        e.setDate(1);

		        var t;
		        if ((!m && !y) || (isNaN(m) && isNaN(y))) {
		            // no month or year passed - default to current month
		            t = new Date().zeroTime();
		            t.setDate(1);
		        } else if (isNaN(m)) {
		            // just year passed in - presume we want the displayedMonth
		            t = new Date(y, this.displayedMonth, 1);
		        } else if (isNaN(y)) {
		            // just month passed in - presume we want the displayedYear
		            t = new Date(this.displayedYear, m, 1);
		        } else {
		            // year and month passed in - that's the date we want!
		            t = new Date(y, m, 1)
		        }
		        // check if the desired date is within the range of our defined startDate and endDate
		        if (t.getTime() < s.getTime()) {
		            t = s;
		        } else if (t.getTime() > e.getTime()) {
		            t = e;
		        }
		        var oldMonth = this.displayedMonth;
		        var oldYear = this.displayedYear;
		        this.displayedMonth = t.getMonth();
		        this.displayedYear = t.getFullYear();

		        if (rerender && (this.displayedMonth != oldMonth || this.displayedYear != oldYear)) {
		            this._rerenderCalendar();
		            $(this.ele).trigger('dpMonthChanged', [this.displayedMonth, this.displayedYear]);
		        }
		    },
		    setSelected: function(d, v, moveToMonth, dispatchEvents) {
		        if (d < this.startDate || d > this.endDate) {
		            // Don't allow people to select dates outside range...
		            return;
		        }
		        var s = this.settings;
		        if (s.selectWeek) {
		            d = d.addDays(-(d.getDay() - Date.firstDayOfWeek + 7) % 7);
		            if (d < this.startDate) // The first day of this week is before the start date so is unselectable...
		            {
		                return;
		            }
		        }
		        if (v == this.isSelected(d)) // this date is already un/selected
		        {
		            return;
		        }
		        if (this.selectMultiple == false) {
		            this.clearSelected();
		        } else if (v && this.numSelected == this.numSelectable) {
		            // can't select any more dates...
		            return;
		        }
		        if (moveToMonth && (this.displayedMonth != d.getMonth() || this.displayedYear != d.getFullYear())) {
		            this.setDisplayedMonth(d.getMonth(), d.getFullYear(), true);
		        }
		        this.selectedDates[d.asString()] = v;
		        this.numSelected += v ? 1 : -1;
		        var selectorString = 'td.' + (d.getMonth() == this.displayedMonth ? 'current-month' : 'other-month');
		        var $td;
		        $(selectorString, this.context).each(
					function() {
					    if ($(this).data('datePickerDate') == d.asString()) {
					        $td = $(this);
					        if (s.selectWeek) {
					            $td.parent()[v ? 'addClass' : 'removeClass']('selectedWeek');
					        }
					        $td[v ? 'addClass' : 'removeClass']('selected');
					    }
					}
				);
		        $('td', this.context).not('.selected')[this.selectMultiple && this.numSelected == this.numSelectable ? 'addClass' : 'removeClass']('unselectable');

		        if (dispatchEvents) {
		            var s = this.isSelected(d);
		            $e = $(this.ele);
		            var dClone = Date.fromString(d.asString());
		            $e.trigger('dateSelected', [dClone, $td, s]);
		            $e.trigger('change');
		        }
		    },
		    isSelected: function(d) {
		        return this.selectedDates[d.asString()];
		    },
		    getSelected: function() {
		        var r = [];
		        for (s in this.selectedDates) {
		            if (this.selectedDates[s] == true) {
		                r.push(Date.fromString(s));
		            }
		        }
		        return r;
		    },
		    clearSelected: function() {
		        this.selectedDates = {};
		        this.numSelected = 0;
		        $('td.selected', this.context).removeClass('selected').parent().removeClass('selectedWeek');
		    },
		    display: function(eleAlignTo) {
		        if ($(this.ele).is('.dp-disabled')) return;

		        eleAlignTo = eleAlignTo || this.ele;
		        var c = this;
		        var $ele = $(eleAlignTo);
		        var eleOffset = $ele.offset();

		        var $createIn;
		        var attrs;
		        var attrsCalendarHolder;
		        var cssRules;

		        if (c.inline) {
		            $createIn = $(this.ele);
		            attrs = {
		                'id': 'calendar-' + this.ele._dpId,
		                'class': 'dp-popup dp-popup-inline'
		            };

		            $('.dp-popup', $createIn).remove();
		            cssRules = {
		        };
		    } else {
		      
                $createIn=$('form');

                if (!$createIn)   $createIn = $('body');

		        attrs = {
		            'id': 'dp-popup',
		            'class': 'dp-popup'
		        };
		        var p = findPos(this.ele.id)
		        cssRules = { 'top': p.bottom + 1, 'left': p.left };
		      	      
		        
		        var _checkMouse = function(e) {
		            var el = e.target;
		            var cal = $('#dp-popup')[0];

                 

		            while (true) {
		                if (el == cal) {
		                    return true;
                        } else if ($(el).is("li") & $(el).attr("class")=="dp-choose-date")
                        {
                            return true;
                                                
		                } else if (el == document) {
		                    c._closeCalendar();
		                    return false;
		                } else {
		                    el = $(el).parent()[0];
		                }
		            }
		        };
		        this._checkMouse = _checkMouse;

		        c._closeCalendar(true);
		        $(document).bind(
						'keydown.datepicker',
						function(event) {
						    if (event.keyCode == 27) {
						        c._closeCalendar();
						    }
						}
					);
		    }

		    if (!c.rememberViewedMonth) {
		        var selectedDate = this.getSelected()[0];
		        if (selectedDate) {
		            selectedDate = new Date(selectedDate);
		            this.setDisplayedMonth(selectedDate.getMonth(), selectedDate.getFullYear(), false);
		        }
		    }

		    $createIn
					.append(
						$('<div></div>')
							.attr(attrs)
							.css(cssRules)
							.append(
//		    								$('<a href="#" class="selecteee">aaa</a>'),
								$('<h2></h2>'),
								$('<div class="dp-nav-prev"></div>')
									.append(
										$('<a class="dp-nav-prev-year" href="#" title="' + $.dpText.TEXT_PREV_YEAR + '">&lt;&lt;</a>')
											.bind(
												'click',
												function() {
												    return c._displayNewMonth.call(c, this, 0, -1);
												}
											),
										$('<a class="dp-nav-prev-month" href="#" title="' + $.dpText.TEXT_PREV_MONTH + '">&lt;</a>')
											.bind(
												'click',
												function() {
												    return c._displayNewMonth.call(c, this, -1, 0);
												}
											)
									),
								$('<div class="dp-nav-next"></div>')
									.append(
										$('<a class="dp-nav-next-year" href="#" title="' + $.dpText.TEXT_NEXT_YEAR + '">&gt;&gt;</a>')
											.bind(
												'click',
												function() {
												    return c._displayNewMonth.call(c, this, 0, 1);
												}
											),
										$('<a class="dp-nav-next-month" href="#" title="' + $.dpText.TEXT_NEXT_MONTH + '">&gt;</a>')
											.bind(
												'click',
												function() {
												    return c._displayNewMonth.call(c, this, 1, 0);
												}
											)
									),
								$('<div class="dp-calendar"></div>')
							)
							
						);

		    var $pop = this.inline ? $('.dp-popup', this.context) : $('#dp-popup');

            try  {$pop.DivMovable();} catch (e) {}

		    if (this.showYearNavigation == false) {
		        $('.dp-nav-prev-year, .dp-nav-next-year', c.context).css('display', 'none');
		    }
		    if (this.displayClose) {
		        $pop.append(
						$('<a href="#" id="dp-close">' + $.dpText.TEXT_CLOSE + '</a>')
							.bind(
								'click',
								function() {
								    c._closeCalendar();
								    return false;
								}
							)
					);
		    }
		    c._renderCalendar();

		    $(this.ele).trigger('dpDisplayed', $pop);
            $(this.ele).trigger('change');

		    if (!c.inline) {
		        if (this.verticalPosition == $.dpConst.POS_BOTTOM) {
		            $pop.css('top', eleOffset.top + $ele.height() - $pop.height() + c.verticalOffset);
		        }
		        if (this.horizontalPosition == $.dpConst.POS_RIGHT) {
		            $pop.css('left', eleOffset.left + $ele.width() - $pop.width() + c.horizontalOffset);
		        }
		        //					$('.selectee', this.context).focus();
		        $(document).bind('mousedown.datepicker', this._checkMouse);
		    }

             
		},
		setRenderCallback: function(a) {
		    if (a == null) return;
		    if (a && typeof (a) == 'function') {
		        a = [a];
		    }
		    this.renderCallback = this.renderCallback.concat(a);
		},
		cellRender: function($td, thisDate, month, year) {
		    var c = this.dpController;
		    var d = new Date(thisDate.getTime());

		    // add our click handlers to deal with it when the days are clicked...

		    $td.bind(
					'click',
					function() {
					    var $this = $(this);
					    if (!$this.is('.disabled')) {
					        c.setSelected(d, !$this.is('.selected') || !c.selectMultiple, false, true);
					        if (c.closeOnSelect) {
					            c._closeCalendar();
					        }
					        // TODO: Instead of this which doesn't work in IE anyway we should find the next focusable element in the document
					        // and pass the focus onto that. That would allow the user to continue on the form as expected...
					        if (!$.browser.msie) {
					            $(c.ele).trigger('focus', [$.dpConst.DP_INTERNAL_FOCUS]);
					        }
					    }
					}
				);
		    if (c.isSelected(d)) {
		        $td.addClass('selected');
		        if (c.settings.selectWeek) {
		            $td.parent().addClass('selectedWeek');
		        }
		    } else if (c.selectMultiple && c.numSelected == c.numSelectable) {
		        $td.addClass('unselectable');
		    }

		},
		_applyRenderCallbacks: function() {
		    var c = this;
		    $('td', this.context).each(
					function() {
					    for (var i = 0; i < c.renderCallback.length; i++) {
					        $td = $(this);
					        c.renderCallback[i].apply(this, [$td, Date.fromString($td.data('datePickerDate')), c.displayedMonth, c.displayedYear]);
					    }
					}
				);
		    return;
		},
		// ele is the clicked button - only proceed if it doesn't have the class disabled...
		// m and y are -1, 0 or 1 depending which direction we want to go in...
		_displayNewMonth: function(ele, m, y) {
		    if (!$(ele).is('.disabled')) {
		        this.setDisplayedMonth(this.displayedMonth + m, this.displayedYear + y, true);
		    }
		    ele.blur();
		    return false;
		},
		_rerenderCalendar: function() {
		    this._clearCalendar();
		    this._renderCalendar();
		},
		_renderCalendar: function() {
		    // set the title...
		    $('h2', this.context).html((new Date(this.displayedYear, this.displayedMonth, 1)).asString($.dpText.HEADER_FORMAT));

		    // render the calendar...
		    $('.dp-calendar', this.context).renderCalendar(
					$.extend(
						{},
						this.settings,
						{
						    month: this.displayedMonth,
						    year: this.displayedYear,
						    renderCallback: this.cellRender,
						    dpController: this,
						    hoverClass: this.hoverClass
						})
				);

		    // update the status of the control buttons and disable dates before startDate or after endDate...
		    // TODO: When should the year buttons be disabled? When you can't go forward a whole year from where you are or is that annoying?
		    if (this.displayedYear == this.startDate.getFullYear() && this.displayedMonth == this.startDate.getMonth()) {
		        $('.dp-nav-prev-year', this.context).addClass('disabled');
		        $('.dp-nav-prev-month', this.context).addClass('disabled');
		        $('.dp-calendar td.other-month', this.context).each(
						function() {
						    var $this = $(this);
						    if (Number($this.text()) > 20) {
						        $this.addClass('disabled');
						    }
						}
					);
		        var d = this.startDate.getDate();
		        $('.dp-calendar td.current-month', this.context).each(
						function() {
						    var $this = $(this);
						    if (Number($this.text()) < d) {
						        $this.addClass('disabled');
						    }
						}
					);
		    } else {
		        $('.dp-nav-prev-year', this.context).removeClass('disabled');
		        $('.dp-nav-prev-month', this.context).removeClass('disabled');
		        var d = this.startDate.getDate();
		        if (d > 20) {
		            // check if the startDate is last month as we might need to add some disabled classes...
		            var st = this.startDate.getTime();
		            var sd = new Date(st);
		            sd.addMonths(1);
		            if (this.displayedYear == sd.getFullYear() && this.displayedMonth == sd.getMonth()) {
		                $('.dp-calendar td.other-month', this.context).each(
								function() {
								    var $this = $(this);
								    if (Date.fromString($this.data('datePickerDate')).getTime() < st) {
								        $this.addClass('disabled');
								    }
								}
							);
		            }
		        }
		    }
		    if (this.displayedYear == this.endDate.getFullYear() && this.displayedMonth == this.endDate.getMonth()) {
		        $('.dp-nav-next-year', this.context).addClass('disabled');
		        $('.dp-nav-next-month', this.context).addClass('disabled');
		        $('.dp-calendar td.other-month', this.context).each(
						function() {
						    var $this = $(this);
						    if (Number($this.text()) < 14) {
						        $this.addClass('disabled');
						    }
						}
					);
		        var d = this.endDate.getDate();
		        $('.dp-calendar td.current-month', this.context).each(
						function() {
						    var $this = $(this);
						    if (Number($this.text()) > d) {
						        $this.addClass('disabled');
						    }
						}
					);
		    } else {
		        $('.dp-nav-next-year', this.context).removeClass('disabled');
		        $('.dp-nav-next-month', this.context).removeClass('disabled');
		        var d = this.endDate.getDate();
		        if (d < 13) {
		            // check if the endDate is next month as we might need to add some disabled classes...
		            var ed = new Date(this.endDate.getTime());
		            ed.addMonths(-1);
		            if (this.displayedYear == ed.getFullYear() && this.displayedMonth == ed.getMonth()) {
		                $('.dp-calendar td.other-month', this.context).each(
								function() {
								    var $this = $(this);
								    var cellDay = Number($this.text());
								    if (cellDay < 13 && cellDay > d) {
								        $this.addClass('disabled');
								    }
								}
							);
		            }
		        }
		    }
		    this._applyRenderCallbacks();
		},
		_closeCalendar: function(programatic, ele) {
		    if (!ele || ele == this.ele) {
		        $(document).unbind('mousedown.datepicker');
		        $(document).unbind('keydown.datepicker');
		        this._clearCalendar();
		        $('#dp-popup a').unbind();
		        $('#dp-popup').empty().remove();
		        if (!programatic) {
		            $(this.ele).trigger('dpClosed', [this.getSelected()]);
		        }
            
		    }
		},
		// empties the current dp-calendar div and makes sure that all events are unbound
		// and expandos removed to avoid memory leaks...
		_clearCalendar: function() {
		    // TODO.
		    $('.dp-calendar td', this.context).unbind();
		    $('.dp-calendar', this.context).empty();
		}
}
	);

    // static constants
    $.dpConst = {
        SHOW_HEADER_NONE: 0,
        SHOW_HEADER_SHORT: 1,
        SHOW_HEADER_LONG: 2,
        POS_TOP: 0,
        POS_BOTTOM: 1,
        POS_LEFT: 0,
        POS_RIGHT: 1,
        DP_INTERNAL_FOCUS: 'dpInternalFocusTrigger'
    };
    // localisable text
    $.dpText = {
        TEXT_PREV_YEAR: 'Previous year',
        TEXT_PREV_MONTH: 'Previous month',
        TEXT_NEXT_YEAR: 'Next year',
        TEXT_NEXT_MONTH: 'Next month',
        TEXT_CLOSE: 'Close',
        TEXT_CHOOSE_DATE: 'Choose date',
        HEADER_FORMAT: 'mmmm yyyy'
    };
    // version
    $.dpVersion = '$Id: jquery.datePicker.js 84 2009-08-05 17:54:35Z kelvin.luck@gmail.com $';

    $.fn.datePicker.defaults = {
        month: undefined,
        year: undefined,
        showHeader: $.dpConst.SHOW_HEADER_SHORT,
        startDate: undefined,
        endDate: undefined,
        inline: false,
        renderCallback: null,
        createButton: true,
        showYearNavigation: true,
        closeOnSelect: true,
        displayClose: false,
        selectMultiple: false,
        numSelectable: Number.MAX_VALUE,
        clickInput: false,
        rememberViewedMonth: true,
        selectWeek: false,
        verticalPosition: $.dpConst.POS_TOP,
        horizontalPosition: $.dpConst.POS_LEFT,
        verticalOffset: 0,
        horizontalOffset: 0,
        hoverClass: 'dp-hover'
    };

    function _getController(ele) {
        if (ele._dpId) return $.event._dpCache[ele._dpId];
        return false;
    };

    // make it so that no error is thrown if bgIframe plugin isn't included (allows you to use conditional
    // comments to only include bgIframe where it is needed in IE without breaking this plugin).
    if ($.fn.bgIframe == undefined) {
        $.fn.bgIframe = function() { return this; };
    };


    // clean-up
    $(window)
		.bind('unload', function() {
		    var els = $.event._dpCache || [];
		    for (var i in els) {
		        $(els[i].ele)._dpDestroy();
		    }
		});


})(jQuery);
