/*Loading Jquery WYSIWYG*/  
(function( $ )
{
    $.fn.document = function()
    {
        var element = this.get(0);

        if ( element.nodeName.toLowerCase() == 'iframe' )
            {
            return element.contentWindow.document;
            /*
            return ( $.browser.msie )
            ? document.frames[element.id].document
            : element.contentWindow.document // contentDocument;
            */
        }
        return this;
    };

    $.fn.documentSelection = function()
    {
        var element = this.get(0);

        if ( element.contentWindow.document.selection )
            return element.contentWindow.document.selection.createRange().text;
        else
            return element.contentWindow.getSelection().toString();
    };

    $.fn.wysiwyg = function( options )
    {
        if ( arguments.length > 0 && arguments[0].constructor == String )
            {
            var action = arguments[0].toString();
            var params = [];

            for ( var i = 1; i < arguments.length; i++ )
                params[i - 1] = arguments[i];

            if ( action in Wysiwyg )
                {
                return this.each(function()
                {
                    $.data(this, 'wysiwyg')
                    .designMode();

                    Wysiwyg[action].apply(this, params);
                });
            }
            else return this;
        }

        var controls = {};

        /**
        * If the user set custom controls, we catch it, and merge with the
        * defaults controls later.
        */
        if ( options && options.controls )
            {
            var controls = options.controls;
            delete options.controls;
        }

        options = $.extend({
            html : '<'+'?xml version="1.0" encoding="UTF-8"?'+'><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">STYLE_SHEET</head><body style="margin: 0px;">INITIAL_CONTENT</body></html>',
            css  : {},

            debug        : false,

            autoSave     : true,  // http://code.google.com/p/jwysiwyg/issues/detail?id=11
            rmUnwantedBr : true,  // http://code.google.com/p/jwysiwyg/issues/detail?id=15
            brIE         : true,

            controls : {},
            messages : {}
        }, options);

        options.messages = $.extend(true, options.messages, Wysiwyg.MSGS_EN);
        options.controls = $.extend(true, options.controls, Wysiwyg.TOOLBAR);

        for ( var control in controls )
            {
            if ( control in options.controls )
                $.extend(options.controls[control], controls[control]);
            else
                options.controls[control] = controls[control];
        }

        // not break the chain
        return this.each(function()
        {
            Wysiwyg(this, options);
        });
    };

    function Wysiwyg( element, options )
    {
        return this instanceof Wysiwyg
        ? this.init(element, options)
        : new Wysiwyg(element, options);
    }

    $.extend(Wysiwyg, {
        insertImage : function( szURL, attributes )
        {
            var self = $.data(this, 'wysiwyg');

            if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
                {
                if ($.browser.msie) self.focus();
                if ( attributes )
                    {
                    self.editorDoc.execCommand('insertImage', false, '#jwysiwyg#');
                    var img = self.getElementByAttributeValue('img', 'src', '#jwysiwyg#');

                    if ( img )
                        {
                        img.src = szURL;

                        for ( var attribute in attributes )
                            {
                            img.setAttribute(attribute, attributes[attribute]);
                        }
                    }
                }
                else
                    {
                    self.editorDoc.execCommand('insertImage', false, szURL);
                }
            }
        },

        createLink : function( szURL )
        {
            var self = $.data(this, 'wysiwyg');

            if ( self.constructor == Wysiwyg && szURL && szURL.length > 0 )
                {
                var selection = $(self.editor).documentSelection();

                if ( selection.length > 0 )
                    {
                    if ($.browser.msie) self.focus();
                    self.editorDoc.execCommand('unlink', false, []);
                    self.editorDoc.execCommand('createLink', false, szURL);
                }
                else if ( self.options.messages.nonSelection )
                    alert(self.options.messages.nonSelection);
            }
        },

        insertHtml : function( szHTML )
        {
            var self = $.data(this, 'wysiwyg');

            if ( self.constructor == Wysiwyg && szHTML && szHTML.length > 0 )
                {
                if ($.browser.msie)
                    {
                    self.focus();
                    self.editorDoc.execCommand('insertImage', false, '#jwysiwyg#');
                    var img = self.getElementByAttributeValue('img', 'src', '#jwysiwyg#');
                    if (img)
                        {
                        $(img).replaceWith(szHTML);
                    }
                }
                else
                    {
                    self.editorDoc.execCommand('insertHTML', false, szHTML);
                }
            }
        },

        setContent : function( newContent )
        {
            var self = $.data(this, 'wysiwyg');
            self.setContent( newContent );
            self.saveContent();
        },

        clear : function()
        {
            var self = $.data(this, 'wysiwyg');
            self.setContent('');
            self.saveContent();
        },

        MSGS_EN : {
            nonSelection : 'select the text you wish to link'
        },

        TOOLBAR : {
            bold          : { visible : true, tags : ['b', 'strong'], css : { fontWeight : 'bold' }, tooltip : "Bold" },
            italic        : { visible : true, tags : ['i', 'em'], css : { fontStyle : 'italic' }, tooltip : "Italic" },
            strikeThrough : { visible : true, tags : ['s', 'strike'], css : { textDecoration : 'line-through' }, tooltip : "Strike-through" },
            underline     : { visible : true, tags : ['u'], css : { textDecoration : 'underline' }, tooltip : "Underline" },

            separator00 : { visible : true, separator : true },

            justifyLeft   : { visible : true, css : { textAlign : 'left' }, tooltip : "Justify Left" },
            justifyCenter : { visible : true, tags : ['center'], css : { textAlign : 'center' }, tooltip : "Justify Center" },
            justifyRight  : { visible : true, css : { textAlign : 'right' }, tooltip : "Justify Right" },
            justifyFull   : { visible : true, css : { textAlign : 'justify' }, tooltip : "Justify Full" },

            separator01 : { visible : true, separator : true },

            indent  : { visible : true, tooltip : "Indent" },
            outdent : { visible : true, tooltip : "Outdent" },

            separator02 : { visible : false, separator : true },

            subscript   : { visible : true, tags : ['sub'], tooltip : "Subscript" },
            superscript : { visible : true, tags : ['sup'], tooltip : "Superscript" },

            separator03 : { visible : true, separator : true },

            undo : { visible : true, tooltip : "Undo" },
            redo : { visible : true, tooltip : "Redo" },

            separator04 : { visible : true, separator : true },

            insertOrderedList    : { visible : true, tags : ['ol'], tooltip : "Insert Ordered List" },
            insertUnorderedList  : { visible : true, tags : ['ul'], tooltip : "Insert Unordered List" },
            insertHorizontalRule : { visible : true, tags : ['hr'], tooltip : "Insert Horizontal Rule" },

            separator05 : { separator : true },

            createLink : {
                visible : true,
                exec    : function()
                {
                    var selection = $(this.editor).documentSelection();

                    if ( selection.length > 0 )
                        {
                        if ( $.browser.msie )
                            {
                            this.focus();
                            this.editorDoc.execCommand('createLink', true, null);
                        }
                        else
                            {
                            var szURL = prompt('URL', 'http://');

                            if ( szURL && szURL.length > 0 )
                                {
                                this.editorDoc.execCommand('unlink', false, []);
                                this.editorDoc.execCommand('createLink', false, szURL);
                            }
                        }
                    }
                    else if ( this.options.messages.nonSelection )
                        alert(this.options.messages.nonSelection);
                },

                tags : ['a'],
                tooltip : "Create link"
            },

            insertImage : {
                visible : true,
                exec    : function()
                {
                    if ( $.browser.msie )
                        {
                        this.focus();
                        this.editorDoc.execCommand('insertImage', true, null);
                    }
                    else
                        {
                        var szURL = prompt('URL', 'http://');

                        if ( szURL && szURL.length > 0 )
                            this.editorDoc.execCommand('insertImage', false, szURL);
                    }
                },

                tags : ['img'],
                tooltip : "Insert image"
            },

            separator06 : { separator : true },

            h1mozilla : { visible : true && $.browser.mozilla, className : 'h1', command : 'heading', arguments : ['h1'], tags : ['h1'], tooltip : "Header 1" },
            h2mozilla : { visible : true && $.browser.mozilla, className : 'h2', command : 'heading', arguments : ['h2'], tags : ['h2'], tooltip : "Header 2" },
            h3mozilla : { visible : true && $.browser.mozilla, className : 'h3', command : 'heading', arguments : ['h3'], tags : ['h3'], tooltip : "Header 3" },

            h1 : { visible : true && !( $.browser.mozilla ), className : 'h1', command : 'formatBlock', arguments : ['<H1>'], tags : ['h1'], tooltip : "Header 1" },
            h2 : { visible : true && !( $.browser.mozilla ), className : 'h2', command : 'formatBlock', arguments : ['<H2>'], tags : ['h2'], tooltip : "Header 2" },
            h3 : { visible : true && !( $.browser.mozilla ), className : 'h3', command : 'formatBlock', arguments : ['<H3>'], tags : ['h3'], tooltip : "Header 3" },

            separator07 : { visible : false, separator : true },

            cut   : { visible : false, tooltip : "Cut" },
            copy  : { visible : false, tooltip : "Copy" },
            paste : { visible : false, tooltip : "Paste" },

            separator08 : { separator : false && !( $.browser.msie ) },

            increaseFontSize : { visible : false && !( $.browser.msie ), tags : ['big'], tooltip : "Increase font size" },
            decreaseFontSize : { visible : false && !( $.browser.msie ), tags : ['small'], tooltip : "Decrease font size" },

            separator09 : { separator : true },

            html : {
                visible : false,
                exec    : function()
                {
                    if ( this.viewHTML )
                        {
                        this.setContent( $(this.original).val() );
                        $(this.original).hide();
                    }
                    else
                        {
                        this.saveContent();
                        $(this.original).show();
                    }

                    this.viewHTML = !( this.viewHTML );
                },
                tooltip : "View source code"
            },

            removeFormat : {
                visible : true,
                exec    : function()
                {
                    if ($.browser.msie) this.focus();
                    this.editorDoc.execCommand('removeFormat', false, []);
                    this.editorDoc.execCommand('unlink', false, []);
                },
                tooltip : "Remove formatting"
            }
        }
    });

    $.extend(Wysiwyg.prototype,
    {
        original : null,
        options  : {},

        element  : null,
        editor   : null,

        focus : function()
        {
            $(this.editorDoc.body).focus();
        },

        init : function( element, options )
        {
            var self = this;

            this.editor = element;
            this.options = options || {};

            $.data(element, 'wysiwyg', this);

            var newX = element.width || element.clientWidth;
            var newY = element.height || element.clientHeight;

            if ( element.nodeName.toLowerCase() == 'textarea' )
                {
                this.original = element;

                if ( newX == 0 && element.cols )
                    newX = ( element.cols * 8 ) + 21;

                if ( newY == 0 && element.rows )
                    newY = ( element.rows * 16 ) + 16;

                var editor = this.editor = $('<iframe src="javascript:false;"></iframe>').css({
                    minHeight : ( newY - 6 ).toString() + 'px',
                    width     : ( newX - 8 ).toString() + 'px'
                }).attr('id', $(element).attr('id') + 'IFrame')
                .attr('frameborder', '0');

                /**
                * http://code.google.com/p/jwysiwyg/issues/detail?id=96
                */
                this.editor.attr('tabindex', $(element).attr('tabindex'));

                if ( $.browser.msie )
                    {
                    this.editor
                    .css('height', ( newY ).toString() + 'px');

                    /**
                    var editor = $('<span></span>').css({
                    width     : ( newX - 6 ).toString() + 'px',
                    height    : ( newY - 8 ).toString() + 'px'
                    }).attr('id', $(element).attr('id') + 'IFrame');

                    editor.outerHTML = this.editor.outerHTML;
                    */
                }
            }

            var panel = this.panel = $('<ul role="menu" class="panel"></ul>');

            this.appendControls();
            this.element = $('<div></div>').css({
                width : ( newX > 0 ) ? ( newX ).toString() + 'px' : '100%'
            }).addClass('wysiwyg')
            .append(panel)
            .append( $('<div><!-- --></div>').css({ clear : 'both' }) )
            .append(editor)
            ;

            $(element)
            .hide()
            .before(this.element)
            ;

            this.viewHTML = false;
            this.initialHeight = newY - 8;

            /**
            * @link http://code.google.com/p/jwysiwyg/issues/detail?id=52
            */
            this.initialContent = $(element).val();
            this.initFrame();

            if ( this.initialContent.length == 0 )
                this.setContent('');

            /**
            * http://code.google.com/p/jwysiwyg/issues/detail?id=100
            */
            var form = $(element).closest('form');

            if ( this.options.autoSave )
                {
                form.submit(function() { self.saveContent(); });
            }

            form.bind('reset', function()
            {
                self.setContent( self.initialContent );
                self.saveContent();
            });
        },

        initFrame : function()
        {
            var self = this;
            var style = '';

            /**
            * @link http://code.google.com/p/jwysiwyg/issues/detail?id=14
            */
            if ( this.options.css && this.options.css.constructor == String )
                {
                style = '<link rel="stylesheet" type="text/css" media="screen" href="' + this.options.css + '" />';
            }

            this.editorDoc = $(this.editor).document();
            this.editorDoc_designMode = false;

            try {
                this.editorDoc.designMode = 'on';
                this.editorDoc_designMode = true;
            } catch ( e ) {
                // Will fail on Gecko if the editor is placed in an hidden container element
                // The design mode will be set ones the editor is focused

                $(this.editorDoc).focus(function()
                {
                    self.designMode();
                });
            }

            this.editorDoc.open();
            this.editorDoc.write(
            this.options.html
            /**
            * @link http://code.google.com/p/jwysiwyg/issues/detail?id=144
            */
            .replace(/INITIAL_CONTENT/, function() { return self.initialContent; })
            .replace(/STYLE_SHEET/, function() { return style; })
            );
            this.editorDoc.close();

            this.editorDoc.contentEditable = 'true';

            if ( $.browser.msie )
                {
                /**
                * Remove the horrible border it has on IE.
                */
                setTimeout(function() { $(self.editorDoc.body).css('border', 'none'); }, 0);
            }

            $(this.editorDoc).click(function( event )
            {
                self.checkTargets( event.target ? event.target : event.srcElement);
            });

            /**
            * @link http://code.google.com/p/jwysiwyg/issues/detail?id=20
            */
            $(this.original).focus(function()
            {
                if (!$.browser.msie)
                    {
                    self.focus();
                }
            });

            if ( this.options.autoSave )
                {
                /**
                * @link http://code.google.com/p/jwysiwyg/issues/detail?id=11
                */
                $(this.editorDoc).keydown(function() { self.saveContent(); })
                .keyup(function() { self.saveContent(); })
                .mousedown(function() { self.saveContent(); });
            }

            if ( this.options.css )
                {
                setTimeout(function()
                {
                    if ( self.options.css.constructor == String )
                        {
                        /**
                        * $(self.editorDoc)
                        * .find('head')
                        * .append(
                        *     $('<link rel="stylesheet" type="text/css" media="screen" />')
                        *     .attr('href', self.options.css)
                        * );
                        */
                    }
                    else
                        $(self.editorDoc).find('body').css(self.options.css);
                }, 0);
            }

            $(this.editorDoc).keydown(function( event )
            {
                if ( $.browser.msie && self.options.brIE && event.keyCode == 13 )
                    {
                    var rng = self.getRange();
                    rng.pasteHTML('<br />');
                    rng.collapse(false);
                    rng.select();
                    return false;
                }
                return true;
            });
        },

        designMode : function()
        {
            if ( !( this.editorDoc_designMode ) )
                {
                try {
                    this.editorDoc.designMode = 'on';
                    this.editorDoc_designMode = true;
                } catch ( e ) {}
            }
        },

        getSelection : function()
        {
            return ( window.getSelection ) ? window.getSelection() : document.selection;
        },

        getRange : function()
        {
            var selection = this.getSelection();

            if ( !( selection ) )
                return null;

            return ( selection.rangeCount > 0 ) ? selection.getRangeAt(0) : selection.createRange();
        },

        getContent : function()
        {
            return $( $(this.editor).document() ).find('body').html();
        },

        setContent : function( newContent )
        {
            $( $(this.editor).document() ).find('body').html(newContent);
        },

        saveContent : function()
        {
            if ( this.original )
                {
                var content = this.getContent();

                if ( this.options.rmUnwantedBr )
                    {
                    content = ( content.substr(-4) == '<br>' ) ? content.substr(0, content.length - 4) : content;
                }

                $(this.original).val(content);
            }
        },

        withoutCss: function()
        {
            if ($.browser.mozilla)
                {
                try
                {
                    this.editorDoc.execCommand('styleWithCSS', false, false);
                }
                catch (e)
                {
                    try
                    {
                        this.editorDoc.execCommand('useCSS', false, true);
                    }
                    catch (e)
                    {
                    }
                }
            }
        },

        appendMenu : function( cmd, args, className, fn, tooltip )
        {
            var self = this;
            args = args || [];

            $('<li></li>').append(
            $('<a role="menuitem" tabindex="-1" href="javascript:;">' + (className || cmd) + '</a>')
            .addClass(className || cmd)
            .attr('title', tooltip)
            ).click(function() {
                if ( fn ) fn.apply(self); else
                    {
                    self.withoutCss();
                    self.editorDoc.execCommand(cmd, false, args);
                }
                if ( self.options.autoSave ) self.saveContent();
            }).appendTo( this.panel );
        },

        appendMenuSeparator : function()
        {
            $('<li role="separator" class="separator"></li>').appendTo( this.panel );
        },

        appendControls : function()
        {
            for ( var name in this.options.controls )
                {
                var control = this.options.controls[name];

                if ( control.separator )
                    {
                    if ( control.visible !== false )
                        this.appendMenuSeparator();
                }
                else if ( control.visible )
                    {
                    this.appendMenu(
                    control.command || name, control.arguments || [],
                    control.className || control.command || name || 'empty', control.exec,
                    control.tooltip || control.command || name || ''
                    );
                }
            }
        },

        checkTargets : function( element )
        {
            for ( var name in this.options.controls )
                {
                var control = this.options.controls[name];
                var className = control.className || control.command || name || 'empty';

                $('.' + className, this.panel).removeClass('active');

                if ( control.tags )
                    {
                    var elm = element;

                    do {
                        if ( elm.nodeType != 1 )
                            break;

                        if ( $.inArray(elm.tagName.toLowerCase(), control.tags) != -1 )
                            $('.' + className, this.panel).addClass('active');
                    } while ((elm = elm.parentNode));
                }

                if ( control.css )
                    {
                    var elm = $(element);

                    do {
                        if ( elm[0].nodeType != 1 )
                            break;

                        for ( var cssProperty in control.css )
                            if ( elm.css(cssProperty).toString().toLowerCase() == control.css[cssProperty] )
                            $('.' + className, this.panel).addClass('active');
                    } while ((elm = elm.parent()));
                }
            }
        },

        getElementByAttributeValue : function( tagName, attributeName, attributeValue )
        {
            var elements = this.editorDoc.getElementsByTagName(tagName);

            for ( var i = 0; i < elements.length; i++ )
                {
                var value = elements[i].getAttribute(attributeName);

                if ( $.browser.msie )
                    {
                    /** IE add full path, so I check by the last chars. */
                    value = value.substr(value.length - attributeValue.length);
                }

                if ( value == attributeValue )
                    return elements[i];
            }

            return false;
        }
    });
})(jQuery);
/*Loading Jquery Tools minified*/
(function(c){function p(e,b,a){var d=this,l=e.add(this),h=e.find(a.tabs),i=b.jquery?b:e.children(b),j;h.length||(h=e.children());i.length||(i=e.parent().find(b));i.length||(i=c(b));c.extend(this,{click:function(f,g){var k=h.eq(f);if(typeof f=="string"&&f.replace("#","")){k=h.filter("[href*="+f.replace("#","")+"]");f=Math.max(h.index(k),0)}if(a.rotate){var n=h.length-1;if(f<0)return d.click(n,g);if(f>n)return d.click(0,g)}if(!k.length){if(j>=0)return d;f=a.initialIndex;k=h.eq(f)}if(f===j)return d;
                g=g||c.Event();g.type="onBeforeClick";l.trigger(g,[f]);if(!g.isDefaultPrevented()){o[a.effect].call(d,f,function(){g.type="onClick";l.trigger(g,[f])});j=f;h.removeClass(a.current);k.addClass(a.current);return d}},getConf:function(){return a},getTabs:function(){return h},getPanes:function(){return i},getCurrentPane:function(){return i.eq(j)},getCurrentTab:function(){return h.eq(j)},getIndex:function(){return j},next:function(){return d.click(j+1)},prev:function(){return d.click(j-1)},destroy:function(){h.unbind(a.event).removeClass(a.current);
                i.find("a[href^=#]").unbind("click.T");return d}});c.each("onBeforeClick,onClick".split(","),function(f,g){c.isFunction(a[g])&&c(d).bind(g,a[g]);d[g]=function(k){c(d).bind(g,k);return d}});if(a.history&&c.fn.history){c.tools.history.init(h);a.event="history"}h.each(function(f){c(this).bind(a.event,function(g){d.click(f,g);return g.preventDefault()})});i.find("a[href^=#]").bind("click.T",function(f){d.click(c(this).attr("href"),f)});if(location.hash)d.click(location.hash);else if(a.initialIndex===
        0||a.initialIndex>0)d.click(a.initialIndex)}c.tools=c.tools||{version:"1.2.3"};c.tools.tabs={conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",rotate:false,history:false},addEffect:function(e,b){o[e]=b}};var o={"default":function(e,b){this.getPanes().hide().eq(e).show();b.call()},fade:function(e,b){var a=this.getConf(),d=a.fadeOutSpeed,l=this.getPanes();d?l.fadeOut(d):l.hide();l.eq(e).fadeIn(a.fadeInSpeed,b)},slide:function(e,b){this.getPanes().slideUp(200);
            this.getPanes().eq(e).slideDown(400,b)},ajax:function(e,b){this.getPanes().eq(0).load(this.getTabs().eq(e).attr("href"),b)}},m;c.tools.tabs.addEffect("horizontal",function(e,b){m||(m=this.getPanes().eq(0).width());this.getCurrentPane().animate({width:0},function(){c(this).hide()});this.getPanes().eq(e).animate({width:m},function(){c(this).show();b.call()})});c.fn.tabs=function(e,b){var a=this.data("tabs");if(a){a.destroy();this.removeData("tabs")}if(c.isFunction(b))b={onBeforeClick:b};b=c.extend({},
        c.tools.tabs.conf,b);this.each(function(){a=new p(c(this),e,b);c(this).data("tabs",a)});return b.api?a:this}})(jQuery);
(function(f){function p(a,b,c){var h=c.relative?a.position().top:a.offset().top,e=c.relative?a.position().left:a.offset().left,i=c.position[0];h-=b.outerHeight()-c.offset[0];e+=a.outerWidth()+c.offset[1];var j=b.outerHeight()+a.outerHeight();if(i=="center")h+=j/2;if(i=="bottom")h+=j;i=c.position[1];a=b.outerWidth()+a.outerWidth();if(i=="center")e-=a/2;if(i=="left")e-=a;return{top:h,left:e}}function t(a,b){var c=this,h=a.add(c),e,i=0,j=0,m=a.attr("title"),q=n[b.effect],k,r=a.is(":input"),u=r&&a.is(":checkbox, :radio, select, :button, :submit"),
        s=a.attr("type"),l=b.events[s]||b.events[r?u?"widget":"input":"def"];if(!q)throw'Nonexistent effect "'+b.effect+'"';l=l.split(/,\s*/);if(l.length!=2)throw"Tooltip: bad events configuration for "+s;a.bind(l[0],function(d){clearTimeout(i);if(b.predelay)j=setTimeout(function(){c.show(d)},b.predelay);else c.show(d)}).bind(l[1],function(d){clearTimeout(j);if(b.delay)i=setTimeout(function(){c.hide(d)},b.delay);else c.hide(d)});if(m&&b.cancelDefault){a.removeAttr("title");a.data("title",m)}f.extend(c,{show:function(d){if(!e){if(m)e=
                    f(b.layout).addClass(b.tipClass).appendTo(document.body).hide().append(m);else if(b.tip)e=f(b.tip).eq(0);else{e=a.next();e.length||(e=a.parent().next())}if(!e.length)throw"Cannot find tooltip for "+a;}if(c.isShown())return c;e.stop(true,true);var g=p(a,e,b);d=d||f.Event();d.type="onBeforeShow";h.trigger(d,[g]);if(d.isDefaultPrevented())return c;g=p(a,e,b);e.css({position:"absolute",top:g.top,left:g.left});k=true;q[0].call(c,function(){d.type="onShow";k="full";h.trigger(d)});g=b.events.tooltip.split(/,\s*/);
                e.bind(g[0],function(){clearTimeout(i);clearTimeout(j)});g[1]&&!a.is("input:not(:checkbox, :radio), textarea")&&e.bind(g[1],function(o){o.relatedTarget!=a[0]&&a.trigger(l[1].split(" ")[0])});return c},hide:function(d){if(!e||!c.isShown())return c;d=d||f.Event();d.type="onBeforeHide";h.trigger(d);if(!d.isDefaultPrevented()){k=false;n[b.effect][1].call(c,function(){d.type="onHide";k=false;h.trigger(d)});return c}},isShown:function(d){return d?k=="full":k},getConf:function(){return b},getTip:function(){return e},
            getTrigger:function(){return a}});f.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(d,g){f.isFunction(b[g])&&f(c).bind(g,b[g]);c[g]=function(o){f(c).bind(g,o);return c}})}f.tools=f.tools||{version:"1.2.3"};f.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,position:["top","center"],offset:[0,0],relative:false,cancelDefault:true,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},
            layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,b,c){n[a]=[b,c]}};var n={toggle:[function(a){var b=this.getConf(),c=this.getTip();b=b.opacity;b<1&&c.css({opacity:b});c.show();a.call()},function(a){this.getTip().hide();a.call()}],fade:[function(a){var b=this.getConf();this.getTip().fadeTo(b.fadeInSpeed,b.opacity,a)},function(a){this.getTip().fadeOut(this.getConf().fadeOutSpeed,a)}]};f.fn.tooltip=function(a){var b=this.data("tooltip");if(b)return b;a=f.extend(true,{},f.tools.tooltip.conf,a);
        if(typeof a.position=="string")a.position=a.position.split(/,?\s/);this.each(function(){b=new t(f(this),a);f(this).data("tooltip",b)});return a.api?b:this}})(jQuery);
/*loading Jeditable minified*/
(function($){$.fn.editable=function(target,options){if('disable'==target){$(this).data('disabled.editable',true);return;}if('enable'==target){$(this).data('disabled.editable',false);return;}
        if('destroy'==target){$(this).unbind($(this).data('event.editable')).removeData('disabled.editable').removeData('event.editable');return;}var settings=$.extend({},$.fn.editable.defaults,{target:target},options);var plugin=$.editable.types[settings.type].plugin||function(){};var submit=$.editable.types[settings.type].submit||function(){};var buttons=$.editable.types[settings.type].buttons||$.editable.types['defaults'].buttons;var content=$.editable.types[settings.type].content||$.editable.types['defaults'].content;var element=$.editable.types[settings.type].element||$.editable.types['defaults'].element;var reset=$.editable.types[settings.type].reset||$.editable.types['defaults'].reset;var callback=settings.callback||function(){};var onedit=settings.onedit||function(){};var onsubmit=settings.onsubmit||function(){};var onreset=settings.onreset||function(){};var onerror=settings.onerror||reset;if(settings.tooltip){$(this).attr('title',settings.tooltip);}
        settings.autowidth='auto'==settings.width;settings.autoheight='auto'==settings.height;return this.each(function(){var self=this;var savedwidth=$(self).width();var savedheight=$(self).height();$(this).data('event.editable',settings.event);if(!$.trim($(this).html())){$(this).html(settings.placeholder);}
            $(this).bind(settings.event,function(e){if(true===$(this).data('disabled.editable')){return;}if(self.editing){return;}if(false===onedit.apply(this,[settings,self])){return;}
                e.preventDefault();e.stopPropagation();if(settings.tooltip){$(self).removeAttr('title');}if(0==$(self).width()){settings.width=savedwidth;settings.height=savedheight;}else{if(settings.width!='none'){settings.width=settings.autowidth?$(self).width():settings.width;}
                    if(settings.height!='none'){settings.height=settings.autoheight?$(self).height():settings.height;}}if($(this).html().toLowerCase().replace(/(;|")/g,'')==settings.placeholder.toLowerCase().replace(/(;|")/g,'')){$(this).html('');}
                self.editing=true;self.revert=$(self).html();$(self).html('');var form=$('<form />');if(settings.cssclass){if('inherit'==settings.cssclass){form.attr('class',$(self).attr('class'));}else{form.attr('class',settings.cssclass);}}
                if(settings.style){if('inherit'==settings.style){form.attr('style',$(self).attr('style'));form.css('display',$(self).css('display'));}else{form.attr('style',settings.style);}}
                var input=element.apply(form,[settings,self]);var input_content;if(settings.loadurl){var t=setTimeout(function(){input.disabled=true;content.apply(form,[settings.loadtext,settings,self]);},100);var loaddata={};loaddata[settings.id]=self.id;if($.isFunction(settings.loaddata)){$.extend(loaddata,settings.loaddata.apply(self,[self.revert,settings]));}else{$.extend(loaddata,settings.loaddata);}
                    $.ajax({type:settings.loadtype,url:settings.loadurl,data:loaddata,async:false,success:function(result){window.clearTimeout(t);input_content=result;input.disabled=false;}});}else if(settings.data){input_content=settings.data;if($.isFunction(settings.data)){input_content=settings.data.apply(self,[self.revert,settings]);}}else{input_content=self.revert;}
                content.apply(form,[input_content,settings,self]);input.attr('name',settings.name);buttons.apply(form,[settings,self]);$(self).append(form);plugin.apply(form,[settings,self]);$(':input:visible:enabled:first',form).focus();if(settings.select){input.select();}
                input.keydown(function(e){if(e.keyCode==27){e.preventDefault();reset.apply(form,[settings,self]);}});var t;if('cancel'==settings.onblur){input.blur(function(e){t=setTimeout(function(){reset.apply(form,[settings,self]);},500);});}else if('submit'==settings.onblur){input.blur(function(e){t=setTimeout(function(){form.submit();},200);});}else if($.isFunction(settings.onblur)){input.blur(function(e){settings.onblur.apply(self,[input.val(),settings]);});}else{input.blur(function(e){});}
                form.submit(function(e){if(t){clearTimeout(t);}e.preventDefault();if(false!==onsubmit.apply(form,[settings,self])){if(false!==submit.apply(form,[settings,self])){if($.isFunction(settings.target)){var str=settings.target.apply(self,[input.val(),settings]);$(self).html(str);self.editing=false;callback.apply(self,[self.innerHTML,settings]);if(!$.trim($(self).html())){$(self).html(settings.placeholder);}}else{var submitdata={};submitdata[settings.name]=input.val();submitdata[settings.id]=self.id;if($.isFunction(settings.submitdata)){$.extend(submitdata,settings.submitdata.apply(self,[self.revert,settings]));}else{$.extend(submitdata,settings.submitdata);}
                                if('PUT'==settings.method){submitdata['_method']='put';}$(self).html(settings.indicator);var ajaxoptions={type:'POST',data:submitdata,dataType:'html',url:settings.target,success:function(result,status){if(ajaxoptions.dataType=='html'){$(self).html(result);}
                                        self.editing=false;callback.apply(self,[result,settings]);if(!$.trim($(self).html())){$(self).html(settings.placeholder);}},error:function(xhr,status,error){onerror.apply(form,[settings,self,xhr]);}};$.extend(ajaxoptions,settings.ajaxoptions);$.ajax(ajaxoptions);}}}
                    $(self).attr('title',settings.tooltip);return false;});});this.reset=function(form){if(this.editing){if(false!==onreset.apply(form,[settings,self])){$(self).html(self.revert);self.editing=false;if(!$.trim($(self).html())){$(self).html(settings.placeholder);}
                        if(settings.tooltip){$(self).attr('title',settings.tooltip);}}}};});};$.editable={types:{defaults:{element:function(settings,original){var input=$('<input type="hidden"></input>');$(this).append(input);return(input);},content:function(string,settings,original){$(':input:first',this).val(string);},reset:function(settings,original){original.reset(this);},buttons:function(settings,original){var form=this;if(settings.submit){if(settings.submit.match(/>$/)){var submit=$(settings.submit).click(function(){if(submit.attr("type")!="submit"){form.submit();}});}else{var submit=$('<button type="submit" />');submit.html(settings.submit);}$(this).append(submit);}
                    if(settings.cancel){if(settings.cancel.match(/>$/)){var cancel=$(settings.cancel);}else{var cancel=$('<button type="cancel" />');cancel.html(settings.cancel);}
                        $(this).append(cancel);$(cancel).click(function(event){if($.isFunction($.editable.types[settings.type].reset)){var reset=$.editable.types[settings.type].reset;}else{var reset=$.editable.types['defaults'].reset;}
                            reset.apply(form,[settings,original]);return false;});}}},text:{element:function(settings,original){var input=$('<input />');if(settings.width!='none'){input.width(settings.width);}
                    if(settings.height!='none'){input.height(settings.height);}input.attr('autocomplete','off');$(this).append(input);return(input);}},textarea:{element:function(settings,original){var textarea=$('<textarea />');if(settings.rows){textarea.attr('rows',settings.rows);}else if(settings.height!="none"){textarea.height(settings.height);}
                    if(settings.cols){textarea.attr('cols',settings.cols);}else if(settings.width!="none"){textarea.width(settings.width);}$(this).append(textarea);return(textarea);}},select:{element:function(settings,original){var select=$('<select />');$(this).append(select);return(select);},content:function(data,settings,original){if(String==data.constructor){eval('var json = '+data);}else{var json=data;}
                    for(var key in json){if(!json.hasOwnProperty(key)){continue;}if('selected'==key){continue;}var option=$('<option />').val(key).append(json[key]);$('select',this).append(option);}
                    $('select',this).children().each(function(){if($(this).val()==json['selected']||$(this).text()==$.trim(original.revert)){$(this).attr('selected','selected');}});}}},addInputType:function(name,input){$.editable.types[name]=input;}};$.fn.editable.defaults={name:'value',id:'id',type:'text',width:'auto',height:'auto',event:'click.editable',onblur:'cancel',loadtype:'GET',loadtext:'Loading...',placeholder:'Click to edit',loaddata:{},submitdata:{},ajaxoptions:{}};})(jQuery);
$.editable.addInputType('wysiwyg', {
    /* Use default textarea instead of writing code here again. */
    //element : $.editable.types.textarea.element,
    element : function(settings, original) {
        /* Hide textarea to avoid flicker. */
        var textarea = $('<textarea>').css("opacity", "0");
        if (settings.rows) {
            textarea.attr('rows', settings.rows);
        } else {
            textarea.height(settings.height);
        }
        if (settings.cols) {
            textarea.attr('cols', settings.cols);
        } else {
            textarea.width(settings.width);
        }
        $(this).append(textarea);
        return(textarea);
    },
    content : function(string, settings, original) { 
        /* jWYSIWYG plugin uses .text() instead of .val()        */
        /* For some reason it did not work work with generated   */
        /* textareas so I am forcing the value here with .text() */
        $('textarea', this).text(string);
    },
    plugin : function(settings, original) {
        var self = this;
        /* Force autosave off to avoid "element.contentWindow has no properties" */
        settings.wysiwyg = $.extend({autoSave: false}, settings.wysiwyg);
        if (settings.wysiwyg) {
            setTimeout(function() { $('textarea', self).wysiwyg(settings.wysiwyg); }, 0);
        } else {
            setTimeout(function() { $('textarea', self).wysiwyg(); }, 0);
        }
    },
    submit : function(settings, original) {
        var iframe         = $("iframe", this).get(0); 
        var inner_document = typeof(iframe.contentDocument) == 'undefined' ?  iframe.contentWindow.document.body : iframe.contentDocument.body;
        var new_content    = $(inner_document).html();
        $('textarea', this).val(new_content);
    }
});
/*loading the livequery.minified*/
(function($){$.extend($.fn,{livequery:function(type,fn,fn2){var self=this,q;if($.isFunction(type))fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&type==query.type&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid))return(q=query)&&false;});q=q||new $.livequery(this.selector,this.context,type,fn,fn2);q.stopped=false;q.run();return this;},expire:function(type,fn,fn2){var self=this;if($.isFunction(type))fn2=fn,fn=type,type=undefined;$.each($.livequery.queries,function(i,query){if(self.selector==query.selector&&self.context==query.context&&(!type||type==query.type)&&(!fn||fn.$lqguid==query.fn.$lqguid)&&(!fn2||fn2.$lqguid==query.fn2.$lqguid)&&!this.stopped)$.livequery.stop(query.id);});return this;}});$.livequery=function(selector,context,type,fn,fn2){this.selector=selector;this.context=context||document;this.type=type;this.fn=fn;this.fn2=fn2;this.elements=[];this.stopped=false;this.id=$.livequery.queries.push(this)-1;fn.$lqguid=fn.$lqguid||$.livequery.guid++;if(fn2)fn2.$lqguid=fn2.$lqguid||$.livequery.guid++;return this;};$.livequery.prototype={stop:function(){var query=this;if(this.type)this.elements.unbind(this.type,this.fn);else if(this.fn2)this.elements.each(function(i,el){query.fn2.apply(el);});this.elements=[];this.stopped=true;},run:function(){if(this.stopped)return;var query=this;var oEls=this.elements,els=jQuery(this.selector,this.context),nEls=els.not(oEls);this.elements=els;if(this.type){nEls.bind(this.type,this.fn);if(oEls.length>0)$.each(oEls,function(i,el){if($.inArray(el,els)<0)$.event.remove(el,query.type,query.fn);});}else{nEls.each(function(){query.fn.apply(this);});if(this.fn2&&oEls.length>0)$.each(oEls,function(i,el){if($.inArray(el,els)<0)query.fn2.apply(el);});}}};$.extend($.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if($.livequery.running&&$.livequery.queue.length){var length=$.livequery.queue.length;while(length--)$.livequery.queries[$.livequery.queue.shift()].run();}},pause:function(){$.livequery.running=false;},play:function(){$.livequery.running=true;$.livequery.run();},registerPlugin:function(){$.each(arguments,function(i,n){if(!$.fn[n])return;var old=$.fn[n];$.fn[n]=function(){var r=old.apply(this,arguments);$.livequery.run();return r;}});},run:function(id){if(id!=undefined){if($.inArray(id,$.livequery.queue)<0)$.livequery.queue.push(id);}else $.each($.livequery.queries,function(id){if($.inArray(id,$.livequery.queue)<0)$.livequery.queue.push(id);});if($.livequery.timeout)clearTimeout($.livequery.timeout);$.livequery.timeout=setTimeout($.livequery.checkQueue,20);},stop:function(id){if(id!=undefined)$.livequery.queries[id].stop();else $.each($.livequery.queries,function(id){$.livequery.queries[id].stop();});}});$.livequery.registerPlugin('append','prepend','after','before','wrap','attr','removeAttr','addClass','removeClass','toggleClass','empty','remove');jQuery(function(){$.livequery.play();});var init=$.prototype.init;$.prototype.init=function(a,c){var r=init.apply(this,arguments);if(a&&a.selector)r.context=a.context,r.selector=a.selector;if(typeof a=='string')r.context=c||document,r.selector=a;return r;};$.prototype.init.prototype=$.prototype;})(jQuery);
/*loading bgiframe.packed*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(b($){$.m.E=$.m.g=b(s){h($.x.10&&/6.0/.I(D.B)){s=$.w({c:\'3\',5:\'3\',8:\'3\',d:\'3\',k:M,e:\'F:i;\'},s||{});C a=b(n){f n&&n.t==r?n+\'4\':n},p=\'<o Y="g"W="0"R="-1"e="\'+s.e+\'"\'+\'Q="P:O;N:L;z-H:-1;\'+(s.k!==i?\'G:J(K=\\\'0\\\');\':\'\')+\'c:\'+(s.c==\'3\'?\'7(((l(2.9.j.A)||0)*-1)+\\\'4\\\')\':a(s.c))+\';\'+\'5:\'+(s.5==\'3\'?\'7(((l(2.9.j.y)||0)*-1)+\\\'4\\\')\':a(s.5))+\';\'+\'8:\'+(s.8==\'3\'?\'7(2.9.S+\\\'4\\\')\':a(s.8))+\';\'+\'d:\'+(s.d==\'3\'?\'7(2.9.v+\\\'4\\\')\':a(s.d))+\';\'+\'"/>\';f 2.T(b(){h($(\'> o.g\',2).U==0)2.V(q.X(p),2.u)})}f 2}})(Z);',62,63,'||this|auto|px|left||expression|width|parentNode||function|top|height|src|return|bgiframe|if|false|currentStyle|opacity|parseInt|fn||iframe|html|document|Number||constructor|firstChild|offsetHeight|extend|browser|borderLeftWidth||borderTopWidth|userAgent|var|navigator|bgIframe|javascript|filter|index|test|Alpha|Opacity|absolute|true|position|block|display|style|tabindex|offsetWidth|each|length|insertBefore|frameborder|createElement|class|jQuery|msie'.split('|'),0,{}));
/*loading the jQselecta.minified*/
jQuery.fn.jqSelecta=function(K){var T=this,R=jQuery(this),O=R.attr("id"),C="cell.ref",S="opt.ref",I={multiSelect:null,autoSelected:null,title:null,showHeader:true,showHeaderCloseIcon:true,showFooter:true,showMultiSelectFooterIcons:true,footerCancelButtonText:"Cancel",footerOkButtonText:" Ok ",showFooterOkCancelButtons:true,onOpen:function(){},onClose:function(){},labelCallback:function(V){if(F.multiSelect){return V+" item"+((V!=1)?"s":"")+" selected"}else{var W=R.find("[selected=true]");if(W==null){W=jQuery(R.children()[0])}return W.html().replace(/\s+/g," ")}},height:null,width:"300px",buttonWidth:null,autoScrollOverflowY:true,autoScrollOverflowX:true,columns:2,fadeSpeed:300,valueSetFrom:"value",titleSetFrom:"title",textSetFrom:"text",persistAsCookie:false,debug:false,trace:false,shadow:false},F=jQuery.extend(I,K),H=null,U=null,G,Q,B,M,J,A;if(F.multiSelect===null){F.multiSelect=R.attr("multiple");if(F.multiSelect===undefined){F.multiSelect===false}}this.cancelAndClose=function(){if(F.multiSelect===true){T.revertState()}T.hideSelecta()};this.refreshLabel=function(){if(typeof A!=="undefined"){A.html(F.labelCallback(R.find("[selected=true]").size()))}};this.revertState=function(){if(U!==null&&U.length>0){this.selectNone();jQuery(U).attr("selected",true)}this.reloadState();this.refreshLabel()};this.reloadState=function(){R.find("[selected=true]").each(function(V){L(jQuery(this).data(S))})};this.showSelecta=function(){M.css("z-index",1000);G.fadeIn(F.fadeSpeed);U=R.find("[selected=true]");H=jQuery('<iframe style="border:0; overflow:hidden; position:absolute;top:0px'+((F.trace===true)?";border: solid blue 1px;":"")+";left:0px;width:"+G.width()+"px;height:"+G.height()+'px;z-index:-1"></iframe>');jQuery("#"+O+"_jqselecta-wrap").prepend(H);if(F.shadow===true){jQuery("#"+O+"_jqselecta-shadow").fadeIn(F.fadeSpeed)}J.removeClass("ui-icon-carat-1-s").addClass("ui-icon-carat-1-n");F.onOpen()};this.hideSelecta=function(){var V=(F.multiSelect===true)?F.fadeSpeed:(F.fadeSpeed*3);G.fadeOut(V,function(){H.remove();J.removeClass("ui-icon-carat-1-n").addClass("ui-icon-carat-1-s");F.onClose()});if(F.shadow===true){jQuery("#"+O+"_jqselecta-shadow").hide()}M.css("z-index",0);if(F.persistAsCookie===true){dehydrateAsCookie()}};this.dehydrateAsCookie=function(){var V="";R.find("[selected=true]").each(function(W){if(W>0){V+="&"}V+=escape(jQuery(this).attr("value"))+"="+escape(jQuery(this).html())});if(V!==""){jQuery.cookie(O+"_jqSelecta",V)}};this.rehydrateFromCookie=function(){var Y=jQuery.cookie(O+"_jqSelecta"),Z,X,V,W;if(Y!==null){Z=Y.split(/\&/);if(Z.length>0){this.selectNone()}for(X=0;X<Z.length;X++){V=Z[X].split(/\=/);R.find("[value="+unescape(V[0])+"]").each(function(a){W=jQuery(this);if(unescape(V[1])===W.html()){jQuery(this).attr("selected",true)}})}this.reloadState()}};this.toggleSelecta=function(){if(G.is(":visible")){T.hideSelecta()}else{T.showSelecta()}};this.selectAll=function(){Q.find(".cellectable").each(function(V){L(this)});T.refreshLabel()};this.selectNone=function(){Q.find(".cellectable").each(function(V){D(this)});T.refreshLabel()};this.selectInverse=function(){Q.find(".cellectable").each(function(V){if(jQuery(this).data(C).attr("selected")===true){D(this)}else{L(this)}});T.refreshLabel()};this.getSelectedValues=function(){var V=[];jQuery(T).find("[selected=true]").each(function(W){V[V.length]=jQuery(this).attr("value")});return V};function D(V){var W=jQuery(V);if(W.data(C).attr("disabled")){return}W.data(C).removeAttr("selected");W.css("font-weight","normal");W.find("span").removeClass("ui-icon-check").addClass("ui-icon-close")}function L(V){var W=jQuery(V);if(W.data(C).attr("disabled")){return}W.data(C).attr("selected",true);W.css("font-weight","bold");W.find("span").removeClass("ui-icon-close").addClass("ui-icon-check")}function E(V){var W=jQuery(V);if(W.data(C).attr("disabled")){return}if(W.data(C).attr("selected")===true&&F.multiSelect){D(V)}else{L(V)}T.refreshLabel()}function N(V){if(F.debug){var W="[jqSelecta]  "+((typeof(V)==="Array")?Array.prototype.join.call(V,""):V);if(window.console&&window.console.log){window.console.log(W)}else{alert(W)}}}function P(){G=jQuery('<div id="'+O+'_jqselecta" class="ui-widget ui-helper-clearfix ui-widget-content ui-corner-all" style="display:none;width:'+F.width+'"></div>');Q=jQuery('<table class="ui-helper-clearfix" style="text-align:left;border:0;padding:0;margin:0;width:'+F.width+";z-index:19;height:"+F.height+'"></table>');B=jQuery("<tbody></tbody>").appendTo(Q);var a=R.children(),l="px",x=F.width.replace(/[^\d]+/g,""),c=(x/F.columns),W=Math.round(a.length/F.columns),g,u,w,h,d,Y,b,n,y,AB,p,s,V,f,e,v,r,o,t,X,Z,q,m,AA,k,z=null;if(F.multiSelect===false&&R.find("[selected=true]").size()>0){z=R.find("[selected=true]")[0].index;if(z===null){z=0}}for(w=0;w<W;w++){g=jQuery("<tr></tr>");for(u=0;u<F.columns;u++){h=w+u*W;if(h>=a.length){for(;u<F.columns;u++){jQuery("<td> </td>").appendTo(g)}break}d=jQuery(a[h]);n=b=d.text();AB=y=d.attr("title");s=p=d.attr("value");if(F.textSetFrom==="value"){n=p}else{if(F.textSetFrom==="title"){n=y}}if(F.valueSetFrom==="text"){s=b}else{if(F.valueSetFrom==="title"){s=y}}if(F.titleSetFrom==="text"){AB=b}else{if(F.titleSetFrom==="value"){AB=p}}V=d.attr("selected");if(!(F.multiSelect===false||F.autoSelected===null)){V=F.autoSelected}if(z!==null&&z!==h){V=false}d.attr("selected",V);Y=jQuery('<td title="'+AB+'" style="border:0px;cursor:pointer;'+((true===V)?"font-weight:bold":"")+'" class="cellectable widget-content"><div style=white-space:nowrap;text-overflow:ellipsis;width:'+c+l+';overflow:hidden><div style="float:left"><span class="ui-icon '+((true===V)?"ui-icon-check":"ui-icon-close")+'"/></div><div> '+n+"</div></div></td>");jQuery(Y).data(C,d);jQuery(d).data(S,Y);jQuery(Y).appendTo(g);if(d.attr("disabled")===true){Y.addClass("ui-state-disabled")}else{Y.hover(function(){jQuery(this).addClass("ui-state-hover")},function(){jQuery(this).removeClass("ui-state-hover")}).click(function(){var AC=jQuery(this),j,i;if(F.multiSelect===false){j=AC.data(C);i=j.attr("selected");Q.find(".cellectable").each(function(AD){jQuery(this).css("font-weight","normal");jQuery(this).find("span").removeClass("ui-icon-check").addClass("ui-icon-close");jQuery(this).data(C).removeAttr("selected")});j.attr("selected",i)}E(this);if(F.multiSelect===false){T.hideSelecta()}return false})}}jQuery(g).appendTo(B)}jQuery(G).bind("mouseaway",function(){jQuery(this).find("ui-state-hover").removeClass("ui-state-hover")});if(true===F.showHeader){if(F.showHeaderCloseIcon===true){f=jQuery('<div title="Cancel &amp; Close" id="'+O+'_jqselecta-header-close" class="ui-state-default ui-corner-all" style="float:right;cursor:pointer"><span class="ui-icon ui-icon-close"/></div>');f.hover(function(){jQuery(this).addClass("ui-state-hover")},function(){jQuery(this).removeClass("ui-state-hover")}).click(T.cancelAndClose);v=jQuery('<div id="'+O+'_jqselecta-header" class="ui-widget-header ui-helper-clearfix" style="padding:1px"></div>');v.append(f)}if(F.title!==null){v.append('<div id="'+O+'_jqselecta-header-text">'+F.title+"</div>")}v.appendTo(G)}e=jQuery('<div style="height:'+F.height+"!important;width:"+F.width+";overflow-y:"+((F.autoScrollOverflowY===true)?"scroll":"hidden")+"!important;overflow-x:"+((F.autoScrollOverflowX===true)?"auto":"hidden")+'!important"></div>');Q.appendTo(e);e.appendTo(G);if(F.showFooter===true){r=jQuery('<div id="'+O+'_jqselecta-footer" class="ui-widget-header ui-helper-clearfix" style="padding:1px"></div>');o=new Array();if(F.multiSelect===true&&F.showMultiSelectFooterIcons===true){Z=jQuery('<div title="Select All" id="'+O+'_jqselecta-select-all" class="ui-state-default ui-corner-all" style="float:left;cursor:pointer"><span class="ui-icon ui-icon-circle-check"/></div>');q=jQuery('<div title="Select None" id="'+O+'_jqselecta-select-none" class="ui-state-default ui-corner-all" style="float:left;cursor:pointer"><span class="ui-icon ui-icon-circle-close"/></div>');m=jQuery('<div title="Invert Selection" id="'+O+'_jqselecta-select-inverse" class="ui-state-default ui-corner-all" style="float:left;cursor:pointer"><span class="ui-icon ui-icon-circle-triangle-s"/></div>');Z.click(T.selectAll);q.click(T.selectNone);m.click(T.selectInverse);r.append(Z);r.append(q);r.append(m);o.push(m,Z,q)}if(F.showFooterOkCancelButtons===true){AA=jQuery('<button class="ui-state-default ui-corner-all" style="text-overflow:ellipsis;overflow:hidden;float:right;cursor:pointer" type="button">'+F.footerOkButtonText+"</button>");k=jQuery('<button class="ui-state-default ui-corner-all" style="text-overflow:ellipsis;overflow:hidden;float:right;cursor:pointer" type="button">'+F.footerCancelButtonText+"</button>");AA.click(T.hideSelecta);k.click(T.cancelAndClose);AA.appendTo(r);k.appendTo(r);o.push(AA,k)}r.appendTo(G);jQuery(o).each(function(){jQuery(this).hover(function(){jQuery(this).addClass("ui-state-hover")},function(){jQuery(this).removeClass("ui-state-hover")})})}if(F.persistAsCookie===true){rehydrateFromCookie()}X=jQuery('<button id="'+O+'_jqselecta-button" class="ui-state-default ui-corner-all" style="width:'+((F.buttonWidth===null)?(R.width()+"px"):F.buttonWidth)+';cursor:pointer" type="button"></button>');t=jQuery("<nobr></nobr>");J=jQuery('<span class="ui-icon ui-icon-carat-1-s" style="float:right"/>');t.append(J);A=jQuery('<span style="width:'+((F.buttonWidth===null)?(R.width()+"px"):F.buttonWidth)+'text-overflow:ellipsis;overflow:hidden">'+F.labelCallback(R.find("[selected=true]").size())+"</span>");t.append(A);X.append(t);X.bind("click",T.toggleSelecta);X.hover(function(){jQuery(this).addClass("ui-state-hover")},function(){jQuery(this).removeClass("ui-state-hover")});M=jQuery('<span  id="'+O+'_jqselecta-holder" style="margin:0;padding:0;overflow:visible;position:relative;width:'+F.width+((F.trace===true)?";border: dashed green 1px;":"")+'"></span>');X.appendTo(M);G.appendTo(M);R.after(M);R.hide();G.wrap('<div  id="'+O+'_jqselecta-wrap" style="position:absolute;z-index:19;display:block;width:'+F.width+((F.trace===true)?";border: dotted red 1px":"")+";top:"+X.height()+'px;left:0px"></div>');if(F.shadow===true){jQuery("#"+O+"_jqselecta-wrap").prepend(jQuery('<div id="'+O+'_jqselecta-shadow" class="ui-widget-shadow" style="position:absolute;z-index:29;top:0;width:'+G.width()+"px;top:"+X.height()+"px;left:0px;height: "+G.height()+'px;display:none"></div>'))}return T}return P()};
/*loading jquery.corner*/
(function($){var style=document.createElement('div').style;var moz=style['MozBorderRadius']!==undefined;var webkit=style['WebkitBorderRadius']!==undefined;var radius=style['BorderRadius']!==undefined;var mode=document.documentMode||0;var noBottomFold=$.browser.msie&&(($.browser.version<8&&!mode)||mode<8);var expr=$.browser.msie&&(function(){var div=document.createElement('div');try{div.style.setExpression('width','0+0');div.style.removeExpression('width');}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;}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'dogfold':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'bevelfold':case'bevel':return i+1;}};$.fn.corner=function(options){if(this.length==0){if(!$.isReady&&this.selector){var s=this.selector,c=this.context;$(function(){$(s,c).corner(options);});}return this;}return this.each(function(index){var $this=$(this);var o=[$this.attr($.fn.corner.defaults.metaAttr)||'',options||''].join(' ').toLowerCase();var keep=/keep/.test(o);var cc=((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);var sc=((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);var width=parseInt((o.match(/(\d+)px/)||[])[1])||10;var re=/round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/;var fx=((o.match(re)||['round'])[0]);var fold=/dogfold|bevelfold/.test(o);var edges={T:0,B:1};var opts={TL:/top|tl|left/.test(o),TR:/top|tr|right/.test(o),BL:/bottom|bl|left/.test(o),BR:/bottom|br|right/.test(o)};if(!opts.TL&&!opts.TR&&!opts.BL&&!opts.BR){opts={TL:1,TR:1,BL:1,BR:1};}if($.fn.corner.defaults.useNative&&fx=='round'&&(radius||moz||webkit)&&!cc&&!sc){if(opts.TL){$this.css(radius?'border-top-left-radius':moz?'-moz-border-radius-topleft':'-webkit-border-top-left-radius',width+'px');}if(opts.TR){$this.css(radius?'border-top-right-radius':moz?'-moz-border-radius-topright':'-webkit-border-top-right-radius',width+'px');}if(opts.BL){$this.css(radius?'border-bottom-left-radius':moz?'-moz-border-radius-bottomleft':'-webkit-border-bottom-left-radius',width+'px');}if(opts.BR){$this.css(radius?'border-bottom-right-radius':moz?'-moz-border-radius-bottomright':'-webkit-border-bottom-right-radius',width+'px');}return;}var strip=document.createElement('div');$(strip).css({overflow:'hidden',height:'1px',minHeight:'1px',fontSize:'1px',backgroundColor:sc||'transparent',borderStyle:'solid'});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;}if(!keep){this.style.border='none';}strip.style.borderColor=cc||gpc(this.parentNode);var cssHeight=$(this).outerHeight();for(var j in edges){var bot=edges[j];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;if(bot){this.appendChild(d)}else{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';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';if(bot){d.appendChild(e)}else{d.insertBefore(e,d.firstChild);}}if(fold&&$.support.boxModel){if(bot&&noBottomFold){continue;}for(var c in opts){if(!opts[c]){continue;}if(bot&&(c=='TL'||c=='TR')){continue;}if(!bot&&(c=='BL'||c=='BR')){continue;}var common={position:'absolute',border:'none',margin:0,padding:0,overflow:'hidden',backgroundColor:strip.style.borderColor};var $horz=$('<div/>').css(common).css({width:width+'px',height:'1px'});switch(c){case'TL':$horz.css({bottom:0,left:0});break;case'TR':$horz.css({bottom:0,right:0});break;case'BL':$horz.css({top:0,left:0});break;case'BR':$horz.css({top:0,right:0});break;}d.appendChild($horz[0]);var $vert=$('<div/>').css(common).css({top:0,bottom:0,width:'1px',height:width+'px'});switch(c){case'TL':$vert.css({left:width});break;case'TR':$vert.css({right:width});break;case'BL':$vert.css({left:width});break;case'BR':$vert.css({right:width});break;}d.appendChild($vert[0]);}}}}});};$.fn.uncorner=function(){if(radius||moz||webkit){this.css(radius?'border-radius':moz?'-moz-border-radius':'-webkit-border-radius',0);}$('div.jquery-corner',this).remove();return this;};$.fn.corner.defaults={useNative:true,metaAttr:'data-corner'};})(jQuery);
/*loading tooltip.packed*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(8($){j e={},9,m,B,A=$.2u.2g&&/29\\s(5\\.5|6\\.)/.1M(1H.2t),M=12;$.k={w:12,1h:{Z:25,r:12,1d:19,X:"",G:15,E:15,16:"k"},2s:8(){$.k.w=!$.k.w}};$.N.1v({k:8(a){a=$.1v({},$.k.1h,a);1q(a);g 2.F(8(){$.1j(2,"k",a);2.11=e.3.n("1g");2.13=2.m;$(2).24("m");2.22=""}).21(1e).1U(q).1S(q)},H:A?8(){g 2.F(8(){j b=$(2).n(\'Y\');4(b.1J(/^o\\(["\']?(.*\\.1I)["\']?\\)$/i)){b=1F.$1;$(2).n({\'Y\':\'1D\',\'1B\':"2r:2q.2m.2l(2j=19, 2i=2h, 1p=\'"+b+"\')"}).F(8(){j a=$(2).n(\'1o\');4(a!=\'2f\'&&a!=\'1u\')$(2).n(\'1o\',\'1u\')})}})}:8(){g 2},1l:A?8(){g 2.F(8(){$(2).n({\'1B\':\'\',Y:\'\'})})}:8(){g 2},1x:8(){g 2.F(8(){$(2)[$(2).D()?"l":"q"]()})},o:8(){g 2.1k(\'28\')||2.1k(\'1p\')}});8 1q(a){4(e.3)g;e.3=$(\'<t 16="\'+a.16+\'"><10></10><t 1i="f"></t><t 1i="o"></t></t>\').27(K.f).q();4($.N.L)e.3.L();e.m=$(\'10\',e.3);e.f=$(\'t.f\',e.3);e.o=$(\'t.o\',e.3)}8 7(a){g $.1j(a,"k")}8 1f(a){4(7(2).Z)B=26(l,7(2).Z);p l();M=!!7(2).M;$(K.f).23(\'W\',u);u(a)}8 1e(){4($.k.w||2==9||(!2.13&&!7(2).U))g;9=2;m=2.13;4(7(2).U){e.m.q();j a=7(2).U.1Z(2);4(a.1Y||a.1V){e.f.1c().T(a)}p{e.f.D(a)}e.f.l()}p 4(7(2).18){j b=m.1T(7(2).18);e.m.D(b.1R()).l();e.f.1c();1Q(j i=0,R;(R=b[i]);i++){4(i>0)e.f.T("<1P/>");e.f.T(R)}e.f.1x()}p{e.m.D(m).l();e.f.q()}4(7(2).1d&&$(2).o())e.o.D($(2).o().1O(\'1N://\',\'\')).l();p e.o.q();e.3.P(7(2).X);4(7(2).H)e.3.H();1f.1L(2,1K)}8 l(){B=S;4((!A||!$.N.L)&&7(9).r){4(e.3.I(":17"))e.3.Q().l().O(7(9).r,9.11);p e.3.I(\':1a\')?e.3.O(7(9).r,9.11):e.3.1G(7(9).r)}p{e.3.l()}u()}8 u(c){4($.k.w)g;4(c&&c.1W.1X=="1E"){g}4(!M&&e.3.I(":1a")){$(K.f).1b(\'W\',u)}4(9==S){$(K.f).1b(\'W\',u);g}e.3.V("z-14").V("z-1A");j b=e.3[0].1z;j a=e.3[0].1y;4(c){b=c.2o+7(9).E;a=c.2n+7(9).G;j d=\'1w\';4(7(9).2k){d=$(C).1r()-b;b=\'1w\'}e.3.n({E:b,14:d,G:a})}j v=z(),h=e.3[0];4(v.x+v.1s<h.1z+h.1n){b-=h.1n+20+7(9).E;e.3.n({E:b+\'1C\'}).P("z-14")}4(v.y+v.1t<h.1y+h.1m){a-=h.1m+20+7(9).G;e.3.n({G:a+\'1C\'}).P("z-1A")}}8 z(){g{x:$(C).2e(),y:$(C).2d(),1s:$(C).1r(),1t:$(C).2p()}}8 q(a){4($.k.w)g;4(B)2c(B);9=S;j b=7(2);8 J(){e.3.V(b.X).q().n("1g","")}4((!A||!$.N.L)&&b.r){4(e.3.I(\':17\'))e.3.Q().O(b.r,0,J);p e.3.Q().2b(b.r,J)}p J();4(7(2).H)e.3.1l()}})(2a);',62,155,'||this|parent|if|||settings|function|current||||||body|return|||var|tooltip|show|title|css|url|else|hide|fade||div|update||blocked|||viewport|IE|tID|window|html|left|each|top|fixPNG|is|complete|document|bgiframe|track|fn|fadeTo|addClass|stop|part|null|append|bodyHandler|removeClass|mousemove|extraClass|backgroundImage|delay|h3|tOpacity|false|tooltipText|right||id|animated|showBody|true|visible|unbind|empty|showURL|save|handle|opacity|defaults|class|data|attr|unfixPNG|offsetHeight|offsetWidth|position|src|createHelper|width|cx|cy|relative|extend|auto|hideWhenEmpty|offsetTop|offsetLeft|bottom|filter|px|none|OPTION|RegExp|fadeIn|navigator|png|match|arguments|apply|test|http|replace|br|for|shift|click|split|mouseout|jquery|target|tagName|nodeType|call||mouseover|alt|bind|removeAttr|200|setTimeout|appendTo|href|MSIE|jQuery|fadeOut|clearTimeout|scrollTop|scrollLeft|absolute|msie|crop|sizingMethod|enabled|positionLeft|AlphaImageLoader|Microsoft|pageY|pageX|height|DXImageTransform|progid|block|userAgent|browser'.split('|'),0,{}));
/*loading magicScroller*/
(function($){/*defines the function name. recive an object with atributes*/$.fn.magicScroller = function(params){
        /*the default opctions*/
        $.fn.magicScroller.opc_default = {
            displaytype:"one",
            elementsByRow:3,
            topSeparator:5,
            leftSeparator:3,
            delayTime:500,
            animationTime:1000,
            rowsDisplayed:2
        };
        /*check if params are sent, else defaults is asigned*/
        opc = $.extend( $.fn.magicScroller.opc_default, params );
        /*the final propieties are appended*/
        $.fn.magicScroller.needed = {
            displaytype: opc.displaytype, /*how the elements will display*/
            positions:{}, /*Contains the positions of all elements*/
            elements:opc.elements, /*contains the elemets to scroll*/
            mask:opc.mask,/*mascara de los elementos*/
            elementsPerRow:new Array(), /*assigned elements per row*/
            elementsByRow: opc.elementsByRow, /*number displayed elements by row*/
            topSeparator:opc.topSeparator, /*number of pixels of top element separator*/
            leftSeparator:opc.leftSeparator, /*number of pixels of left element separator*/
            totalRows: 0, /*the total of rows created*/
            delayTime:opc.delayTime, /*interval time of next element*/
            animationTime:opc.animationTime, /*diring animation time*/
            rowsDisplayed:opc.rowsDisplayed, /*how rows will display on each next action*/
            blockElements: new Array(), /*the elements in blocks*/
            numberOfBlocks:0, /*blocks generated ( this depends of rows displayed and elements per row )*/
            actualyDisplayed:0, /*block actulally displayed*/
            stepScroll:0,  /*the step of scroll*/
            prev:opc.prevbtn, /*prev button*/
            next:opc.nextbtn /*next button*/
        };
        $.fn.magicScroller.initializeAll = function(){
            /*elements of actual row*/
            row = new Array();
            /*elements of actual block*/
            block = new Array();
            /*files counter*/
            counter = 0;
            /*initiallize the elements block*/
            $.fn.magicScroller.needed.blockElements = new Array();
            /*for each elements*/
            $.fn.magicScroller.needed.elements.each( function(i){
                //the element is in absolute position
                this.style.position = "absolute";
                //top style to the element
                this.style.top = $.fn.magicScroller.needed.positions.top[i] + 'px';
                //drop the margins
                this.style.margin = "0px";
                //asign the leftstyle to element ( initialize in negative value )
                this.style.left = '-' + $.fn.magicScroller.needed.positions.width[i] + 'px';
                //the opacity of the element is 0 for display in fadeIn efect
                this.style.opacity = '0';
                //get the mod for to know if is a new row
                mod = i % $.fn.magicScroller.needed.elementsByRow;
                if( mod == 0 ){
                    //re initialize the row
                    row = new Array();
                    //increase the files counter for to know what row to manipulate
                    counter++;
                }
                //add the element index to the row
                row.push( i );
                //verify if the rows counter is greater than rowsDisplayed, if true the elements block is completed
                if( counter > $.fn.magicScroller.needed.rowsDisplayed ){
                    //add the block to the block elements
                    $.fn.magicScroller.needed.blockElements.push( block );
                    //reinitialize the block
                    block = new Array();
                    //the counter is 1
                    counter = 1;
                }
                //the index of element is added to block
                block.push( i );
                //if is the last element per row or if is the last element
                if( mod == $.fn.magicScroller.needed.elementsByRow - 1 || i == $.fn.magicScroller.needed.elements.size() -1 )
                    $.fn.magicScroller.needed.elementsPerRow.push(row); //se agrega la fila completa a el array
                //only if is the last element
                if( i == $.fn.magicScroller.needed.elements.size() -1 )
                    $.fn.magicScroller.needed.blockElements.push(block);//se agrega block a blockelements
            });
            /*get the number of blocks*/
            $.fn.magicScroller.needed.numberOfBlocks = $.fn.magicScroller.needed.blockElements.length;
            /*the actually block displayed*/
            $.fn.magicScroller.needed.actualyDisplayed = 0;
            display();
        };




        // returns the jQuery object list
        return this.each( function(){
            //set the styles to mask
            $.fn.magicScroller.needed.mask.css({
                position:"absolute",
                'overflow-y':"hidden"

            });
            //get positions
            setPositions();
            //initialize
            $.fn.magicScroller.initializeAll();
            $.fn.magicScroller.needed.prev.click( function(e){
                e.preventDefault();
                prevRow();
            });
            $.fn.magicScroller.needed.next.click( function(e){
                e.preventDefault();
                nextRow();
            });
        });
        //define the positions of elements
        function setPositions(){
            /**
            * left positions of all elements
            * @var Array
            */
            var left = new Array();
            /**
            * top positions of all elements
            * @var Array
            */
            var top = new Array();
            /**
            * width of all elements
            * @var Array
            */
            var clientWidth = new Array();
            /**
            * height of all elemets
            * @var Array
            */
            var clientHeight = new Array();
            /**
            * total of elements
            * @var int
            */
            totalEl = $.fn.magicScroller.needed.elements.size();

            /**
            * top of next elements, starts 0
            * @var int
            */
            ftop = 0;
            /**
            * left of next elements, starts 0
            * @var Array
            */
            fleft = 0;
            //for each element
            $.fn.magicScroller.needed.elements.each( function(i){
                //add this width element to array
                clientWidth.push(this.clientWidth);
                //add this height element to array
                clientHeight.push(this.clientHeight);
                // if mod is 0, will add new row
                if( i % $.fn.magicScroller.needed.elementsByRow == 0 ){
                    //the first element of row will be the leftSeparator only
                    fleft = $.fn.magicScroller.needed.leftSeparator;
                    //the top will increase, except if it�s the first row instead will be the top  separatyor only
                    ftop += (i==0) ? $.fn.magicScroller.needed.topSeparator:this.clientHeight + $.fn.magicScroller.needed.topSeparator;
                    $.fn.magicScroller.needed.totalRows++;
                }
                else //for each added element the left will increase
                    fleft += $.fn.magicScroller.needed.leftSeparator + this.clientWidth;
                top.push(ftop); //this top element is added to array
                left.push(fleft); //this left element is added to array
            });
            //to positions object will add the propieties top, left, clientWith y clientHeight, width the elemets values
            $.fn.magicScroller.needed.positions.top = top;
            $.fn.magicScroller.needed.positions.left = left;
            $.fn.magicScroller.needed.positions.width = clientWidth;
            $.fn.magicScroller.needed.positions.height = clientHeight;
            //the step scroll is asigned
            $.fn.magicScroller.needed.stepScroll = $.fn.magicScroller.needed.positions.height[0] + $.fn.magicScroller.needed.topSeparator;
        }
        //show the elements by one
        function displayElementsByOne(){
            time = $.fn.magicScroller.needed.delayTime;
            $($.fn.magicScroller.needed.blockElements[ $.fn.magicScroller.needed.actualyDisplayed ]).each( function(i){
                index = parseInt(this);
                animationTime = $.fn.magicScroller.needed.animationTime;
                delayTime = $.fn.magicScroller.needed.delayTime;
                eval("setTimeout(\"$($.fn.magicScroller.needed.elements[" + index + "]).animate({left: $.fn.magicScroller.needed.positions.left[" + index + "] + 'px',opacity:'.6'}," + animationTime + ").delay(200).animate({opacity:1},'medium')\"," + ( time+=delayTime ) + ")");
            });
        }
        //show the elements by row
        function displayElementsByRow(){
            time = 0;
            animationTime = $.fn.magicScroller.needed.animationTime;
            delayTime = $.fn.magicScroller.needed.delayTime;
            elementsByRow = $.fn.magicScroller.needed.elementsByRow;
            $($.fn.magicScroller.needed.blockElements[ $.fn.magicScroller.needed.actualyDisplayed ]).each( function(i){
                index = parseInt(this);
                eval("setTimeout(\"$($.fn.magicScroller.needed.elements[" + index + "]).animate({left: $.fn.magicScroller.needed.positions.left[" + index + "] + 'px',opacity:'.6'}," + animationTime + ").delay(200).animate({opacity:1},'medium')\"," + ( ( i%elementsByRow==0 ) ? time+=delayTime:time ) + ")");
            });
        }
        //display elements by column
        function displayElementsByColumn(){

            animationTime = $.fn.magicScroller.needed.animationTime;
            delayTime = $.fn.magicScroller.needed.delayTime;
            elementsByRow = $.fn.magicScroller.needed.elementsByRow;
            time = new Array();
            timeA = 0;
            counter = -1;
            for(i = 0;i < elementsByRow;i++ )
                time.push( timeA+=delayTime );
            $($.fn.magicScroller.needed.blockElements[ $.fn.magicScroller.needed.actualyDisplayed ]).each( function(i){
                index = parseInt(this);
                mod = i % elementsByRow;
                counter = ( mod == 0) ? counter+1:counter;
                eval("setTimeout(\"$($.fn.magicScroller.needed.elements[" + index + "]).animate({left: $.fn.magicScroller.needed.positions.left[" + index + "] + 'px',opacity:'.6'}," + (animationTime + (counter * 200)) + ").delay(200).animate({opacity:1},'medium')\"," + ( time[mod] ) + ")");
            });
        }
        //display the prev row
        function prevRow(){
            $.fn.magicScroller.needed.actualyDisplayed--;
            if( $.fn.magicScroller.needed.actualyDisplayed >= 0 ){
                addtop =  ( $.fn.magicScroller.needed.actualyDisplayed == $.fn.magicScroller.needed.numberOfBlocks - 1 ) ? Math.ceil($.fn.magicScroller.needed.blockElements[ $.fn.magicScroller.needed.numberOfBlocks - 1 ].length / $.fn.magicScroller.needed.elementsPerRow) * $.fn.magicScroller.needed.stepScroll : $.fn.magicScroller.needed.rowsDisplayed * $.fn.magicScroller.needed.stepScroll;

                $.fn.magicScroller.needed.elements.animate({top:'+=' + addtop + 'px'});
            }
            else
                $.fn.magicScroller.needed.actualyDisplayed = 0;
        }
        //display the next row
        function nextRow(){
            if( $.fn.magicScroller.needed.actualyDisplayed < $.fn.magicScroller.needed.numberOfBlocks-1 ){
                addtop =  ( $.fn.magicScroller.needed.actualyDisplayed == $.fn.magicScroller.needed.numberOfBlocks - 1 ) ? Math.ceil($.fn.magicScroller.needed.blockElements[ $.fn.magicScroller.needed.numberOfBlocks - 1 ].length / $.fn.magicScroller.needed.elementsPerRow) * $.fn.magicScroller.needed.stepScroll : $.fn.magicScroller.needed.rowsDisplayed * $.fn.magicScroller.needed.stepScroll;
                $.fn.magicScroller.needed.elements.animate({top:'-=' + addtop + 'px'});
                $.fn.magicScroller.needed.actualyDisplayed++;
                display();
            }
            else
                $.fn.magicScroller.needed.actualyDisplayed = $.fn.magicScroller.needed.numberOfBlocks -1;
        }
        function display(){
            switch($.fn.magicScroller.needed.displaytype){
                case 'one':
                    displayElementsByOne();
                    break;
                case 'row':
                    displayElementsByRow();
                    break;
                case 'column':
                    displayElementsByColumn();
                    break;
            }
        }

    };})(jQuery);
/*document ready and other ports*/       
jQuery(document).ready(function()
{
    var ja = window.location.pathname;
    var o = ja.split('/');
    var js = o[2];
    var c = o[3];
    var indx = '';
	
    jQuery.fn.exists = function()
    {
        return jQuery(this).length > 0;
    };
    jQuery('#keyword').focus(function()
    {
        jQuery(this).val('').css(
        {
            'color': 'black'
        }).addClass('ui-state-highlight');
    })
    .blur(function()
    {
        jQuery(this).css(
        {
            'color': 'black'
        }).removeClass('ui-state-active');
    });         
    jQuery(".fg-button:not(.ui-state-disabled)")
    .hover(function()
    {
        jQuery(this).addClass("ui-state-hover");
    }, 
    function()
    {
        jQuery(this).removeClass("ui-state-hover");
    })
    .mousedown(function()
    {
        jQuery(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
        if (jQuery(this).is('.ui-state-activer.fg-button-toggleable, .fg-buttonset-multi .ui-state-active')) 
            {
            jQuery(this).removeClass("ui-state-active");
        }
        else 
            {
            jQuery(this).addClass("ui-state-active");
        }
    })
    .mouseup(function()
    {
        if (!jQuery(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button')) 
            {
            jQuery(this).removeClass("ui-state-active");
        }
    });
    jQuery(".fg-button:not(.ui-state-disabled)").livequery(function()
    {
        jQuery(this).hover(function()
        {
            jQuery(this).addClass("ui-state-hover");
        }, function()
        {
            jQuery(this).removeClass("ui-state-hover");
        })
        .mousedown(function()
        {
            jQuery(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
            if (jQuery(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active')) 
                {
                jQuery(this).removeClass("ui-state-active");
            }
            else 
                {
                jQuery(this).addClass("ui-state-active");
            }
        })
        .mouseup(function()
        {
            if (!jQuery(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button')) 
                {
                jQuery(this).removeClass("ui-state-active");
            }
        });
    });
    if( jQuery('#legacy #district').exists() )
        {
        jQuery("#district").jqSelecta(
        {
            closeButton: true,
            autoScrollOverflowX: false,
            autoScrollOverflowY: false,
            autoSelected: true,
            titleSetFrom: 'text',
            height: '250px',
            width: '750px',
            columns: 2,
            title: 'Select districts',
            onClose: function()
            {
                set_districts();
            }
        });         
    }
    if( jQuery( '#tabs' ).exists() ){jQuery('#tabs').tabs();}
    if( jQuery( '.main_nav' ).exists() ){jQuery('.main_nav ul').hide();}
    if( jQuery( '#legacy' ).exists() ){jQuery('#legacy').hide();}
    jQuery('.r_search_a').click(function()
    {
        jQuery('#legacy').toggle();
        if(jQuery('SPAN.ui-icon').hasClass('ui-icon-arrowthickstop-1-s'))
            {
            jQuery('SPAN.ui-icon')
            .removeClass('ui-icon-arrowthickstop-1-s')
            .addClass('ui-icon-arrowthickstop-1-n')
        }
        else
            {
            jQuery('SPAN.ui-icon')
            .removeClass('ui-icon-arrowthickstop-1-n')
            .addClass('ui-icon-arrowthickstop-1-s')           
        }
    });
    if( jQuery('#legacy').exists() )    
        {         
        jQuery("#slider-range-max").slider(
        {
            range: "max",
            min: 1,
            max: 10,
            value: 1,
            slide: function(event, ui)
            {
                jQuery("#rooms").val(ui.value);
                $("#rooms_t").val(ui.value);
            }
        });
        jQuery("#rooms").val(jQuery("#slider-range-max").slider("value"));
        var jn = set_price(js);
        jQuery("#slider-range-min").slider(jn);
        jQuery("#price").val('$ ' + format_price(jQuery("#slider-range-min").slider("value")));
        jQuery("#slider-size").slider(
        {
            range: "min",
            value: 300,
            min: 100,
            max: 20000,
            step: 500,
            slide: function(event, ui)
            {
                jQuery("#size").val(format_price(ui.value) + ' sqft');
            }
        });
        jQuery("#size").val(format_price(jQuery("#slider-size").slider("value")) + ' sqft');


    }
    var $url = '';
    var $link = '';
    var $b = null;
    jQuery("#divId").livequery(function()
    {

        jQuery(this).dialog(
        {
            autoOpen: false,
            title: '<span class="ui-icon ui-icon-mail-closed" style="float:left;margin-right:.3em"></span>Got a Question?',
            buttons: 
            {
                "Send": function()
                {
                    $.ajax
                    ({
                        type: "POST",
                        url: $url + '/send',
                        data: 
                        {
                            name: jQuery(this).find("input[name*='name']").val(),
                            number: jQuery(this).find("input[name*='number']").val(),
                            email: jQuery(this).find("input[name*='email']").val(),
                            preferred: jQuery(this).find("select[name='preferred'] option:selected").val(),
                            message: jQuery(this).find("textarea[name*='message']").val(),
                            link: $link					   	
                        },
                        success: function($data)
                        {
                            jQuery(this).dialog("close");
                            jQuery("#divId").html($data).dialog('open');
                        }
                    });

                    jQuery(this).dialog("close");
                    jQuery('#divId').html('<p>Sending...</p>').dialog('open');
                },
                "Close": function()
                {
                    jQuery(this).dialog("close");
                    jQuery("#divId").html();
                }
            }
        });
    });
    jQuery('.converse').livequery(function()
    {
        jQuery(this).click(function(event)
        {
			indx = jQuery('.converse').index(this)		
			if( event.preventDefault() )
			{
				event.preventDefault();
			}
			else
			{
				event.returnValue = false;
			}
            $link = (jQuery(this).attr('rel').length > 3) ? jQuery(this).attr('rel') : '';
            $url = jQuery(this).attr('href');
            $.ajax(
            {
                type: "POST",
                url: $url,
                data: "",
                success: function($data)
                {
                    jQuery("#divId").html($data).dialog('open');
					//window.scrollTo($('#divId').dialog('option', 'position')[indx],$('#divId').dialog('option', 'position')[indx]);
					
                }
            });
        });
    });
    $ajax = '';
    jQuery('form#slf').submit(function(event)
    {
        event.preventDefault();
        jQuery('#ajax_box').html('<div style="margin-top:100px">'+
        '<img src="http://privateproperty.com.sg/realestate/css/images/ajax-loader.gif" >'+
        '</div>');   
        $url = jQuery(this).attr('action');
        $mrt = (jQuery('input[name=mrt]:checked').length > 0) ? '&mrt=mrt' : '';
        $query = '?ajax=1&price='+jQuery('#price').val()+'&district='+jQuery('#district').val()+
        '&size='+jQuery('#size').val()+'&rooms='+jQuery('#rooms').val()+'&keyword='+jQuery('#searchfield').val()+$mrt;
        $.get($url+$query, 
        function(data)
        {
            jQuery('#ajax_box').empty().fadeIn('slow').html(data);
        });     
        $ajax = 1;            
    });
    jQuery('p.pagination a').live('click', function(event)
    {
        if($ajax == 1)
            {
            event.preventDefault();
            jQuery('#ajax_box').html('<div style="margin-top:100px">'+
            '<img src="http://privateproperty.com.sg/realestate/css/images/ajax-loader.gif" >'+
            '</div>');   
            $url = jQuery(this).attr('href');
            $.get($url, 
            function(data)
            {
                jQuery('#ajax_box').empty().fadeIn('slow').html(data);
            });             
        }

    });
    jQuery('div#announcements').hide().fadeIn('slow');
    //jQuery('.listing_details').hide();  
    /*jQuery('.rounded').corner("round 8px").parent().css('padding', '4px').corner("round 10px");*/
    jQuery('#ajax_box').livequery(function()
    {
        //jQuery('.listing_details').hide();       
        jQuery('.expander').click(function(event)
        {event.preventDefault();jQuery(this).parent().next('.listing_details').toggle('highlight',900);});  
        jQuery('.listing_header').click(function()
        {jQuery(this).next().next('.listing_details').toggle('highlight',900);});                                                     
    });
    jQuery("ul.tabs").tabs("div.panes > ul", {effect: 'fade', fadeOutSpeed: 400});
    params = {
        mask:$('#scrollable'),
        elements:$('#scrollable li'),
        prevbtn:$('#prev-up'),
        nextbtn:$('#next-down'),
        displaytype:'column',
        elementsByRow:1,
        rowsDisplayed:4        
    };
    jQuery('#scrollable').magicScroller( params );
    var cache = {};
    jQuery("#searchfield").autocomplete({
        source: "http://localhost/testing/global/autocomplete/apartments",
        minLength: 3,
        source: function(request, response) 
        {
            if ( request.term in cache ) {
                response( cache[ request.term ] );
                return;
            }
            $.ajax
            ({
                url: "/" + o[1] + "/" + o[2] + "/autocomplete/" + o[3],
                dataType: "json",
                data: request,
                success: function( data ) 
                {
                    cache[ request.term ] = data;
                    response( data );
                }
            });
        }      
    });
    jQuery("ul.subnav").parent().append("<span></span>"); /*Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)*/
    jQuery("ul.topnav li span").click(function() { /*When trigger is clicked...*/

        /*Following events are applied to the subnav itself (moving subnav up and down)*/
        jQuery(this).parent().find("ul.subnav").slideDown('fast').show(); /*Drop down the subnav on click*/

        jQuery(this).parent().hover(function() {
        }, function(){
            jQuery(this).parent().find("ul.subnav").slideUp('slow'); /*When the mouse hovers out of the subnav, move it back up*/
        });

        /*Following events are applied to the trigger (Hover events for the trigger)*/
    }).hover(function() {
        jQuery(this).addClass("subhover"); /*On hover over, add class "subhover"*/
    }, function(){    /*On Hover Out*/
        jQuery(this).removeClass("subhover"); /*On hover out, remove class "subhover"*/
    });
jQuery('*[title]').tooltip();
});   
function format_price(num, decpoint, sep){
    if (arguments.length == 2) 
        {
        sep = ",";
    }
    if (arguments.length == 1) 
        {
        sep = ",";
        decpoint = ".";
    }
    num = num.toString();
    a = num.split(decpoint);
    x = a[0];
    y = a[1];
    z = "";
    if (typeof(x) != "undefined") 
        {
        for (i = x.length - 1; i >= 0; i--) 
            {
            z += x.charAt(i);
        }
        z = z.replace(/(\d{3})/g, "$1" + sep);
        if (z.slice(-sep.length) == sep) 
            {
            z = z.slice(0, -sep.length);
        }
        x = "";
        for (i = z.length - 1; i >= 0; i--) 
            {
            x += z.charAt(i);
        }
        if (typeof(y) != "undefined" && y.length > 0) 
            {
            x += decpoint + y;
        }
    }
    return x;
}
function get_map($street, $id, $url, $type){
    $.getJSON($url, 
    {
        street: $street,
        //project: nn,
        type: $type
    }, function(data)
    {
        var $map;
        var $street_view_pano;
        var $street_view;
        var $pano_id;
        var $latlng = new GLatLng(data.lat, data.long);
        $street_view = new GStreetviewClient();
        $map = new GMap2(document.getElementById('m' + $id));
        $map.setCenter($latlng, 14);
        $map.setUIToDefault();
        $map.addOverlay(new GMarker($latlng));
        GEvent.addListener($map, "click", function(overlay, latlng)
        {
            $street_view.getNearestPanorama(latlng, showPanoData);
        });
        $street_view_pano = new GStreetviewPanorama(document.getElementById('p' + $id));
        $street_view_pano.setLocationAndPOV($latlng);
        GEvent.addListener($street_view_pano, "error", handleNoFlash);
        $street_view.getNearestPanorama($latlng, showPanoData);

        function showPanoData(panoData)
        {
            if (panoData.code != 200) 
                {
                jQuery('#p' + $id).html('<div id="no_map">We couldn\'t find a Street View for this property. Try zooming in the <span class="enlarge">Map</span> and clicking on a nearby road.</div>');
                return;
            }
            else 
                {
                var nr = '#p' + $id;
                $(nr).text('');
            }
            $pano_id = panoData.links[0].panoId;
            var nl = '<table id="description">' + $street + '</table>';
            $map.openInfoWindowHtml(panoData.location.latlng, nl);
            $street_view_pano.setLocationAndPOV(panoData.location.latlng);
        }
        function next()
        {
            $street_view.getPanoramaById($pano_id, showPanoData);
        }
        function handleNoFlash(errorCode)
        {
            if (errorCode == 603) 
                {
                jQuery('#p' + $id).html('<div id="no_map">There is a problem with Flash in your browser. Street-View will not be shown</div>');
                return;
            }
        }
    });
}
function set_price(js){
    var jn;
    switch (js)
    {
        case 'rent':
            jn = 
            {
                range: "min",
                value: 6000,
                min: 1500,
                max: 30000,
                step: 500,
                slide: function(event, ui)
                {
                    jQuery("#price").val('$ ' + format_price(ui.value));
                }
            };
            break;
        case 'sale':
            jn = 
            {
                range: "min",
                value: 2500000,
                min: 300000,
                max: 30000000,
                step: 10000,
                slide: function(event, ui)
                {
                    jQuery("#price").val('$ ' + format_price(ui.value));
                }
            };
            break;
    }
    return jn;
}
function set_districts(){
    var jc = '';
    jQuery('#district > :selected').each(function(i)
    {
        var na = jQuery(this);
        jc += na.attr('value') + ',';
    });
    jc = jc.substring(0, jc.length - 1);
    return jc;
}
function add_wishlist ( $id ){
    jQuery('td#right_content #wishlist ')
    .html(
    '<div style="margin:10px">'+
    '<img src="http://privateproperty.com.sg/realestate/css/images/ajax-loader.gif" >'+
    '</div>'
    );   
    jQuery.get('add_to_cart/' + $id, function(data) 
    {
        jQuery('td#right_content .rounded:first')
        .empty()
        .hide()
        .html(data)
        .fadeIn('slow');
        jQuery('#adder_' + $id).addClass('ui-state-disabled').text('Added...');
    }); 

}
function remove_wishlist ( $id ){
    jQuery('td#right_content #wishlist ')
    .html(
    '<div style="margin:10px">'+
    '<img src="http://privateproperty.com.sg/realestate/css/images/ajax-loader.gif" >'+
    '</div>'
    );   
    jQuery.get('delete_from_cart/' + $id, function(data) 
    {
        jQuery('td#right_content .rounded:first').empty().hide().html(data).fadeIn('slow');
        jQuery('#adder_' + $id).removeClass('ui-state-disabled').html('<span class="add">Add to Wishlist</span>');
    });

}
function empty_cart(){
    jQuery('td#right_content #wishlist ')
    .html(
    '<div style="margin-top:10px">'+
    '<img src="http://privateproperty.com.sg/realestate/css/images/ajax-loader.gif" >'+
    '</div>'
    );   
    jQuery.get('empty_cart/' + $id, function(data) 
    {
        jQuery('td#right_content .rounded').empty().fadeIn('slow').html(data);       
    });

}
function do_slide( $opts ){
    $('h2.post_title').empty().text( $opts[0].title ).fadeIn("slow"); 
    $('div.wordp_content').empty().html( $opts[0].content ).fadeIn("slow");
    var $parent_id = '';     
    $('#video').crossSlide({ fade: 1 }, 
    $opts, function(idx, img, idxOut, imgOut) 
    {
        if (idxOut == undefined)
            {
            $('span.caption').text( $opts[idx].caption ).fadeIn();
            $parent_id =  $opts[idx].pid;          
        }
        else
            {
            /*            if( $opts[idx].pid !== $parent_id && $parent_id !=='' )
            { */
            //$('h2.post_title').fadeOut().text( $opts[idx].title ).fadeIn('slow');
            //$('div.wordp_content').html( $opts[idx].content ).fadeIn('slow');
            /*            }      */          
            $('span.caption').fadeOut() 
        }

    });                  
} 