/**
 * TweetPhoto - http://tweetphoto.com
 * Copyright (C) 2010 TweetPhoto
 * Author: John Eisberg (john@tweetphoto.com)
 *
 * V 2.0 TweetPhoto photo widget
 * http://tweetphoto.com/widget
 */
var TPprofileJSON=null;var TPphotoJSON=null;var TPretry=0;var TPretries=10;var TPcolor=null;function TPinit(user_id,count,color){TPcolor=color;TPjsonpSearch('http://api.tweetphoto.com/api/TPAPI.svc/jsonp/users/'+user_id+'?','TPhandleProfileData',0);TPjsonpSearch('http://api.tweetphoto.com/api/TPAPI.svc/jsonp/users/'+user_id+'/photos?ps='+count,'TPhandlePhotoData',1);TPrender();}function TPjsonpSearch(url,callback,index){var head=document.getElementsByTagName('head');var scriptElement=document.createElement('script');scriptElement.type='text/javascript';scriptElement.src=url+'&callback='+callback;scriptElement.id='TPjsonp_'+index;head[0].appendChild(scriptElement);}function TPhandleProfileData(data){TPprofileJSON=data;}function TPhandlePhotoData(data){TPphotoJSON=data;}function TPclean(index){var script=document.getElementById('TPjsonp_'+index);if(script){for(var property in script){if(property){delete script[property];}}var parent=script.parentNode;for(i=0;i<parent.children.length;i++){if(parent.children[i].id=='TPjsonp_'+index){delete parent.children[i];}}}}function TPrender(){if(TPprofileJSON&&TPphotoJSON){TPdraw(TPprofileJSON,TPphotoJSON);}else{if(TPretry++<TPretries){setTimeout('TPrender()',1000);}}}function TPdraw(profileData,photoData){var widget=document.getElementById('TPwidget');var widgetHtml='<div style="width:160px;font-size:12px;color:#333333;font-family:Arial,Helvetica,Sans-Serif;line-height:1.231em;"><div style="height:32px;padding:5px;background-color:'+TPcolor+';">';widgetHtml+='<span style="float:left;"><a href="http://tweetphoto.com/user/'+profileData.Id+'" target="_blank" id="avatar">';widgetHtml+='<img align="top" alt="" src="'+profileData.ProfileImage+'" style="height:32px;width:32px;border:none;"/>';widgetHtml+='</a></span><span style="float:right;padding-top:6px;">';widgetHtml+='<a href="http://tweetphoto.com/user/'+profileData.Id+'" target="_blank" id="screenname" style="color:#3399DD;text-decoration:none;">@'+profileData.ScreenName+'</a>';widgetHtml+='</span><span style="clear:both"></span></div>';widgetHtml+='<div style="border-right-style:solid;border-right-width:3px;border-left-style:solid;border-left-width:3px;padding:5px 5px 1px 5px;border-left-color:'+TPcolor+';border-right-color:'+TPcolor+';">';widgetHtml+='<ul style="position:relative;margin:0px;padding:0px;list-style-image:none !important;list-style-position:outside !important;list-style-type:none !important;overflow:hidden !important;">';var photos=photoData.List;for(i=0;i<photos.length;i++){if((i%2)==0){widgetHtml+=TPinsertPhoto(photos[i],false);}else{widgetHtml+=TPinsertPhoto(photos[i],true);}}widgetHtml+='</ul>';widgetHtml+='</div><div style="height:17px;padding:6px;text-align:center;background-color:'+TPcolor+';">Powered by <a href="http://tweetphoto.com" target="_blank" style="color:#3399DD;text-decoration:none;">TweetPhoto</a></div></div>';widget.innerHTML=widgetHtml;}function TPinsertPhoto(photo,odd){var li='<li';if(odd){li=li+' style="padding:0px 0px 6px 0px;float:left;margin:0px;position:relative;">';}else{li=li+' style="float:left;padding:0px 6px 6px 0px;margin:0px;position:relative;">';}return li+'<a href="http://tweetphoto.com/'+photo['Id']+'" target="_blank"><img style="height:69px;width:69px;border:none;" align="top" alt="" src="'+photo['ThumbnailUrl']+'"/></a></li>';}