// www.PressDisplay.com
// � 2003-2008 NewspaperDirect, Inc. All rights reserved.

Newspapers={pageview_page:"",issue_page:"",category:"",categoryname:"",current:0,currurl:0,w:0,cols:0,html:[],html_list:[],imageurls:[],imagedir:window.NDImagesUrl||"images/",addIssueDatesToMenu:false,Init:function(newspapers,columns){var t=this;t.current=0;t.currurl=0;t.w=pdcore.bodyWidth()-230;t.cols=Math.max(1,Math.floor(t.w/230));newspapers=Math.max(newspapers,1);if(columns&&columns>0)
t.cols=columns;else
t.cols=Math.ceil(newspapers/Math.ceil(newspapers/t.cols));t.html=[];t.html_list=[];},AddIssue:function(issue,issuedate,newspaper,scale,smart,issue_smart,has_sections,backgroundColor){var t=this;var resSmartNavigationSupported=ResourceManager.getVal("SmartNavigationSupported");if(!backgroundColor)
backgroundColor="#FFF";var url=t.GetURL(issue,has_sections);t.html_list.push("<div class=folder3_lev2><a href='"+url+"' "+(smart?" title='"+resSmartNavigationSupported+"' ":"")+"> "+(smart?"<img src='"+t.imagedir+"i_smart.gif' border=0 align=absmiddle>":"")+newspaper);if(t.addIssueDatesToMenu)t.html_list.push("<br>"+issuedate);t.html_list.push("</a></DIV>");if(t.current==0){t.html.push("<TR><TD><img src='"+t.imagedir+"/1x1.gif'></TD>");}
t.current++;t.html.push("<TD WIDTH=208 valign=top align=center><TABLE class='"+(issue_smart?"paper_smart":"paper")+"' BORDER=0 CELLPADDING=0 CELLSPACING=0 style='cursor: "+pdcore.cursors.hand+";' onclick='Newspapers."+(!has_sections?"ShowNewspaper":"ShowSections")+"(\""+issue+"\");'>");t.html.push("<TR><TD class=paper_01 COLSPAN=3><IMG SRC='"+t.imagedir+"1x1.gif' ></TD></TR>");t.html.push("<TR><TD class=paper_02><IMG SRC='"+t.imagedir+"1x1.gif'></TD>");t.html.push("<TD class=paper_03 style='background-color:"+backgroundColor+";'><DIV><IMG WIDTH=180 src='"+t.GetImageURL(issue,scale)+"' onerror='Newspapers.onerror(this)' onabort='Newspapers.onabort(this)' tooltipId='newspapers.thumbnail'></DIV></TD>");t.html.push("<TD class=paper_04><IMG SRC='"+t.imagedir+"1x1.gif'></TD></TR>");t.html.push("<TR><TD class='paper_05' COLSPAN='3'"+(issue_smart?" title='"+resSmartNavigationSupported+"'":"")+"><IMG SRC='"+t.imagedir+"1x1.gif' ></TD></TR>");t.html.push("</TABLE>");t.html.push("<a class=paper_title href='"+url+"'>"+newspaper+"</a><br><a class=paper_date href='"+url+"'>"+issuedate+"</a></TD><TD><img src='"+t.imagedir+"/1x1.gif'></TD>");if(t.current==t.cols){t.html.push("</TR><TR><TD><img src='"+t.imagedir+"/1x1.gif'></TD></TR>");t.current=0;}},AddNewspaperIssue:function(issue,issuedate,newspaper,scale,smart,issue_smart,has_sections,backgroundColor){var t=this;var resSmartNavigationSupported=ResourceManager.getVal("SmartNavigationSupported");if(!backgroundColor)
backgroundColor="#FFF";var url=t.GetURL(issue,has_sections);var issue_url=t.GetIssueURL(issue,has_sections);t.html_list.push("<div class=folder3_lev2><a href='"+url+"' "+(smart?" title='"+resSmartNavigationSupported+"' ":"")+"> "+(smart?"<img src='"+t.imagedir+"i_smart.gif' border=0 align=absmiddle>":"")+newspaper);if(t.addIssueDatesToMenu)t.html_list.push("<br>"+issuedate);t.html_list.push("</a></DIV>");if(t.current==0){t.html.push("<TR><TD><img src='"+t.imagedir+"/1x1.gif'></TD>");}
t.current++;t.html.push("<TD WIDTH=208 valign=top align=center><TABLE class='"+(issue_smart?"paper_smart":"paper")+"' BORDER=0 CELLPADDING=0 CELLSPACING=0 style='cursor: "+pdcore.cursors.hand+";' onclick='Newspapers."+(!has_sections?"ShowIssue":"ShowIssue")+"(\""+issue+"\");'>");t.html.push("<TR><TD class=paper_01 COLSPAN=3><IMG SRC='"+t.imagedir+"1x1.gif' ></TD></TR>");t.html.push("<TR><TD class=paper_02><IMG SRC='"+t.imagedir+"1x1.gif'></TD>");t.html.push("<TD class=paper_03 style='background-color:"+backgroundColor+";'><DIV><IMG WIDTH=180 src='"+t.GetImageURL(issue,scale)+"' onerror='Newspapers.onerror(this)' onabort='Newspapers.onabort(this)' tooltipId='newspapers.thumbnail'></DIV></TD>");t.html.push("<TD class=paper_04><IMG SRC='"+t.imagedir+"1x1.gif'></TD></TR>");t.html.push("<TR><TD class='paper_05' COLSPAN='3'"+(issue_smart?" title='"+resSmartNavigationSupported+"'":"")+"><IMG SRC='"+t.imagedir+"1x1.gif' ></TD></TR>");t.html.push("</TABLE>");t.html.push("<a class=paper_title href='"+issue_url+"'>"+newspaper+"</a><br><a class=paper_date href='"+issue_url+"'>"+issuedate+"</a></TD><TD><img src='"+t.imagedir+"/1x1.gif'></TD>");if(t.current==t.cols){t.html.push("</TR><TR><TD><img src='"+t.imagedir+"/1x1.gif'></TD></TR>");t.current=0;}},GetThumbnailsHtml:function(){if(this.html)
return"<table width='100%' border=0 cellspacing=0 cellpadding=0>"+this.html.join("")+"</table>";this.html=null;},WriteThumbnails:function(id){var el=document.getElementById(id);if(el)el.innerHTML=this.GetThumbnailsHtml();},GetMenuHtml:function(){if(this.html_list)
return"<div class=folder_fld_lev1>"+this.categoryname+"</div>"+this.html_list.join("");this.html_list=null;},WriteMenu:function(id){var el=document.getElementById(id);if(el)el.innerHTML=this.GetMenuHtml();},WriteTitle:function(id){var el=document.getElementById(id);if(el)el.innerHTML=this.categoryname;},onerror:function(img){if(img&&!(img.inerror==true)&&(img.num!=5)){img.inerror=true;if(!img.num)img.num=0;img.num++;img.src=img.src+"&"+img.num;img.inerror=false;}},onabort:function(){},GetImageURL:function(issue,scale){var t=this;if(t.currurl>=t.imageurls.length)t.currurl=0;var url=t.imageurls[t.currurl]+"?file="+issue+"&page="+1+"&scale="+scale;t.currurl++;return url;},GetURL:function(issue,has_sections){if(has_sections)
return'javascript:Newspapers.ShowSections("'+issue+'");';else
return'javascript:Newspapers.ShowNewspaper("'+issue+'");';},GetIssueURL:function(issue,has_sections){return'javascript:Newspapers.ShowIssue("'+issue+'");';},ShowNewspaper:function(issue){var tmp=this.pageview_page.split('?');var url=tmp[0]+"?issue="+issue;if(this.category)url+="&category="+this.category+"&categoryname="+this.categoryname;window.location=url;},ShowIssue:function(issue){var url=this.issue_page+"?issue="+issue;if(this.category)
url+="&category="+this.category+"&categoryname="+this.categoryname;window.location=url;},ShowSections:function(issue){var url=this.sectionsview_page+"?cid="+issue.substring(0,4);window.location=url;}}