//Global Vars
var jQ = jQuery.noConflict();
var lastStartRow;
var FLfader = "";
var UAfader = "";

var frVar = "FALSE";


//Cookie Plugin
eval(function(p,a,c,k,e,d){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--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[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(7){7.i=b(4,5,3){8(l 4===\'m\'||l 5===\'m\')9 t;c 6=4+\'=\'+u(5);8(3.d)6+=\'; d=\'+3.d;8(3.e)6+=\'; e=\'+3.e;8(3.f){c a=r x();a.y(a.p()+3.f*q*j*j*o);6+=\'; w=\'+a.z()}8(3.h)6+=\'; h\';9 k.n=6};7.D=b(4){9 7.i(4,\'\',{f:-1})};7.A=b(4){c 5=k.n.C(\'(?:^|;)\\\\s*\'+4.F(/([-.*+?^${}()|[\\]\\/\\\\])/g,\'\\\\$1\')+\'=([^;]*)\');9(5)?B(5[1]):H};7.G=\'v 2.0\'})(E);',44,44,'|||options|name|value|str|jq|if|return|date|function|var|domain|path|duration||secure|setCookie|60|document|typeof|undefined|cookie|1000|getTime|24|new||false|encodeURIComponent||expires|Date|setTime|toGMTString|readCookie|decodeURIComponent|match|delCookie|jQuery|replace|CooQueryVersion|null'.split('|'),0,{}));
//URL Params Plugin
jQ.extend({getUrlParams:function(){var d=[],c;var a=window.location.href.slice(window.location.href.indexOf("?")+1).split("&");for(var b=0;b<a.length;b++){c=a[b].split("=");d.push(c[0]);d[c[0]]=c[1];}return d;},getUrlParam:function(a){return jQ.getUrlParams()[a];}});

/////////////////////////////////////////////////////////////

/*
function messagingPopup() {
	jQ("#lightsOutDiv").animate({opacity:  "0.7" }, 500 );
	jQ("#lightsOutDiv, #messagingPopup").fadeIn(500);
	jQ("#messagingPopup").animate({top:  "50px" }, 500 );
};

jQ(window).load( function() {
	jQ("#lightsOutDiv").css("width",jQ(document).width());
	jQ("#lightsOutDiv").css("height",jQ(document).height());
	jQ("#lightsOutDiv").css("top","0");
	jQ("#lightsOutDiv").css("left","0");
	
	jQ("#messagingPopup").css("left", ( jQ(document).width()/2 - jQ("#messagingPopup").width()/2 ) );
	jQ("#messagingPopup").css("top", 0 - jQ("#messagingPopup").height() );
	
	jQ("#lightsOutDiv, #messagingPopup").click( function() {
		jQ("#lightsOutDiv, #messagingPopup").fadeOut();
		jQ("#messagingPopup").css("top", 0 - jQ("#messagingPopup").height() );
	});
	
	jQ("#messagingPopupLI").fadeIn();
	
	jQ("#closeWindow").click( function() {
		jQ("#lightsOutDiv, #messagingPopup").fadeOut();
		jQ("#messagingPopup").css("top", 0 - jQ("#messagingPopup").height() );
	});
	
	jQ("#closeWindow").css("cursor","pointer");
});
*/

/////////////////////////////////////////////////////////////

function toggleForgotPwd()
	{
		jQ("#loginInfo").toggle();
		jQ("div#forgotpasswordContent").toggle();
	}

function textFocus(e)
	{
		var target = e.target;
		if (jQ(target).val() == "Recherche dans les ventes à venir") {
			jQ(target).val("");
			frVar = "TRUE";
		}
		if(jQ(target).val() == "Search Upcoming Auctions" || jQ(target).val() == "Search Forthcoming Auctions" || jQ(target).val() == "Email Address")
			{
				jQ(target).val("");
			}
	}
 
function textBlur(e)
	{
	var target = e.target;
	var myField = target.id;
	if(myField == "searchBox" && jQ(target).val() == "")
		{
			if(document.domain.match("artfact") && frVar == "FALSE")
				{
					jQ("input#"+myField).val("Search Upcoming Auctions");
				}
			else if (document.domain.match("artfact") && frVar == "TRUE") {
				jQ("input#"+myField).val("Recherche dans les ventes à venir");
			}
			else
				{
					jQ("input#"+myField).val("Search Forthcoming Auctions");
				}
		}
	if(myField == "nwsltremail" && jQ(target).val() == "")
		{
			jQ("input#"+myField).val("Email Address");
		}
	else if(myField == "ntSignUp-Email" && jQ(target).val() == "")
		{
			jQ("input#"+myField).val("Email Address");
		}
	}

// Artfact FR Page JS  ----------------------------------------------------//

//-------------------------------------------------------------------------//

function copyURL() 
	{
		var $url = jQ("ul#FLUL li:visible a").attr('href');
		var $newURL =jQ("div#featuredlots div#FLnav a#FLinfo");
		$newURL.attr('href',$url);
	}
	
function restartProgBar()
	{
		jQ("img#progbar").attr("src", "/wwwImages/FLprog.gif");
	}
	
function startTimerSlow()
	{
		if(jQ("ul#FLUL li").length > 1)
			{
				FLfader = setTimeout(FLnextAuto, 13000);	
			}
	}
	
function FLnextAuto()
	{
		if(jQ("ul#FLUL li:visible").next().length)
			{
				jQ("ul#FLUL li:visible").fadeOut(function(){
					jQ(this).next().fadeIn();
					copyURL();
				});
				restartProgBar();
				startTimerSlow();
			}
		else
			{
				jQ("ul#FLUL li:visible").fadeOut(function(){
					jQ("ul#FLUL li:first").fadeIn();
					copyURL();
				});
				restartProgBar();
				startTimerSlow();
			}	
	}

function FLprevAuto()
	{
		if(jQ("ul#FLUL li:visible").prev().length)
			{
				jQ("ul#FLUL li:visible").fadeOut(function(){
					jQ(this).prev().fadeIn();
					copyURL();
				});
				restartProgBar();
				startTimerSlow();	
			}
		else
			{
				jQ("ul#FLUL li:visible").fadeOut(function(){
					jQ("ul#FLUL li:last").fadeIn();
					copyURL();
				});
				restartProgBar();
				startTimerSlow();
			}	
	}

function FLnext()
	{
		if(jQ("ul#FLUL li:visible").next().length)
			{
				jQ("ul#FLUL li:visible").fadeOut(function(){
					jQ(this).next().fadeIn();
					copyURL();
				});	
			}
		else
			{
				jQ("ul#FLUL li:visible").fadeOut(function(){
					jQ("ul#FLUL li:first").fadeIn();
					copyURL();
				});
			}	
	}

function FLprev()
	{
		if(jQ("ul#FLUL li:visible").prev().length)
			{
				jQ("ul#FLUL li:visible").fadeOut(function(){
					jQ(this).prev().fadeIn();
					copyURL();
				});
			}
		else
			{
				jQ("ul#FLUL li:visible").fadeOut(function(){
					jQ("ul#FLUL li:last").fadeIn();
					copyURL();
				});
			}	
	}
	
function FLright()
	{
		if(!jQ("ul#FLUL li").is(":animated"))
			{
				clearTimeout(FLfader);
				restartProgBar();
				FLnext();
			}
	}

function FLleft()
	{
		if(!jQ("ul#FLUL li").is(":animated"))
			{
				clearTimeout(FLfader);
				restartProgBar();
				FLprev();
			}
	}
	
function UAnext()
	{
		if(jQ("div.UAitem:visible").next().length)
			{
				jQ("div.UAitem:visible").animate({
						top: "-100px",
						opacitcy: 0
					}, function(){
						jQ(this).hide().css("top", "0px");
				}).next().fadeIn();
				startTimerFast();
			}
		else
			{
				jQ("div.UAitem:last").animate({
						top: "-100px",
						opacitcy: 0
					}, function(){
						jQ(this).hide().css("top", "0px");
				});
				jQ("div.UAitem:first").fadeIn();
				startTimerFast();
			}		
	}

function UAprev()
	{
		if(jQ("div.UAitem:visible").prev().length)
			{
				jQ("div.UAitem:visible").animate({
						top: "100px",
						opacitcy: 0
					}, function(){
						jQ(this).hide().css("top", "0px");
				}).prev().fadeIn();
				startTimerFast();
			}
		else
			{
				jQ("div.UAitem:first").animate({
						top: "100px",
						opacitcy: 0
					}, function(){
						jQ(this).hide().css("top", "0px");
				});
				jQ("div.UAitem:last").fadeIn();
				startTimerFast();
			}
	}
	
function startTimerFast()
	{
		if(jQ("div.UAitem").length > 1)
			{
				UAfader = setTimeout(UAnext, 5000);
			}
	}
	
function UAup()
	{
		if(!jQ("div.UAitem").is(":animated"))
			{
				clearTimeout(UAfader);
				UAnext();
			}
	}

function UAdown()
	{
		if(!jQ("div.UAitem").is(":animated"))
			{
				clearTimeout(UAfader);
				UAprev();
			}
	}
	
function accordion(e) 
	{
		var target = e.target;
		if(target.tagName == "SPAN" || target.tagName == "IMG")
			{
				target = jQ(target)
					.parent()
					.get(0);
			}else{
				$target = jQ(target);
			}
		
		var $target = jQ(target);
		if ('!$target.next.css("display","none")')
			{
				$target.next('div:visible').slideUp('normal');
			}
		$target
		.next('div:hidden').slideDown('slow')
		.siblings('div:visible').slideUp('normal');
	}

function openPanel()
	{
		var $panel = jQ("div#loginWrapper div#loginPanel");
		var pita;
		if (jQ($panel).css("top") != "0px")
			{
				jQ("div#loginWrapper").show(0);
				jQ($panel).animate({top: "60px"}).animate({top: "0px"}, "fast");
				jQ("ul#navigation a.login").removeClass("login").addClass("loginOpen");
				/********************************************************************
				*
				*		The logic below is for a bug/regression in IE 8. When the login panel drops down , if  
				*		there are any hoverable items below in input field, it becomes very difficult to get focus
				*		on the field without the hoverbale item registering. The fix is to set the items visibility
				*		to 'hidden' when the panel is shown and 'visible' when it is hidden.
				*		to do this just add a else if statement assigning the item that is hindering to the variable
				*		'pita'. NOTE THERE ARE TWO INSTANCES OF PITA.
				*
				********************************************************************/
				
				if ( jQ.browser.msie && jQ.browser.version == 8)
				{
					if(jQ("div#featuredlots").length)
						{
							pita = jQ("div#featuredlots");
						}
					else if(jQ("#sidenavcontainer").length)
						{
							pita = jQ("#sidenavcontainer");
						}
					if(pita)
						{
							pita.css("visibility","hidden");
							pita = "";
						}
				}
			}
		else
			{

					if(jQ("div#featuredlots").length)
						{
							pita = jQ("div#featuredlots");
						}
					else if(jQ("#sidenavcontainer").length)
						{
							pita = jQ("#sidenavcontainer");
						}
					if(pita)
						{
							pita.css("visibility","visible");
							pita = "";
						}
				jQ($panel).animate({top: "60px"}, "fast").animate({top: "-321px"}, function(){
					jQ("div#loginWrapper").hide(0); 
				});
				jQ("ul#navigation a.loginOpen").removeClass("loginOpen").addClass("login");
			}
		jQ('div#searchFilterMenu').hide();
	}

function closeIt(e)
	{
		var target = e.target;
		jQ(target).parent().parent().parent().hide();
	} 
	
function closeFilter()
	{
		jQ("div.filterWrap").hide();
	}

function bubble() {
	var distance = 10;
	var time = 500;
	var beingShown = false;
	var shown = false;
	content = "";
	content += "<div class='infoBubble clearfix'>";
	content += "<div class='bubbleTop left2'></div>";
	content += "<div class='bubbleBody left2'>";
	content += "<p>This auction will begin shortly. Please check back and refresh your browser to join the live bidding.</p>";
	content += "</div>";
	content += "<div class='bubbleBottom left2'></div>";
	content += "</div>";
	var $button = jQ('img.apStartingSoon');	
	$button.before(content);
	var $bubble = jQ('div.infoBubble');
	$bubble.hide();
	$button.mouseover(function(){
		if (beingShown || shown) {
			return;
		} else {
			beingShown = true;
			$bubble.css({
				top: -100,
				display: 'block'
			})
			.animate({
				top: '-=' + distance + 'px',
				opacity: 1
			}, time, 'swing', function() {
				beingShown = false;
				shown = true;
			});
		}
	}).mouseout(function() {
		$bubble.animate({
			top: '-=' + distance + 'px',
			opacity: 0
		}, time, 'swing', function() {
			shown = false;
			$bubble.css('display', 'none');
		});
	});
}

function getCampaignCookie ()
           {           
             var cookieCampaign = jQ.readCookie('CAMPAIGN');
              }
	
function initNewsletterSignup() {
	jQ("#nlSignUpWrapper .errormsg, #nlSignUpWrapper p").hide();
	//jQ("div#footerWrapper div#nlSignupWrapper ul").show();
	//jQ("div#footerWrapper div#nlSignUpWrapper").fadeIn("slow");
}

function validEmail(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}

function loadPage(emailAddy, myInput, myLocation, myHref, myProtocol, myHost, myHostName)
	{
		var mySearch = "?type=newsletter",
		myPath = "services/userInfo.cfm",
		mySecHost,
		mySecProtocol,
		myNewUrl;

		//if my host has the string 'sec' then im all set, if not
		// then build the secure host
	switch (myHost)
			{
				case "artfact.com":
					mySecHost = "secure.artfact.com";
					mySecProtocol = "https";
					break;
				case "invaluable.com":
					mySecHost = "secure.invaluable.com";
					mySecProtocol = myProtocol;
					break;
				case "secure.artfact.com":
					mySecHost = myHost;
					mySecProtocol = "https";
					break;
				case "secure.invaluable.com":
					mySecHost = myHost;
					mySecProtocol = myProtocol;
					break;
				case "www.artfact.com":
					mySecHost = "secure.artfact.com";
					mySecProtocol = "https:";
					break;
				case "www.invaluable.com":
					mySecHost = "secure.invaluable.com";
					mySecProtocol = "https:";
					break;
//Comment out below here for and production
				case "stage.artfact.com":
					mySecHost = "stagesec.artfact.com";
					mySecProtocol = myProtocol;
					break;
				case "stage.invaluable.com":
					mySecHost = "stagesec.invaluable.com";
					mySecProtocol = myProtocol;
					break;
				case "joeysec.artfact.com":
					mySecHost = myHost;
					mySecProtocol = myProtocol;
					break;
					case "shawnsec.artfact.com":
					mySecHost = myHost;
					mySecProtocol = myProtocol;
					break;
				case "joeysec.invaluable.com":
					mySecHost = myHost;
					mySecProtocol = myProtocol;
					break;
				case "shawnsec.invaluable.com":
					mySecHost = myHost;
					mySecProtocol = myProtocol;
					break;
				case "alexsec.artfact.com":
					mySecHost = myHost;
					mySecProtocol = myProtocol;
					break;
				case "alexsec.invaluable.com":
					mySecHost = myHost;
					mySecProtocol = myProtocol;
					break;
				case "joey.artfact.com":
					mySecHost = "joeysec.artfact.com";
					mySecProtocol = myProtocol;
					break;
				case "shawn.artfact.com":
					mySecHost = "shawnsec.artfact.com";
					mySecProtocol = myProtocol;
					break;
				case "joey.invaluable.com":
					mySecHost = "joeysec.arinvaluabletfact.com";
					mySecProtocol = myProtocol;
					break;
					case "shawn.invaluable.com":
					mySecHost = "shawnsec.arinvaluabletfact.com";
					mySecProtocol = myProtocol;
					break;
				case "alex.artfact.com":
					mySecHost = "alexsec.artfact.com";
					mySecProtocol = myProtocol;
					break;
				case "alex.invaluable.com":
					mySecHost = "alexsec.arinvaluabletfact.com";
					mySecProtocol = myProtocol;
					break;
//Comment out above here for and production
				default : 
					mySecHost = myHost;
					mySecProtocol = myProtocol;
			}

		myNewUrl = mySecProtocol + "//"+mySecHost+"/"+myPath+mySearch+"&emailAddy="+emailAddy;
		location.href=myNewUrl;
	}

function sayThanks() {
	var companyRef,
		emailAddy,
		errMsg, 
		errTxt,
		myInput,
		myLocation = window.location,
		myHref = location.href,
		myProtocol =  location.protocol,
		myHost = location.host,
		myHostName = location.hostname;
	
		
		errTxt = "";
		emailAddy = jQ(this).prev("input").val();
		companyRef = jQ("#companyRef").val();
		errMsg = jQ("#nlSignUpWrapper .errormsg");
		myInput = jQ("#ntSignUp-Email");

	if (emailAddy == "" || emailAddy =="Email Address")
		{
			errMsg.text("Please enter a valid email address.").fadeIn();
			myInput.focus();
			return;
		}
	else if (!validEmail(emailAddy))
		{
			errMsg.text("Email address is of an improper format.").fadeIn();
			myInput.focus();
			return;
		}
	else
		{

			submitSignupInfo(emailAddy,companyRef);
			getCampaignCookie ();
			loadPage(emailAddy, myInput, myLocation, myHref, myProtocol, myHost, myHostName );

			return false;
		}

}

function submitSignupInfo(emailAddy,companyRef)
{
	if (!jQ.readCookie('CAMPAIGN')) {
		jQ.getJSON("/lib/jQueryObj/jUserSubscription.cfc?wsdl", {
			method: "addUserSignup",
			mbrEmailAddress: emailAddy,
			companyID: companyRef
		})
	}
	else {
		jQ.getJSON("/lib/jQueryObj/jUserSubscription.cfc?wsdl", {
			method: "addUserSignup",
			mbrEmailAddress: emailAddy,
			companyID: companyRef,
			campaign: jQ.readCookie('CAMPAIGN')
		});
	}
	location.path
}

jQ(function(){
	
	jQ("a.nowhere").attr("href", "javascript:void(0);");

	if(jQ("ul#FLUL li").length > 1)
		{
			jQ("div#featuredlots").hover(function(){
				jQ("div#FLnav").stop().animate({"top": "0"}, 250);
					clearTimeout(FLfader);
					jQ("img#progbar").hide();
			}, function(){
				jQ("div#FLnav").stop().animate({"top": "-42px"}, 250);
					startTimerSlow();
					jQ("img#progbar").show();
					restartProgBar();
			});
		}
	
	if(jQ("div.UAitem").length > 1)
		{
			jQ("div#UAcontainer").hover(function(){
				clearTimeout(UAfader);
			}, function(){
				startTimerFast();
			});
		}
	else
		{
			jQ("div#UAnav").hide(); //hide UAnav if less than 2 items
		}

	jQ('div#filters div.filters a').click(function(){
		var filterContainers = jQ('div.filterWrap');
		if(jQ(filterContainers.filter(this.hash)).is(":hidden"))
			{
				filterContainers.hide().filter(this.hash).show();
				return false;
			}
	});
	
	jQ('img#btnSearchFilter').click(function(){
		window.location="/catalog/advancedSearch.cfm?srchScope=p";
	});
	
	if (jQ("div#results div.resultsRight div.auctionButton img").hasClass("apStartingSoon")) 
		{
			bubble();
		}
	
	jQ("ul#FLUL li:first").fadeIn(startTimerSlow);
	jQ("img#progbar").show().attr("src", "/wwwImages/FLprog.gif").css("opacity", "0.5");
	jQ("div.UAitem:first").fadeIn(startTimerFast);
	jQ("a#FLnext").click(FLright);
	jQ("a#FLprev").click(FLleft);
	jQ("a#UAup").click(UAup);
	jQ("a#UAdown").click(UAdown);
	jQ("input#searchBox,#loginPanel input, #newslettersignup input, #nlSignUpWrapper input").focus(textFocus);
	jQ("input#searchBox, #loginPanel input, #newslettersignup input, #nlSignUpWrapper input").blur(textBlur);
	jQ("a#forgotpassword, a#cancelForgotPwd").click(toggleForgotPwd);
/*	jQ("div#navContainer li#panel_button, .panel_button").click(openPanel);*/
	jQ('div.filterWrap > div').filter('.accordion').hide();
	jQ('div.filterWrap').click(accordion);
	jQ('div.filterWrap > h3 span.close').click(closeIt);
	jQ("div#filters, div#navContainer").click(closeFilter);
	jQ("#nlSignUpWrapper input[type='submit']").live("click",sayThanks);
//removed auto show of old dashboard upon login 3-7-11 redesign of MyArtfact pages and login process
// !!!!!!!!!!!!!!!!!  Potentially just change this to add href link to the <a> tag to take the user to their My Artfact home page on click
	//if (jQ("ul#navigation li#panel_button a").hasClass("firstload"))
	//	{
	//		jQ("div#navContainer ul#navigation li#panel_button").trigger("click");
	//	}

	copyURL();
	initNewsletterSignup();
});

// equal column heights
//Usage: $(object).equalHeights([minHeight], [maxHeight]);
(function(jQ) {
	jQ.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if(jQ(this).height() > tallest) {
				tallest = jQ(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			jQ(this).height(tallest).css("overflow","auto");
		});
	}
})(jQuery);

 
 // breadcrumb
 /**
 * @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
 *
 */
(function($)
{

    // Private variables
    
    var _options = {};
    var _container = {};
    var _breadCrumbElements = {};
    var _autoIntervalArray = [];
	var _easingEquation;
    
    // Public functions
    
    jQuery.fn.jBreadCrumb = function(options)
    {
        _options = $.extend({}, $.fn.jBreadCrumb.defaults, options);
        
        return this.each(function()
        {
            _container = $(this);
            setupBreadCrumb();
        });
        
    };
    
    // Private functions
    
    function setupBreadCrumb()
    {
		//Check if easing plugin exists. If it doesn't, use "swing"
		if(typeof(jQuery.easing) == 'object')
		{
			_easingEquation = 'easeOutQuad'
		}
		else
		{
			_easingEquation = 'swing'
		}
    
        //The reference object containing all of the breadcrumb elements
        _breadCrumbElements = jQuery(_container).find('li');
        
        //Keep it from overflowing in ie6 & 7
        jQuery(_container).find('ul').wrap('<div style="overflow:hidden; position:relative;  width: ' + jQuery(_container).css("width") + ';"><div>');
        //Set an arbitrary width width to avoid float drop on the animation
        jQuery(_container).find('ul').width(5000);
        
        //If the breadcrumb contains nothing, don't do anything
        if (_breadCrumbElements.length > 0) 
        {
            jQuery(_breadCrumbElements[_breadCrumbElements.length - 1]).addClass('last');
            jQuery(_breadCrumbElements[0]).addClass('first');
            
            //If the breadcrumb object length is long enough, compress.
            
            if (_breadCrumbElements.length > _options.minimumCompressionElements) 
            {
                compressBreadCrumb();
            };
                    };
            };
    
    function compressBreadCrumb()
    {
    
        // Factor to determine if we should compress the element at all
        var finalElement = jQuery(_breadCrumbElements[_breadCrumbElements.length - 1]);
        
        
        // If the final element is really long, compress more elements
        if (jQuery(finalElement).width() > _options.maxFinalElementLength) 
        {
            if (_options.beginingElementsToLeaveOpen > 0) 
            {
                _options.beginingElementsToLeaveOpen--;
                
            }
            if (_options.endElementsToLeaveOpen > 0) 
            {
                _options.endElementsToLeaveOpen--;
            }
        }
        // If the final element is within the short and long range, compress to the default end elements and 1 less beginning elements
        if (jQuery(finalElement).width() < _options.maxFinalElementLength && jQuery(finalElement).width() > _options.minFinalElementLength) 
        {
            if (_options.beginingElementsToLeaveOpen > 0) 
            {
                _options.beginingElementsToLeaveOpen--;
                
            }
        }
        
        var itemsToRemove = _breadCrumbElements.length - 1 - _options.endElementsToLeaveOpen;
        
        // We compress only elements determined by the formula setting below
        
        //TODO : Make this smarter, it's only checking the final elements length.  It could also check the amount of elements.
        jQuery(_breadCrumbElements[_breadCrumbElements.length - 1]).css(
        {
            background: 'none'
        });
        
        $(_breadCrumbElements).each(function(i, listElement)
        {
            if (i > _options.beginingElementsToLeaveOpen && i < itemsToRemove) 
            {
            
                jQuery(listElement).find('a').wrap('<span></span>').width(jQuery(listElement).find('a').width() + 10);
                
                // Add the overlay png.
                jQuery(listElement).append(jQuery('<div class="' + _options.overlayClass + '"></div>').css(
                {
                    display: 'block'
                })).css(
                {
                    background: 'none'
                });
                if (isIE6OrLess()) 
                {
                    fixPNG(jQuery(listElement).find('.' + _options.overlayClass).css(
                    {
                        width: '20px',
                        right: "-1px"
                    }));
                }
                var options = 
                {
                    id: i,
                    width: jQuery(listElement).width(),
                    listElement: jQuery(listElement).find('span'),
                    isAnimating: false,
                    element: jQuery(listElement).find('span')
                
                };
                jQuery(listElement).bind('mouseover', options, expandBreadCrumb).bind('mouseout', options, shrinkBreadCrumb);
                jQuery(listElement).find('a').unbind('mouseover', expandBreadCrumb).unbind('mouseout', shrinkBreadCrumb);
                listElement.autoInterval = setInterval(function()
                {
                    clearInterval(listElement.autoInterval);
                    jQuery(listElement).find('span').animate(
                    {
                        width: _options.previewWidth
                    }, _options.timeInitialCollapse, _options.easing);
                }, (150 * (i - 2)));
                
            }
        });
        
    };
    
    function expandBreadCrumb(e)
    {
        var elementID = e.data.id;
        var originalWidth = e.data.width;
        jQuery(e.data.element).stop();
        jQuery(e.data.element).animate(
        {
            width: originalWidth
        }, 
        {
            duration: _options.timeExpansionAnimation,
            easing: _options.easing,
            queue: false
        });
        return false;
        
    };
    
    function shrinkBreadCrumb(e)
    {
        var elementID = e.data.id;
        jQuery(e.data.element).stop();
        jQuery(e.data.element).animate(
        {
            width: _options.previewWidth
        }, 
        {
            duration: _options.timeCompressionAnimation,
            easing: _options.easing,
            queue: false
        });
        return false;
    };
    
    function isIE6OrLess()
    {
        var isIE6 = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent);
        return isIE6;
    };
    // Fix The Overlay for IE6
    function fixPNG(element)
    {
        var image;
        if (jQuery(element).is('img')) 
        {
            image = jQuery(element).attr('src');
        }
        else 
        {
            image = $(element).css('backgroundImage');
            image.match(/^url\(["']?(.*\.png)["']?\)$/i);
            image = RegExp.$1;
            ;
        }
        $(element).css(
        {
            'backgroundImage': 'none',
            'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='" + image + "')"
        });
    };
    
    // Public global variables
    
    jQuery.fn.jBreadCrumb.defaults = 
    {
        maxFinalElementLength: 100,
        minFinalElementLength: 100,
        minimumCompressionElements: 1,
        endElementsToLeaveOpen: 1,
        beginingElementsToLeaveOpen: 2,
        timeExpansionAnimation: 300,
        timeCompressionAnimation: 500,
        timeInitialCollapse: 300,
        //easing: _easingEquation,
        overlayClass: 'chevronOverlay',
        previewWidth: 25
    };
    
})(jQuery);
// conditional search phrase
function searchPhrase() {
	jQ('#searchContainer input[type="radio"]').change( function() {
		var value=jQ(this).val();
		var past = 'Search over <span class="highlight">62 million auction price results</span>';
		var upcoming = 'Search from over <span class="highlight">100,000 items available at auction</span> now';
		if (value=='p') {
			jQ('#searchContainer h2').html(past);
		} else if (value=='u') {
			jQ('#searchContainer h2').html(upcoming);
		} 		
	});
}
//  zebra stripes on any UL with a class of zebra
function zebrastripes() {
	jQ('ul.zebra li:nth-child(even)').addClass('odd');
}
/*///  This is a custon show/hide function for the Collections pages, it isn't meant to be a site wide script */
function collaspeContent() {
	jQ('.showmore-btn').live('click',function() {
			var container=jQ(this).next('.collapse ')			
			if (jQ(container).hasClass('closed')) {
				jQ(container).removeClass('closed');
				jQ(this).addClass('open').html('view less');
			} else {
				jQ(container).addClass('closed');
				jQ(this).removeClass('open').html('view more');
			};
	});
}
/* must have listSplitter.js on page for this to work */
function listSplit(columns) {
jQ('.two-cols, .three-cols, .four-cols').easyListSplitter({ 
		colNumber:columns,
		direction: 'vertical'
	});
}

function showLogin() {
	var loginPanel = jQ('#loginPanel')
	var loginBtn = jQ('#panel_button  a')
	jQ(loginBtn).live('click', function() {		
		if (jQ(this).hasClass('login')) {			
			jQ(loginPanel).slideDown('slow', function() {
				jQ('#mbrUName').focus();
			});
			jQ(this).removeClass('login').addClass('loginOpen');
		}	else {
			jQ(loginPanel).slideUp('slow');
			jQ(this).addClass('login').removeClass('loginOpen');
		}	
	});
	jQ('.closer').live('click', function() {
		jQ(loginPanel).slideUp('slow');
		jQ(loginBtn).addClass('login').removeClass('loginOpen');
	});
}

/*  reuseable show/hide code */
function showHide() {
	jQ('.expander').live('click', function() {
			var content = jQ(this).next('.expander-content')
			if (jQ(this).hasClass('open')) {
				jQ(content).slideUp('fast');
				jQ(this).removeClass('open').html('view more');			
			} else {
				jQ(this).addClass('open').html('view less');
				jQ(content).slideDown('fast');
			}
	});
}
function helpInit() {
	var	helpWrapper = jQ(".helpWrapper"),
		myHost = location.hostname,
		host="";
		isArtfact = myHost.indexOf("artfact.com");
		isInvaluable = myHost.indexOf("invaluable.com");
		
		if(isArtfact > -1){
			host="artfact";
		} else if(isInvaluable > -1){
			host="invaluable";
		}
		helpWrapper.addClass(host);	
}
function updateNotify(notification,memberRef,lotRef){
	var method = "updateWatchedLotNotification";
		
	doWatchLot = jQ.getJSON(
		'/lib/jQueryObj/jFineArtObj.cfc?wsdl',
			{ 
			   method : method,
			   lotRef : lotRef,
			   memberRef : memberRef,
			   notification : notification
			},
		function()
		   {
				return;
		   }
	);						
	return false;
}
function setAlert() {
	var theStatus = jQ(this).parent().siblings().find("a"),
	theStatusText = '',
	theText = jQ(this).text(),
	notification,
	memberRef=jQ(this).parent("li").parent("ul#emailAlerts").attr("memberref"),
	lotRef=jQ(this).parent("li").parent("ul#emailAlerts").attr("lotref");
	
	switch (theText)
	{
		case "Do not send email":
			theText = "You are NOT set to receive email Alerts";
			theStatusText = "Send alerts via email";
			notification = 0;
			break;
		case "Send alerts via email":
			theText = "You are set to receive email Alerts";
			theStatusText = "Do not send email";
			notification = 1;
			break;
		default:
			return;
	}
	jQ(this)
		.text(theStatusText)
		.parent()
		.siblings()
		.find("a")
		.text(theText);
	
		updateNotify(notification,memberRef,lotRef);
}
function updateAlert() {

	var method = "updateWatchedLotNotification",
		memberRef = jQ("#updateAlert").attr("memberref"),
		lotRef = jQ("#updateAlert").attr("lotref"),
		notification = 1;
		
	doWatchLot = jQ.getJSON(
		'/lib/jQueryObj/jFineArtObj.cfc?wsdl',
			{ 
			   method : method,
			   lotRef : lotRef,
			   memberRef : memberRef,
			   notification : notification
			},
		function()
		   {	
				jQ("#updateAlert").prev("span").hide();
				jQ("#updateAlert").html("Alert added to your <a href='/myLive/myWatchedLots.cfm'>watched lots</a>");
		   }
	);

}

jQ(document).ready(function() {
	jQ(".footerBox").equalHeights();
	jQ("#breadCrumb").jBreadCrumb();
	jQ("#emailAlerts > li > a").live("click",setAlert);
	//Opera Fix
	jQ("#updateAlert > a").live("click", function() {if(jQ(this).parent().attr("id")=="updateAlert") {updateAlert();}});
	zebrastripes();
	searchPhrase() ;
	showLogin();
	helpInit();
 });
