(function(c){function p(e,b,a){var d=this,l=e.add(this),h=e.find(a.tabs),i=b.jquery?b:e.children(b),j;h.length||(h=e.children());i.length||(i=e.parent().find(b));i.length||(i=c(b));c.extend(this,{click:function(f,g){var k=h.eq(f);if(typeof f=="string"&&f.replace("#","")){k=h.filter("[href*="+f.replace("#","")+"]");f=Math.max(h.index(k),0)}if(a.rotate){var n=h.length-1;if(f<0)return d.click(n,g);if(f>n)return d.click(0,g)}if(!k.length){if(j>=0)return d;f=a.initialIndex;k=h.eq(f)}if(f===j)return d;g=g||c.Event();g.type="onBeforeClick";l.trigger(g,[f]);if(!g.isDefaultPrevented()){o[a.effect].call(d,f,function(){g.type="onClick";l.trigger(g,[f])});j=f;h.removeClass(a.current);k.addClass(a.current);return d}},getConf:function(){return a},getTabs:function(){return h},getPanes:function(){return i},getCurrentPane:function(){return i.eq(j)},getCurrentTab:function(){return h.eq(j)},getIndex:function(){return j},next:function(){return d.click(j+1)},prev:function(){return d.click(j-1)},destroy:function(){h.unbind(a.event).removeClass(a.current);i.find("a[href^=#]").unbind("click.T");return d}});c.each("onBeforeClick,onClick".split(","),function(f,g){c.isFunction(a[g])&&c(d).bind(g,a[g]);d[g]=function(k){c(d).bind(g,k);return d}});if(a.history&&c.fn.history){c.tools.history.init(h);a.event="history"}h.each(function(f){c(this).bind(a.event,function(g){d.click(f,g);return g.preventDefault()})});i.find("a[href^=#]").bind("click.T",function(f){d.click(c(this).attr("href"),f)});if(location.hash)d.click(location.hash);else if(a.initialIndex===0||a.initialIndex>0)d.click(a.initialIndex)}c.tools=c.tools||{version:"1.2.3"};c.tools.tabs={conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",rotate:false,history:false},addEffect:function(e,b){o[e]=b}};var o={"default":function(e,b){this.getPanes().hide().eq(e).show();b.call()},fade:function(e,b){var a=this.getConf(),d=a.fadeOutSpeed,l=this.getPanes();d?l.fadeOut(d):l.hide();l.eq(e).fadeIn(a.fadeInSpeed,b)},slide:function(e,b){this.getPanes().slideUp(200);this.getPanes().eq(e).slideDown(400,b)},ajax:function(e,b){this.getPanes().eq(0).load(this.getTabs().eq(e).attr("href"),b)}},m;c.tools.tabs.addEffect("horizontal",function(e,b){m||(m=this.getPanes().eq(0).width());this.getCurrentPane().animate({width:0},function(){c(this).hide()});this.getPanes().eq(e).animate({width:m},function(){c(this).show();b.call()})});c.fn.tabs=function(e,b){var a=this.data("tabs");if(a){a.destroy();this.removeData("tabs")}if(c.isFunction(b))b={onBeforeClick:b};b=c.extend({},c.tools.tabs.conf,b);this.each(function(){a=new p(c(this),e,b);c(this).data("tabs",a)});return b.api?a:this}})(jQuery);(function(f){function p(a,b,c){var h=c.relative?a.position().top:a.offset().top,e=c.relative?a.position().left:a.offset().left,i=c.position[0];h-=b.outerHeight()-c.offset[0];e+=a.outerWidth()+c.offset[1];var j=b.outerHeight()+a.outerHeight();if(i=="center")h+=j/2;if(i=="bottom")h+=j;i=c.position[1];a=b.outerWidth()+a.outerWidth();if(i=="center")e-=a/2;if(i=="left")e-=a;return{top:h,left:e}}function t(a,b){var c=this,h=a.add(c),e,i=0,j=0,m=a.attr("title"),q=n[b.effect],k,r=a.is(":input"),u=r&&a.is(":checkbox, :radio, select, :button, :submit"),s=a.attr("type"),l=b.events[s]||b.events[r?u?"widget":"input":"def"];if(!q)throw'Nonexistent effect "'+b.effect+'"';l=l.split(/,\s*/);if(l.length!=2)throw"Tooltip: bad events configuration for "+s;a.bind(l[0],function(d){clearTimeout(i);if(b.predelay)j=setTimeout(function(){c.show(d)},b.predelay);else c.show(d)}).bind(l[1],function(d){clearTimeout(j);if(b.delay)i=setTimeout(function(){c.hide(d)},b.delay);else c.hide(d)});if(m&&b.cancelDefault){a.removeAttr("title");a.data("title",m)}f.extend(c,{show:function(d){if(!e){if(m)e=f(b.layout).addClass(b.tipClass).appendTo(document.body).hide().append(m);else if(b.tip)e=f(b.tip).eq(0);else{e=a.next();e.length||(e=a.parent().next())}if(!e.length)throw"Cannot find tooltip for "+a;}if(c.isShown())return c;e.stop(true,true);var g=p(a,e,b);d=d||f.Event();d.type="onBeforeShow";h.trigger(d,[g]);if(d.isDefaultPrevented())return c;g=p(a,e,b);e.css({position:"absolute",top:g.top,left:g.left});k=true;q[0].call(c,function(){d.type="onShow";k="full";h.trigger(d)});g=b.events.tooltip.split(/,\s*/);e.bind(g[0],function(){clearTimeout(i);clearTimeout(j)});g[1]&&!a.is("input:not(:checkbox, :radio), textarea")&&e.bind(g[1],function(o){o.relatedTarget!=a[0]&&a.trigger(l[1].split(" ")[0])});return c},hide:function(d){if(!e||!c.isShown())return c;d=d||f.Event();d.type="onBeforeHide";h.trigger(d);if(!d.isDefaultPrevented()){k=false;n[b.effect][1].call(c,function(){d.type="onHide";k=false;h.trigger(d)});return c}},isShown:function(d){return d?k=="full":k},getConf:function(){return b},getTip:function(){return e},getTrigger:function(){return a}});f.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(d,g){f.isFunction(b[g])&&f(c).bind(g,b[g]);c[g]=function(o){f(c).bind(g,o);return c}})}f.tools=f.tools||{version:"1.2.3"};f.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,position:["top","center"],offset:[0,0],relative:false,cancelDefault:true,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,b,c){n[a]=[b,c]}};var n={toggle:[function(a){var b=this.getConf(),c=this.getTip();b=b.opacity;b<1&&c.css({opacity:b});c.show();a.call()},function(a){this.getTip().hide();a.call()}],fade:[function(a){var b=this.getConf();this.getTip().fadeTo(b.fadeInSpeed,b.opacity,a)},function(a){this.getTip().fadeOut(this.getConf().fadeOutSpeed,a)}]};f.fn.tooltip=function(a){var b=this.data("tooltip");if(b)return b;a=f.extend(true,{},f.tools.tooltip.conf,a);if(typeof a.position=="string")a.position=a.position.split(/,?\s/);this.each(function(){b=new t(f(this),a);f(this).data("tooltip",b)});return a.api?b:this}})(jQuery);(function(a){function t(d,b){var c=this,i=d.add(c),o=a(window),k,f,m,g=a.tools.expose&&(b.mask||b.expose),n=Math.random().toString().slice(10);if(g){if(typeof g=="string")g={color:g};g.closeOnClick=g.closeOnEsc=false}var p=b.target||d.attr("rel");f=p?a(p):d;if(!f.length)throw"Could not find Overlay: "+p;d&&d.index(f)==-1&&d.click(function(e){c.load(e);return e.preventDefault()});a.extend(c,{load:function(e){if(c.isOpened())return c;var h=q[b.effect];if(!h)throw'Overlay: cannot find effect : "'+b.effect+'"';b.oneInstance&&a.each(s,function(){this.close(e)});e=e||a.Event();e.type="onBeforeLoad";i.trigger(e);if(e.isDefaultPrevented())return c;m=true;g&&a(f).expose(g);var j=b.top,r=b.left,u=f.outerWidth({margin:true}),v=f.outerHeight({margin:true});if(typeof j=="string")j=j=="center"?Math.max((o.height()-v)/2,0):parseInt(j,10)/100*o.height();if(r=="center")r=Math.max((o.width()-u)/2,0);h[0].call(c,{top:j,left:r},function(){if(m){e.type="onLoad";i.trigger(e)}});g&&b.closeOnClick&&a.mask.getMask().one("click",c.close);b.closeOnClick&&a(document).bind("click."+n,function(l){a(l.target).parents(f).length||c.close(l)});b.closeOnEsc&&a(document).bind("keydown."+n,function(l){l.keyCode==27&&c.close(l)});return c},close:function(e){if(!c.isOpened())return c;e=e||a.Event();e.type="onBeforeClose";i.trigger(e);if(!e.isDefaultPrevented()){m=false;q[b.effect][1].call(c,function(){e.type="onClose";i.trigger(e)});a(document).unbind("click."+n).unbind("keydown."+n);g&&a.mask.close();return c}},getOverlay:function(){return f},getTrigger:function(){return d},getClosers:function(){return k},isOpened:function(){return m},getConf:function(){return b}});a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(e,h){a.isFunction(b[h])&&a(c).bind(h,b[h]);c[h]=function(j){a(c).bind(h,j);return c}});k=f.find(b.close||".close");if(!k.length&&!b.close){k=a('<a class="close"></a>');f.prepend(k)}k.click(function(e){c.close(e)});b.load&&c.load()}a.tools=a.tools||{version:"1.2.3"};a.tools.overlay={addEffect:function(d,b,c){q[d]=[b,c]},conf:{close:null,closeOnClick:true,closeOnEsc:true,closeSpeed:"fast",effect:"default",fixed:!a.browser.msie||a.browser.version>6,left:"center",load:false,mask:null,oneInstance:true,speed:"normal",target:null,top:"10%"}};var s=[],q={};a.tools.overlay.addEffect("default",function(d,b){var c=this.getConf(),i=a(window);if(!c.fixed){d.top+=i.scrollTop();d.left+=i.scrollLeft()}d.position=c.fixed?"fixed":"absolute";this.getOverlay().css(d).fadeIn(c.speed,b)},function(d){this.getOverlay().fadeOut(this.getConf().closeSpeed,d)});a.fn.overlay=function(d){var b=this.data("overlay");if(b)return b;if(a.isFunction(d))d={onBeforeLoad:d};d=a.extend(true,{},a.tools.overlay.conf,d);this.each(function(){b=new t(a(this),d);s.push(b);a(this).data("overlay",b)});return d.api?b:this}})(jQuery);(function(e){function n(f,c){var a=e(c);return a.length<2?a:f.parent().find(c)}function t(f,c){var a=this,l=f.add(a),g=f.children(),k=0,m=c.vertical;j||(j=a);if(g.length>1)g=e(c.items,f);e.extend(a,{getConf:function(){return c},getIndex:function(){return k},getSize:function(){return a.getItems().size()},getNaviButtons:function(){return o.add(p)},getRoot:function(){return f},getItemWrap:function(){return g},getItems:function(){return g.children(c.item).not("."+c.clonedClass)},move:function(b,d){return a.seekTo(k+
b,d)},next:function(b){return a.move(1,b)},prev:function(b){return a.move(-1,b)},begin:function(b){return a.seekTo(0,b)},end:function(b){return a.seekTo(a.getSize()-1,b)},focus:function(){return j=a},addItem:function(b){b=e(b);if(c.circular){e(".cloned:last").before(b);e(".cloned:first").replaceWith(b.clone().addClass(c.clonedClass))}else g.append(b);l.trigger("onAddItem",[b]);return a},seekTo:function(b,d,h){if(c.circular&&b===0&&k==-1&&d!==0)return a;if(!c.circular&&b<0||b>a.getSize()||b<-1)return a;var i=b;if(b.jquery)b=a.getItems().index(b);else i=a.getItems().eq(b);var q=e.Event("onBeforeSeek");if(!h){l.trigger(q,[b,d]);if(q.isDefaultPrevented()||!i.length)return a}i=m?{top:-i.position().top}:{left:-i.position().left};k=b;j=a;if(d===undefined)d=c.speed;g.animate(i,d,c.easing,h||function(){l.trigger("onSeek",[b])});return a}});e.each(["onBeforeSeek","onSeek","onAddItem"],function(b,d){e.isFunction(c[d])&&e(a).bind(d,c[d]);a[d]=function(h){e(a).bind(d,h);return a}});if(c.circular){var r=a.getItems().slice(-1).clone().prependTo(g),s=a.getItems().eq(1).clone().appendTo(g);r.add(s).addClass(c.clonedClass);a.onBeforeSeek(function(b,d,h){if(!b.isDefaultPrevented())if(d==-1){a.seekTo(r,h,function(){a.end(0)});return b.preventDefault()}else d==a.getSize()&&a.seekTo(s,h,function(){a.begin(0)})});a.seekTo(0,0)}var o=n(f,c.prev).click(function(){a.prev()}),p=n(f,c.next).click(function(){a.next()});!c.circular&&a.getSize()>1&&a.onBeforeSeek(function(b,d){setTimeout(function(){if(!b.isDefaultPrevented()){o.toggleClass(c.disabledClass,d<=0);p.toggleClass(c.disabledClass,d>=a.getSize()-1)}},1)});c.mousewheel&&e.fn.mousewheel&&f.mousewheel(function(b,d){if(c.mousewheel){a.move(d<0?1:-1,c.wheelSpeed||50);return false}});c.keyboard&&e(document).bind("keydown.scrollable",function(b){if(!(!c.keyboard||b.altKey||b.ctrlKey||e(b.target).is(":input")))if(!(c.keyboard!="static"&&j!=a)){var d=b.keyCode;if(m&&(d==38||d==40)){a.move(d==38?-1:1);return b.preventDefault()}if(!m&&(d==37||d==39)){a.move(d==37?-1:1);return b.preventDefault()}}});e(a).trigger("onBeforeSeek",[c.initialIndex])}e.tools=e.tools||{version:"1.2.3"};e.tools.scrollable={conf:{activeClass:"active",circular:false,clonedClass:"cloned",disabledClass:"disabled",easing:"swing",initialIndex:0,item:null,items:".items",keyboard:true,mousewheel:false,next:".next",prev:".prev",speed:400,vertical:false,wheelSpeed:0}};var j;e.fn.scrollable=function(f){var c=this.data("scrollable");if(c)return c;f=e.extend({},e.tools.scrollable.conf,f);this.each(function(){c=new t(e(this),f);e(this).data("scrollable",c)});return f.api?c:this}})(jQuery);(function($){$.pageTrackerLoaded=function(handler){if($.getPageTracker()){return handler();}else{return $(document).bind('pageTrackerLoaded',handler);}};$.setUserValue=function(value){var pageTracker=$.getPageTracker();if(!pageTracker){debug("pageTracker is not initialized");return;}else{debug('UserValue: '+value);pageTracker._setVar(value);}}
$.setCustomVar=function(index,name,value,opt_scope){var pageTracker=$.getPageTracker();if(!pageTracker){debug("pageTracker is not initialized");return;}else{debug('CustomVar: '+index+', '+name+', '+value+', '+opt_scope);pageTracker._setCustomVar(index,name,value,opt_scope);}}
$.getPageTracker=function(){if(typeof $._gaPageTracker!='undefined'){return $._gaPageTracker;}else{return false;}};$.loadPageTracker=function(account_id,options){var settings=$.extend({onload:true},options);debug('Page tracker not loaded yet, loading now');var src=(("https:"==document.location.protocol)?"https://ssl.":"http://www.")+'google-analytics.com/ga.js';function gat_loaded(){if(typeof _gat!='undefined'){debug('Google Analytics loaded');$._gaPageTracker=_gat._getTracker(account_id);if($.isFunction(settings.callback)){debug('loadPageTracker calling provided callback');settings.callback();}
$(document).trigger('pageTrackerLoaded');}else{throw"_gat is undefined";}}
function load_script(){if(typeof _gat!='undefined'){gat_loaded();}else{$.ajax({type:"GET",url:src,success:gat_loaded,dataType:"script",cache:true});}}
if(settings.onload==true||settings.onload==null){$(window).load(load_script);}else{load_script();}};$.trackPage=function(account_id,options){var settings=$.extend({},{status_code:200},options);var callback;if($.isFunction(settings.callback)){debug('Callback provided to trackPage, saving for later use');callback=settings.callback;}
settings.callback=function(){if(settings.status_code==null||settings.status_code==200){$.trackPageview();}else{debug('Tracking error '+settings.status_code);$.trackPageview("/"+settings.status_code+".html?page="+document.location.pathname+document.location.search+"&from="+document.referrer);}
if(callback!=null){debug('Calling callback provided to trackPage');callback();}};$.loadPageTracker(account_id,settings);};$.trackEvent=function(category,action,label,value){var pageTracker=$.getPageTracker();if(!pageTracker){debug("pageTracker is not initialized");return;}
debug("Track Event called");pageTracker._trackEvent(category,action,label,value);};$.trackPageview=function(uri){var pageTracker=$.getPageTracker();if(!pageTracker){debug("pageTracker is not initialized");return;}
debug("Track Page called");pageTracker._trackPageview(uri);}
$.fn.track=function(options){return this.each(function(){var element=$(this);if(element.hasClass('tracked')){return false;}else{element.addClass('tracked');}
var settings=$.extend({},$.fn.track.defaults,options);var category=evaluate(element,settings.category);var action=evaluate(element,settings.action);var label=evaluate(element,settings.label);var value=evaluate(element,settings.value);var event_name=evaluate(element,settings.event_name);var message="category:'"+category+"' action:'"+action+"' label:'"+label+"' value:'"+value+"'";debug('Tracking '+event_name+' '+message);element.bind(event_name+'.track',function(){var skip=settings.skip_internal&&(element[0].hostname==location.hostname);if(!skip){$.trackEvent(category,action,label,value);debug('Tracked '+message);}else{debug('Skipped '+message);}
return true;});});function evaluate(element,text_or_function){if(typeof text_or_function=='function'){text_or_function=text_or_function(element);}
return text_or_function;};};$.trackTransaction=function(options){var pageTracker=$.getPageTracker();if(!pageTracker){debug("pageTracker is not initialized");return;}else{debug("Adding Transaction: "+options['orderId']+','+options['total']+','+options['tax']+','+options['shipping']+','+options['city']+','+options['state']+','+options['country']);pageTracker._addTrans(options['orderId'],null,options['total'],options['tax'],options['shipping'],options['city'],options['state'],options['country']);$.each(options['items'],function(){debug("Adding Transaction Item: "+this['sku']+','+this['name']+','+this['category']+','+this['price']+','+this['quantity']);pageTracker._addItem(options['orderId'],this['sku'],this['name'],this['category'],this['price'],this['quantity']);});debug("Sending Transaction");pageTracker._trackTrans();}}
function debug(message){if(typeof console!='undefined'&&typeof console.debug!='undefined'&&$.fn.track.defaults.debug){console.debug(message);}};$.fn.track.defaults={category:function(element){return(element[0].hostname==location.hostname)?'internal':'external';},action:'click',label:function(element){return element.attr('href');},value:null,skip_internal:true,event_name:'click',debug:false};})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};var NextId=1,Custom="Custom",GoogleCheckout="GoogleCheckout",PayPal="PayPal",Email="Email",AustralianDollar=AUD="AUD",CanadianDollar=CAD="CAD",CzechKoruna=CZK="CZK",DanishKrone=DKK="DKK",Euro=EUR="EUR",HongKongDollar=HKD="HKD",HungarianForint=HUF="HUF",IsraeliNewSheqel=ILS="ILS",JapaneseYen=JPY="JPY",MexicanPeso=MXN="MXN",NorwegianKrone=NOK="NOK",NewZealandDollar=NZD="NZD",PolishZloty=PLN="PLN",PoundSterling=GBP="GBP",SingaporeDollar=SGD="SGD",SwedishKrona=SEK="SEK",SwissFranc=CHF="CHF",USDollar=USD="USD";function Cart(name){var me=this;me.Version='2.0.1';me.Shelf=new Shelf();me.items={};me.isLoaded=false;me.pageIsReady=false;me.quantity=0;me.total=0;me.taxRate=0;me.taxCost=0;me.shippingFlatRate=0;me.shippingTotalRate=0;me.shippingQuantityRate=0;me.shippingRate=0;me.shippingCost=0;me.currency=USD;me.checkoutTo=PayPal;me.email="";me.merchantId="";me.cartHeaders=['Name','Price','Quantity','Total'];me.onAddItem=null;me.onRejectAdd=null;me.onRejectAddSupport=null;me.onItemIncrement=null;me.onItemDecrement=null;me.onItemRemove=null;me.products={};if(name==null)
me.name='simpleCart';else
me.name=name;me.initializeProducts=function(arr){for(i in arr){var prod=arr[i];var p=new ProductInfo();p.id=prod.id;p.name=prod.n;p.maxDuration=prod.mD;p.maxQuantity=prod.mQ;p.incrementalPricing=prod.p.i;for(x in prod.p.p){var price=prod.p.p[x];p.addPricing({max:price.m,price:price.p,discountPrice:price.dP});}
for(x in prod.s){var method=prod.s[x];s={id:method.id,name:method.n,pricing:[]};for(j in method.p){var price=method.p[j];s.pricing.push({max:price.m,shipping:price.s,handling:price.h})}
p.addShippingMethod(s);}
me.products[p.id]=p;}}
me.add=function(){var me=this;if(!me.pageIsReady){me.initializeView();me.update();}
if(!me.isLoaded){me.load();me.update();}
var newItem=new CartItem();if(!arguments||arguments.length===0){error('No values passed for item.');return;}
var argumentArray=arguments;if(arguments[0]&&typeof(arguments[0])!='string'&&typeof(arguments[0])!='number'){argumentArray=arguments[0];}
newItem.parseValuesFromArray(argumentArray);newItem.checkQuantityAndPrice();if(newItem.checkDuration()&&newItem.checkQuantity()){if(me.hasItem(newItem)){var id=me.hasItem(newItem);var newQuantity=parseInt(me.items[id].quantity,10)+parseInt(newItem.quantity,10);me.items[id].quantity=newQuantity;if(newQuantity>=me.items[id].quantity){if($.isFunction(me.onItemIncrement)){me.onItemIncrement(me.items[id]);}}
else
{if($.isFunction(me.onItemDecrement)){me.onItemDecrement(me.items[id]);}}}else{me.items[newItem.id]=newItem;}
if($.isFunction(me.onAddItem)){me.onAddItem(newItem.name,newItem.quantity,newItem.price);}
me.update();}};me.remove=function(id){var tempArray={};for(var item in this.items){if(item!=id){tempArray[item]=this.items[item];}}
this.items=tempArray;};me.empty=function(){simpleCart.items={};simpleCart.update();};me.find=function(criteria){if(!criteria)
return null;var results=[];for(var next in me.items){var item=me.items[next],fits=true;for(var name in criteria){if(!item[name]||item[name]!=criteria[name])
fits=false;}
if(fits)
results.push(me.next)}
return(results.length==0)?null:results;}
me.checkout=function(){if(simpleCart.quantity===0){error("Cart is empty");return;}
switch(simpleCart.checkoutTo){case PayPal:simpleCart.paypalCheckout();break;case GoogleCheckout:simpleCart.googleCheckout();break;case Email:simpleCart.emailCheckout();break;default:simpleCart.customCheckout();break;}};me.paypalCheckout=function(){var me=this,winpar="scrollbars,location,resizable,status",strn="https://www.paypal.com/cgi-bin/webscr?cmd=_cart"+"&upload=1"+"&business="+me.email+"&currency_code="+me.currency,counter=1,itemsString="";if(me.taxRate){strn=strn+"&tax_cart="+me.currencyStringForPaypalCheckout(me.taxCost);}
for(var current in me.items){var item=me.items[current];var optionsString="";for(var field in item){if(typeof(item[field])!="function"&&field!="id"&&field!="price"&&field!="quantity"&&field!="name"&&field!="shipping"){optionsString=optionsString+", "+field+"="+item[field];}}
optionsString=optionsString.substring(2);itemsString=itemsString+"&item_name_"+counter+"="+item.name+"&item_number_"+counter+"="+counter+"&quantity_"+counter+"="+item.quantity+"&amount_"+counter+"="+me.currencyStringForPaypalCheckout(item.price)+"&on0_"+counter+"="+"Options"+"&os0_"+counter+"="+optionsString;counter++;}
if(me.shipping()!=0){itemsString=itemsString+"&item_name_"+counter+"=Shipping"+"&item_number_"+counter+"="+counter+"&quantity_"+counter+"=1"+"&amount_"+counter+"="+me.currencyStringForPaypalCheckout(me.shippingCost);}
strn=strn+itemsString;window.open(strn,"paypal",winpar);};me.googleCheckout=function(){var me=this;if(me.currency!=USD&&me.currency!=GBP){error("Google Checkout only allows the USD and GBP for currency.");return;}else if(me.merchantId===""||me.merchantId===null||!me.merchantId){error("No merchant Id for google checkout supplied.");return;}
var form=document.createElement("form"),counter=1;form.style.display="none";form.method="POST";form.action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/"+
me.merchantId;form.acceptCharset="utf-8";for(var current in me.items){var item=me.items[current];form.appendChild(me.createHiddenElement("item_name_"+counter,item.name));form.appendChild(me.createHiddenElement("item_quantity_"+counter,item.quantity));form.appendChild(me.createHiddenElement("item_price_"+counter,item.price));form.appendChild(me.createHiddenElement("item_currency_"+counter,me.currency));form.appendChild(me.createHiddenElement("item_tax_rate_"+counter,me.taxRate));form.appendChild(me.createHiddenElement("_charset_",""));var descriptionString="";for(var field in item){if(typeof(item[field])!="function"&&field!="id"&&field!="quantity"&&field!="price")
{descriptionString=descriptionString+", "+field+": "+item[field];}}
descriptionString=descriptionString.substring(1);form.appendChild(me.createHiddenElement("item_description_"+counter,descriptionString));counter++;}
document.body.appendChild(form);form.submit();document.body.removeChild(form);};me.emailCheckout=function(){return;};me.customCheckout=function(){return;};me.load=function(){var me=this;me.items={};me.total=0.00;me.quantity=0;if(readCookie(me.name)){var data=unescape(readCookie(me.name)).split('++');for(var x=0,xlen=data.length;x<xlen;x++){var info=data[x].split('||');var newItem=new CartItem();if(newItem.parseValuesFromArray(info)){newItem.checkQuantityAndPrice();me.items[newItem.id]=newItem;}}}
me.isLoaded=true;};me.save=function(){var dataString="";for(var item in this.items){dataString=dataString+"++"+this.items[item].print();}
createCookie(me.name,dataString.substring(2),30);};me.initializeView=function(){var me=this;me.totalOutlets=getElementsByClassName('simpleCart_total');me.quantityOutlets=getElementsByClassName('simpleCart_quantity');me.cartDivs=getElementsByClassName('simpleCart_items');me.taxCostOutlets=getElementsByClassName('simpleCart_taxCost');me.taxRateOutlets=getElementsByClassName('simpleCart_taxRate');me.shippingCostOutlets=getElementsByClassName('simpleCart_shippingCost');me.finalTotalOutlets=getElementsByClassName('simpleCart_finalTotal');me.addEventToArray(getElementsByClassName('simpleCart_checkout'),simpleCart.checkout,"click");me.addEventToArray(getElementsByClassName('simpleCart_empty'),simpleCart.empty,"click");me.Shelf.readPage();me.pageIsReady=true;};me.updateView=function(){me.updateViewTotals();if(me.cartDivs&&me.cartDivs.length>0){me.updateCartView();}};me.updateViewTotals=function(){var outlets=[["quantity","none"],["total","currency"],["shippingCost","currency"],["taxCost","currency"],["taxRate","percentage"],["finalTotal","currency"]];for(var x=0,xlen=outlets.length;x<xlen;x++){var arrayName=outlets[x][0]+"Outlets",outputString;for(var element in me[arrayName]){switch(outlets[x][1]){case"none":outputString=""+me[outlets[x][0]];break;case"currency":outputString=me.valueToCurrencyString(me[outlets[x][0]]);break;case"percentage":outputString=me.valueToPercentageString(me[outlets[x][0]]);break;default:outputString=""+me[outlets[x][0]];break;}
me[arrayName][element].innerHTML=""+outputString;}}};me.updateCartView=function(){var newRows=[],x,newRow,item,current,header,newCell,info,outputValue,option,headerInfo;newRow=document.createElement('div');for(header in me.cartHeaders){newCell=document.createElement('div');headerInfo=me.cartHeaders[header].split("_");newCell.innerHTML=headerInfo[0];newCell.className="item"+headerInfo[0];for(x=1,xlen=headerInfo.length;x<xlen;x++){if(headerInfo[x].toLowerCase()=="noheader"){newCell.style.display="none";}}
newRow.appendChild(newCell);}
newRow.className="cartHeaders";newRows[0]=newRow;x=1;if($.objectSize(simpleCart.items)==0){newRow=document.createElement('div');newRow.innerHTML="Your cart is empty";newRow.className="itemContainer empty";newRows[x]=newRow;}
else{for(current in me.items){newRow=document.createElement('div');item=me.items[current];var q=parseInt(item.quantity,10);for(header in me.cartHeaders){newCell=document.createElement('div');info=me.cartHeaders[header].split("_");switch(info[0].toLowerCase()){case"total":outputValue=me.valueToCurrencyString(item.getTotal());break;case"increment":if(item.quantitycontrols)
outputValue=me.valueToLink("+","javascript:;","onclick=\"simpleCart.items[\'"+item.id+"\'].increment();\"");else
outputValue="";break;case"decrement":if(item.quantitycontrols)
outputValue=me.valueToLink("-","javascript:;","onclick=\"simpleCart.items[\'"+item.id+"\'].decrement();\"");else
outputValue="";break;case"remove":outputValue=me.valueToLink("Remove","javascript:;","onclick=\"simpleCart.items[\'"+item.id+"\'].remove();\"");break;case"price":outputValue=me.valueToCurrencyString(item[info[0].toLowerCase()]?item[info[0].toLowerCase()]:" ");break;default:outputValue=item[info[0].toLowerCase()]?item[info[0].toLowerCase()]:" ";break;}
for(var y=1,ylen=info.length;y<ylen;y++){option=info[y].toLowerCase();switch(option){case"image":case"img":outputValue=me.valueToImageString(outputValue);break;case"input":outputValue=me.valueToTextInput(outputValue,"onchange=\"simpleCart.items[\'"+item.id+"\'].set(\'"+outputValue+"\' , this.value);\"");break;case"div":case"span":case"h1":case"h2":case"h3":case"h4":case"p":outputValue=me.valueToElement(option,outputValue,"");break;case"noheader":break;default:error("unkown header option: "+option);break;}}
newCell.innerHTML=outputValue;newCell.className="item"+info[0];newRow.appendChild(newCell);}
newRow.className="itemContainer";newRows[x]=newRow;x++;}}
for(current in me.cartDivs){var div=me.cartDivs[current];while(div.childNodes[0]){div.removeChild(div.childNodes[0]);}
for(var j=0,jLen=newRows.length;j<jLen;j++){div.appendChild(newRows[j]);}}};me.addEventToArray=function(array,functionCall,theEvent){for(var outlet in array){var element=array[outlet];if(element.addEventListener){element.addEventListener(theEvent,functionCall,false);}else if(element.attachEvent){element.attachEvent("on"+theEvent,functionCall);}}};me.createHiddenElement=function(name,value){var element=document.createElement("input");element.type="hidden";element.name=name;element.value=value;return element;};me.currencySymbol=function(){switch(me.currency){case JPY:return"&yen;";case EUR:return"&euro;";case GBP:return"&pound;";case USD:case CAD:case AUD:case NZD:case HKD:case SGD:return"&#36;";default:return"";}};me.currencyStringForPaypalCheckout=function(value){if(me.currencySymbol()=="&#36;"){return"$"+parseFloat(value).toFixed(2);}else{return""+parseFloat(value).toFixed(2);}};me.valueToCurrencyString=function(value){return parseFloat(value).toCurrency(me.currencySymbol());};me.valueToPercentageString=function(value){return parseFloat(100*value)+"%";};me.valueToImageString=function(value){if(value.match(/<\s*img.*src\=/)){return value;}else{return"<img src=\""+value+"\" />";}};me.valueToTextInput=function(value,html){return"<input type=\"text\" value=\""+value+"\" "+html+" />";};me.valueToLink=function(value,link,html){return"<a href=\""+link+"\" "+html+" >"+value+"</a>";};me.valueToElement=function(type,value,html){return"<"+type+" "+html+" > "+value+"</"+type+">";};me.hasItem=function(item){for(var current in me.items){var testItem=me.items[current];var matches=true;for(var field in item){if(typeof(item[field])!="function"&&field!="quantity"&&field!="id"){if(item[field]!=testItem[field]){matches=false;}}}
if(matches){return current;}}
return false;};me.getTotalSupportDuration=function(cartItem){var duration=0;for(var current in me.items){var testItem=me.items[current];if(testItem.registration_id==cartItem.registration_id){duration+=(parseInt(testItem.quantity,10)*parseInt(testItem.product_support_duration,10));}}
return duration;};me.update=function(){if(!simpleCart.isLoaded){simpleCart.load();}
if(!simpleCart.pageIsReady){simpleCart.initializeView();}
me.updateTotals();me.updateView();me.save();};me.updateTotals=function(){me.total=0;me.quantity=0;for(var current in me.items){var item=me.items[current];if(item.quantity<1){item.remove();}else if(item.quantity!==null&&item.quantity!="undefined"){me.quantity=parseInt(me.quantity,10)+parseInt(item.quantity,10);}
me.total=parseFloat(me.total)+parseFloat(item.getTotal());}
me.shippingCost=me.shipping();me.taxCost=parseFloat(me.total)*me.taxRate;me.finalTotal=me.shippingCost+me.taxCost+me.total;};me.shipping=function(){if(parseInt(me.quantity,10)===0)
return 0;var shipping=parseFloat(me.shippingFlatRate)+
parseFloat(me.shippingTotalRate)*parseFloat(me.total)+
parseFloat(me.shippingQuantityRate)*parseInt(me.quantity,10),nextItem,next;for(next in me.items){nextItem=me.items[next];if(nextItem.shipping){if(typeof nextItem.shipping=='function'){shipping+=parseFloat(nextItem.shipping());}else{shipping+=parseFloat(nextItem.shipping);}}}
return shipping;}
me.initialize=function(){simpleCart.initializeView();simpleCart.load();simpleCart.update();};}
function CartItem(){this.id="c"+NextId++;this.quantitycontrols=true;}
CartItem.prototype.set=function(field,value){field=field.toLowerCase();if(typeof(this[field])!="function"&&field!="id"){if(field=="quantity"){value=value.replace(/[^(\d|\.)]*/gi,"");value=value.replace(/,*/gi,"");value=parseInt(value,10);}else if(field=="price"){value=value.replace(/[^(\d|\.)]*/gi,"");value=value.replace(/,*/gi,"");value=parseFloat(value);}
if(typeof(value)=="number"&&isNaN(value)){error("Improperly formatted input.");}else{this[field]=value;this.checkQuantityAndPrice();}}else{error("Cannot change "+field+", this is a reserved field.");}
simpleCart.update();};CartItem.prototype.increment=function(){this.quantity=parseInt(this.quantity,10)+1;if(this.checkQuantity()){if($.isFunction(simpleCart.onItemIncrement)){simpleCart.onItemIncrement(this);}
simpleCart.update();}
else
this.quantity=parseInt(this.quantity,10)-1;};CartItem.prototype.decrement=function(){if(parseInt(this.quantity,10)<2){this.remove();}else{this.quantity=parseInt(this.quantity,10)-1;if(this.checkQuantity()){if($.isFunction(simpleCart.onItemDecrement)){simpleCart.onItemDecrement(this);}
simpleCart.update();}
else
this.quantity=parseInt(this.quantity,10)+1;}};CartItem.prototype.print=function(){var returnString='';for(var field in this){if(typeof(this[field])!="function"){returnString+=escape(field)+"="+escape(this[field])+"||";}}
return returnString.substring(0,returnString.length-2);};CartItem.prototype.checkQuantityAndPrice=function(){if(!this.price||this.quantity==null||this.quantity=='undefined'){this.quantity=1;error('No quantity for item.');}else{this.quantity=(""+this.quantity).replace(/,*/gi,"");this.quantity=parseInt((""+this.quantity).replace(/[^(\d|\.)]*/gi,""),10);if(isNaN(this.quantity)){error('Quantity is not a number.');this.quantity=1;}}
if(!this.price||this.price==null||this.price=='undefined'){this.price=0.00;error('No price for item or price not properly formatted.');}else{this.price=(""+this.price).replace(/,*/gi,"");this.price=parseFloat((""+this.price).replace(/[^(\d|\.)]*/gi,""));if(isNaN(this.price)){error('Price is not a number.');this.price=0.00;}}};CartItem.prototype.checkDuration=function(){try{if(this.registration_id!=null&&this.registration_id!=""){var maxDuration=parseInt(simpleCart.products[this.registered_product_id].maxDuration,10);var thisDuration=parseInt(this.quantity,10)*parseInt(this.product_support_duration,10);var cartDuration=simpleCart.getTotalSupportDuration(this);var wouldBeDuration=parseInt(this.current_support_duration,10)+thisDuration+cartDuration;if(wouldBeDuration>maxDuration)
{if($.isFunction(simpleCart.onRejectAddSupport))
simpleCart.onRejectAddSupport(this.name,this.quantity,maxDuration,thisDuration);return false;}}}catch(err){error(err)}
return true;};CartItem.prototype.checkQuantity=function(){try{var newQuantity=parseInt(this.quantity,10);if(simpleCart.hasItem(this)){var id=simpleCart.hasItem(this);if(!(this===simpleCart.items[id]))
newQuantity+=parseInt(simpleCart.items[id].quantity,10);}
var maxQuantity=parseInt(simpleCart.products[this.product_id].maxQuantity,10);if(maxQuantity!=null)
{if(newQuantity>maxQuantity)
{if($.isFunction(simpleCart.onRejectAdd))
simpleCart.onRejectAdd(this.name,this.quantity,maxQuantity);return false;}}}catch(err){error(err)}
return true;};CartItem.prototype.parseValuesFromArray=function(array){if(array&&array.length&&array.length>0){for(var x=0,xlen=array.length;x<xlen;x++){array[x].replace(/||/,"| |");array[x].replace(/\+\+/,"+ +");var value=array[x].split('=');if(value.length>1){if(value.length>2){for(var j=2,jlen=value.length;j<jlen;j++){value[1]=value[1]+"="+value[j];}}
var valueToUse=unescape(value[1]);if(valueToUse=="true"||valueToUse=="false")
valueToUse=(unescape(value[1])=="true");this[unescape(value[0]).toLowerCase()]=valueToUse;}}
return true;}else{return false;}};CartItem.prototype.remove=function(){simpleCart.remove(this.id);if($.isFunction(simpleCart.onItemRemove)){simpleCart.onItemRemove(this);}
simpleCart.update();};CartItem.prototype.getTotal=function(){var q=parseInt(this.quantity,10);if(this.udp==undefined||this.udp)
var discount=true;else
var discount=false;if(simpleCart.products[this.product_id]!=undefined){var p=simpleCart.products[this.product_id];var tQ=q;if(p.incrementalPricing){var sortedPrices=p.sortPricingByMax(p.pricing);var total=0.0;for(i in sortedPrices){var priceObj=sortedPrices[i];var price=p.getPrice(priceObj.max,discount)
if(priceObj.max<q){total+=price*priceObj.max;tQ-=priceObj.max;}
else{total+=price*tQ;break;}}
return total;}
else
return p.getPrice(q,discount)*q;}
else
return this.price*q;};function Shelf(){this.items={};}
Shelf.prototype.readPage=function(){this.items={};var newItems=getElementsByClassName("simpleCart_shelfItem");for(var current in newItems){var newItem=new ShelfItem();this.checkChildren(newItems[current],newItem);this.items[newItem.id]=newItem;}};Shelf.prototype.checkChildren=function(item,newItem){for(var x=0;item.childNodes[x];x++){var node=item.childNodes[x];if(node.className&&node.className.match(/item_[^ ]+/)){var data=/item_[^ ]+/.exec(node.className)[0].split("_");if(data[1]=="add"||data[1]=="Add"){var tempArray=[];tempArray.push(node);var addFunction=simpleCart.Shelf.addToCart(newItem.id);simpleCart.addEventToArray(tempArray,addFunction,"click");node.id=newItem.id;}else{newItem[data[1]]=node;}}
if(node.childNodes[0]){this.checkChildren(node,newItem);}}};Shelf.prototype.empty=function(){this.items={};};Shelf.prototype.addToCart=function(id){return function(){if(simpleCart.Shelf.items[id]){simpleCart.Shelf.items[id].addToCart();}else{error("Shelf item with id of "+id+" does not exist.");}};};function ShelfItem(){this.id="s"+NextId++;}
ShelfItem.prototype.remove=function(){simpleCart.Shelf.items[this.id]=null;};ShelfItem.prototype.addToCart=function(){var outStrings=[],valueString;for(var field in this){if(typeof(this[field])!="function"&&field!="id"){valueString="";switch(field){case"price":if(this[field].value){valueString=this[field].value;}else if(this[field].innerHTML){valueString=this[field].innerHTML;}
valueString=valueString.replace(/[^(\d|\.)]*/gi,"");valueString=valueString.replace(/,*/,"");break;case"image":valueString=this[field].src;break;default:if(this[field].value){valueString=this[field].value;}else if(this[field].innerHTML){valueString=this[field].innerHTML;}else if(this[field].src){valueString=this[field].src;}else{valueString=this[field];}
break;}
outStrings.push(field+"="+valueString);}}
simpleCart.add(outStrings);};function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)===0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
var getElementsByClassName=function(className,tag,elm){if(document.getElementsByClassName){getElementsByClassName=function(className,tag,elm){elm=elm||document;var elements=elm.getElementsByClassName(className),nodeName=(tag)?new RegExp("\\b"+tag+"\\b","i"):null,returnElements=[],current;for(var i=0,il=elements.length;i<il;i+=1){current=elements[i];if(!nodeName||nodeName.test(current.nodeName)){returnElements.push(current);}}
return returnElements;};}
else if(document.evaluate){getElementsByClassName=function(className,tag,elm){tag=tag||"*";elm=elm||document;var classes=className.split(" "),classesToCheck="",xhtmlNamespace="http://www.w3.org/1999/xhtml",namespaceResolver=(document.documentElement.namespaceURI===xhtmlNamespace)?xhtmlNamespace:null,returnElements=[],elements,node;for(var j=0,jl=classes.length;j<jl;j+=1){classesToCheck+="[contains(concat(' ', @class, ' '), ' "+classes[j]+" ')]";}
try{elements=document.evaluate(".//"+tag+classesToCheck,elm,namespaceResolver,0,null);}
catch(e){elements=document.evaluate(".//"+tag+classesToCheck,elm,null,0,null);}
while((node=elements.iterateNext())){returnElements.push(node);}
return returnElements;};}
else{getElementsByClassName=function(className,tag,elm){tag=tag||"*";elm=elm||document;var classes=className.split(" "),classesToCheck=[],elements=(tag==="*"&&elm.all)?elm.all:elm.getElementsByTagName(tag),current,returnElements=[],match;for(var k=0,kl=classes.length;k<kl;k+=1){classesToCheck.push(new RegExp("(^|\\s)"+classes[k]+"(\\s|$)"));}
for(var l=0,ll=elements.length;l<ll;l+=1){current=elements[l];match=false;for(var m=0,ml=classesToCheck.length;m<ml;m+=1){match=classesToCheck[m].test(current.className);if(!match){break;}}
if(match){returnElements.push(current);}}
return returnElements;};}
return getElementsByClassName(className,tag,elm);};function ProductInfo(){var self=this;self.id=null;self.name="";self.maxQuantity=0;self.maxDuration=0;self.pricing=[];self.shippingMethods=[];self.incrementalPricing=false;};ProductInfo.prototype.sortPricingByMax=function(prices){var self=this;var sortedPrices=prices;sortedPrices.sort(function(a,b){return(a.max-b.max);});return sortedPrices;};ProductInfo.prototype.getVolumePrice=function(prices,qty){var self=this;sortedPrices=self.sortPricingByMax(prices);for(i in sortedPrices){var price=sortedPrices[i];if(price.max>=qty)
return price;}
return null;};ProductInfo.prototype.getPrice=function(qty,discount){var self=this;var priceObj=self.getVolumePrice(self.pricing,qty);if(discount)
return priceObj.discountPrice;else
return priceObj.price;};ProductInfo.prototype.getHandlingPrice=function(methodId,qty){var self=this;for(i in self.shippingMethods){method=self.shippingMethods[i];if(method.id==methodId){var priceObj=self.getVolumePrice(method.pricing,qty);return priceObj.handling;}}
return null;};ProductInfo.prototype.getShippingPrice=function(methodId,qty){var self=this;for(i in self.shippingMethods){method=self.shippingMethods[i];if(method.id==methodId){var priceObj=self.getVolumePrice(method.pricing,qty);return priceObj.shipping;}}
return null;};ProductInfo.prototype.addPricing=function(price){var self=this;self.pricing.push(price);};ProductInfo.prototype.addShippingMethod=function(method){var self=this;self.shippingMethods.push(method);};String.prototype.reverse=function(){return this.split("").reverse().join("");};Number.prototype.withCommas=function(){var x=6,y=parseFloat(this).toFixed(2).toString().reverse();while(x<y.length){y=y.substring(0,x)+","+y.substring(x);x+=4;}return y.reverse();};Number.prototype.toCurrency=function(){return(arguments[0]?arguments[0]:"$")+this.withCommas();};function error(message){try{console.log(message);}catch(err){}}
jQuery.fn.exists=function(){return jQuery(this).length>0;}
$.extend({getUrlVars:function(){var vars=[],hash;var hashes=window.location.href.slice(window.location.href.indexOf('?')+1).split('&');for(var i=0;i<hashes.length;i++)
{hash=hashes[i].split('=');vars.push(hash[0]);vars[hash[0]]=hash[1];}
return vars;},getUrlVar:function(name){return $.getUrlVars()[name];},objectSize:function(obj){var size=0,key;for(key in obj){if(obj.hasOwnProperty(key))size++;}
return size;}});function facebook_signup(){$.ajax({url:'/determinator',type:'POST',dataType:'script',data:"page[name]=signup&fbc=1"});}
function empty_cart(){simpleCart.empty();}
function gotoNextPage(path){$('#next_button').attr('disabled',true);redirectTo(path);}
function redirectTo(path){var div=document.createElement('div');div.innerHTML=path;var decoded=div.firstChild.nodeValue;if(window.parent.document!=undefined)
window.parent.document.location=decoded;else
window.location=decoded;}
function showError(error){$('div.registria.form_messages').hide();var decoded=$("<div/>").html(error).text();$('#next_button').attr('disabled',false);$('#next_button').val(oldValue);$('div.registria.form_errors').html(decoded);$('div.registria.form_errors').show();scroll(0,0);}
function showMessage(message){$('div.registria.form_errors').hide();var decoded=$("<div/>").html(message).text();$('#next_button').attr('disabled',false);$('#next_button').val(oldValue);$('div.registria.form_messages').html(decoded);$('div.registria.form_messages').show();scroll(0,0);}
function makeSublist(parent,child,showPrompt,prompt,listAll){if(!parent.exists()||!child.exists())
return;listAll=(typeof listAll=="undefined")?true:listAll;if(!$("option#preselect",parent).length)
$("option:first",parent).attr('selected','selected');else
$("option#preselect",parent).attr('selected','selected');var populateChild=function(v,ph,c,p,sp,la){if(v==null||v=="")
if(la)
c.html($("option",ph).clone());else
c.html('');else
c.html($(".sub_"+v.replace(/ /gi,'_'),ph).clone());if(sp)
{pr=(typeof p=="undefined")?"Select One":p;c.prepend("<option value=''>"+pr+"</option>");}
if(!$("option#preselect",c).length)
$("option:first",c).attr('selected','selected');else
$("option#preselect",c).attr('selected','selected');}
var parentValue=parent.val();var childValue=$("option#preselect",child).val();var placeHolderName=parent.attr('id')+child.attr('id');$("body").append("<select style='display:none' id='"+placeHolderName+"'></select>");var placeHolder=$('#'+placeHolderName);placeHolder.html($("option",child));populateChild(parentValue,placeHolder,child,prompt,showPrompt,listAll);if(childValue!='undefined')
child.val(childValue);parent.change(function(){populateChild(parent.val(),placeHolder,child,prompt,showPrompt,listAll);child.trigger("change");child.focus();});};function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+"="+escape(value)+
((expiredays==null)?"":";expires="+exdate.toUTCString());}
function getCookie(c_name)
{if(document.cookie.length>0)
{c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1)
{c_start=c_start+c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end));}}
return"";}
function switchCurrency(currencyId)
{data=getRegistriaData();data=$.makeArray(data);data.push($("<input name='currency' value='"+currencyId+"' />"));postwith(window.location,data);}
function postwith(to,p){var myForm=$("<form action='"+to+"' method='POST'></form>");$.each(p,function(i,element){var element=$(element);if(element.attr('type')=='radio'){if(element.attr('checked')){var newElement=element.clone(true);newElement.val(element.val());newElement.attr('checked',true);element.attr('checked',true);newElement.appendTo(myForm);}}
else{var newElement=element.clone(true);newElement.val(element.val());newElement.appendTo(myForm);}});myForm.appendTo('body');myForm.submit();myForm.remove();}
function switchLanguage(locale)
{var path=window.location.pathname.split('/');path.shift();if($.inArray(path[0],$.availableLocales)!=-1)
path.shift();path=path.join('/');newUrl=window.location.protocol+"//"+window.location.host+"/"+locale+"/"+path;data=getRegistriaData();postwith(newUrl,data);}
$(document).ready(function(){simpleCart=new Cart($.currencyCode+'_cart');simpleCart.currencySymbol=function(){return $.currencyUnit;};simpleCart.checkoutTo='custom';simpleCart.cartHeaders=['Name','Quantity','increment_noHeader','decrement_noHeader','Total','Remove'];simpleCart.customCheckout=function(){gotoNextPage("/checkout")}
simpleCart.onAddItem=function(name,quantity,price){$.jGrowl(name,{theme:'registria',header:$.translator.t('Added to cart'),life:10000});}
simpleCart.onRejectAdd=function(name,quantity,limit){$.jGrowl("You may only add "+limit+" of "+name,{theme:'registria-error',header:$.translator.t('Error'),sticky:true});}
simpleCart.onRejectAddSupport=function(name,quantity,maxDuration,itemDuration){$.jGrowl("Unable to extend warranty past "+Math.floor(maxDuration/365)+" years",{theme:'registria-error',header:$.translator.t('Error'),sticky:true});}
$.each(['Name','Quantity','Total','Remove'],function(){$("div.cartHeaders > div.item<%= header %>").html($.translator.t(this));});$("div.itemRemove > a").html($.translator.t('Remove'));$("#registria_checkout").click(function(e){if(simpleCart.quantity<1)
alert($.translator.t('Your Cart is empty'));else
gotoNextPage("/checkout");});simpleCart.initializeProducts($.productInfo);simpleCart.initialize();});$(document).ready(function(){if($('span#registria_form_placeholder').exists())
$('span#registria_form_placeholder').children().wrapAll("<form id='registria_form' enctype='multipart/form-data'></form>");else
$('body').children().wrapAll("<form id='registria_form' enctype='multipart/form-data'></form>");$('body').append("<div id=\"FB_HiddenContainer\"  style=\"position:absolute; top:-10000px; width:0px; height:0px;\" ></div>");$("select[name$='[shipping_method_id]'] option:first[value='']").remove();$("#registria_form input:visible:first").focus();$('#registria_form').validate({errorClass:"invalid"});$('#registria_form').append("<input name='extra_info' type='hidden' value='"+$.extraInfo+"' class='registria_field'></input>");$('#registria_form').submit(function(){if($('#registria_form').valid()){$('#next_button').attr('disabled',true);oldValue=$('#next_button').val();$('#next_button').val($.translator.t('Please wait'));var fieldData=getRegistriaData();$.ajaxFileUpload({url:'/determinator',secureuri:false,elements:fieldData,dataType:'script',success:function(data,status){},error:function(data,status,e){alert(e);$('#next_button').attr('disabled',false);$('#next_button').val(oldValue);}});}
return false;});$("option#preselect").attr('selected','selected');var country_field=$("select[name$='[address_attributes][country]']");var state_field=$("select[name$='[address_attributes][state]']");var card_type_field=$("select[name$='[credit_card][type]']");var billing_country_field=$("select[name$='[billing_address_attributes][country]']");var billing_state_field=$("select[name$='[billing_address_attributes][state]']");var shipping_country_field=$("select[name$='[shipping_address_attributes][country]']");var shipping_state_field=$("select[name$='[shipping_address_attributes][state]']");var installation_country_field=$("select[name$='[installation_address_attributes][country]']");var installation_state_field=$("select[name$='[installation_address_attributes][state]']");var product_field=$("select[name$='[product]']");var product_family_field=$("select[name$='[product_family]']");var product_category_field=$("select[name$='[product_category]']");jQuery.each([shipping_state_field,shipping_country_field,billing_state_field,billing_country_field,country_field,state_field,product_field,product_category_field,product_family_field],function(){$("option:first[value='']",this).remove();})
country_field.prepend("<option value=''>"+$.translator.t("country_prompt")+"</option>")
billing_country_field.prepend("<option value=''>"+$.translator.t("country_prompt")+"</option>")
shipping_country_field.prepend("<option value=''>"+$.translator.t("country_prompt")+"</option>")
installation_country_field.prepend("<option value=''>"+$.translator.t("country_prompt")+"</option>")
product_family_field.prepend("<option value=''>"+$.translator.t("product_family_prompt")+"</option>")
product_category_field.prepend("<option value=''>"+$.translator.t("product_category_prompt")+"</option>")
if(country_field.exists())
makeSublist(country_field,state_field,true,$.translator.t("state_prompt"));if(billing_country_field.exists())
makeSublist(billing_country_field,billing_state_field,true,$.translator.t("state_prompt"));if(shipping_country_field.exists())
makeSublist(shipping_country_field,shipping_state_field,true,$.translator.t("state_prompt"));if(installation_country_field.exists())
makeSublist(installation_country_field,installation_state_field,true,$.translator.t("state_prompt"));if(product_category_field.exists()){makeSublist(product_category_field,product_family_field,true,$.translator.t("product_family_prompt"));$("option:first[value='']",product_family_field).remove();}
if(product_family_field.exists())
makeSublist(product_family_field,product_field,true,$.translator.t("product_prompt"));if(!product_category_field.exists()&&!product_family_field.exists()){product_field.prepend("<option value=''>"+$.translator.t("product_prompt")+"</option>");if(!$("option#preselect",product_field).length){$("option:first",product_field).attr('selected','selected');}}
if(!$.cim){if(billing_country_field.exists()&&card_type_field.exists()){makeSublist(billing_country_field,card_type_field,false,'');}}});function getRegistriaData()
{return $('.registria_field, #recaptcha_response_field, #recaptcha_challenge_field');}
$.validator.addMethod("regex",function(value,element,regexp){var check=false;var mod="";if(regexp.charAt(0)=="/"){var tokens=regexp.split("/");tokens.shift();mod=tokens.pop();regexp=tokens.join("/");}
var re=new RegExp(regexp,mod);return this.optional(element)||re.test(value)},"Please check your input.");$.validator.addMethod("checksum",function(value,element){var lookup="0123456789abcdefghjklmnprstuvwxy";serial=value.toLowerCase();checksum=lookup.indexOf(serial.slice(7,8));newSerial=serial.slice(0,7).concat(serial.slice(8));total=0;for(i=0;i<newSerial.length;i++){v=newSerial.charAt(i);var multipler=12-i;total+=(lookup.indexOf(v)*multipler);}
return this.optional(element)||checksum==(total%32);},"Invalid serial number");jQuery.fn.toggleValidations==function(){var element=jQuery(this);if(element.rules().length>0){element.removeValidations();}
else{element.restoreValidations();}}
jQuery.fn.removeValidations=function(){var element=jQuery(this);element.data("stored_validations",element.rules());element.rules("remove");}
jQuery.fn.restoreValidations=function(){var element=jQuery(this);var validations=element.data("stored_validations");if(validations!=undefined)
element.rules("add",validations);}
$(window).load(function(){var fbInit=function(){var target="/xd_receiver";if($.secure)
target+="_ssl";target+=".html"
FB.init($.fbkey,target,{permsToRequestOnConnect:"email"});$('#fb-login').live('click',function(){$('#fb-login').unbind();$.each(["_expires","_session_key","_ss","_user",""],function(){$.cookie($.fbkey+this,null);});FB.Connect.requireSession(function(){var uid=FB.Facebook.apiClient.get_session().uid;FB.Facebook.apiClient.users_getInfo([uid],['email'],function(results,ex){$.ajax({url:'/fb_select/'+uid,type:'POST',dataType:'script',data:"email="+results[0]['email']});});},function(){});});$fbinitialized=true;};$fbinitialized=false;var head=document.getElementsByTagName("head")[0];var script=document.createElement('script');script.type='text/javascript';if($.secure)
script.src='https://ssl.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php';else
script.src='http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php';script.onload=fbInit;script.onreadystatechange=function(){if(!$fbinitialized&&(this.readyState=='loaded'||this.readyState=='complete'))fbInit();}
head.appendChild(script);$('#fb-disconnect').live('click',function(){$('#fb-disconnect').unbind();$.ajax({url:'/fb_disconnect',type:'POST',dataType:'script'});});});
