/**
 * @author Jason Roy for CompareNetworks Inc.
 * Thanks to mikejbond for suggested udaptes
 *
 * Version 1.1
 * Copyright (c) 2009 CompareNetworks Inc.
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
/* jshint ignore:start */
define(["jquery","core/log"],function(a,b){"use strict";
// Private functions
function c(){
//Check if easing plugin exists. If it doesn't, use "swing"
g="object"==typeof a.easing?"easeOutQuad":"swing",
//The reference object containing all of the breadcrumb elements
j=a(i).find("li"),
//Keep it from overflowing in ie6 & 7
a(i).find("ul").wrap('<div style="overflow:hidden; position:relative;  width: '+a(i).css("width")+';"><div>'),
//If the breadcrumb contains nothing, don't do anything
j.length>0&&(a(j[j.length-1]).addClass("last"),a(j[0]).addClass("first"),
//If the breadcrumb object length is long enough, compress.
j.length>h.minimumCompressionElements&&d())}function d(){
// Factor to determine if we should compress the element at all
var b=a(j[j.length-1]);
// If the final element is really long, compress more elements
a(b).width()>h.maxFinalElementLength&&(h.beginningElementsToLeaveOpen>0&&h.beginningElementsToLeaveOpen--,h.endElementsToLeaveOpen>0&&h.endElementsToLeaveOpen--),/* If the final element is within the short and long range,
           compress to the default end elements and 1 less beginning elements. */
a(b).width()<h.maxFinalElementLength&&a(b).width()>h.minFinalElementLength&&h.beginningElementsToLeaveOpen>0&&h.beginningElementsToLeaveOpen--;var c=j.length-1-h.endElementsToLeaveOpen;
// We compress only elements determined by the formula setting below.
a(j).each(function(b,d){if(b>h.beginningElementsToLeaveOpen&&b<c){a(d).find("a").wrap("<span></span>").width(a(d).find("a").width()+h.previewWidth);var g={id:b,width:a(d).width(),listElement:a(d).find("span"),isAnimating:!1,element:a(d).find("span")};a(d).bind("mouseover",g,e).bind("mouseout",g,f),a(d).find("a").unbind("mouseover",e).unbind("mouseout",f),d.autoInterval=setInterval(function(){clearInterval(d.autoInterval),a(d).find("span").animate({width:h.previewWidth},h.timeInitialCollapse,h.easing)},150*(b-2))}})}function e(b){var c=b.data.width;return a(b.data.element).stop(),a(b.data.element).animate({width:c+h.previewWidth/2},{duration:h.timeExpansionAnimation,easing:h.easing,queue:!1}),!1}function f(b){return a(b.data.element).stop(),a(b.data.element).animate({width:h.previewWidth},{duration:h.timeCompressionAnimation,easing:h.easing,queue:!1}),!1}// jshint ;_;
b.debug("Essential jBreadCrumb AMD");
// Private variables
var g,h={},i={},j={};
// Public functions
// Public global variables.
return a.fn.jBreadCrumb=function(b){return h=a.extend({},a.fn.jBreadCrumb.defaults,b),this.each(function(){i=a(this),c()})},a.fn.jBreadCrumb.defaults={maxFinalElementLength:Math.round(.05*a(window).width()),minFinalElementLength:Math.round(.02*a(window).width()),minimumCompressionElements:1,endElementsToLeaveOpen:0,beginningElementsToLeaveOpen:0,timeExpansionAnimation:500,timeCompressionAnimation:400,timeInitialCollapse:500,easing:"swing",previewWidth:Math.round(.015*a(window).width())},{init:function(){a(document).ready(function(a){a(".breadcrumb.style1").jBreadCrumb()}),b.debug("Essential jBreadCrumb AMD init")}}});