/*
           ___
          /__/|       ___
         |  |:|      /  /\
         |  |:|     /  /:/
       __|  |:|    /__/::\
      /__/\_|:|____\__\/\:\__     KISSinsights
      \  \:\/:::::/   \  \:\/\    (C) 2010. All rights reserved.
       \  \::/~~~~     \__\::/
        \  \:\         /__/:/
         \  \:\        \__\/
          \__\/
*/

var KI_Loader=function(){var a={options:{bucket:'j.kissinsights.com',response_bucket:'r.kissinsights.com',bucket_version:"1.0",loader_id:"ki_loader",loader_id_sio:"sio_loader"},has_km:false,use_ssl:false,user:{},logger:null,initialize:function(){if(document.location.protocol.toLowerCase().indexOf("https")!=-1){this.use_ssl=true}this.options=((typeof KI_LOADER_OPTIONS_OVERRIDE!="undefined")?KI_LOADER_OPTIONS_OVERRIDE:this.options);this.load_event(function(){if(typeof KM!="undefined"){a.has_km=true}var b=a.match_site_from_loader();if(b){a.load_site(b)}});return this},log:function(c,b){try{__ki_log_handler(c,b)}catch(d){}},url:function(d){var b=true;if(this.use_ssl){var c="https://s3.amazonaws.com/"+this.options.bucket}else{var c="http://"+this.options.bucket}if(typeof KI_URL_OVERRIDE!="undefined"){var c=KI_URL_OVERRIDE}c+="/"+this.options.bucket_version;switch(d.toLowerCase()){case"site":c+="/sites/"+arguments[1]+".js";break;case"survey":c+="/surveys/"+arguments[1]+".js";break;case"images":var b=false;c+="/images/";if(arguments[1]){c+=arguments[1]}break}if(b){c+="?"+this.date_slug()}return c},km_record:function(c,b){if(this.has_km&&typeof KI_Controller!="undefined"&&KI_Controller.match.km){KM.record(c,b)}},match_site_from_loader:function(){var c=document.getElementById(this.options.loader_id);if(!c){var c=document.getElementById(this.options.loader_id_sio)}if(c){var b=c.src.match(/site=(.*)/);b=(b&&b[1])?b[1].split("&")[0]:null;if(b){return b}}},load_site:function(c){var b=document.createElement("script");b.type="text/javascript";b.src=this.url("site",c);document.body.appendChild(b)},identify:function(b){this.user.identity=b},date_slug:function(){var b=new Date();if(typeof KI_DEV!="undefined"){return b.getTime()}else{return[b.getFullYear(),b.getMonth()+1,b.getDate(),b.getHours()].join("")+"-"+(5*Math.floor(b.getMinutes()/5))}},load_event:function(b){var c=window.onload;if(typeof window.onload!="function"){window.onload=b}else{window.onload=function(){if(c){c()}b()}}},merge:function(){var b={},f=arguments.length,c=null,e=null;if(f<2){return arguments[0]}for(var d=0;d<f;++d){c=arguments[d];for(var e in c){if(!c.hasOwnProperty(e)){continue}b[e]=c[e]}}return b}};return a.initialize()};var KI=new KI_Loader();var SIO={};SIO.identify=function(a){KI.identify(a)};
