/* Sets a variable of $jq as a no conflict to work with SiteCore's JS engine. All jQuery needs to use $jq instead of just $*/
var $jq = jQuery.noConflict(); 


jQuery.fn.fadeToggle = function(speed, easing, callback) {
    return this.animate({ opacity: 'toggle' }, speed, easing, callback);

};


//About us > Process tooltips
jQuery.fn.processTooltip = function () {
    return this.each(function () {
        $jq('.process-section').each(function () {
            // options
            var distance = 10;
            var time = 250;
            var hideDelay = 200;
            var hideDelayTimer = null;
            var beingShown = false;
            var shown = false;
            var trigger = $jq('.process-link', this);
            var popup = $jq('.process-desc', this).css('opacity', 0);

            // set the mouseover and mouseout on both element
            $jq([trigger.get(0), popup.get(0)]).mouseover(function () {
                // stops the hide event if we move from the trigger to the popup element
                if (hideDelayTimer) clearTimeout(hideDelayTimer);

                // don't trigger the animation again if we're being shown, or already visible
                if (beingShown || shown) {
                    return;
                } else {
                    beingShown = true;

                    // reset position of popup box
                    popup.css({
                        left: -159,
                        display: 'block',
                        "z-index": 100
                    })

                    // (we're using chaining on the popup) now animate it's opacity and position
        .animate({
            bottom: '+=' + distance + 'px',
            opacity: 1
        }, time, 'swing', function () {
            // once the animation is complete, set the tracker variables
            beingShown = false;
            shown = true;
        });
                }
            }).mouseout(function () {
                // reset the timer if we get fired again - avoids double animations
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                popup.css({
                    'z-index': 20

                });
                // store the timer so that it can be cleared in the mouseover if required
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    popup.animate({
                        opacity: 0
                    }, time, 'swing', function () {
                        // once the animate is complete, set the tracker variables
                        shown = false;
                        // hide the popup entirely after the effect (opacity alone doesn't do the job)
                        popup.css({
                            display: 'none',
                            bottom: 56
                        });
                    });
                }, hideDelay);
            });
        });
    });
}
//End of tooltip

$jq(document).ready(function() {
$jq(".images span.no-jq").remove();
$jq("#banner.no-jq").removeClass('no-jq');
});


/* ABOUT US
------------------------------------------*/
$jq(document).ready(function() {


    $jq('p')
    .filter(function() {
        return $jq.trim($jq(this).text()) === ''
    }).remove();




$jq(document).ready(function() {


    var twitterlinkheight = $jq('#twitter-feed').height(); 
    $jq(".twitter-feed-icon").css('padding-bottom', twitterlinkheight);/*sets the height of the twitter icon to sit in the middle of the tweet*/


$jq(".vid-link.no-jq").removeClass('no-jq');
});

$jq('#newsletter-box input').focus(function() {
        $jq(this).addClass('focus');
    });


    /* $jq(function() {
    if (typeof document.body.style.maxHeight === "undefined") {
    return false;
    }
    else {
    $jq('.wide').columnize({ width: 368 });
    }
    });*/
    

/* New items badge
------------------------------------------*/
    var newDiv = $jq("<span class='newitem'></span>");
    $jq(".new").parent().prepend(newDiv);


    /*$jq('#newsletter-box .submit').click(function() {
    $jq('#newsthanks').fadeIn('fast');
    });*/

/* Form validation (Contact us, Blog)
------------------------------------------*/
    $jq('.form-validation')
    .filter(function() {
        return $jq.trim($jq(this).text()) === 'Please enter your email address'
    }).addClass("invalid");

    $jq('.form-validation')
    .filter(function() {
        return $jq.trim($jq(this).text()) === 'Please enter your last name'
    }).addClass("invalid");

    $jq('.form-validation')
    .filter(function() {
        return $jq.trim($jq(this).text()) === 'Please enter a valid email address'
    }).addClass("invalid");

    $jq('.form-validation')
    .filter(function() {
        return $jq.trim($jq(this).text()) === 'Please enter your first name'
    }).addClass("invalid");

    $jq('.form-validation')
    .filter(function() {
        return $jq.trim($jq(this).text()) === 'Please enter a comment'
    }).addClass("invalid");

    $jq('#newsletter-box input').focus(function() {
        $jq(this).addClass('focus');
    });
    

    $jq(".form-field-text input.fname").focus(function() {
        $jq(".form-validation.fname").fadeOut('fast');
    });
    $jq(".form-field-text input.lname").focus(function() {
        $jq(".form-validation.lname").fadeOut('fast');
    });
    $jq(".form-field-text input.email").focus(function() {
        $jq(".form-validation.email").fadeOut('fast');
    });
    $jq(".form-textarea .comment").focus(function() {
        $jq(".form-validation.comment").fadeOut('fast');
    });


    $jq(".form-validation.fname").click(function() {
        $jq(".form-field-text input.fname").focus();
    });
    $jq(".form-validation.lname").click(function() {
        $jq(".form-field-text input.lname").focus();
    });
    $jq(".form-validation.email").click(function() {
        $jq(".form-field-text input.email").focus();
    });
    $jq(".form-validation.comment").click(function() {
        $jq(".form-textarea .comment").focus();
    });

/* Newsletter sign up submit
------------------------------------------*/
    $jq('input[type="text"]').keydown(function(e) {
        if (e.which == 13) {
            var param_fieldset = $jq(this).parents('.frm_form').attr('id');
            $jq('#' + param_fieldset).find('.submit').trigger('click');
        }
    });

/* Newsletter focus - text fields
------------------------------------------*/

    $jq('#newsletter-box input').blur(function() {
        $jq(this).removeClass('focus').addClass('blur');
    });

    $jq('input.newsletter-focus').click(function() {
        if ($jq(this).val() == "Name") $jq(this).val("").removeClass('blur').addClass('focus');
    }).blur(function() {
        if ($jq(this).val() == "") $jq(this).val("Name").removeClass('focus').addClass('blur');
    });

    $jq('input.newsletter-focus').keydown(function() {
        if ($jq(this).val() == "Name") $jq(this).val("");
    }).blur(function() {
        if ($jq(this).val() == "") $jq(this).val("Name");
    })


    $jq('input.newsletter-emailadd').click(function() {
        if ($jq(this).val() == "Email Address") $jq(this).val("").removeClass('blur').addClass('focus');
    }).blur(function() {
        if ($jq(this).val() == "") $jq(this).val("Email Adress").removeClass('focus').addClass('blur');
    });

    $jq('input.newsletter-emailadd').keydown(function() {
        if ($jq(this).val() == "Email Address") $jq(this).val("");
    }).blur(function() {
        if ($jq(this).val() == "") $jq(this).val("Email Address");
    })
    
/* Search focus - text fields
------------------------------------------*/
    $jq('#search-box input').focus(function() {
        $jq(this).addClass('focus');
    });

    $jq('#search-box input').blur(function() {
        $jq(this).removeClass('focus').addClass('blur');
    });

    $jq('input.search-focus').click(function() {
        if ($jq(this).val() == "Enter Keyword") $jq(this).val("").removeClass('blur').addClass('focus');
    }).blur(function() {
        if ($jq(this).val() == "") $jq(this).val("Enter Keyword").removeClass('focus').addClass('blur');
    });

    $jq('input.search-focus').keydown(function() {
        if ($jq(this).val() == "Enter Keyword") $jq(this).val("");
    }).blur(function() {
        if ($jq(this).val() == "") $jq(this).val("Enter Keyword");
    });



/* Search focus - text fields
------------------------------------------*/
    $jq(".photowall").removeClass('no-jquery');
    $jq(".tooltip").hide();
    $jq(".thumb", this).mouseenter(
	function() {
	    $jq(".tooltip", this).parent().css('zIndex', 5000, 'overflow', scroll);
	    $jq(".tooltip", this).stop().fadeTo('fast', 1);
	});
    $jq(".thumb", this).mouseleave(
	function() {
	    $jq(".tooltip", this).parent().css('zIndex', 1);
	    $jq(".tooltip", this).hide();
	});


    $jq("#videowallcontainer").hide();
    var newheight = $jq("#videowallcontainer").parent().height();
    $jq("#videowallcontainer").height((newheight) + 41);
});

$jq(document).keydown(function(esc) {
        if (esc.which == 27) {
            $jq("#videowallcontainer").fadeOut('fast');
            $jq("#pnlVideoItem").remove();
        }
    });


   


/* TOP WIDGETS - Newsletter, login, search 
------------------------------------------*/


    /* $jq(document).ready(function() {
    var newheight2 = $jq("#banner").height();
    $jq(".newsletter-submit-thanks").height(newheight2);
$jq(".newsletter-submit-thanks").delay(2000).fadeOut(400);
});*/


    $jq(document).ready(function() {
    $jq(".newsletter-submit-thanks").delay(2000).fadeOut(400);
});


/* closes all open widget boxes with escape key press */
$jq(document).keydown(function(e) {
    if (e.which == 27) {
        $jq(".newsletter-widget, .login-widget, .search-widget").fadeOut('fast');
    }
});

/* Header Links */
$jq(document).ready(function() {
    $jq("#wrapper").removeClass("no-jquery");
    $jq(".newsletter-widget, .login-widget, .search-widget").hide();
    $jq("#newsletter-link").click(function() {
        $jq("#search-link, .login-widget").removeClass("current");
        $jq(".search-widget, .login-widget").fadeOut('fast');
        $jq(".newsletter-widget").fadeToggle('fast');
        $jq(".newsletter-focus").focus();
        $jq("#newsletter-link").toggleClass("current");
        return false;
    });
    $jq("#login-link").click(function() {
        $jq("#search-link, #newsletter-link").removeClass("current");
        $jq(".search-widget, .newsletter-widget").fadeOut('fast');
        $jq(".login-widget").fadeToggle('fast');
        $jq(".login-focus").focus();
        $jq("#login-link").toggleClass("current");
        return false;
    });
    $jq("#search-link").click(function() {
        $jq("#login-link, #newsletter-link").removeClass("current");
        $jq(".login-widget, .newsletter-widget").fadeOut('fast');
        $jq(".search-widget").fadeToggle('fast');
        $jq(".search-focus").focus();
        $jq("#search-link").toggleClass("current");
        return false;
    });
    $jq('.tab').click(function() {
        $jq(".newsletter-widget, .login-widget, .search-widget").fadeOut('fast');
    });
    $jq('body').click(function() {
        $jq("#newsletter-link, #login-link, #search-link").removeClass("current");
        $jq(".newsletter-widget, .login-widget, .search-widget").fadeOut('fast');
    });
    $jq("#newsletter-link, .newsletter-widget, #login-link, #login-box, #search-link, #search-box").click(function(event) {
        event.stopPropagation();
    });
});


$jq(document).ready(function() {
    $jq("ul.dashed li").prepend('<span class="hyphen">- </span>').css({ 'list-style-type': 'none', 'margin-left': '0' });

});




/*JQTRANSFORM
------------------------------------------*/

(function($jq) {
    var defaultOptions = { preloadImg: true };
    var jqTransformImgPreloaded = false;

    var jqTransformPreloadHoverFocusImg = function(strImgUrl) {
        //guillemets to remove for ie
        strImgUrl = strImgUrl.replace(/^url\((.*)\)/, '$jq1').replace(/^\"(.*)\"$jq/, '$jq1');
        var imgHover = new Image();
        imgHover.src = strImgUrl.replace(/\.([a-zA-Z]*)$jq/, '-hover.$jq1');
        var imgFocus = new Image();
        imgFocus.src = strImgUrl.replace(/\.([a-zA-Z]*)$jq/, '-focus.$jq1');
    };

/* Labels */
    var jqTransformGetLabel = function(objfield) {
        var selfForm = $jq(objfield.get(0).form);
        var oLabel = objfield.next();
        if (!oLabel.is('label')) {
            oLabel = objfield.prev();
            if (oLabel.is('label')) {
                var inputname = objfield.attr('id');
                if (inputname) {
                    oLabel = selfForm.find('label[for="' + inputname + '"]');
                }
            }
        }
        if (oLabel.is('label')) { return oLabel.css('cursor', 'pointer'); }
        return false;
    };

/* Hide all open selects */
    var jqTransformHideSelect = function(oTarget) {
        var ulVisible = $jq('.jqTransformSelectWrapper ul:visible');
        ulVisible.each(function() {
            var oSelect = $jq(this).parents(".jqTransformSelectWrapper:first").find("select").get(0);
            //do not hide if click on the label object associated to the select
            if (!(oTarget && oSelect.oLabel && oSelect.oLabel.get(0) == oTarget.get(0))) { $jq(this).hide(); }
        });
    };
/* Check for an external click */
    var jqTransformCheckExternalClick = function(event) {
        if ($jq(event.target).parents('.jqTransformSelectWrapper').length === 0) { jqTransformHideSelect($jq(event.target)); }
    };
/* Apply document listener */
    var jqTransformAddDocumentListener = function() {
        $jq(document).mousedown(jqTransformCheckExternalClick);
    };

/* Add a new handler for the reset action */
    var jqTransformReset = function(f) {
        var sel;
        $jq('.jqTransformSelectWrapper select', f).each(function() { sel = (this.selectedIndex < 0) ? 0 : this.selectedIndex; $jq('ul', $jq(this).parent()).each(function() { $jq('a:eq(' + sel + ')', this).click(); }); });
        $jq('a.jqTransformCheckbox, a.jqTransformRadio', f).removeClass('jqTransformChecked');
        $jq('input:checkbox, input:radio', f).each(function() { if (this.checked) { $jq('a', $jq(this).parent()).addClass('jqTransformChecked'); } });
    };

/* Labels */
    $jq.fn.jqTransInputButton = function() {
        return this.each(function() {
            var newBtn = $jq('<button id="' + this.id + '" name="' + this.name + '" type="' + this.type + '" class="' + this.className + ' jqTransformButton"><span><span>' + $jq(this).attr('value') + '</span></span>')
				.hover(function() { newBtn.addClass('jqTransformButton_hover'); }, function() { newBtn.removeClass('jqTransformButton_hover') })
				.mousedown(function() { newBtn.addClass('jqTransformButton_click') })
				.mouseup(function() { newBtn.removeClass('jqTransformButton_click') })
			;
            $jq(this).replaceWith(newBtn);
        });
    };

/* Text fields */
    $jq.fn.jqTransInputText = function() {
        return this.each(function() {
            var $jqinput = $jq(this);

            if ($jqinput.hasClass('jqtranformdone') || !$jqinput.is('input')) { return; }
            $jqinput.addClass('jqtranformdone');

        });
    };

    /***************************
    Check Boxes 
    ***************************/
    $jq.fn.jqTransCheckBox = function() {
        return this.each(function() {
            if ($jq(this).hasClass('jqTransformHidden')) { return; }

            var $jqinput = $jq(this);
            var inputSelf = this;

            //set the click on the label
            var oLabel = jqTransformGetLabel($jqinput);
            oLabel && oLabel.click(function() { aLink.trigger('click'); });

            var aLink = $jq('<a href="#" class="jqTransformCheckbox"></a>');
            //wrap and add the link
            $jqinput.addClass('jqTransformHidden').wrap('<span class="jqTransformCheckboxWrapper"></span>').parent().prepend(aLink);
            //on change, change the class of the link
            $jqinput.change(function() {
                this.checked && aLink.addClass('jqTransformChecked') || aLink.removeClass('jqTransformChecked');
                return true;
            });
            // Click Handler, trigger the click and change event on the input
            aLink.click(function() {
                //do nothing if the original input is disabled
                if ($jqinput.attr('disabled')) { return false; }
                //trigger the envents on the input object
                $jqinput.trigger('click').trigger("change");
                return false;
            });

            // set the default state
            this.checked && aLink.addClass('jqTransformChecked');
        });
    };
    /***************************
    Radio Buttons 
    ***************************/
    $jq.fn.jqTransRadio = function() {
        return this.each(function() {
            if ($jq(this).hasClass('jqTransformHidden')) { return; }

            var $jqinput = $jq(this);
            var inputSelf = this;

            oLabel = jqTransformGetLabel($jqinput);
            oLabel && oLabel.click(function() { aLink.trigger('click'); });

            var aLink = $jq('<a href="#" class="jqTransformRadio" rel="' + this.name + '"></a>');
            $jqinput.addClass('jqTransformHidden').wrap('<span class="jqTransformRadioWrapper"></span>').parent().prepend(aLink);

            $jqinput.change(function() {
                inputSelf.checked && aLink.addClass('jqTransformChecked') || aLink.removeClass('jqTransformChecked');
                return true;
            });
            // Click Handler
            aLink.click(function() {
                if ($jqinput.attr('disabled')) { return false; }
                $jqinput.trigger('click').trigger('change');

                // uncheck all others of same name input radio elements
                $jq('input[name="' + $jqinput.attr('name') + '"]', inputSelf.form).not($jqinput).each(function() {
                    $jq(this).attr('type') == 'radio' && $jq(this).trigger('change');
                });

                return false;
            });
            // set the default state
            inputSelf.checked && aLink.addClass('jqTransformChecked');
        });
    };

    /***************************
    TextArea 
    ***************************/
    $jq.fn.jqTransTextarea = function() {
        return this.each(function() {
            var textarea = $jq(this);

            if (textarea.hasClass('jqtransformdone')) { return; }
            textarea.addClass('jqtransformdone');


        });
    };

    /***************************
    Select 
    ***************************/
    

    
    
    $jq.fn.jqTransSelect = function() {
        return this.each(function(index) {
            var $jqselect = $jq(this);

            if ($jqselect.hasClass('jqTransformHidden')) { return; }
            if ($jqselect.attr('multiple')) { return; }

            var oLabel = jqTransformGetLabel($jqselect);
            /* First thing we do is Wrap it */
            var $jqwrapper = $jqselect
				.addClass('jqTransformHidden')
				.wrap('<div class="jqTransformSelectWrapper"></div>')
				.parent()
				.css({ zIndex: 10 - index })
			;

            /* Now add the html for the select */
            $jqwrapper.prepend('<div><span></span><a href="#" class="jqTransformSelectOpen"></a></div><ul></ul>');
            var $jqul = $jq('ul', $jqwrapper).css('width', $jqselect.width()).hide();
            /* Now we add the options */
            $jq('option', this).each(function(i) {
                var oLi = $jq('<li><a href="#" index="' + i + '">' + $jq(this).html() + '</a></li>');
                $jqul.append(oLi);
            });

            /* Add click handler to the a */
            $jqul.find('a').click(function() {
                $jq('a.selected', $jqwrapper).removeClass('selected');
                $jq(this).addClass('selected');
                /* Fire the onchange event */
                if ($jqselect[0].selectedIndex != $jq(this).attr('index') && $jqselect[0].onchange) { $jqselect[0].selectedIndex = $jq(this).attr('index'); $jqselect[0].onchange(); }
                $jqselect[0].selectedIndex = $jq(this).attr('index');
                $jq('span:eq(0)', $jqwrapper).html($jq(this).html());
                $jqul.hide();
                return false;
            });
            /* Set the default */
            $jq('a:eq(' + this.selectedIndex + ')', $jqul).click();
            $jq('span:first', $jqwrapper).click(function() { $jq("a.jqTransformSelectOpen", $jqwrapper).trigger('click'); });
            oLabel && oLabel.click(function() { $jq("a.jqTransformSelectOpen", $jqwrapper).trigger('click'); });
            this.oLabel = oLabel;

            $jq("a.jqTransformSelectOpen").focus(function() {
            $jq("a.jqTransformSelectOpen").addClass('open');
            });

            $jq("a.jqTransformSelectOpen").blur(function() {
                $jq("a.jqTransformSelectOpen").removeClass('open');
            });
            
            /* Apply the click handler to the Open */
            var oLinkOpen = $jq('a.jqTransformSelectOpen', $jqwrapper)
				.click(function() {
				    //Check if box is already open to still allow toggle, but close all other selects
				    if ($jqul.css('display') == 'none') { jqTransformHideSelect(); }
				    if ($jqselect.attr('disabled')) { return false; }

				    $jqul.slideToggle('fast', function() {
				        var offSet = ($jq('a.selected', $jqul).offset().top - $jqul.offset().top);
				        $jqul.animate({ scrollTop: offSet });
				    });
				    return false;
				})
			;

            // Set the new width
            var iSelectWidth = $jqselect.outerWidth();
            var oSpan = $jq('span:first', $jqwrapper);
            var newWidth = (iSelectWidth > oSpan.innerWidth()) ? iSelectWidth + oLinkOpen.outerWidth() : $jqwrapper.width();
            $jqwrapper.css('width', newWidth);
            $jqul.css('width', newWidth - 2);
            oSpan.css({ width: iSelectWidth });

            // Calculate the height if necessary, less elements that the default height
            //show the ul to calculate the block, if ul is not displayed li height value is 0
            $jqul.css({ display: 'block', visibility: 'hidden' });
            var iSelectHeight = ($jq('li', $jqul).length) * ($jq('li:first', $jqul).height()); //+1 else bug ff
            (iSelectHeight < $jqul.height()) && $jqul.css({ height: iSelectHeight, 'overflow': 'hidden' }); //hidden else bug with ff
            $jqul.css({ display: 'none', visibility: 'visible' });

        });
    };
    $jq.fn.jqTransform = function(options) {
        var opt = $jq.extend({}, defaultOptions, options);

        /* each form */
        return this.each(function() {
            var selfForm = $jq(this);
            if (selfForm.hasClass('jqtransformdone')) { return; }
            selfForm.addClass('jqtransformdone');

            $jq('input:submit, input:reset, input[type="button"]', this).jqTransInputButton();
            $jq('input:text, input:password', this).jqTransInputText();
            $jq('input:checkbox', this).jqTransCheckBox();
            $jq('input:radio', this).jqTransRadio();
            $jq('textarea', this).jqTransTextarea();

            if ($jq('select', this).jqTransSelect().length > 0) { jqTransformAddDocumentListener(); }
            selfForm.bind('reset', function() { var action = function() { jqTransformReset(this); }; window.setTimeout(action, 10); });

            //preloading dont needed anymore since normal, focus and hover image are the same one
            /*if(opt.preloadImg && !jqTransformImgPreloaded){
            jqTransformImgPreloaded = true;
            var oInputText = $jq('input:text:first', selfForm);
            if(oInputText.length > 0){
            //pour ie on eleve les ""
            var strWrapperImgUrl = oInputText.get(0).wrapper.css('background-image');
            jqTransformPreloadHoverFocusImg(strWrapperImgUrl);					
            var strInnerImgUrl = $jq('div.jqTransformInputInner',$jq(oInputText.get(0).wrapper)).css('background-image');
            jqTransformPreloadHoverFocusImg(strInnerImgUrl);
            }
				
				var oTextarea = $jq('textarea',selfForm);
            if(oTextarea.length > 0){
            var oTable = oTextarea.get(0).oTable;
            $jq('td',oTable).each(function(){
            var strImgBack = $jq(this).css('background-image');
            jqTransformPreloadHoverFocusImg(strImgBack);
            });
            }
            }*/


        }); /* End Form each */

       

    }; /* End the Plugin */

})(jQuery);






/* COLUMNIZE */

(function($jq) {
    $jq.fn.columnize = function(options) {
        var defaults = { width: 400, columns: false, buildOnce: false, overflow: false, doneFunc: function() { }, target: false, ignoreImageLoading: true, float: "left", lastNeverTallest: false }; var options = $jq.extend(defaults, options); return this.each(function() {
            var $jqinBox = options.target ? $jq(options.target) : $jq(this); var maxHeight = $jq(this).height(); var $jqcache = $jq('<div></div>'); var lastWidth = 0; var columnizing = false; $jqcache.append($jq(this).children().clone(true)); if (!options.ignoreImageLoading && !options.target) { if (!$jqinBox.data("imageLoaded")) { $jqinBox.data("imageLoaded", true); if ($jq(this).find("img").length > 0) { var func = function($jqinBox, $jqcache) { return function() { if (!$jqinBox.data("firstImageLoaded")) { $jqinBox.data("firstImageLoaded", "true"); $jqinBox.empty().append($jqcache.children().clone(true)); $jqinBox.columnize(options); } } } ($jq(this), $jqcache); $jq(this).find("img").one("load", func); $jq(this).find("img").one("abort", func); return; } } }
            $jqinBox.empty(); columnizeIt(); if (!options.buildOnce) {
                $jq(window).resize(function() {
                    if (!options.buildOnce && $jq.browser.msie) {
                        if ($jqinBox.data("timeout")) { clearTimeout($jqinBox.data("timeout")); }
                        $jqinBox.data("timeout", setTimeout(columnizeIt, 200));
                    } else if (!options.buildOnce) { columnizeIt(); } else { } 
                });
            }
            function columnize($jqputInHere, $jqpullOutHere, $jqparentColumn, height) {
                while ($jqparentColumn.height() < height && $jqpullOutHere[0].childNodes.length) { $jqputInHere.append($jqpullOutHere[0].childNodes[0]); }
                if ($jqputInHere[0].childNodes.length == 0) return; var kids = $jqputInHere[0].childNodes; var lastKid = kids[kids.length - 1]; $jqputInHere[0].removeChild(lastKid); var $jqitem = $jq(lastKid); if ($jqitem[0].nodeType == 3) {
                    var oText = $jqitem[0].nodeValue; var counter2 = options.width / 18; if (options.accuracy)
                        counter2 = options.accuracy; var columnText; var latestTextNode = null; while ($jqparentColumn.height() < height && oText.length) {
                        if (oText.indexOf(' ', counter2) != '-1') { columnText = oText.substring(0, oText.indexOf(' ', counter2)); } else { columnText = oText; }
                        latestTextNode = document.createTextNode(columnText); $jqputInHere.append(latestTextNode); if (oText.length > counter2) { oText = oText.substring(oText.indexOf(' ', counter2)); } else { oText = ""; } 
                    }
                    if ($jqparentColumn.height() >= height && latestTextNode != null) { $jqputInHere[0].removeChild(latestTextNode); oText = latestTextNode.nodeValue + oText; }
                    if (oText.length) { $jqitem[0].nodeValue = oText; } else { return false; } 
                }
                if ($jqpullOutHere.children().length) { $jqpullOutHere.prepend($jqitem); } else { $jqpullOutHere.append($jqitem); }
                return $jqitem[0].nodeType == 3;
            }
            function split($jqputInHere, $jqpullOutHere, $jqparentColumn, height) {
                if ($jqpullOutHere.children().length) {
                    $jqcloneMe = $jqpullOutHere.children(":first"); $jqclone = $jqcloneMe.clone(true); if ($jqclone.attr("nodeType") == 1 && !$jqclone.hasClass("dontend")) {
                        $jqputInHere.append($jqclone); if ($jqclone.is("img") && $jqparentColumn.height() < height + 20) { $jqcloneMe.remove(); } else if (!$jqcloneMe.hasClass("dontsplit") && $jqparentColumn.height() < height + 20) { $jqcloneMe.remove(); } else if ($jqclone.is("img") || $jqcloneMe.hasClass("dontsplit")) { $jqclone.remove(); } else {
                            $jqclone.empty(); if (!columnize($jqclone, $jqcloneMe, $jqparentColumn, height)) { if ($jqcloneMe.children().length) { split($jqclone, $jqcloneMe, $jqparentColumn, height); } }
                            if ($jqclone.get(0).childNodes.length == 0) { $jqclone.remove(); } 
                        } 
                    } 
                } 
            }
            function singleColumnizeIt() {
                if ($jqinBox.data("columnized") && $jqinBox.children().length == 1) { return; }
                $jqinBox.data("columnized", true); $jqinBox.data("columnizing", true); $jqinBox.empty(); $jqinBox.append($jq("<div class='first last column' style='width:98%; padding: 3px; float: " + options.float + ";'></div>")); $jqcol = $jqinBox.children().eq($jqinBox.children().length - 1); $jqdestroyable = $jqcache.clone(true); if (options.overflow) {
                    targetHeight = options.overflow.height; columnize($jqcol, $jqdestroyable, $jqcol, targetHeight); if (!$jqdestroyable.children().find(":first-child").hasClass("dontend")) { split($jqcol, $jqdestroyable, $jqcol, targetHeight); }
                    while (checkDontEndColumn($jqcol.children(":last").length && $jqcol.children(":last").get(0))) { var $jqlastKid = $jqcol.children(":last"); $jqlastKid.remove(); $jqdestroyable.prepend($jqlastKid); }
                    var html = ""; var div = document.createElement('DIV'); while ($jqdestroyable[0].childNodes.length > 0) {
                        var kid = $jqdestroyable[0].childNodes[0]; for (var i = 0; i < kid.attributes.length; i++) { if (kid.attributes[i].nodeName.indexOf("jQuery") == 0) { kid.removeAttribute(kid.attributes[i].nodeName); } }
                        div.innerHTML = ""; div.appendChild($jqdestroyable[0].childNodes[0]); html += div.innerHTML;
                    }
                    var overflow = $jq(options.overflow.id)[0]; overflow.innerHTML = html;
                } else { $jqcol.append($jqdestroyable); }
                $jqinBox.data("columnizing", false); if (options.overflow) { options.overflow.doneFunc(); } 
            }
            function checkDontEndColumn(dom) { if (dom.nodeType != 1) return false; if ($jq(dom).hasClass("dontend")) return true; if (dom.childNodes.length == 0) return false; return checkDontEndColumn(dom.childNodes[dom.childNodes.length - 1]); }
            function columnizeIt() {
                if (lastWidth == $jqinBox.width()) return; lastWidth = $jqinBox.width(); var numCols = Math.round($jqinBox.width() / options.width); if (options.columns) numCols = options.columns; if (numCols <= 1) { return singleColumnizeIt(); }
                if ($jqinBox.data("columnizing")) return; $jqinBox.data("columnized", true); $jqinBox.data("columnizing", true); $jqinBox.empty(); $jqinBox.append($jq("<div style='width:" + (Math.round(100 / numCols) - 2) + "%; padding: 3px; float: " + options.float + ";'></div>")); $jqcol = $jqinBox.children(":last"); $jqcol.append($jqcache.clone()); maxHeight = $jqcol.height(); $jqinBox.empty(); var targetHeight = maxHeight / numCols; var firstTime = true; var maxLoops = 3; var scrollHorizontally = false; if (options.overflow) { maxLoops = 1; targetHeight = options.overflow.height; } else if (options.height && options.width) { maxLoops = 1; targetHeight = options.height; scrollHorizontally = true; }
                for (var loopCount = 0; loopCount < maxLoops; loopCount++) {
                    $jqinBox.empty(); var $jqdestroyable; try { $jqdestroyable = $jqcache.clone(true); } catch (e) { $jqdestroyable = $jqcache.clone(); }
                    $jqdestroyable.css("visibility", "hidden"); for (var i = 0; i < numCols; i++) { var className = (i == 0) ? "first column" : "column"; var className = (i == numCols - 1) ? ("last " + className) : className; $jqinBox.append($jq("<div class='" + className + "' style='width:" + (Math.round(100 / numCols) - 2) + "%; float: " + options.float + ";'></div>")); }
                    var i = 0; while (i < numCols - (options.overflow ? 0 : 1) || scrollHorizontally && $jqdestroyable.children().length) {
                        if ($jqinBox.children().length <= i) { $jqinBox.append($jq("<div class='" + className + "' style='width:" + (Math.round(100 / numCols) - 2) + "%; float: " + options.float + ";'></div>")); }
                        var $jqcol = $jqinBox.children().eq(i); columnize($jqcol, $jqdestroyable, $jqcol, targetHeight); if (!$jqdestroyable.children().find(":first-child").hasClass("dontend")) { split($jqcol, $jqdestroyable, $jqcol, targetHeight); } else { }
                        while (checkDontEndColumn($jqcol.children(":last").length && $jqcol.children(":last").get(0))) { var $jqlastKid = $jqcol.children(":last"); $jqlastKid.remove(); $jqdestroyable.prepend($jqlastKid); }
                        i++;
                    }
                    if (options.overflow && !scrollHorizontally) {
                        var IE6 = false; var IE7 = (document.all) && (navigator.appVersion.indexOf("MSIE 7.") != -1); if (IE6 || IE7) {
                            var html = ""; var div = document.createElement('DIV'); while ($jqdestroyable[0].childNodes.length > 0) {
                                var kid = $jqdestroyable[0].childNodes[0]; for (var i = 0; i < kid.attributes.length; i++) { if (kid.attributes[i].nodeName.indexOf("jQuery") == 0) { kid.removeAttribute(kid.attributes[i].nodeName); } }
                                div.innerHTML = ""; div.appendChild($jqdestroyable[0].childNodes[0]); html += div.innerHTML;
                            }
                            var overflow = $jq(options.overflow.id)[0]; overflow.innerHTML = html;
                        } else { $jq(options.overflow.id).empty().append($jqdestroyable.children().clone(true)); } 
                    } else if (!scrollHorizontally) {
                        $jqcol = $jqinBox.children().eq($jqinBox.children().length - 1); while ($jqdestroyable.children().length) $jqcol.append($jqdestroyable.children(":first")); var afterH = $jqcol.height(); var diff = afterH - targetHeight; var totalH = 0; var min = 10000000; var max = 0; var lastIsMax = false; $jqinBox.children().each(function($jqinBox) {
                            return function($jqitem) {
                                var h = $jqinBox.children().eq($jqitem).height(); lastIsMax = false; totalH += h; if (h > max) { max = h; lastIsMax = true; }
                                if (h < min) min = h;
                            } 
                        } ($jqinBox)); var avgH = totalH / numCols; if (options.lastNeverTallest && lastIsMax) { targetHeight = targetHeight + 30; if (loopCount == maxLoops - 1) maxLoops++; } else if (max - min > 30) { targetHeight = avgH + 30; } else if (Math.abs(avgH - targetHeight) > 20) { targetHeight = avgH; } else { loopCount = maxLoops; } 
                    } else { $jqinBox.children().each(function(i) { $jqcol = $jqinBox.children().eq(i); $jqcol.width(options.width + "px"); if (i == 0) { $jqcol.addClass("first"); } else if (i == $jqinBox.children().length - 1) { $jqcol.addClass("last"); } else { $jqcol.removeClass("first"); $jqcol.removeClass("last"); } }); $jqinBox.width($jqinBox.children().length * options.width + "px"); }
                    $jqinBox.append($jq("<br style='clear:both;'>"));
                }
                $jqinBox.find('.column').find(':first.removeiffirst').remove(); $jqinBox.find('.column').find(':last.removeiflast').remove(); $jqinBox.data("columnizing", false); if (options.overflow) { options.overflow.doneFunc(); }
                options.doneFunc();
            } 
        });
    };
})(jQuery);



/*EASING*/

/*
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*
* Uses the built in easing capabilities added In jQuery 1.1
* to offer multiple easing options
*
* TERMS OF USE - jQuery Easing
* 
* Open source under the BSD License. 
* 
* Copyright © 2008 George McGinley Smith
* All rights reserved.
* 
* Redistribution and use in source and binary forms, with or without modification, 
* are permitted provided that the following conditions are met:
* 
* Redistributions of source code must retain the above copyright notice, this list of 
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list 
* of conditions and the following disclaimer in the documentation and/or other materials 
* provided with the distribution.
* 
* Neither the name of the author nor the names of contributors may be used to endorse 
* or promote products derived from this software without specific prior written permission.
* 
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
*  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
*  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
* OF THE POSSIBILITY OF SUCH DAMAGE. 
*
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend(jQuery.easing,
{
    def: 'easeOutQuad',
    swing: function(x, t, b, c, d) {
        //alert(jQuery.easing.default);
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    },
    easeInQuad: function(x, t, b, c, d) {
        return c * (t /= d) * t + b;
    },
    easeOutQuad: function(x, t, b, c, d) {
        return -c * (t /= d) * (t - 2) + b;
    },
    easeInOutQuad: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t + b;
        return -c / 2 * ((--t) * (t - 2) - 1) + b;
    },
    easeInCubic: function(x, t, b, c, d) {
        return c * (t /= d) * t * t + b;
    },
    easeOutCubic: function(x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t + 1) + b;
    },
    easeInOutCubic: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    },
    easeInQuart: function(x, t, b, c, d) {
        return c * (t /= d) * t * t * t + b;
    },
    easeOutQuart: function(x, t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    },
    easeInOutQuart: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
        return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
    },
    easeInQuint: function(x, t, b, c, d) {
        return c * (t /= d) * t * t * t * t + b;
    },
    easeOutQuint: function(x, t, b, c, d) {
        return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
    },
    easeInOutQuint: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
    },
    easeInSine: function(x, t, b, c, d) {
        return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
    },
    easeOutSine: function(x, t, b, c, d) {
        return c * Math.sin(t / d * (Math.PI / 2)) + b;
    },
    easeInOutSine: function(x, t, b, c, d) {
        return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
    },
    easeInExpo: function(x, t, b, c, d) {
        return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
    },
    easeOutExpo: function(x, t, b, c, d) {
        return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
    },
    easeInOutExpo: function(x, t, b, c, d) {
        if (t == 0) return b;
        if (t == d) return b + c;
        if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
        return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
    },
    easeInCirc: function(x, t, b, c, d) {
        return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
    },
    easeOutCirc: function(x, t, b, c, d) {
        return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
    },
    easeInOutCirc: function(x, t, b, c, d) {
        if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
        return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
    },
    easeInElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    },
    easeOutElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    },
    easeInOutElastic: function(x, t, b, c, d) {
        var s = 1.70158; var p = 0; var a = c;
        if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5);
        if (a < Math.abs(c)) { a = c; var s = p / 4; }
        else var s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    },
    easeInBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * (t /= d) * t * ((s + 1) * t - s) + b;
    },
    easeOutBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
    },
    easeInOutBack: function(x, t, b, c, d, s) {
        if (s == undefined) s = 1.70158;
        if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
        return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
    },
    easeInBounce: function(x, t, b, c, d) {
        return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
    },
    easeOutBounce: function(x, t, b, c, d) {
        if ((t /= d) < (1 / 2.75)) {
            return c * (7.5625 * t * t) + b;
        } else if (t < (2 / 2.75)) {
            return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
        } else if (t < (2.5 / 2.75)) {
            return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
        } else {
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
        }
    },
    easeInOutBounce: function(x, t, b, c, d) {
        if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
        return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
    }
});

/*
*
* TERMS OF USE - EASING EQUATIONS
* 
* Open source under the BSD License. 
* 
* Copyright © 2001 Robert Penner
* All rights reserved.
* 
* Redistribution and use in source and binary forms, with or without modification, 
* are permitted provided that the following conditions are met:
* 
* Redistributions of source code must retain the above copyright notice, this list of 
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list 
* of conditions and the following disclaimer in the documentation and/or other materials 
* provided with the distribution.
* 
* Neither the name of the author nor the names of contributors may be used to endorse 
* or promote products derived from this software without specific prior written permission.
* 
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
*  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
*  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
* OF THE POSSIBILITY OF SUCH DAMAGE. 
*
*/

