text: (function(d,b,a,f){var c="ProfileWidget",e={username:null,clientID:null};function g(i,h){this.element=i;this.settings=d.extend({},e,h);this._defaults=e;this._name=c;this.apiurl="https://api.instagram.com/v1/",this.userID=null,this.pictures=[],this.init()}g.prototype={init:function(){if((this.settings.username!==null)&&(this.settings.clientID!==null)){d(this.element).addClass("insta-profile-widget").append('<div class="insta-profile-details"><div class="insta-profile-icon"></div><h1 class="insta-profile-username"></h1></div><div class="insta-profile-images"><div class="insta-profile-cell insta-profile-picture-slot"></div></div><div class="insta-profile-stats"><div class="insta-profile-stat"><strong></strong>Photos</div><div class="insta-profile-divider"></div><div class="insta-profile-stat"><strong></strong>Followers</div><a href="#" class="insta-profile-btn">View Profile</a></div>').find(".insta-profile-cell:nth-child(3n)").addClass("first");this.sendRequest("users/search",{q:this.settings.username},this.callbackUsername)}else{alert("Username and ClientID must be supplied")}},callbackImages:function(k,l){d.each(k.data,function(m,n){l.pictures.push(n.images.low_resolution.url)});var j=l.pictures.slice(0);var h=1;var i=d(l.element).find(".insta-profile-picture-slot");i.each(function(){if(h<=l.pictures.length){var n=Math.floor((Math.random()*j.length));var o=j[n];j.splice(n,1);var m=i.index(d(this));setTimeout(function(){l.fadeImage(m,o)},200*h);h++}});if(l.pictures.length>1){setInterval(function(){var m=l.pictures.slice(0);i.each(function(){m.splice(m.indexOf(d(this).data("bg")),1)});var o=Math.floor((Math.random()*1));var n=m[Math.floor((Math.random()*m.length))];l.fadeImage(o,n)},5000)}},callbackUserStats:function(h,i){d(i.element).find(".insta-profile-stat:eq(0) strong").text(h.data.counts.media.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","));d(i.element).find(".insta-profile-stat:eq(1) strong").text(h.data.counts.followed_by.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","));i.sendRequest("users/"+i.userID+"/media/recent/",{count:18},i.callbackImages)},callbackUsername:function(h,i){if(h.data.length>0){i.userID=h.data[0].id;d(i.element).find(".insta-profile-username").text(h.data[0].username);d(i.element).find(".insta-profile-avatar").append('<a href="https://instagram.com/'+h.data[0].username+'"><img src="'+h.data[0].profile_picture+'"></a>');d(i.element).find(".insta-profile-btn").attr("href","https://instagram.com/"+h.data[0].username);i.sendRequest("users/"+i.userID+"/",{},i.callbackUserStats)}else{alert("No user was found")}},sendRequest:function(h,j,k){j.client_id=this.settings.clientID;var i=this;d.ajax({method:"GET",url:this.apiurl+h,data:j,dataType:"jsonp",success:function(l){k(l,i)},error:function(l,n,m){console.log(l);console.log(n);console.log(m)}})},fadeImage:function(h,j){var i=d('<div class="insta-profile-cell-image" style="background-image: url('+j+');"></div>');d(this.element).find(".insta-profile-picture-slot:eq("+h+")").append(i).children(".insta-profile-cell-image").fadeIn(500,function(){d(this).parent().css("background-image","url("+j+")").data("bg",j);d(this).remove()})},destroy:function(){}};d.fn[c]=function(i){var h=arguments;if(i===f||typeof i==="object"){return this.each(function(){if(!d.data(this,"plugin_"+c)){d.data(this,"plugin_"+c,new g(this,i))}})}else{if(typeof i==="string"&&i[0]!=="_"&&i!=="init"){var j;this.each(function(){var k=d.data(this,"plugin_"+c);if(k instanceof g&&typeof k[i]==="function"){j=k[i].apply(k,Array.prototype.slice.call(h,1))}if(i==="destroy"){d.data(this,"plugin_"+c,null)}});return j!==f?j:this}}}})(jQuery,window,document);
  