var GigparkBlogWidget=(function(){function t(a,b){var c=new Element('div',{className:'row'});c.insert((new Element('div',{className:'form-label'})).insert((new Element('label')).update(b)));c.insert((new Element('div',{className:'field'})).update(a));c.insert(new Element('div',{className:'clear'}));return c}function o(a){if(!a||!a.parentNode)return false;var b=a.parentNode;if(typeof b=="undefined")return false;else if((/head/i).test(a.tagName))return true;else return o(b)}function j(a,b){for(var c in b)a[c]=b[c];return a}function q(a,b){if(!b)b=document.getElementsByTagName("body")[0];var c=[];var f=new RegExp('\\b'+a+'\\b');var h=b.getElementsByTagName("*");for(var d=0,i=h.length;d<i;d++)if(f.test(h[d].className))c.push(h[d]);return c}function u(a){if(window.console&&window.console.log)console.log(a);else alert(a)}function m(n,k){var r=/{[\w\[\]']+?}/mig;var s=/\[[\w']+?\]/i;return n.replace(r,function(a,b){var c=a.replace(/({|})/g,'');try{if(s.test(c)){var f=/\['([\w]+?)'\]/ig;var h=[];var d=k[c.match(/\w+/)[0]];var i;while(i=f.exec(c))h.push(i[1]);for(var l=0;l<h.length;l++)d=d[h[l]];return d}else return k[c].toString()}catch(e){throw(new Error('[GigPark] Cannot find template variable: {'+c+'}.'));}});}function g(a,b){if(b)this.script=b;else{this.script=g.script;if(o(this.script)){return null;}}this.options={};this.options=j(this.options,g.options);this.options=j(this.options,a||{});if(this.script!=b&&typeof b=="undefined")this.options=j(this.options,this.getScriptParams());this.target=this.generateTarget();this.loadJSONP();}g._1=0;g.options={text_colour:'4D4D4D',link_colour:'3366CC',limit:5,design_mode:'remote',widget_type:'business',url:{user:'http://www.gigpark.com/people/{string_id}/recommendations.json?callback={callback}',business:'http://www.gigpark.com/businesses/{string_id}/recommendations.json?callback={callback}'}};var p=document.getElementsByTagName('script');g.script=p[p.length-1];g.prototype={getScriptParams:function(){var a={};var b=this.script.src.split(/\?/)[1].split(/&/);for(var c=0;c<b.length;c++){var f=b[c].split(/=/);a[f[0]]=f[1]||false;}return a;},generateTarget:function(){if(this.target)return this.target;else{if(this.options.design_mode=="remote"){var a=document.createElement('iframe');a.setAttribute('id',"gpbw-iframe-"+ ++g._1);a.setAttribute('frameBorder',"0");a.setAttribute('scrolling',"no");a.setAttribute('allowTransparency',"true");a.style.height="14px";a.style.width="100%";if(this.script.nextSibling)this.script.parentNode.insertBefore(a,this.script.nextSibling);else this.script.parentNode.appendChild(a);var b=null;if(a.contentDocument)b=a.contentDocument;else if(a.contentWindow)b=a.contentWindow.document;else if(a.document)b=a.document;else throw(new Error("[GigPark Blog Widget] Cannot access iframe document."));var c=frames[a.getAttribute('id')]||a.contentWindow;b.write(m(g.templates.remote_design_template,this.options));b.body.style.backgroundColor="transparent";b.close();var f=q('gigpark-blog-widget',b.body)[0];this.target={'element':f,'container':a,'window':c,'document':b};}else{var f=document.createElement('div');f.className="gigpark-blog-widget";f.innerHTML='<p class="loading">Loading</p>';if(this.script.nextSibling)this.script.parentNode.insertBefore(f,this.script.nextSibling);else this.script.parentNode.appendChild(f);this.target={'element':f,'container':f,'window':window,'document':document};}return this.target;}},loadJSONP:function(){var a='gpbwHandler';var b=this;this.target['window'][a]=function(){b._2.apply(b,arguments);};var c=this.target['document'].createElement('script');c.type='text/javascript';c.src=m(this.options.url[this.options.widget_type],j({callback:a},this.options));this.target['document'].getElementsByTagName('head')[0].appendChild(c);},_2:function(a){var b="";var c=a.recommendations||[a.recommendation];var f=c.length>this.options.limit?this.options.limit:c.length;var h=this.options.widget_type=="business"?80:50;if(f>0){for(var d=0;d<f;d++){var i=c[d]['comment']==""?c[d]['user']['abbr_name']+' recommends '+c[d]['name']:c[d]['comment'];if(i.length>h)i=i.substring(0,h-3)+"...";var l=j({quote:i},c[d]);b+=m(g.templates[this.options.widget_type].recommendation,l);}}else b=g.templates[this.options.widget_type].blank;b=m(g.templates[this.options.widget_type].shell,j({'content':b},this.options));this.target['element'].innerHTML=b;if(this.options.design_mode=="remote"){var n=this.target['element'].offsetWidth-40;for(var d=0,k=this.target['element'].getElementsByTagName('blockquote');d<k.length;d++){k[d].style.width=n+'px';}this.target['container'].style.height=this.target['element'].offsetHeight+'px';}}};return g;})();GigparkBlogWidget.templates={remote_design_template:'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">     <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">       <head>         <title>           GigPark Widget         </title>         <meta content="application/xhtml+xml; charset=utf-8" http-equiv="Content-Type" />         <meta content="GigPark is a place to find services with the help of your friends." name="description" />         <link href="http://www.gigpark.com/stylesheets/tripoli/reset.css" media="screen" rel="stylesheet" type="text/css" />         <link href="http://www.gigpark.com/stylesheets/tripoli/generic.css" media="screen" rel="stylesheet" type="text/css" />         <!--[if IE]>            <link href="http://www.gigpark.com/stylesheets/tripoli/ie.css" media="screen" rel="stylesheet" type="text/css" />         <![endif]-->         <link href="http://www.gigpark.com/stylesheets/tripoli/print.css" media="print" rel="stylesheet" type="text/css" />         <link href="http://www.gigpark.com/stylesheets/extra/widget.css" media="screen" rel="stylesheet" type="text/css" />         <style media="screen" type="text/css">           .content a:link {             color: #{link_colour}}           .content a:visited {             color: #{link_colour}}           .content a:hover {             color: #{link_colour}}           .content a:active {             color: #{link_colour}}           #widget, #widget ol li a {             color: #{text_colour}}         </style>       </head>       <body id="widget">         <div class="gigpark-blog-widget">           <p>Loading</p>         </div>       </body>     </html>',business:{shell:'<div class="content">         <div id="business-widget">           <h3>Testimonials</h3>           <ol>             {content}           </ol>           <p>             <a href="http://www.gigpark.com/businesses/{string_id}" title="Recommend me on GigPark" target="_0">Read more...</a>           </p>           <form method="get" target="_0" action="http://www.gigpark.com/businesses/{string_id}?recommend=true">             <input type="hidden" name="recommend" value="true" />             <input type="submit" class="submit" value="Recommend Me »" />           </form>         </div>       </div>',blank:'<li class="blank-state">         Like my work? Please take a minute to recommend me.       </li>',recommendation:'<li>         <a href="http://www.gigpark.com/recommendations/{string_id}" title="View recommendation on GigPark" target="_0">           <div class="profile-picture">             <img src="{user[\'profile_picture_small\']}" alt="Profile Pic" width="24" height="24" />           </div>           <blockquote>             <p>               <span class="title">{user[\'name\']}:</span>               &#8220;{quote}&#8221;             </p>           </blockquote>           <div class="clear"></div>         </a>       </li>'},user:{shell:'<div class="content">         <div id="business-widget">           <h3>My Recommendations</h3>           <ol>             {content}           </ol>           <p>             <a href="http://www.gigpark.com/people/{string_id}" title="See my profile on GigPark" target="_0">See more...</a>           </p>         </div>       </div>',blank:'<li class="blank-state">I haven&#39;t made any recommendations yet.</li>',recommendation:'<li>         <a href="http://www.gigpark.com/recommendations/{string_id}" title="View recommendation on GigPark" target="_0">           <div class="profile-picture">             <img src="{user[\'profile_picture_small\']}" alt="Profile Pic" width="24" height="24" />           </div>           <blockquote>             <p>               <span class="title">{service}, {name}:</span>               &#8220;{quote}&#8221;             </p>           </blockquote>           <div class="clear"></div>         </a>       </li>'}};try{new GigparkBlogWidget()}catch(e){}