if(typeof window.GoogleAnalytics==="undefined"){window.GoogleAnalytics={}}(function(a){a.extend(window.GoogleAnalytics,(function(){function e(){var i=window.TradeMe.Environment;f(g(i));var j=document.createElement("script");j.type="text/javascript";j.async=true;j.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var k=document.getElementsByTagName("script")[0];k.parentNode.insertBefore(j,k)}function g(i){return[["_setAccount",d(i)],["_setDomainName",c(i)],["_setCampaignCookieTimeout",2592000000],["_addIgnoredRef","www."+c(i)],["_setSampleRate","25"]]}function c(i){return i!="Sandbox"?"trademe.co.nz":"tmsandbox.co.nz"}function d(i){var j=null;switch(i){case"Development":j="UA-10222729-4";break;case"Test":case"Stage":j="UA-10222729-3";break;case"Sandbox":j="UA-24602301-1";break;case"Production":j="UA-10222729-2";break;default:throw ("EnvironmentType does not have a corresponding Google Analytics tracking code.")}return j}function h(j,i){if(typeof(console)!=="undefined"&&typeof(window.TradeMe)==="object"&&typeof(window.TradeMe.IsAdmin)==="boolean"&&window.TradeMe.IsAdmin===true){console.log(j,i)}}function f(i){if(window._gaq){window._gaq.push.apply(window._gaq,i)}else{window._gaq=i}h("Gaq Commands: ",i)}function b(k,i){var j=[],m=null;for(m in k){var l=k[m];j.push(i(l))}return j}return{Log:h,Init:e,CreateCommands:b,PushCommands:f}})())})(jQuery);if(typeof window.GoogleAnalytics.VirtualURLs==="undefined"){window.GoogleAnalytics.VirtualURLs={}}(function(a){a.extend(window.GoogleAnalytics.VirtualURLs,(function(){function d(){var n=2,m=window.TradeMe.BreadCrumbs,l=!!m?m.split("|"):[],o=window.GoogleAnalytics.VirtualURLs.OnLoadURL;j(o,l);a(function(){k(l)})}function b(l){if(typeof l==="undefined"){throw"Undefined argument exception: breadCrumbs"}if(l.length===0){throw"Zero breadCrumbs Exception"}var m=l.slice(0,c(l));return a.map(m,function(o){var n=o.toLowerCase();n=f(n);n=i(n);n=g(n);n=h(n);return encodeURIComponent(n)}).join("/")}function i(l){return l.replace(/[^a-zA-Z]+/g,"-")}function f(l){return l.replace(/&amp;/g,"and")}function g(l){return l.replace(/-and-/g,"-")}function h(l){return l.replace(/-apos-s-/g,"-")}function c(l){if(!l){throw"Null argument exception: breadCrumbs"}if(l.length===0){throw"Array length of zero exception: breadCrumbs"}l=a.map(l,function(o){if(typeof o!=="string"){throw"Element must be string exception: breadCrumbs, item"}return o.toLowerCase()});var n={"trade me jobs":2,"trade me motors":{"boats & marine":3,"caravans & motorhomes":3,motorbikes:{"helmets, clothing & footwear":4,"parts for sale":4,"default":3},"default":2},"trade me property":{"residential property":{"houses for sale":4,"houses to rent":4,"default":3},"commercial property":{"commercial property for sale":4,"commercial property for lease":4,"default":3},"default":2},"default":2};function m(p,o){if(typeof p==="number"){return p}if(o.length===0){return p["default"]}if(o[0] in p){return m(p[o[0]],o.slice(1,o.length))}return p["default"]}return m(n,l)}function j(m,l){if(typeof m==="string"&&m.length>0){window.GoogleAnalytics.PushCommands([["_trackPageview",e(m,l)]])}else{window.GoogleAnalytics.PushCommands([["_trackPageview"]])}}function e(m,l){if(typeof m!=="string"){throw"Argument has invalid type: virtualURLTemplate; found: "+typeof m+" expected: string"}if(!a.isArray(l)){throw"Argument has invalid type: breadCrumbs; found: "+typeof l+" expected: array"}return a.tmpl(m,{Path:b(l)}).text()}function k(l){var m=window.GoogleAnalytics.VirtualURLs.OnClickURLs;function n(o){return function(){var p=["_trackPageview",e(o,l)];window._gaq.push(p);window.GoogleAnalytics.Log("Gaq mousedown: ",p)}}a.each(m,function(o,p){a(p.cssSelector).bind("mousedown",n(p.VirtualURL))})}return{Init:d}}()))}(jQuery));if(typeof window.GoogleAnalytics.CustomVariables==="undefined"){window.GoogleAnalytics.CustomVariables={}}(function(a){a.extend(window.GoogleAnalytics.CustomVariables,(function(){var g=window.GoogleAnalytics.PushCommands,f=window.GoogleAnalytics.Log,b=window.GoogleAnalytics.CreateCommands;function e(){var i=window.GoogleAnalytics.CustomVariables.OnLoadData,h=window.GoogleAnalytics.CustomVariables.OnClickData;if(i!==null&&i.length>0){g(b(i,d))}a(function(){c(h)})}function d(h){return["_setCustomVar",h.Index,h.Name,h.Value,h.OptScope]}function c(i){function h(j){return function(){var k=d(j);g([k])}}a.each(i,function(k,j){a(j.cssSelector).live("mousedown",h(j))})}return{Init:e}})())})(jQuery);if(typeof window.GoogleAnalytics.Ecommerce==="undefined"){window.GoogleAnalytics.Ecommerce={}}(function(a){a.extend(window.GoogleAnalytics.Ecommerce,(function(){var h=window.GoogleAnalytics.PushCommands,g=window.GoogleAnalytics.Log,d=window.GoogleAnalytics.CreateCommands;function f(){var l=window.GoogleAnalytics.Ecommerce.Transaction,i=window.GoogleAnalytics.Ecommerce.Items,k=window.GoogleAnalytics.Ecommerce.OnClickTransaction,j=window.GoogleAnalytics.Ecommerce.OnClickItems;if(l!==null){h([c(l)]);h(d(i,b));h([["_trackTrans"]])}if(k!==null){a(function(){e(k,j)})}}function e(j,i){a(j.cssSelector).live("mousedown",function(){h([c(j)]);h(d(i,b));h([["_trackTrans"]]);g(window._gaq)})}function c(i){return["_addTrans",i.OrderID,i.StoreName,i.Total,i.Tax,i.Shipping,i.City,i.State,i.Country]}function b(i){return["_addItem",i.OrderID,i.SKU,i.ProductName,i.Category,i.UnitPrice,i.Quantity]}return{Init:f}})())})(jQuery);
