jQuery.fn.prettyCheckboxes=function(settings){settings=jQuery.extend({checkboxWidth:17,checkboxHeight:17,className:'prettyCheckbox',display:'list'},settings);$(this).each(function(){$label=$('label[for='+$(this).attr('id')+']');$label.prepend("<span class='holderWrap'><span class='holder'></span></span>");if($(this).is(':checked')){$label.addClass('checked');};$label.addClass(settings.className).addClass($(this).attr('type')).addClass(settings.display);$label.find('span.holderWrap').width(settings.checkboxWidth).height(settings.checkboxHeight);$label.find('span.holder').width(settings.checkboxWidth);$(this).addClass('hiddenCheckbox');$label.bind('click',function(){$('input#'+$(this).attr('for')).triggerHandler('click');if($('input#'+$(this).attr('for')).is(':checkbox')){$(this).toggleClass('checked');$('input#'+$(this).attr('for')).checked=true;}else{$toCheck=$('input#'+$(this).attr('for'));$('input[name='+$toCheck.attr('name')+']').each(function(){$('label[for='+$(this).attr('id')+']').removeClass('checked');});$(this).addClass('checked');$toCheck.checked=true;};});$('input#'+$label.attr('for')).bind('keypress',function(e){if(e.keyCode==32){if($.browser.msie){$('label[for='+$(this).attr('id')+']').toggleClass("checked");}else{$(this).trigger('click');}
return false;};});});};checkAllPrettyCheckboxes=function(caller,container){if($(caller).is(':checked')){$(container).find('input[type=checkbox]:not(:checked)').each(function(){$('label[for='+$(this).attr('id')+']').trigger('click');if($.browser.msie){$(this).attr('checked','checked');}else{$(this).trigger('click');};});}else{$(container).find('input[type=checkbox]:checked').each(function(){$('label[for='+$(this).attr('id')+']').trigger('click');if($.browser.msie){$(this).attr('checked','');}else{$(this).trigger('click');};});};};var imageRoot='/bocajava/images/2008/defaultclub/coffee/';function createErrorDialog(el,msg)
{$("#errordialog").remove();var off=$(el).offset();var errHTML='<div id="errordialog"><div class="left">'+msg+'</div><a class="right" href="#">x</a></div>';$("body").append(errHTML);var elheight=$("#errordialog").height();var thetop=off.top-elheight;$("#errordialog").css({top:thetop+"px",left:off.left+"px",display:'none'});$("#errordialog").fadeIn('slow');$("#errordialog a").click(function(){$("#errordialog").fadeOut('slow',function(){$(this).remove();});return false;});}
function run_buildyourown()
{ieVer=vIE();$("#btn_account_submit").click(function(){if(selectCount==4)return true;else
{var more=4-selectCount;var html='You have currently selected '+selectCount+' coffees.  Please select '+more+' more.<br /><br /><a href="#" class="over_choose_close">close this message</a>';$("#over_choose .onsiteclub_errortext").html(html);if(ieVer>=6){$("#over_choose .onsiteclub_errorback").css('display','none');}
$("#over_choose").css('top','0px').animate({"opacity":"1"});var window_top=$(window).scrollTop();var new_top=window_top-200;$(window).scrollTop(new_top);return false;}});$('input[type=checkbox]').each(function(){if($(this).is(':checked'))$(this).attr('checked','');});$('input[type=checkbox],input[type=radio]').prettyCheckboxes({display:'list'});$(".onsiteclub_error,.over_choose_close").click(function(){$(".onsiteclub_error:visible").animate({"opacity":"0"},function(){$(this).css('top','-500px');});return false;});$(".select_copy").click(function(){var parentID=$(this).parent().attr('id');if($("#"+parentID+" .selection .col100").html()!=null)
{var parentID_split=parentID.split('_');num=parseInt(parentID_split[1]);var newnum=0;for(i=1;i<=4;i++)
{if(i!=num)
{if($("#select_"+i+" .selection .col100").html()==null)
{newnum=i;break;}}}
if(newnum>0)
{var selectionInfo=$("#"+parentID+" .selection").html();eval('selectionInfo = selectionInfo.replace(/Selection'+num+'/g,"Selection'+newnum+'")');$("#select_"+newnum+" .selection").html(selectionInfo);$("#select_"+newnum+" .selection .col100").fadeIn('slow');selectCount++;$("#select_"+newnum+" .select_status").addClass('active');}
else
{createErrorDialog(this,'You have no selections available.');}}
else
{createErrorDialog(this,'There is no selection to copy');}
return false;});$(".select_status").click(function(){var cl=$(this).attr('class');if(cl.match(/active/)!=null)
{var newcl=cl.replace(/active/,'');$(this).attr('class',newcl);var parentID=$(this).parent().attr('id');var parentID_split=parentID.split('_');num=parseInt(parentID_split[1]);var coffee=$("#"+parentID+" h4").text();coffee=coffee.replace(/\s/g,'');var lowercasecoffee=coffee.toLowerCase();$("#"+parentID+" .selection .col100").fadeOut('slow',function(){$(this).remove();});var exists=false;for(i=1;i<=4;i++)
{if(i!=num)
{var duplicate=$("#select_"+i+" h4").text();duplicate=duplicate.replace(/\s/g,'');if(duplicate==coffee)exists=true;break;}}
$("#onsiteclub_choose label").each(function(){var txt=$(this).text();txt=txt.replace(/\s/g,'');if(txt==lowercasecoffee)
{if(!exists)
{var label=this;var tclass=$(label).attr('class');var nclass=tclass.replace(/checked/,'');$(label).prev().attr('checked','');$(label).attr('class',nclass);}
selectCount--;}});}
return false;});var selectCount=0;$("#onsiteclub_choose label").mouseover(function(){var n=$(this).text().capitalize();var pic=imageRoot+n.replace(/\s/g,'');var picHTML='<img src="'+pic+'.jpg" />';$("#tooltip .tt_img").html(picHTML);$("#tooltip .tt_body").html(n);});$("#onsiteclub_choose label").click(function(){var label=this;var tclass=$(label).attr('class');var nclass=tclass.replace(/checked/,'');var n=$(this).text().capitalize();var pic=imageRoot+n.replace(/\s/g,'');var sku=$(this).prev().val();var hasDecaf=$(this).prev().attr('title');var roast=$(this).parent().parent().prev().attr('class');var r_s=roast.split(' ');roast=r_s[0];if(tclass.match(/checked/))
{selectCount++;if(selectCount>4)
{var html='You may only select 4 coffees.  If you would like to change your selections, please de-select a coffee before adding another.<br /><br /><a href="#" class="over_choose_close">close this message</a>';$("#over_choose .onsiteclub_errortext").html(html);if(ieVer>6){$("#over_choose .onsiteclub_errorback").css('display','none');}
$("#over_choose").css('top','0px').animate({"opacity":"1"});$(label).prev().attr('checked','');$(label).attr('class',nclass);selectCount--;}
else
{for(i=1;i<=4;i++)
{if($("#select_"+i+" .selection .col100").html()==null)
{var html='<div class="col100" style="overflow:hidden"><input type="hidden" name="CoffeeSelection'+i+'" value="'+sku+'" /><h4 class="'+roast+'">'+n+'</h4><div class="left" style="width:103px;"><img src="'+pic+'.jpg" width="100" height="100" /></div><div class="radios left"><input type="radio" name="CoffeeSelection'+i+'Grind" value="Universal" checked> Ground<br /><input type="radio" name="CoffeeSelection'+i+'Grind" value="WholeBean"> Whole Bean<br /><hr />'
if(hasDecaf=='nodecaf')
{html=html+'<input type="hidden" name="CoffeeSelection'+i+'Caffeine" value="regular"> Decaffeinated not available for this coffee.<br /></div></div>';}
else
{html=html+'<input type="radio" name="CoffeeSelection'+i+'Caffeine" value="regular" checked> Regular<br /><input type="radio" name="CoffeeSelection'+i+'Caffeine" value="decaf"> Decaf<br /></div></div>';}
$("#select_"+i+" .selection").append(html);$("#select_"+i+" .selection .col100").fadeIn('slow');$("#select_"+i+" .select_status").addClass('active');break;}}}}
else
{$(".selection h4").each(function(){if($(this).text()==n)
{$(this).parent().fadeOut('slow',function(){$(this).remove();});selectCount--;}});}
return false;});}
function make_selection(id)
{var cl=$('.select_status').attr('class');if(cl.match(/active/)==null)$('.select_status').addClass('active');id='group'+id;$(".selection .col100:visible").each(function(){$(this).fadeOut('slow',function(){$(this).remove();});});for(i=0;i<picks[id].length;i++)
{var n=i+1;var pic=imageRoot+picks[id][i].n.replace(/\s/g,'');var html='<div class="col100" style="overflow:hidden"><input type="hidden" name="CoffeeSelection'+n+'" value="'+picks[id][i].sku+'" /><h4 class="roast_'+picks[id][i].roast+'">'+picks[id][i].n+'</h4><div class="left" style="width:103px;"><img src="'+pic+'.jpg" width="100" height="100" /></div><div class="radios left"><input type="radio" name="CoffeeSelection'+n+'Grind" value="Universal" checked> Ground<br /><input type="radio" name="CoffeeSelection'+n+'Grind" value="WholeBean"> Whole Bean<br /><hr />';if(picks[id][i].decaf!=false)var html=html+'<input type="radio" name="CoffeeSelection'+n+'Caffeine" value="regular" checked> Regular<br /><input type="radio" name="CoffeeSelection'+n+'Caffeine" value="decaf"> Decaf<br />';else var html=html+'<input type="hidden" name="CoffeeSelection'+n+'Caffeine" value="regular">Decaffeinated not available for this coffee.<br />';html=html+'</div></div>';$("#select_"+n+" .selection").append(html);$("#select_"+n+" .selection .col100").fadeIn('slow');}
if(id=='group1')
{$("#over_2").css('top','0px').animate({"opacity":".5"});$("#over_1:visible").animate({"opacity":"0"},function(){$(this).css('top','-500px');});}
else
{$("#over_1").css('top','0px').animate({"opacity":".5"});$("#over_2:visible").animate({"opacity":"0"},function(){$(this).css('top','-500px');});}}
var picks={group1:[{n:'Ocean Drive',sku:'COF-HB-OD-02-8oz',roast:'2'},{n:'Boca Sunrise',sku:'COF-HB-BS-02-8oz',roast:'3'},{n:'Palm Beach Passion',sku:'COF-HB-PB-02-8oz',roast:'4'},{n:'Boca Mocha Java',sku:'COF-SB-MJ-02',roast:'3'}],group2:[{n:'Panamanian Rainforest',sku:'COF-SB-RP-8oz',roast:'3',decaf:false},{n:'Pure Peruvian Organic',sku:'COF-OB-PP-8oz',roast:'3',decaf:false},{n:'Guatemalan Adventure',sku:'COF-SB-GA-02',roast:'3'},{n:'Coastal Costa Rica',sku:'COF-SB-CR-02-8oz',roast:'4'}]}
function run_roastmasterspicks()
{$('.btn_choose').click(function(){var id=$(this).attr('id');var id_split=id.split('_');make_selection(id_split[1]);return false;});$('.over').click(function(){var id=$(this).attr('id');var id_split=id.split('_');make_selection(id_split[1]);return false;});$('.tip_s').mouseover(function(){var n=$(this).text().capitalize();var pic=imageRoot+n.replace(/\s/g,'');var picHTML='<img src="'+pic+'.jpg" />';$("#tooltip .tt_img").html(picHTML);$("#tooltip .tt_body").html(n);});$('.select_status').click(function(){var cl=$(this).attr('class');if(cl.match(/active/)!=null)
{var newcl=cl.replace(/active/,'');$(this).attr('class',newcl);$(".selection .col100:visible").each(function(){$(this).fadeOut('slow',function(){$(this).remove();});});$(".over:visible").animate({"opacity":"0"},function(){$(this).css('top','-500px');});}
return false;});}