$(function(){var MIN_WIDTH=300,SCRIPT='/v2/dialog.php',L=0.9,M=0.6;function createLinkDialog(link){var j,i=$(link).attr('href');if((!i)||(!i.length)){return;}j=i.indexOf('#');if(j>=0){i=i.substr(j+1);}$.ajax({type:'GET',url:SCRIPT,data:{id:i},dataType:'json',success:function(r){if(!r.r){if(r.e&&r.e.length){alert(r.e);}return;}var d='<div class="CGDialogBody ui-helper-reset" style="text-align: left; font-size: 14px; font-family: \'Verdana\';">'+r.b+'</div>',w=MIN_WIDTH;d=$(d).appendTo($(document.body));if(r.w=='L'){w=parseInt(L*document.body.clientWidth,10);}else if(r.w=='M'){w=parseInt(M*document.body.clientWidth,10);}else if(typeof(r.w)==='number'){w=r.w;}d.dialog({width:w,minWidth:MIN_WIDTH,resizable:true,title:r.h,modal:true,position:'center',draggable:true,buttons:{"Close":function(){$(this).dialog('close');}},close:function(event,ui){$(this).empty().dialog('destroy');}});}});}function closeLinkDialog(link){$(link).parents('div.CGDialogBody').dialog('destroy').empty().parent().remove('div.CGDialogBody');}$('a.CGDialog').live('click',function(e){createLinkDialog(this);return false;});$('a.CGDialogReplace').live('click',function(e){closeLinkDialog(this);createLinkDialog(this);return false;});window.CGLibrary={getZone1:function(zip){var tdRes=$('#tdZoneResult');if(!tdRes){return false;}tdRes.empty();$.ajax({type:'GET',url:'/cgstore/ajaxZone.php',data:{'zip':zip},dataType:'json',success:function(response){if(!response.r){if(response.e&&response.e.length){alert(response.e);tdRes.append('<div style="color: #ff0000;">'+response.e+'<'+'/div>');}return false;}var s='';var st='';if(response.z!==null){s='Your cold hardiness zone is most likely <b>'+response.z+'<'+'/b>';}else{s='Cold hardiness zone for your zip '+zip+' can not be found';st=' style="color: #ff0000;" ';}tdRes.append('<div'+st+'>'+s+'<'+'/div>');return false;}});return false;},calc_plants:function(f){var area=f.area.value,space=f.space.value,plants=f.plants.value,filled=(area.length!==0)+(space.length!==0)+(plants.length!==0),result='',st;if(filled<2){alert("Two of the three fields must be filled in");return false;}else if(filled>2){alert("Only two of the fields should be filled in, please clear one of the fields.");return false;}function round1(x){var y=Math.round((x-Math.floor(x))*10);x=Math.floor(x);if(y==10){x++;y=0;}return x+'.'+y;}if(!plants.length){result=area*144/(space*space);result=Math.round(result);result="Number of plants is "+result;}else if(!area.length){result=(space*space)*plants/144;result=round1(result);result="Area covered is "+result+" square feet";}else if(!space.length){result=Math.sqrt(area*144/plants);result=round1(result);result="Spacing between plants is "+result+" inches";}var cell=document.getElementById("tdPResult");if(!cell){return false;}st=document.createTextNode(result);if(!st){return false;}while(cell.firstChild){cell.removeChild(cell.firstChild);}cell.appendChild(st);cell.style.display='block';return false;},deliveryByZip:function(z,out){var t=[[5,5,3],[10,69,3],[70,104,2],[105,108,3],[109,119,2],[120,149,3],[150,281,2],[282,282,1],[283,295,2],[296,296,1],[297,297,2],[298,314,1],[315,316,2],[317,319,1],[320,361,2],[362,362,1],[363,367,2],[368,368,1],[369,372,2],[373,374,1],[375,397,2],[398,399,1],[400,549,2],[550,599,3],[600,659,2],[660,679,2,3],[680,699,3],[700,729,2],[730,789,2,3],[790,791,3],[792,792,2],[793,794,3],[795,796,2],[797,847,3],[870,885,3]],N=t.length,z1=parseInt(z.substr(0,3),10),i,j;for(i=0;i<N;i++){j=t[i];if((j[0]<=z1)&&(z1<=j[1])){i='Number of weekdays in transit is '+j[2];if(j.length>3){i+='-'+j[3];}$(out).text(i);return false;}}i="Your zip code is unsupported. We only ship to the continental United States, and we do not ship to AZ, CA, NV, OR, or WA";$(out).text(i);return false;}};});
