function diggAsylum(count,domain,endPoint,htmlId,showDesc,sortType){this.count=count;this.domain=domain;this.htmlId=htmlId;this.showDesc=showDesc;this.endPoint=endPoint;if(this.sortType==null||this.sortType!="asc"){this.sortType="desc";}
else{this.sortType=sortType;}
if(showDesc==null){this.showDesc=false;}
this.createScript();}
diggAsylum.prototype.createScript=function(){var s=this.mkeEl("script");s.setAttribute('src',this.buildURL());s.setAttribute('type','text/javascript');var h=document.getElementsByTagName('head');h[0].appendChild(s);}
diggAsylum.prototype.buildURL=function(){var method=this;function wrapperFunc(obj){method.returnDataHandler(obj);}
var rand=Math.ceil(Math.random()*100000000000);window['DiggAsylumCallback'+rand]=wrapperFunc;var urlBase="http://digg.com/tools/services?type=javascript&callback=DiggAsylumCallback"+rand+"&endPoint="+this.endPoint+"&domain="+this.domain+"&sort=promote_date-"+this.sortType+"&count="+this.count;return urlBase;}
diggAsylum.prototype.returnDataHandler=function(obj){this.data=obj;this.createHTML();}
diggAsylum.prototype.createHTML=function(){try{var l=this.data.stories.length;var elemArray=[];for(var i=0;i<l;i++)
{var s=this.data.stories[i];if(this.data.stories[i].thumbnail){var img=this.buildImg(s.href+"/a.jpg","digg_thumb");}else{var img=this.buildImg("http://coedmediagroup.com/digg/c_icon.png","digg_thumb");}
var a=this.buildLink(s.href);var dDiv=this.buildTxtEl('div',s.diggs,'digg_count');var dInfo=this.buildTxtEl('div','','digg_info');var hed=this.buildTxtEl('h4',s.title,'digg_sing_hedr');a.appendChild(dDiv);a.appendChild(img);dInfo.appendChild(hed);if(this.showDesc){dInfo.appendChild(this.buildTxtEl('p',s.description,'digg_sing_desc'));}
a.appendChild(dInfo);elemArray[elemArray.length]=a;}
this.getEl(this.htmlId).appendChild(this.assemble(elemArray));}
catch(e){}}
diggAsylum.prototype.buildImg=function(thumbUrl,className){var img=this.mkeEl('img');img.src=thumbUrl;img.width=30;img.height=30;img.className=className;img.border=0;return img;}
diggAsylum.prototype.buildLink=function(url){var a=this.mkeEl('a');a.href=url;return a;}
diggAsylum.prototype.assemble=function(elemArray){var ul=this.mkeEl('ul');ul.className="digg_sing_list"
for(var i=0;i<elemArray.length;i++){var li=this.mkeEl('li');li.appendChild(elemArray[i]);ul.appendChild(li);}
return ul;}
diggAsylum.prototype.getEl=function(id){return document.getElementById(id);}
diggAsylum.prototype.mkeEl=function(tagName){return document.createElement(tagName);}
diggAsylum.prototype.buildTxtEl=function(elemType,txt,className,id){var elem=this.mkeEl(elemType);if(className!=null&&className!=''){elem.className=className;}
if(id!=null&&id!=''){elem.id=id;}
if(txt!=null&&txt!=''){elem.innerHTML=txt;}
return elem;}