Event.addBehavior({'body form#form_checkout_1 input#zip:blur':function()
{estore.getUPS('form_checkout_1');},'body form#form_checkout_1 select#shipping_ups_method:change':function()
{$('shipping_method').checked=true;},'body form#form_checkout_1 select#country:change':function()
{estore.getUPS('form_checkout_1');},'body form#form_checkout_1 select#state:change':function()
{estore.getUPS('form_checkout_1');},'body form#form_checkout_1 input#city:blur':function()
{estore.getUPS('form_checkout_1');},'body form#form_checkout_1 input#state_outside:blur':function()
{estore.getUPS('form_checkout_1');},'input#username:blur':function()
{estore.checkUsername();},'input#username:change':function()
{estore.checkUsername();},'input#username:keydown':function()
{estore.checkUsername();},'body form#form_checkout_1 select#address_id:change':function()
{var timer=1000;if(estore.getAddressBookEntry('form_checkout_1')!=''){setTimeout(function(){estore.getUPS('form_checkout_1')},timer);}},'body form#form_checkout_1 input#saved:click':function()
{if($('saved').checked==true){$('labelInp').show();$('label').focus();}else{$('label').value='';$('labelInp').hide();}},'body form#form_checkout_2 select#address_id:change':function()
{estore.getAddressBookEntry('form_checkout_2');},'body form#form_checkout_2 input#sameAsShipping:click':function()
{if($('sameAsShipping').checked){$('labelInp').hide();$('saved').value=0;$('saved').checked=false;$('saveInp').hide();estore.sameAsShipping();$('label').value='';}else{$('labelInp').show();$('saveInp').show();}},'body form#form_checkout_2 input#saved:click':function()
{if($('saved').checked==true){$('labelInp').show();$('label').focus();}else{$('label').value='';$('labelInp').hide();}},'body form#form_checkout_2 input#paypal_ec:click':function()
{if($('paypal_ec').checked==true){$('checkoutBillingInfo').hide();}else{$('checkoutBillingInfo').show();}},'body form#form_checkout_2 input#yourpay:click':function()
{if($('yourpay').checked==true){$('checkoutBillingInfo').show();}},'body form#form_checkout_4 input#finish_pay:click':function()
{if($('agree').checked==false){alert('You must read and agree to our Terms and Conditions');return false;}
$('finish_pay').disabled=true;$('finish_pay').value='Processing, please wait...';$('form_checkout_4').submit();},'body form#form_cart input#calc:click':function()
{if($('zip').value==''){return false;}
estore.getUPS('form_cart');},thumbTimer:null,thumbObserver:false,'div.img img:mouseover':function(){if(estore.thumbObserver){var id=this.getAttribute('id').substr(7);Event.observe(document,'mouseover',function(event){var x,y;x=event.clientX;y=event.clientY;x+=Geo.getScrollX()+15;y+=Geo.getScrollY()+25;estore.thumbTimer=setTimeout(function(){estore.thumbExpand(id,x,y)},500);});}},'div.img img:mouseout':function(){if(estore.thumbObserver){estore.thumbRemove();}},'a#optin:mouseup':function(){estore.newsletter('in');},'a#btnUnsubscribe:mouseup':function(){if(window.confirm('Are you sure you want to stop receiving updates from us?')){estore.newsletter('out');}}});estore={validateSearchForm:function(){if($('k').value!=''&&$('k').value!='Search Products and Sellers'){$('form_search').submit()}else{return false;}},checkUsername:function(){new Ajax.Updater('userLoader','/ajax',{parameters:{action:'checkUsername',username:$('username').value}});},getUPS:function(form){$('ratesUPS').show();$('ratesUPS').update('<img src="/images/loading.gif" border="0">');new Ajax.Updater('ratesUPS','/index.php?action=estore.ajax&func=ups.rates&'+$(form).serialize(),{asynchronous:true});},updateCartTotal:function(){$('cartTotal').update('<img src="/images/loading.gif" border="0">');new Ajax.Updater('cartTotal','/index.php?action=estore.ajax&func=cart_total&'+$('form_cart').serialize(),{asynchronous:true});},getAddressBookEntry:function(form){if($('address_id').value=='0'){return false;}
if($('address_id').value=='new'){var elName;for(i=0;i<$(form).elements.length;i++){elName=$(form).elements[i];if($(elName).type=='text'||$(elName).name=='country'||$(elName).name=='state'){$(elName).value='';}}
return'new';}
new Ajax.Request('/index.php?action=estore.ajax&func=address_book&address_id='+$('address_id').value,{method:'post',onSuccess:function(t){var keys=new Array();var vals=new Array();var text=t.responseText||'Error';var rawString=text.substr(text.indexOf('{')+1);var rawString2=rawString.substr(0,rawString.length-2);var values=rawString2.split(';');var tC,n=0,k,v;for(i=0;i<values.length;i++){if(n%2===0){tC=values[n].split(':');keys[i]=tC[2];n++;tC=values[n].split(':');vals[i]=tC[2];try{k=$(keys[i].substr(1,keys[i].length-2));v=vals[i].substr(1,vals[i].length-2);if(k)k.value=v;}catch(e){}}else{n++;}}},onFailure:function(){alert('Connection Error');}});},sameAsShipping:function(){var keys=new Array();var vals=new Array();var rawString=$('shippingInfo').value.substr($('shippingInfo').value.indexOf('{')+1);var rawString2=rawString.substr(0,rawString.length-2);var values=rawString2.split(';');var tC,n=0,k,v;for(i=0;i<values.length;i++){if(n%2===0){tC=values[n].split(':');keys[i]=tC[2];n++;tC=values[n].split(':');vals[i]=tC[2];try{k=$(keys[i].substr(1,keys[i].length-2));v=vals[i].substr(1,vals[i].length-2);k.value=v;}catch(e){alert(e.description);}}else{n++;}}},thumbMinWidth:200,thumbMinHeight:200,thumbExpand:function(product,ix,iy){var newDiv=document.createElement('div');newDiv.setAttribute('id','thumbEx');document.body.appendChild(newDiv);$('thumbEx').addClassName('thumbExpander');$('thumbEx').show();estore.thumbMove(ix,iy);Event.observe(document,'mousemove',function(event){if(Event.element(event).tagName!='IMG'){estore.thumbRemove();return false;}
x=event.clientX;y=event.clientY;x+=(Geo.getScrollX()+15);y+=(Geo.getScrollY()+25);estore.thumbMove(x,y);});Ajax.Responders.register({onCreate:function(){$('thumbEx').update('Loading...')}});new Ajax.Updater('thumbEx','/index.php?action=estore.ajax&func=thumbs_expander&product_id='+product);},thumbMove:function(x,y){var theH=$('thumbEx').getHeight()<=100?estore.thumbMinHeight:$('thumbEx').getHeight();var theW=$('thumbEx').getWidth()<=100?estore.thumbMinWidth:$('thumbEx').getWidth();if(window.event){if(Geo.getViewportHeight()+Geo.getScrollY()-y<(theH+25)){y+=y-((25+theH)+y);}}else{if(Math.min(Geo.getViewportHeight(),Geo.getDocHeight())+Geo.getScrollY()-y<theH+25){y+=y-Math.max(0,(25+theH+y));}}
if(Geo.getDocWidth()-x<theW+15){x=x-theW-25;}
$('thumbEx').setStyle({top:y+'px',left:x+'px'});},thumbRemove:function(){Event.stopObserving(document,'mousemove');Event.stopObserving(document,'mouseover');if($('thumbEx')){$('thumbEx').update('');$('thumbEx').hide();document.body.removeChild($('thumbEx'));clearTimeout(estore.thumbTimer);}},setSortingMethod:function(v){var urlSet=document.URL;var newUrl;var curPage;var restURL='';if(urlSet.indexOf('?')!=-1){newUrl=urlSet.substr(0,urlSet.indexOf('?'));var query=document.location.search.substr(1);var args='?';var pairs=query.split('&');if(pairs.length>0){for(var i=0;i<pairs.length;i++){var pos=pairs[i].indexOf('=');if(pos==-1)continue;var key=pairs[i].substr(0,pos);var value=pairs[i].substr(pos+1);value=decodeURIComponent(value);if(key!='sort'){if(i==0){args+=''+key+'='+value;}else{args+='&'+key+'='+value;}}}
args+='&sort='+v;document.location.href=newUrl+args;}else{document.location.href=newUrl+'?sort='+v;}}else{newUrl=urlSet;document.location.href=newUrl+'?sort='+v;}
return true;},newsletter:function(opt){Ajax.Responders.register({onCreate:function(){var loader=document.createElement('div');loader.setAttribute('id','newsletterLoader');document.body.appendChild(loader);loader.show();loader.update('<img src="/images/loading.gif" border="0" title="loading" alt="loading"');loader.setStyle({position:'absolute',top:'600px',left:'200px',zIndex:'102'});}});new Ajax.Request('/index.php?action=estore.ajax&func=newsletter&opt='+opt+'&email='+$('email_newsletter').value,{method:'post',onSuccess:function(t){alert(t.responseText);$('email_newsletter').value='';}});},addressBookLoadEntry:function(e){$('ab-'+e).update('<img src="/images/loading.gif" border="0">');new Ajax.Updater({success:'ab-'+e},'/estore/ajax',{parameters:{action:'estore.ajax',func:'address_book_entry',address_id:e}},{evalScripts:true},{evalJS:true});},addressBookSaveEntry:function(e){$('btn-'+e).update('<img src="/images/loading.gif" border="0">');new Ajax.Updater({success:'btn-'+e},'/estore/ajax',{parameters:$('form_ab-'+e).serialize(true),onComplete:function(){jQuery('div#ab-'+e).hide('slow');estore.addressBookUpdateEntry(e);}},{evalScripts:true},{evalJS:true});},addressBookUpdateEntry:function(e){$('abEntry-'+e).update('<td colspan="5"><img src="/images/loading.gif" border="0"></td>');new Ajax.Updater({success:'abEntry-'+e},'/estore/ajax',{parameters:{action:'estore.ajax',func:'address_book_update_row',address_id:e}},{evalScripts:true},{evalJS:true});},addressBookDeleteEntry:function(e){$('abEntry-'+e).update('<td colspan="5"><img src="/images/loading.gif" border="0"></td>');new Ajax.Updater({success:'abEntry-'+e},'/estore/ajax',{parameters:{action:'estore.ajax',func:'address_book_delete_entry',address_id:e},onComplete:function(){$('abEntry-'+e).remove();jQuery('div#ab-'+e).hide('slow');$('ab-'+e).remove();}},{evalScripts:true},{evalJS:true});},messagesSend:function(to,bin){var s=$('subject').value;var m=$('message').value;if(bin){var name=$('from_name').value;var email=$('from_email').value;var code=$('code').value;}
if($('listing')){var listing=$('listing').value;}
$('btnSend').disabled=true;$j.ajax({type:"POST",url:"/ajax",data:"action=messagesSend&to="+to+"&subject="+s+"&message="+m+"&from_email="+email+"&from_name="+name+"&code="+code+"&listing="+listing,success:function(r){if(r==1){$j('#messageBox').html('Your message has been sent');}else{alert(r);$('btnSend').disabled=false;if(bin){$('codeHolder').update('<img src="/code.php" border="0" />');}
return false;}}});},catsTime:null,showCats:function(){clearTimeout(estore.catsTime);estore.catsTime=setTimeout(function(){$j('#supercategories').show()},450);},hideCats:function(){clearTimeout(estore.catsTime);estore.catsTime=setTimeout(function(){$j('#supercategories').hide()},100);},swapImage:function(img){$j('.thumbAsMain').hide();$j('#thumbAsMainHolder-'+img).show();},productLikes:function(product){$j.ajax({type:"POST",url:"/ajax",data:"action=estore.ajax&func=products.likes&product="+product,success:function(r){if(r==1){$j('#productLikes-'+product).fadeOut('fast');$j('#productLikes-'+product).html('Thank You!');$j('#productLikes-'+product).fadeIn('slow');}else{alert(r);return false;}}});},submitReview:function(){if($('rate').value==0){alert('Please select a rate for this item');return false;}
$('btnSubmitReview').disabled=true;$j.ajax({type:"POST",url:"/ajax",data:"action=estore.ajax&func=products.review&"+$('form_review').serialize(),success:function(r){if(r==1){$j('#reviewForm').html('<div class="notice nbabyblue">Thank you!, your review has been submitted successfully</div>');return true;}else{alert(r);$('btnSubmitReview').disabled=false;return false;}}});},sendToFriend:function(i){$j.ajax({type:"POST",url:"/ajax",data:"action=sendToFriend&listing_id="+i+"&from_name="+$('txt_from_name').value+"&to_name="+$('txt_to_name').value+"&to_email="+$('txt_to_email').value,success:function(r){if(r==1){$j('#sendFriendForm').html('<div class="notice nbabyblue">Thank you!, a message has been sent to your friend!</div>');return true;}else{alert(r);return false;}}});},submitComments:function(w){var theForm=$j(w.form);var o=$j(":hidden",w.form).get(0).value;if(o=='undefined')return false;$j('input.continue').attr('value','Saving, please wait...');$j('input.continue').attr('disabled',true);$j.ajax({type:"POST",url:"/ajax",data:"action=submitComments&"+theForm.serialize(),success:function(r){if(r!=0){$j('#commentsForm').hide('fast');theForm.get(0).reset();$j('input.continue').attr('value','Submit Comments');$j('input.continue').attr('disabled',false);var div=$j('div.comments div.entry:first');if(div.length==0){$j('#commentsEntries').html(r);return true;}
div.before(r);return true;}else{alert(r);$j('input.continue').attr('value','Submit Comments');$j('input.continue').attr('disabled',false);return false;}}});},addFavorite:function(type,id){$j.ajax({type:"POST",url:"/ajax",data:"action=addFavorite&type="+type+"&id="+id,success:function(r){if(r==1){$j('#favoriteHolder').fadeOut('fast');$j('#favoriteHolder').html('In your favorites!');$j('#favoriteHolder').fadeIn('slow');return true;}else{alert(r);return false;}}});},miniNavTime:null,miniNavShow:function() {clearTimeout(estore.miniNavTime);estore.miniNavTime = setTimeout(function() { $j('#nav-user-mini').show() },100);},miniNavHide:function() {clearTimeout(estore.miniNavTime);estore.miniNavTime = setTimeout(function() { $j('#nav-user-mini').hide() }, 100);}}
Geo={getScrollX:function(){var scLeft=document.documentElement.scrollLeft||document.body.scrollLeft||window.pageXOffset;return scLeft>0?scLeft:0;},getScrollY:function(){var scTop=document.documentElement.scrollTop||document.body.scrollTop||window.pageYOffset;return scTop>0?scTop:0;},getAvailHeight:function(){var ah=document.documentElement.clientHeight||window.innerHeight||document.body.clientHeight;return ah;},getAvailWidth:function(){var aw=document.documentElement.clientWidth||window.innerWidth||document.body.clientWidth;return aw;},getXPos:function(element){var x=0;for(var e=element;e;e=e.offsetParent){x+=e.offsetLeft;}
for(e=element.parentNode;e&&e!=document.body;e=e.parentNode){if(e.scrollLeft){x-=e.scrollLeft;}}
return x;},getYPos:function(element){var y=0;for(var e=element;e;e=e.offsetParent){y+=e.offsetTop;}
for(e=element.parentNode;e&&e!=document.body;e=e.parentNode){if(e.scrollTop){y-=e.scrollTop;}}
return y;},getViewportWidth:function(){if(window.innerWidth){return window.innerWidth}else if(document.documentElement&&document.documentElement.clientWidth){return document.documentElement.clientWidth;}else if(document.body.clientWidth){return document.body.clientWidth;}},getViewportHeight:function(){if(window.innerHeight){return window.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){return document.documentElement.clientHeight;}else if(document.body.clientHeight){return document.body.clientHeight;}},getDocWidth:function(){if(document.documentElement&&document.documentElement.scrollWidth){return document.documentElement.scrollWidth;}else if(document.body.scrollWidth){return document.body.scrollWidth;}},getDocHeight:function(){if(document.documentElement&&document.documentElement.scrollHeight){return document.documentElement.scrollHeight;}else if(document.body.scrollHeight){return document.body.scrollHeight;}}};