// www.PressDisplay.com
// © 2003-2008 NewspaperDirect, Inc. All rights reserved.
// check for XPath implementation for Compatibility with Firefox and mozilla

if(document.implementation.hasFeature("XPath","3.0")){if(typeof(XMLDocument)!="undefined"){XMLDocument.prototype.selectNodes=function(cXPathString,xNode){if(!xNode){xNode=this;}
var oNSResolver=this.createNSResolver(this.documentElement)
var aItems=this.evaluate(cXPathString,xNode,oNSResolver,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null)
var aResult=[];for(var i=0;i<aItems.snapshotLength;i++){aResult[i]=aItems.snapshotItem(i);}
return aResult;}
XMLDocument.prototype.selectSingleNode=function(cXPathString,xNode){if(!xNode){xNode=this;}
var xItems=this.selectNodes(cXPathString,xNode);if(xItems.length>0){return xItems[0];}else{return null;}}}
if(typeof(Element)!="undefined"){Element.prototype.selectNodes=function(cXPathString){if(this.ownerDocument.selectNodes){return this.ownerDocument.selectNodes(cXPathString,this);}else{throw"For XML Elements Only";}}
Element.prototype.selectSingleNode=function(cXPathString){if(this.ownerDocument.selectSingleNode){return this.ownerDocument.selectSingleNode(cXPathString,this);}else{throw"For XML Elements Only";}}}}
var searchHeader="Search Results";var currentSubscriptionLength;var isMonitoringAvailable=false;var imagedir;var imageurls;var currurl=0;var activeMonitorCount=0;var accountAuthonteficated=false;var isSubscriptionFree=false;var accountEmail="";var loginRedirect="accountingloginregistred.aspx?returnurl="+encodeURIComponent("AdvancedSearch.aspx?monitor=true");function checkEnterKey(evt){if(pdcore.events.getKeyCode(evt)==13){AdvancedSearch_onClick();}}
function SearchDate_OnClick(flag){if(flag){pdcore.getElm(CALENDAR.tableCalendar).style.display="none";pdcore.hide(pdcore.getElm("searchDateRangeDate"));pdcore.getElm("SearchDateMenu").checked=true;pdcore.getElm("SearchDateRange").checked=false;var elm;switch(pdcore.getElm("browseDateType")){case assInstance.Instance().AdvancedSearch_dateMenuValues.Today:elm=pdcore.getElm("browseByToday");break;case assInstance.Instance().AdvancedSearch_dateMenuValues.Last3Days:elm=pdcore.getElm("browseBy3Days");break;case assInstance.Instance().AdvancedSearch_dateMenuValues.ThisWeek:elm=pdcore.getElm("browseThisWeek");break;case assInstance.Instance().AdvancedSearch_dateMenuValues.ThisMonth:elm=pdcore.getElm("browseThisMonth");break;case assInstance.Instance().AdvancedSearch_dateMenuValues.Anytime:elm=pdcore.getElm("browseSubscription");break;default:elm=pdcore.getElm("browseBy3Days");break;}
selectDateMenuItem(elm);}else{setDataFields(assInstance.Instance().AdvancedSearch_StartDate,assInstance.Instance().AdvancedSearch_StopDate);pdcore.show(pdcore.getElm("searchDateRangeDate"));pdcore.getElm("SearchDateMenu").checked=false;pdcore.getElm("SearchDateRange").checked=true;}}
function browseDateMenu_onClick(evt){SearchDate_OnClick(true);pdcore.getElm('browseDateMenu').style.display='block';pdcore.events.preventBubble(evt);}
function highlightElm(elm){if(!elm)return;elm.className="highlight";}
function retstylebackElm(elm){if(!elm)return;elm.className="";}
function showSelectedDate(elm,date){elm.value=ResourceManager.formatDate("Search.DateFormat",date,"yyyy-MM-dd");}
function setDataFields(start,stop){assInstance.Instance().AdvancedSearch_StartDate=start;showSelectedDate(pdcore.getElm("dtFrom"),start);assInstance.Instance().AdvancedSearch_StopDate=stop;showSelectedDate(pdcore.getElm("dtTo"),stop);}
function selectDateMenuItem(elm){if(elm){var spanElm=pdcore.getElm("browseDateType");spanElm.innerHTML=elm.innerHTML;var start=new Date();var stop=new Date();var stopdate=stop.getTime();stopdate+=3600*1000*24;stop.setTime(stopdate);var startdate=start.getTime();switch(elm.innerHTML){case assInstance.Instance().AdvancedSearch_dateMenuValues.Today:break;case assInstance.Instance().AdvancedSearch_dateMenuValues.Last3Days:startdate-=3*3600*1000*24;start.setTime(startdate);break;case assInstance.Instance().AdvancedSearch_dateMenuValues.ThisWeek:startdate-=7*3600*1000*24;start.setTime(startdate);break;case assInstance.Instance().AdvancedSearch_dateMenuValues.ThisMonth:startdate-=30*3600*1000*24;start.setTime(startdate);break;case assInstance.Instance().AdvancedSearch_dateMenuValues.Anytime:startdate-=currentSubscriptionLength*3600*1000*24;start.setTime(startdate);break;default:startdate-=3*3600*1000*24;start.setTime(startdate);break;}
setDataFields(start,stop);}
pdcore.getElm("browseDateMenu").style.display="none";}
function checkOppositeSelection(elmName){if(elmName=="headlineImg"){elmName="bodyImg";}else{elmName="headlineImg";}
var elm=pdcore.getElm(elmName);if(elm){if(elm.alt=="Add"){var textEmptySearchInCheckbox="You cannot delete both selection simultaniously.";if(ResourceManager.isLoaded()){textEmptySearchInCheckbox=ResourceManager.getVal("SearchPanel.EmptySearchInCheckbox",textEmptySearchInCheckbox);}
alert(textEmptySearchInCheckbox);return false;}}
return true;}
function reverseSelection(elmName){var elm=pdcore.getElm(elmName);if(elm){if(elm.alt=="Remove"){if(checkOppositeSelection(elmName)){elm.alt="Add";elm.src=imagedir+"i_add.gif";}}else{elm.alt="Remove";elm.src=imagedir+"i_remove.gif";}}}
function getSearchType(){if(pdcore.getElm("headlineImg").alt=="Remove"&&pdcore.getElm("bodyImg").alt=="Remove"){return"ALL";}
if(pdcore.getElm("headlineImg").alt=="Remove"){return"HEADLINE";}
return"BODY";}
function showSelectedArticle(issue,page,articleId,previewmode){if(window.parent.PDViewer){assInstance.Instance().AdvancedSearchActiveState=true;if(articleId=='00000000-0000-0000-0000-0000000000000000'){articleId=null;}
try{window.parent.PDViewer.showIssue(issue,page,articleId,previewmode,null,null);}catch(e){alert("cannot show article");}}else{alert("window.parent.PDViewer = null");}}
function ClearResultPanel(){pdcore.getElm("SearchResultPanel").innerHTML="";assInstance.Instance().AdvancedSearchInnerHtml=null;}
function createHeader(arr,headerElm){var textShawing="Showing ";var textTo="to";var textOf="of";var textFor="for";var textSortBy="Sort by: ";var textRelevance="Relevance";var textDate="Date";var textNewspaper="Newspaper";var textDidYouMean="Did you mean:";if(ResourceManager.isLoaded()){textShawing=ResourceManager.getVal("SearchPanel.Infobar",textShawing);textTo=ResourceManager.getVal("SearchPanel.InfobarTo",textTo);textOf=ResourceManager.getVal("SearchPanel.InfobarOf",textOf);textFor=ResourceManager.getVal("SearchPanel.InfobarFor",textFor);textSortBy=ResourceManager.getVal("SearchPanel.Sortbar",textSortBy);textRelevance=ResourceManager.getVal("SearchPanel.SortbarRelevance",textRelevance);textDate=ResourceManager.getVal("SearchPanel.SortbarDate",textDate);textNewspaper=ResourceManager.getVal("SearchPanel.SortbarNewspaper",textNewspaper);textDidYouMean=ResourceManager.getVal("SearchPanel.DidYouMean",textDidYouMean);}
arr.push("<table class=\"table_info\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");arr.push("<tr class=\"table_info_cover\">");var UpLevel=parseInt(headerElm.getElementsByTagName("Total")[0].firstChild.nodeValue);if(UpLevel>((parseInt(assInstance.Instance().AdvancedSearchCurrentPage)+1)*10)){UpLevel=((parseInt(assInstance.Instance().AdvancedSearchCurrentPage)+1)*10);}
var DownLevel=(parseInt(assInstance.Instance().AdvancedSearchCurrentPage)*10+1);if(DownLevel>UpLevel){DownLevel=UpLevel;}
arr.push("<td style=\"font-weight:normal\"> "+textShawing+" <strong>"+
+DownLevel+"</strong> "+textTo+" <strong>"+
UpLevel+"</strong> "+textOf+" <strong>"+
headerElm.getElementsByTagName("Total")[0].firstChild.nodeValue+"</strong> "+textFor+" <strong> "+
headerElm.getElementsByTagName("SearchText")[0].firstChild.nodeValue+"</strong></td>");var didYouMeanLink=headerElm.getElementsByTagName("DidYouMeanLink")[0].firstChild==null?"":headerElm.getElementsByTagName("DidYouMeanLink")[0].firstChild.nodeValue;var didYouMean=headerElm.getElementsByTagName("DidYouMean")[0].firstChild==null?"":headerElm.getElementsByTagName("DidYouMean")[0].firstChild.nodeValue;if(assInstance.Instance().AdvancedSearchVersion==2){if(assInstance.Instance().AdvancedSearchSortOrder=="Relevance"){arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+textRelevance+" | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Date' );\">"+textDate+"</a></td>");}else if(assInstance.Instance().AdvancedSearchSortOrder=="Date"){arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+"<a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Relevance' );\">"+textRelevance+"</a> | "+textDate+"</td>");}}else{if(assInstance.Instance().AdvancedSearchSortOrder=="Relevance"){arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+textRelevance+" | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Date' );\">"+textDate+"</a> | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Newspaper' );\">"+textNewspaper+"</a></td>");}else if(assInstance.Instance().AdvancedSearchSortOrder=="Date"){arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+"<a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Relevance' );\">"+textRelevance+"</a> | "+textDate+" | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Newspaper' );\">"+textNewspaper+"</a></td>");}else{arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+"<a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Relevance' );\">"+textRelevance+"</a> | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Date' );\">"+textDate+"</a> | "+textNewspaper+"</td>");}}
arr.push("</tr>");arr.push("</table>");if(didYouMeanLink.length>0&&didYouMean.length>0){arr.push("<div class=\"color3\">"+textDidYouMean+" <strong>"
+"<a href=\"javascript:void(0);\" onclick=\"return TryDidYouMeanLink( '"+didYouMeanLink+"' );\">"+didYouMean+"</a>"
+"</strong></div><br>");}}
function GetImageUrl(issue,scale,page){try{if(currurl>=imageurls.length){currurl=0;}
var url=imageurls[currurl]+"?file="+issue+"&page="+page+"&scale="+scale;currurl++;return url;}catch(e){return"paper_small.jpg";}}
function addIssuePageItem(issue,page){if(assInstance.Instance().AdvancedSearchMode){if(!assInstance.Instance().IssuePageCollection){assInstance.Instance().IssuePageCollection={};}
if(!assInstance.Instance().IssuePageCollection[issue]){assInstance.Instance().IssuePageCollection[issue]=[];}
assInstance.Instance().IssuePageCollection[issue].push(page);}}
function convertArticleToHTML(arr,xmlArticle){var textPage="Page";var issueString=xmlArticle.getElementsByTagName("IssueString")[0].firstChild==null?"":xmlArticle.getElementsByTagName("IssueString")[0].firstChild.nodeValue;var imageScale=xmlArticle.getElementsByTagName("ImageScale")[0].firstChild==null?"":xmlArticle.getElementsByTagName("ImageScale")[0].firstChild.nodeValue;var pageNumber=xmlArticle.getElementsByTagName("PageNumber")[0].firstChild==null?"":xmlArticle.getElementsByTagName("PageNumber")[0].firstChild.nodeValue;var articleComments=xmlArticle.getElementsByTagName("Comments")[0].firstChild==null?"":xmlArticle.getElementsByTagName("Comments")[0].firstChild.nodeValue;var articleRank=xmlArticle.getElementsByTagName("Rank")[0].firstChild==null?"":xmlArticle.getElementsByTagName("Rank")[0].firstChild.nodeValue;var articleTitle=xmlArticle.getElementsByTagName("Title")[0].firstChild==null?"":xmlArticle.getElementsByTagName("Title")[0].firstChild.nodeValue;var description=xmlArticle.getElementsByTagName("Description")[0].firstChild==null?"":xmlArticle.getElementsByTagName("Description")[0].firstChild.nodeValue;var author=xmlArticle.getElementsByTagName("Author")[0].firstChild==null?"":xmlArticle.getElementsByTagName("Author")[0].firstChild.nodeValue;var newspaperName=xmlArticle.getElementsByTagName("NewspaperName")[0].firstChild==null?"":xmlArticle.getElementsByTagName("NewspaperName")[0].firstChild.nodeValue;var issueDate=xmlArticle.getElementsByTagName("IssueDate")[0].firstChild==null?"":xmlArticle.getElementsByTagName("IssueDate")[0].firstChild.nodeValue;var country=xmlArticle.getElementsByTagName("Country")[0].firstChild==null?"":xmlArticle.getElementsByTagName("Country")[0].firstChild.nodeValue;var language=xmlArticle.getElementsByTagName("Language")[0].firstChild==null?"":xmlArticle.getElementsByTagName("Language")[0].firstChild.nodeValue;if(assInstance.Instance().AdvancedSearchVersion==2){var articleRegionId=xmlArticle.getElementsByTagName("RegionId")[0].firstChild==null?"":xmlArticle.getElementsByTagName("RegionId")[0].firstChild.nodeValue;var released=xmlArticle.getElementsByTagName("Released")[0].firstChild==null?"":xmlArticle.getElementsByTagName("Released")[0].firstChild.nodeValue;}else{var articleGuid=xmlArticle.getElementsByTagName("Guid")[0].firstChild==null?"":xmlArticle.getElementsByTagName("Guid")[0].firstChild.nodeValue;var articleRankValue="";}
addIssuePageItem(issueString,pageNumber);arr.push("<table class=\"searchres_table\" cellpadding=\"0\" cellspacing=\"0\">");arr.push("<tr>");if(assInstance.Instance().AdvancedSearchVersion==2){arr.push("<td class=\"searchres_image\"><img src=\""+GetImageUrl(issueString,imageScale,pageNumber)+"\" class=\"searchres_img\" style=\"cursor: pointer;\" onclick=\"showSelectedArticle( '"+issueString+"', "+pageNumber+", '"+articleRegionId+"', 1 );\"></td>");}else{arr.push("<td class=\"searchres_image\"><img src=\""+GetImageUrl(issueString,imageScale,pageNumber)+"\" class=\"searchres_img\" style=\"cursor: pointer;\" onclick=\"showSelectedArticle( '"+issueString+"', "+pageNumber+", '"+articleGuid+"', 1 );\"></td>");}
arr.push("<td class=\"searchres_content\">");if(assInstance.Instance().AdvancedSearchVersion==2){arr.push("<div class=\"artbox_rank\">"+ResourceManager.getVal("SearchMonitorPanel.ArticleRelevance","Article relevance")+" <img src=\""+imagedir+articleRank+"\" style=\"vertical-align: middle\" class=\"rank_img\"></div>");}else{arr.push("<div class=\"artbox_rank\">"+ResourceManager.getVal("SearchMonitorPanel.ArticleRelevance","Article relevance")+" <img src=\""+imagedir+articleRank+"\" style=\"vertical-align: middle\" class=\"rank_img\">"+articleRankValue+"</div>");}
arr.push("<div class=\"searchres_text\">");if(assInstance.Instance().AdvancedSearchVersion==2){arr.push("<a href=\"javascript: showSelectedArticle( '"+issueString+"', "+pageNumber+", '"+articleRegionId+"', 2 );\">");}else{arr.push("<a href=\"javascript: showSelectedArticle( '"+issueString+"', "+pageNumber+", '"+articleGuid+"', 2 );\">");}
arr.push("<span class=\"pop_inverse\">&nbsp;"+textPage+"&nbsp;"+pageNumber+"&nbsp;</span>&nbsp; <span class=\"searchres_title\">"+articleTitle+"</span>");if(articleComments.length>0&&articleComments!="0"){arr.push("&nbsp;<span class=\"lbl-comment\" title=\""+ResourceManager.format("ArticleView.CommentsTitleWithCount",articleComments)+"\"><span>"+articleComments+"</span></span>");}
arr.push("<br>");arr.push(description);arr.push("<span class=\"art_byline\" style=\"text-align:right \">"+author+"</span>");arr.push("</a>");arr.push("</div>");arr.push("<div class=\"searchres_source\">"+newspaperName+" &nbsp;|&nbsp; "+issueDate+" &nbsp;|&nbsp; ");if(country!="Unknown"){arr.push(country+" &nbsp;|&nbsp; ");}
if(language!="Unknown"){arr.push(language+" &nbsp;|&nbsp;");}
if(assInstance.Instance().AdvancedSearchVersion==2){if(released.length>0){arr.push(ResourceManager.getVal("SearchPanel.Released","Released")+": "+released+" &nbsp;|&nbsp;");}}
arr.push(textPage+": "+pageNumber+"</div>");arr.push("</td>");arr.push("</tr>");arr.push("</table>");issueString=null;imageScale=null;pageNumber=null;articleRank=null;articleTitle=null;description=null;author=null;newspaperName=null;issueDate=null;country=null;language=null;if(assInstance.Instance().AdvancedSearchVersion==2){articleRegionId=null;released=null;}else{articleGuid=null;similarArticles=null;}}
function CheckCurrent(idx){if(idx==assInstance.Instance().AdvancedSearchCurrentPage){return" class=\"pd_pages_current\"";}else{return"";}}
function createPagination(arr,headerElm){var textPagination="Results page:";var textPrevious="Previous";var textNext="Next";if(ResourceManager.isLoaded()){textPagination=ResourceManager.getVal("SearchPanel.Pagination",textPagination);textPrevious=ResourceManager.getVal("SearchPanel.Prev",textPrevious);textNext=ResourceManager.getVal("SearchPanel.Next",textNext);}
arr.push("<ul class=\"pd_pages\">");arr.push("<li>"+textPagination+"&nbsp;</li>");if(assInstance.Instance().AdvancedSearchCurrentPage!=0){arr.push("<li><a href=\"javascript: void(0);\" onclick=\"btPrevious_onClick( );\">"+textPrevious+"</a></li>&nbsp;");}
var StartPage;if(assInstance.Instance().AdvancedSearchCurrentPage<3){StartPage=0;}else{StartPage=assInstance.Instance().AdvancedSearchCurrentPage-2;}
var StopPage=parseInt(parseInt(headerElm.getElementsByTagName("Total")[0].firstChild.nodeValue)/10)+1;if(StopPage>StartPage+5){StopPage=StartPage+5;}
for(var idx=StartPage;idx<StopPage;idx++){arr.push("<li"+CheckCurrent(idx)+"><a href=\"javascript: void(0);\" onclick=\"btSetCurrent_onClick( "+idx+" );\">"+(idx+1)+"</a></li>&nbsp;");}
if((assInstance.Instance().AdvancedSearchCurrentPage+1)*10<headerElm.getElementsByTagName("Total")[0].firstChild.nodeValue){arr.push("<li><a href=\"javascript: void(0);\" onclick=\"btNext_onClick( );\">"+textNext+"</a></li>");}
arr.push("</ul>");}
function ShowEmptyResult(){var textShawing="Showing ";var textTo="to";var textOf="of";var textFor="for";var textSortBy="Sort by: ";var textRelevance="Relevance";var textDate="Date";var textNewspaper="Newspaper";if(ResourceManager.isLoaded()){textShawing=ResourceManager.getVal("SearchPanel.Infobar",textShawing);textTo=ResourceManager.getVal("SearchPanel.InfobarTo",textTo);textOf=ResourceManager.getVal("SearchPanel.InfobarOf",textOf);textFor=ResourceManager.getVal("SearchPanel.InfobarFor",textFor);textSortBy=ResourceManager.getVal("SearchPanel.Sortbar",textSortBy);textRelevance=ResourceManager.getVal("SearchPanel.SortbarRelevance",textRelevance);textDate=ResourceManager.getVal("SearchPanel.SortbarDate",textDate);textNewspaper=ResourceManager.getVal("SearchPanel.SortbarNewspaper",textNewspaper);}
var arr=[];arr.push("<div class=\"t_cover\">"+searchHeader+"</div>");arr.push("<table class=\"table_info\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");arr.push("<tr class=\"table_info_cover\">");arr.push("<td style=\"font-weight:normal\">"+textShawing+" <strong>0</strong> "+textTo+" <strong>0</strong> "+textOf+" <strong>0</strong> "+textFor+" <strong>"+
assInstance.Instance().AdvancedSearchText+"</strong></td>");if(assInstance.Instance().AdvancedSearchVersion==2){if(assInstance.Instance().AdvancedSearchSortOrder=="Relevance"){arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+textRelevance+" | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Date' );\">"+textDate+"</a></td>");}else if(assInstance.Instance().AdvancedSearchSortOrder=="Date"){arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+"<a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Relevance' );\">"+textRelevance+"</a> | "+textDate+"</td>");}}else{if(assInstance.Instance().AdvancedSearchSortOrder=="Relevance"){arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+textRelevance+" | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Date' );\">"+textDate+"</a> | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Newspaper' );\">"+textNewspaper+"</a></td>");}else if(assInstance.Instance().AdvancedSearchSortOrder=="Date"){arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+"<a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Relevance' );\">"+textRelevance+"</a> | "+textDate+" | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Newspaper' );\">"+textNewspaper+"</a></td>");}else{arr.push("<td style=\"font-weight:normal; text-align:right\">"+textSortBy+"<a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Relevance' );\">"+textRelevance+"</a> | <a href=\"javascript:void(0);\" onclick=\"return sortResult_onClick( 'Date' );\">"+textDate+"</a> | "+textNewspaper+"</td>");}}
arr.push("</tr>");arr.push("</table>");var html=arr.join("");pdcore.getElm("SearchResultPanel").innerHTML=html;}
function onDataLoaded(xmlDoc){window.document.body.style.cursor='default';assInstance.Instance().AdvancedSearchInnerHtml=xmlDoc;if(!xmlDoc){ShowEmptyResult();return;}
var rootElm=xmlDoc.documentElement;if(!rootElm){ShowEmptyResult();return;}
var headerElm=rootElm.getElementsByTagName("result_header")[0];if(!headerElm){ShowEmptyResult();return;}
try{var arr=[];arr.push("<div class=\"t_cover\">"+searchHeader+"</div>");createHeader(arr,headerElm);var body=rootElm.getElementsByTagName("result_body")[0];if(body){var xmlArticlesRoot=body.getElementsByTagName("Articles")[0];if(xmlArticlesRoot){var xmlArticles=xmlArticlesRoot.getElementsByTagName("Article");if(xmlArticles){arr.push("<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top'>");var xmlArticle;for(var idx=0;idx<xmlArticles.length;idx++){xmlArticle=xmlArticles[idx];convertArticleToHTML(arr,xmlArticle);}
if(NDHostName=='dailymirror.newspaperdirect.com'){arr.push("</td><td valign='top' style='background-color:#979D9E;width:160px'>");drawHistory(arr);}
if(NDHostName=='refdag.newspaperdirect.com'){arr.push("</td><td valign='top' style='background-color:#979D9E;width:160px'>");drawHistory2(arr);}
arr.push("</td></tr></table>");}}}
arr.push("<table class=\"table_info\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");arr.push("<tr class=\"table_info_cover\">");if(isMonitoringAvailable&&typeof(ResourceManager)!="undefined"){var addMonitorMessage=ResourceManager.format2("AdvancedSearch.AddToMyMonitorsFormat",{name:"query",value:assInstance.Instance().AdvancedSearchText});arr.push("<td style=\"font-weight:normal\"><a href=\"javascript:ShowNewsMonitor( '"+encodeURIComponent(assInstance.Instance().AdvancedSearchText)+"' );\">"+addMonitorMessage+"</a></td>");}
arr.push("<td style=\"font-weight:normal\">&nbsp;</td>");arr.push("</tr>");arr.push("</table>");createPagination(arr,headerElm);var html=arr.join("");pdcore.getElm("SearchResultPanel").innerHTML=html;}catch(e){ShowEmptyResult();}
try{PDUrchinTracker(window.location.href.replace(new RegExp("^http://[^/]*/|/[^/]*$","g"),"/")+"AdvancedSearchResults")}catch(e){}
return;}
function drawHistory(arr){arr.push("<div id='ArchiveResalt' style='background-color:#979D9E;width:160px;margin:auto; text-align:center; overflow:hidden; padding-top:auto;'>");arr.push("<p><b><span style='color:White; font-size:12px'>Archive</span></b></p><div>");arr.push("<a href='http://dailymirror.newspaperdirect.com/epaper/pageview.aspx?issue=10391934020700000000001001'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=10391934020700000000001001&page=1&scale=18' width='110' oncontextmenu='return false'></a><br>");arr.push("<p><b><span style='color:White; font-size:11px'>Daily Mirror<br />Feb 7, 1934 Page 1</span></b></p></div>");arr.push("<br/><div><a href='http://dailymirror.newspaperdirect.com/epaper/pageview.aspx?issue=10391961041300000000001001&page=9'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=10391961041300000000001001&page=9&scale=18' width='110' oncontextmenu='return false'></a><br>");arr.push("<p><b><span style='color:White; font-size:11px'>Daily Mirror<br />Apr 13, 1961 Page 9</span></b></p></div>");arr.push("<br/><div><a href='http://dailymirror.newspaperdirect.com/epaper/pageview.aspx?issue=10391982111200000000001001&page=6'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=10391982111200000000001001&page=6&scale=18' width='110' oncontextmenu='return false'></a><br>");arr.push("<p><b><span style='color:White; font-size:11px'>Daily Mirror<br />Nov 12, 1982 Page 6</span></b></p></div>");arr.push("<br/><div><a href='http://dailymirror.newspaperdirect.com/epaper/pageview.aspx?issue=10392005122100000000001001&page=17'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=10392005122100000000001001&page=17&scale=20' width='110' oncontextmenu='return false'></a><br>");arr.push("<p><b><span style='color:White; font-size:11px'>Daily Mirror<br />Dec, 21 2005 Page 17</span></b></p></div>");arr.push("<br/><div><a href='http://dailymirror.newspaperdirect.com/epaper/pageview.aspx?issue=10392004120200000000001001&page=7'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=10392004120200000000001001&page=7&scale=20' width='110' oncontextmenu='return false'></a><br>");arr.push("<b><span style='color:White; font-size:11px'>Daily Mirror<br />Dec, 2 2007 Page 7</span></b></div></div>");}
function drawHistory2(arr){arr.push("<div id='ArchiveResalt' style='background-color:#979D9E;width:160px;margin:auto; text-align:center; overflow:hidden; padding-top:auto;'>");arr.push("<p><b><span style='color:White; font-size:12px'>Archive</span></b></p><div>");arr.push("<a href='http://refdag.newspaperdirect.com/epaper/pageview.aspx?issue=32461974010200000000001001&page=5'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=32461974010200000000001001&page=5&scale=20' width='110'></a><br>");arr.push("<p><b><span style='color:White; font-size:11px'>Reformatorisch Dagblad<br />Jan 2, 1974 Page 5</span></b></p></div>");arr.push("<br/><div><a href='http://refdag.newspaperdirect.com/epaper/pageview.aspx?issue=32461974010400000000001001'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=32461974010400000000001001&page=1&scale=20' width='110'></a><br>");arr.push("<p><b><span style='color:White; font-size:11px'>Reformatorisch Dagblad<br />Jan 4, 1974 Page 1</span></b></p></div>");arr.push("<br/><div><a href='http://refdag.newspaperdirect.com/epaper/pageview.aspx?issue=32461974010900000000001001&page=3'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=32461974010900000000001001&page=3&scale=20' width='110'></a><br>");arr.push("<p><b><span style='color:White; font-size:11px'>Reformatorisch Dagblad<br />Jan 9, 1974 Page 3</span></b></p></div>");arr.push("<br/><div><a href='http://refdag.newspaperdirect.com/epaper/pageview.aspx?issue=32461974011200000000001001&page=7'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=32461974011200000000001001&page=7&scale=20' width='110'></a><br>");arr.push("<p><b><span style='color:White; font-size:11px'>Reformatorisch Dagblad<br />Jan 12, 1974 Page 7</span></b></p></div>");arr.push("<br/><div><a href='http://refdag.newspaperdirect.com/epaper/pageview.aspx?issue=32461974011200000000001001&page=10'><img src='http://thumbnails1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=32461974011200000000001001&page=10&scale=20' width='110'></a><br>");arr.push("<b><span style='color:White; font-size:11px'>Reformatorisch Dagblad<br />Jan 12, 1974 Page 10</span></b></div></div>");}
function getNewspaperList(bTitle){var newspapers="";var newspapersCollection=assInstance.Instance().AdvancedSearch_NewspapersCollection;if(newspapersCollection){var items=newspapersCollection.getKeys();for(var idx=0;idx<items.length;idx++){var delIndex=items[idx].lastIndexOf("#");if(delIndex>0){if(newspapers.length<1){if(bTitle==true){newspapers+=items[idx].substr(0,delIndex);}else{newspapers+=items[idx].substr(delIndex+1);}}else{if(bTitle==true){newspapers+=", "+items[idx].substr(0,delIndex);}else{newspapers+=", "+items[idx].substr(delIndex+1);}}}}}
return newspapers;}
function getCountryList(){var countries="";var newspapersCollection=assInstance.Instance().AdvancedSearch_NewspapersCollection;if(newspapersCollection){var items=newspapersCollection.getKeys();for(var idx=0;idx<items.length;idx++){if(items[idx].lastIndexOf("#")<0){if(countries.length<1){countries+=items[idx];}else{countries+=", "+items[idx];}}}}
return countries;}
function getLanguageList(){var langs="";var languagesCollection=assInstance.Instance().AdvancedSearch_LanguagesCollection;if(languagesCollection){var items=languagesCollection.toString();for(var idx=0;idx<items.length;idx++){if(langs.length<1){langs+=items[idx];}else{langs+=", "+items[idx];}}}
return langs;}
function ShowResultLocated(){var sSearchType=getSearchType();var textAnywhere="Anywhere in the article";var textHeadline="Anywhere in the headline";var textBody="Anywhere in the body of the article";if(ResourceManager.isLoaded()){textAnywhere=ResourceManager.getVal("SearchMonitorPanel.ResultLocationAnywhere",textAnywhere);textHeadline=ResourceManager.getVal("SearchMonitorPanel.ResultLocationHeadline",textHeadline);textBody=ResourceManager.getVal("SearchMonitorPanel.ResultLocationBody",textBody);}
if(sSearchType=="ALL"){return textAnywhere;}else if(sSearchType="HEADLINE"){return textHeadline;}else{return textBody;}}
function RestoreSearchResult(){onDataLoaded(assInstance.Instance().AdvancedSearchInnerHtml);}
function convertNotificationToHTML(arr,xmlNotification,criteria){var active=(xmlNotification.getElementsByTagName("Active")[0].firstChild.nodeValue=="true")?true:false;if((criteria=="active"&&active==false)||(criteria=="passive"&&active==true)){return;}
var monitorId=xmlNotification.getAttribute("monitorId");var xmlInternal=xmlNotification.getElementsByTagName("MonitorInternal")[0];var xmlRoot=xmlInternal.getElementsByTagName("Root")[0];var search=xmlRoot.getElementsByTagName("SearchTerm")[0].firstChild.nodeValue;var contentTerm=xmlRoot.getElementsByTagName("ContentTerm")[0];var InSearch="";var xmlNewspapers=contentTerm.getElementsByTagName("Newspaper");if(xmlNewspapers){if(xmlNewspapers.length>0){var textInNewspapers="In newspapers:";if(ResourceManager.isLoaded()){textInNewspapers=ResourceManager.getVal("SearchMonitorPanel.InNewspapers",textInNewspapers);}
InSearch+=textInNewspapers+" ";for(var idx=0;idx<xmlNewspapers.length;idx++){var pdViewer=window.parent.PDViewer;if(pdViewer){if(pdViewer.Catalog.is_loaded){try{var newspaper=pdViewer.Catalog.getNewspaper(xmlNewspapers[idx].firstChild.nodeValue);InSearch+=newspaper.name+", ";}catch(e){}}}}}}
var xmlNames=contentTerm.getElementsByTagName("Categories/Category[@type='country']/Name");if(xmlNames){if(xmlNames.length>0){var textInCountries="In countries:";if(ResourceManager.isLoaded()){textInCountries=ResourceManager.getVal("SearchMonitorPanel.InCountries",textInCountries);}
InSearch+=textInCountries+" ";for(var indx=0;indx<xmlNames.length;indx++){InSearch+=xmlNames[indx].firstChild.nodeValue+", ";}}}
xmlNames=contentTerm.getElementsByTagName("Categories/Category[@type='language']/Name");if(xmlNames){if(xmlNames.length>0){var textInLanguages="In languages:";if(ResourceManager.isLoaded()){textInLanguages=ResourceManager.getVal("SearchMonitorPanel.InLanguages",textInLanguages);}
InSearch+=textInLanguages+" ";for(var indx=0;indx<xmlNames.length;indx++){InSearch+=xmlNames[indx].firstChild.nodeValue+", ";}}}
var xmlResultLocated=xmlRoot.getElementsByTagName("ResultLocation")[0];var textResultLocated="Result located:";var textAnywhere="Anywhere in the article";var textHeadline="Anywhere in the headline";var textBody="Anywhere in the body of the article";if(ResourceManager.isLoaded()){textResultLocated=ResourceManager.getVal("SearchMonitorPanel.ResultLocation",textResultLocated);textAnywhere=ResourceManager.getVal("SearchMonitorPanel.ResultLocationAnywhere",textAnywhere);textHeadline=ResourceManager.getVal("SearchMonitorPanel.ResultLocationHeadline",textHeadline);textBody=ResourceManager.getVal("SearchMonitorPanel.ResultLocationBody",textBody);}
if(xmlResultLocated.getAttribute("headline")=="true"&&xmlResultLocated.getAttribute("articleBody")){InSearch+=textResultLocated+" "+textAnywhere;}else if(xmlResultLocated.getAttribute("headline")=="true"&&xmlResultLocated.getAttribute("articleBody")){InSearch+=textResultLocated+" "+textHeadline;}else{InSearch+=textResultLocated+" "+textBody;}
var hours;var textHours0="As-it-happens";var textHours24="Once a day";var textHours48="Every other day";var textHours72="Once a three days";var textHoursWeek="Once a week";if(ResourceManager.isLoaded()){textHours0=ResourceManager.getVal("SearchMonitorPanel.HoursAsItHappend",textHours0);textHours24=ResourceManager.getVal("SearchMonitorPanel.HoursOnesDay",textHours24);textHours48=ResourceManager.getVal("SearchMonitorPanel.HoursEveryOtherDay",textHours48);textHours72=ResourceManager.getVal("SearchMonitorPanel.HoursOnesThreeDay",textHours72);textHoursWeek=ResourceManager.getVal("SearchMonitorPanel.HoursOnesWeek",textHoursWeek);}
switch(parseInt(xmlRoot.getElementsByTagName("TimeTerm")[0].firstChild.nodeValue)){case 0:hours=textHours0;break;case 24:hours=textHours24;break;case 48:hours=textHours48;break;case 72:hours=textHours72;break;default:hours=textHoursWeek;break;}
arr.push("<tr>");if(active==true){arr.push("<td class=\"ti_c4\"><input id=\"activeMonitor"+monitorId+"\" type=\"checkbox\" name=\"activeMonitor"+monitorId+"\" style=\"vertical-align:middle;\" checked=\"true\" onclick=\"updateMonitor( "+monitorId+", pdcore.getElm( 'activeMonitor"+monitorId+"' )  );\"></td>");}else{arr.push("<td class=\"ti_c4\"><input id=\"activeMonitor"+monitorId+"\" type=\"checkbox\" name=\"activeMonitor"+monitorId+"\" style=\"vertical-align:middle;\" onclick=\"updateMonitor( "+monitorId+", pdcore.getElm( 'activeMonitor"+monitorId+"' )  );\"></td>");}
arr.push("<td class=\"ti_c2\"><a href=\"javascript: MonitorAdvancedSearch_onLoad( unescape( '"+escape(search)+"' ) );\">"+search+"</a></td>");arr.push("<td>");arr.push(InSearch);arr.push("</td>");var txtEmail="Email";if(ResourceManager.isLoaded()){txtEmail=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderNotificationBy","Email");}
arr.push("<td class=\"ti_c4\">"+txtEmail+"</td>");arr.push("<td class=\"ti_c4\">");arr.push(hours+"<br>");arr.push("</td>");arr.push("<td class=\"ti_c3\">");var textDeleteButton="Delete";if(ResourceManager.isLoaded()){textDeleteButton=ResourceManager.getVal("SearchMonitorPanel.DeleteButton",textDeleteButton);}
arr.push("<a href=\"javascript: deleteMonitor( "+monitorId+" );\">"+textDeleteButton+"</a>");arr.push("</td>");arr.push("</tr>");}
function ShowEmptyMonitor(){var textMyMonitors="My Monitors";if(ResourceManager.isLoaded()){textMyMonitors=ResourceManager.getVal("Menu.MyServices.MyMonitors",textMyMonitors);}
var arr=[];arr.push("<div class=\"t_cover\"><img src=\""+imagedir+"toolb_but_newsmonitor.gif\" align=\"middle\"> "+textMyMonitors+"</div>");arr.push("<br><br>");if(isMonitoringAvailable){arr.push("<table class=\"but_univ_blue\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"float:left\">");arr.push("<tr>");arr.push("<td class=\"but_left\"><img src=\""+imagedir+"1x1.gif\" width=\"14\"></td>");arr.push("<td class=\"but_center\" nowrap><a href=\"javascript: ShowEmptyNewsMonitor( );\">Add new monitor...</a></td>");arr.push("<td class=\"but_right\"><img src=\""+imagedir+"1x1.gif\" width=\"14\"></td>");arr.push("</tr>");arr.push("</table>");}
arr.push("<br>");var html=arr.join("");pdcore.getElm("SearchResultPanel").innerHTML=html;}
function changeMonitorList(val){var arr=[];var textStatus="Active";var textSearchTerm="Search term";var textSearchCriteria="Search Criteria";var textNotification="Notification";var textFrequency="Frequency";if(ResourceManager.isLoaded()){textStatus=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderStatus",textStatus);textSearchTerm=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderSearchTerm",textSearchTerm);textSearchCriteria=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderSearchCriteria",textSearchCriteria);textNotification=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderNotification",textNotification);textFrequency=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderFrequency",textFrequency);}
if(assInstance.Instance().AdvancedSearchMonitorNodes){if(assInstance.Instance().AdvancedSearchMonitorNodes.length>0){arr.push("<table class=\"table_info\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");arr.push("<tr class=\"table_info_cover\">");arr.push("<td class=\"ti_c4\">"+textStatus+"</td>");arr.push("<td style=\"width:25%;\">"+textSearchTerm+"</td>");arr.push("<td>"+textSearchCriteria+"</td>");arr.push("<td class=\"ti_c4\">"+textNotification+"</td>");arr.push("<td class=\"ti_c4\">"+textFrequency+"</td>");arr.push("<td class=\"ti_c3\">&nbsp;</td>");arr.push("</tr>");for(var idx=0;idx<assInstance.Instance().AdvancedSearchMonitorNodes.length;idx++){var xmlNotification=assInstance.Instance().AdvancedSearchMonitorNodes[idx];convertNotificationToHTML(arr,xmlNotification,val);xmlNotification=null;}
arr.push("</table>");}}
var html=arr.join("");pdcore.getElm("monitorDivId").innerHTML=html;}
function onMonitorLoaded(xmlDoc){if(!xmlDoc){ShowEmptyMonitor();return;}
var xmlNotificationRoot=xmlDoc.documentElement;if(!xmlNotificationRoot){ShowEmptyMonitor();return;}
try{var totalMonitor=parseInt(xmlNotificationRoot.getElementsByTagName("Total")[0].firstChild.nodeValue,10);var availableMonitor=totalMonitor;var xmlActiveMonitor=xmlNotificationRoot.selectNodes("Monitor[Active='true']");if(xmlActiveMonitor){availableMonitor-=xmlActiveMonitor.length;}
activeMonitorCount=availableMonitor;xmlActiveMonitor=null;var textAvailable="Available";var textOfPredicat="of";var textAllMonitors="All monitors";var textActiveMonitors="Active monitors";var textInactiveMonitors="Inactive monitors";var textAddNewMonitorsLink="Add new monitor...";var textMyMonitors="My Monitors";if(ResourceManager.isLoaded()){textAvailable=ResourceManager.getVal("SearchMonitorPanel.Available",textAvailable);textOfPredicat=ResourceManager.getVal("SearchMonitorPanel.OfPredicat",textOfPredicat);textAllMonitors=ResourceManager.getVal("SearchMonitorPanel.AllMonitors",textAllMonitors);textActiveMonitors=ResourceManager.getVal("SearchMonitorPanel.ActiveMonitors",textActiveMonitors);textInactiveMonitors=ResourceManager.getVal("SearchMonitorPanel.InactiveMonitors",textInactiveMonitors);textAddNewMonitorsLink=ResourceManager.getVal("SearchMonitorPanel.AddNewMonitorLink",textAddNewMonitorsLink);textMyMonitors=ResourceManager.getVal("Menu.MyServices.MyMonitors",textMyMonitors);}
var arr=[];arr.push("<div class=\"t_cover\"><img src=\""+imagedir+"toolb_but_newsmonitor.gif\" align=\"middle\"> "+textMyMonitors+"</div>");if(isMonitoringAvailable){arr.push("<table class=\"table_info\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");arr.push("<tr class=\"table_info_cover\">");arr.push("<td style=\"font-weight:normal\">"+textAvailable+" <strong>"+availableMonitor+"</strong> "+textOfPredicat+" "+totalMonitor+"</td>");arr.push("<td style=\"font-weight:normal\">&nbsp;</td>");arr.push("</tr>");arr.push("</table>");}
arr.push("<br>");arr.push("<select id=\"monitorShowType\" name=\"monitorShowType\" size=\"1\" style=\"vertical-align:middle;\" onChange=\"changeMonitorList( this.options[this.selectedIndex].value );\">");arr.push("<option selected value=\"*\" >"+textAllMonitors+"</option>")
arr.push("<option value=\"active\">"+textActiveMonitors+"</option>");arr.push("<option value=\"passive\">"+textInactiveMonitors+"</option>");arr.push("</select>");arr.push("<br><br>");arr.push("<div id=\"monitorDivId\">");assInstance.Instance().AdvancedSearchMonitorNodes=xmlNotificationRoot.getElementsByTagName("Monitor");if(assInstance.Instance().AdvancedSearchMonitorNodes){var textStatus="Active";var textSearchTerm="Search term";var textSearchCriteria="Search Criteria";var textNotification="Notification";var textFrequency="Frequency";if(ResourceManager.isLoaded()){textStatus=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderStatus",textStatus);textSearchTerm=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderSearchTerm",textSearchTerm);textSearchCriteria=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderSearchCriteria",textSearchCriteria);textNotification=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderNotification",textNotification);textFrequency=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderFrequency",textFrequency);}
if(assInstance.Instance().AdvancedSearchMonitorNodes.length>0){arr.push("<table class=\"table_info\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");arr.push("<tr class=\"table_info_cover\">");arr.push("<td class=\"ti_c4\">"+textStatus+"</td>");arr.push("<td style=\"width:25%;\">"+textSearchTerm+"</td>");arr.push("<td>"+textSearchCriteria+"</td>");arr.push("<td class=\"ti_c4\">"+textNotification+"</td>");arr.push("<td class=\"ti_c4\">"+textFrequency+"</td>");arr.push("<td class=\"ti_c3\">&nbsp;</td>");arr.push("</tr>");for(var idx=0;idx<assInstance.Instance().AdvancedSearchMonitorNodes.length;idx++){var xmlNotification=assInstance.Instance().AdvancedSearchMonitorNodes[idx];convertNotificationToHTML(arr,xmlNotification,"*");xmlNotification=null;}
arr.push("</table>");}}
arr.push("</div>");if(isMonitoringAvailable){arr.push("<table class=\"but_univ_blue\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"float:left\">");arr.push("<tr>");arr.push("<td class=\"but_left\"><img src=\""+imagedir+"1x1.gif\" width=\"14\"></td>");arr.push("<td class=\"but_center\" nowrap><a href=\"javascript: ShowEmptyNewsMonitor( );\">"+textAddNewMonitorsLink+"</a></td>");arr.push("<td class=\"but_right\"><img src=\""+imagedir+"1x1.gif\" width=\"14\"></td>");arr.push("</tr>");arr.push("</table>");}
arr.push("<br>");var html=arr.join("");pdcore.getElm("SearchResultPanel").innerHTML=html;}catch(e){ShowEmptyMonitor();}
return;}
function showMonitor(){if(!accountAuthonteficated){document.location=loginRedirect;return;}
var serviceUrl="services/AdvancedSearchMonitoring.ashx";;var data="operation=showusermonitors"
XmlRpc.submitPostData(serviceUrl,data,onMonitorLoaded);}
function updateMonitor(monitorId,elm){if(activeMonitorCount<1&&elm.checked){alert("You exceeded number of active monitors");elm.checked=false;return;}
var serviceUrl="services/AdvancedSearchMonitoring.ashx";;var data="operation=update&monitorId="+monitorId+"&activeStatus="+elm.checked;XmlRpc.submitPostData(serviceUrl,data,onMonitorLoaded);}
function deleteMonitor(monitorId){var serviceUrl="services/AdvancedSearchMonitoring.ashx";;var data="operation=delete&monitorId="+monitorId;XmlRpc.submitPostData(serviceUrl,data,onMonitorLoaded);}
function SaveAndShow(){if(pdcore.getElm("tbMonitorSearch").value.length==pdcore.getElm("tbMonitorSearch").value.replace(/[^\s]/g,'').length){var textEmptySearchString="Search string cannot be empty or blank!";if(ResourceManager.isLoaded()){textEmptySearchString=ResourceManager.getVal("SearchPanel.EmptySearchString",textEmptySearchString);}
alert(textEmptySearchString);return;}
assInstance.Instance().AdvancedSearchText=pdcore.getElm("tbMonitorSearch").value;var serviceUrl="services/AdvancedSearchMonitoring.ashx";;var data="operation=insert";data+="&srchText="+encodeURIComponent(assInstance.Instance().AdvancedSearchText);if(assInstance.Instance().AdvancedSearchAuthor.length>0){data+="&srchAuthor="+encodeURIComponent(assInstance.Instance().AdvancedSearchAuthor);}
var newspaperList=getNewspaperList(false);if(newspaperList.length>0){data+="&newspapers="+newspaperList;}
var countryList=getCountryList();if(countryList.length>0){data+="&countries="+encodeURIComponent(countryList);}
var languageList=getLanguageList();if(languageList.length>0){data+="&languages="+encodeURIComponent(languageList);}
data+="&srchIn="+getSearchType();data+="&srchFrequency="+pdcore.getElm("notificationFrequency").options[pdcore.getElm("notificationFrequency").selectedIndex].value;var today=new Date();var dateObj=new Date(today.getUTCFullYear(),today.getUTCMonth(),today.getUTCDate(),parseInt(pdcore.getElm("notificationDeliveryTime").options[pdcore.getElm("notificationDeliveryTime").selectedIndex].value,10),0,0);data+="&srchNotificationTime="+dateObj.getUTCHours();XmlRpc.submitPostData(serviceUrl,data,onMonitorLoaded);}
function processNotificationFrequencyClick(val){if(val==0){pdcore.hide(pdcore.getElm("notificationDeliveryTimeSpan"));}else{pdcore.show(pdcore.getElm("notificationDeliveryTimeSpan"));}}
function ShowNewsMonitor(monitorValue){if(!accountAuthonteficated){document.location=loginRedirect+encodeURIComponent("&monitorValue="+monitorValue);return;}
var infoString="";var newspaperList=getNewspaperList(true);if(newspaperList.length>0){var textInNewspapers="In newspapers:";if(ResourceManager.isLoaded()){textInNewspapers=ResourceManager.getVal("SearchMonitorPanel.InNewspapers",textInNewspapers);}
infoString+=textInNewspapers+" "+newspaperList+". ";}
var countryList=getCountryList();if(countryList.length>0){var textInCountries="In countries:";if(ResourceManager.isLoaded()){textInCountries=ResourceManager.getVal("SearchMonitorPanel.InCountries",textInCountries);}
infoString+=textInCountries+" "+countryList+". ";}
var languageList=getLanguageList();if(languageList.length>0){var textInLanguages="In languages:";if(ResourceManager.isLoaded()){textInLanguages=ResourceManager.getVal("SearchMonitorPanel.InLanguages",textInLanguages);}
infoString+=textInLanguages+" "+languageList+". ";}
var textResultLocated="Result located:";if(ResourceManager.isLoaded()){textResultLocated=ResourceManager.getVal("SearchMonitorPanel.ResultLocation",textResultLocated);}
infoString+=textResultLocated+" "+ShowResultLocated();var arr=[];var textNotificationPreferences="Notification preferences";if(ResourceManager.isLoaded()){textNotificationPreferences=ResourceManager.getVal("SearchMonitorPanel.NotificationPreferences",textNotificationPreferences);}
arr.push("<div class=\"t_cover\"><img src=\""+imagedir+"toolb_but_newsmonitor.gif\" align=\"middle\"> "+textNotificationPreferences+"</div> ");var textSaveTime="Save time by storing your favorite searches in My Monitors.";if(ResourceManager.isLoaded()){textSaveTime=ResourceManager.getVal("SearchMonitorPanel.SaveTime",textSaveTime);}
arr.push(textSaveTime);arr.push("<br><br>");arr.push("<table class=\"table_info\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");arr.push("<tr class=\"table_info_cover\">");var textMonitoringDetails="Monitoring details";if(ResourceManager.isLoaded()){textMonitoringDetails=ResourceManager.getVal("SearchMonitorPanel.MonitoringDetails",textMonitoringDetails);}
arr.push("<td colspan=\"2\">"+textMonitoringDetails+" </td>");arr.push("</tr>");arr.push("<tr>");var textSearchTerm="Search term";var textSearchCriteria="Search Criteria";if(ResourceManager.isLoaded()){textSearchTerm=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderSearchTerm",textSearchTerm);textSearchCriteria=ResourceManager.getVal("SearchMonitorPanel.ResultTableHeaderSearchCriteria",textSearchCriteria);}
arr.push("<td style=\"width:25%;\">"+textSearchTerm+":</td>");arr.push("<td class=\"ti_c2\"><input type=\"text\" name=\"tbMonitorSearch\" id=\"tbMonitorSearch\" style=\"width:100%; margin:2px 0px 5px 0px;\" value=\"\"/></td>");arr.push("</tr>");arr.push("<tr>");arr.push("<td>"+textSearchCriteria+":</td>");arr.push("<td>");arr.push(infoString);arr.push("</td>");arr.push("</tr>");arr.push("<tr>");var textNotifyMe="Notify me:";if(ResourceManager.isLoaded()){textNotifyMe=ResourceManager.getVal("SearchMonitorPanel.NotifyMe",textNotifyMe);}
arr.push("<td>"+textNotifyMe+"</td>");arr.push("<td>");var textSendEmail="Send email &nbsp;(";if(ResourceManager.isLoaded()){textSendEmail=ResourceManager.getVal("SearchMonitorPanel.SendEmail",textSendEmail);}
arr.push("<div style=\"padding:4px; width:29px; margin:2px 5px 2px 0px; text-align:center; background-color:#d5d5d5; display:inline; vertical-align:middle;\"><input id=\"\" type=\"checkbox\" name=\"\" checked=\"checked\" disabled=\"disabled\" ></div> <span class=\"alt\" title=\"\">"+textSendEmail+accountEmail+")</span>");arr.push("</td>");arr.push("</tr>");arr.push("<tr>");var textNotificationFrequency="Notification frequency:";if(ResourceManager.isLoaded()){textNotificationFrequency=ResourceManager.getVal("SearchMonitorPanel.NotificationFrequency",textNotificationFrequency);}
arr.push("<td>"+textNotificationFrequency+"</td>");arr.push("<td>");var textHours0="As-it-happens";var textHours24="Once a day";var textHours48="Every other day";var textHours72="Once a three days";var textHoursWeek="Once a week";var showDeliveryTime="12";if(ResourceManager.isLoaded()){textHours0=ResourceManager.getVal("SearchMonitorPanel.HoursAsItHappend",textHours0);textHours24=ResourceManager.getVal("SearchMonitorPanel.HoursOnesDay",textHours24);textHours48=ResourceManager.getVal("SearchMonitorPanel.HoursEveryOtherDay",textHours48);textHours72=ResourceManager.getVal("SearchMonitorPanel.HoursOnesThreeDay",textHours72);textHoursWeek=ResourceManager.getVal("SearchMonitorPanel.HoursOnesWeek",textHoursWeek);showDeliveryTime=ResourceManager.getVal("SearchMonitorPanel.ShowDeliveryTime",showDeliveryTime);}
arr.push("<select id=\"notificationFrequency\" name=\"notificationFrequency\" value=\"\" style=\"vertical-align:middle;\" onChange=\"processNotificationFrequencyClick( this.options[this.selectedIndex].value );\">");arr.push("<option selected value=\"24\">"+textHours24+"</option>");arr.push("<option value=\"48\">"+textHours48+"</option>");if(!isSubscriptionFree){arr.push("<option value=\"0\">"+textHours0+"</option>");}
arr.push("</select>");arr.push("&nbsp;");arr.push("<span id=\"notificationDeliveryTimeSpan\">");var textSelectTime="Select time:";if(ResourceManager.isLoaded()){textSelectTime=ResourceManager.getVal("SearchMonitorPanel.SelectTime",textSelectTime);}
arr.push(textSelectTime);arr.push("<select id=\"notificationDeliveryTime\" name=\"notificationDeliveryTime\" value=\"\" style=\"vertical-align:middle;\">");if(showDeliveryTime=="12"){arr.push("<option value=\"0\">12:00 AM</option>");arr.push("<option selected value=\"1\"> 1:00 AM</option>");arr.push("<option value=\"2\"> 2:00 AM</option>");arr.push("<option value=\"3\"> 3:00 AM</option>");arr.push("<option value=\"4\"> 4:00 AM</option>");arr.push("<option value=\"5\"> 5:00 AM</option>");arr.push("<option value=\"6\"> 6:00 AM</option>");arr.push("<option value=\"7\"> 7:00 AM</option>");arr.push("<option value=\"8\"> 8:00 AM</option>");arr.push("<option value=\"9\"> 9:00 AM</option>");arr.push("<option value=\"10\">10:00 AM</option>");arr.push("<option value=\"11\">11:00 AM</option>");arr.push("<option value=\"12\">12:00 PM</option>");arr.push("<option value=\"13\">1:00 PM</option>");arr.push("<option value=\"14\">2:00 PM</option>");arr.push("<option value=\"15\">3:00 PM</option>");arr.push("<option value=\"16\">4:00 PM</option>");arr.push("<option value=\"17\">5:00 PM</option>");arr.push("<option value=\"18\">6:00 PM</option>");arr.push("<option value=\"19\">7:00 PM</option>");arr.push("<option value=\"20\">8:00 PM</option>");arr.push("<option value=\"21\">9:00 PM</option>");arr.push("<option value=\"22\">10:00 PM</option>");arr.push("<option value=\"23\">11:00 PM</option>");}else{arr.push("<option value=\"0\"> 0:00</option>");arr.push("<option selected value=\"1\"> 1:00 </option>");arr.push("<option value=\"2\"> 2:00 </option>");arr.push("<option value=\"3\"> 3:00 </option>");arr.push("<option value=\"4\"> 4:00 </option>");arr.push("<option value=\"5\"> 5:00 </option>");arr.push("<option value=\"6\"> 6:00 </option>");arr.push("<option value=\"7\"> 7:00 </option>");arr.push("<option value=\"8\"> 8:00 </option>");arr.push("<option value=\"9\"> 9:00 </option>");arr.push("<option value=\"10\">10:00 </option>");arr.push("<option value=\"11\">11:00 </option>");arr.push("<option value=\"12\">12:00 </option>");arr.push("<option value=\"13\">13:00 </option>");arr.push("<option value=\"14\">14:00 </option>");arr.push("<option value=\"15\">15:00 </option>");arr.push("<option value=\"16\">16:00 </option>");arr.push("<option value=\"17\">17:00 </option>");arr.push("<option value=\"18\">18:00 </option>");arr.push("<option value=\"19\">19:00 </option>");arr.push("<option value=\"20\">20:00 </option>");arr.push("<option value=\"21\">21:00 </option>");arr.push("<option value=\"22\">22:00 </option>");arr.push("<option value=\"23\">23:00 </option>");}
arr.push("</select>");arr.push("</span>");arr.push("</td>");arr.push("</tr>");arr.push("</table>");arr.push("<br>");arr.push("<table class=\"but_univ_blue\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"float:left\">");arr.push("<tr>");var textSaveMonitorLink="Save monitor";if(ResourceManager.isLoaded()){textSaveMonitorLink=ResourceManager.getVal("SearchMonitorPanel.SaveMonitorLink",textSaveMonitorLink);}
arr.push("<td class=\"but_left\"><img src=\""+imagedir+"1x1.gif\" width=\"14\"></td>");arr.push("<td class=\"but_center\" nowrap><a href=\"javascript:SaveAndShow( );\">"+textSaveMonitorLink+"</a></td>");arr.push("<td class=\"but_right\"><img src=\""+imagedir+"/1x1.gif\" width=\"14\"></td>");arr.push("</tr>");arr.push("</table>");arr.push("<table class=\"but_univ_white\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"float:left\">");arr.push("<tr>");var textCancelMonitorLink="Cancel";if(ResourceManager.isLoaded()){textCancelMonitorLink=ResourceManager.getVal("SearchMonitorPanel.CancelMonitorLink",textCancelMonitorLink);}
arr.push("<td class=\"but_left\"><img src=\""+imagedir+"1x1.gif\" width=\"14\"></td>");arr.push("<td class=\"but_center\" nowrap><a href=\"javascript:RestoreSearchResult( );\">"+textCancelMonitorLink+"</a></td>");arr.push("<td class=\"but_right\"><img src=\""+imagedir+"1x1.gif\" width=\"14\"></td>");arr.push("</tr>");arr.push("</table>");arr.push("<br>");var html=arr.join("");pdcore.getElm("SearchResultPanel").innerHTML=html;if(monitorValue&&monitorValue.length==0){pdcore.getElm("tbMonitorSearch").value=monitorValue;}else{pdcore.getElm("tbMonitorSearch").value=assInstance.Instance().AdvancedSearchText;}}
function ShowEmptyNewsMonitor(){ShowNewsMonitor("");}
function SortedCollection(){this.order=[];this.collection={};}
SortedCollection.prototype={sorting:function(val1,val2){if(val1!=null&&val2!=null){if(val1>val2)
return 1;else if(val1<val2)
return-1;}else if(val1==null&&val2!=null){return 1;}else if(val1!=null&&val2==null){return-1;}
return 0;},add:function(key,value){if(!this.exists(key)){this.collection[key]=value;this.order.push(key);this.order.sort(this.sorting);}},remove:function(key){if(this.exists(key)){this.collection[key]=null;var idx=this.order.length;var arLength=idx-1;while(idx-->0){if(this.order[idx]==key){this.order[idx]=null;this.order.sort(this.sorting);this.order.length=arLength;break;}}}},toString:function(){var output=[];var length=this.order.length;for(var idx=0;idx<length;++idx){var key=this.order[idx];if(key!=null&&key!=undefined)
output.push(this.collection[key]);}
return output;},getValues:function(){var output=[];var length=this.order.length;for(var idx=0;idx<length;++idx){var key=this.order[idx];if(key!=null&&key!=undefined)
output.push(this.collection[key]);}
return output;},getKeys:function(){var keys=[];var length=this.order.length;for(var idx=0;idx<length;++idx){var key=this.order[idx];if(key!=null&&key!=undefined)
keys.push(key);}
return keys;},update:function(key,value){if(value!=null&&this.collection[key]!=null){this.collection[key]=value;}else{this.add(key,value);}},exists:function(key){var val=this.collection[key];return val!=null&&val!=undefined;},clear:function(){this.collection={};this.order.length=0;}}
function AdvancedSearchStorage(){this.proxy=null;this.AdvancedSearchMode=true;this.AdvancedSearchSimilarArticleCount=0;this.AdvancedSearchSimilarText="";this.AdvancedSearchArticleGuid=null;this.AdvancedSearchSortOrder="Relevance";this.AdvancedSearchText="";this.AdvancedSearch_NewspapersCollection=new SortedCollection();this.AdvancedSearch_LanguagesCollection=new SortedCollection();this.AdvancedSearch_CancelStorage=new SortedCollection();this.AdvancedSearch_dateMenuValues={};this.AdvancedSearch_dateMenuValues.None="None";this.AdvancedSearch_dateMenuValues.Anytime="Anytime";this.AdvancedSearch_dateMenuValues.Today="Today";this.AdvancedSearch_dateMenuValues.Last3Days="Last 3 days";this.AdvancedSearch_dateMenuValues.ThisWeek="This week";this.AdvancedSearch_dateMenuValues.ThisMonth="This month";this.AdvancedSearch_dateMenuValues.Default=this.AdvancedSearch_dateMenuValues.Last3Days;this.AdvancedSearch_dateMenuValue=this.AdvancedSearch_dateMenuValues.Default
this.AdvancedSearch_StartDate=null;this.AdvancedSearch_StopDate=null;this.AdvancedSearchAuthor="";this.AdvancedSearchInInnerHtml=null;this.AdvancedSearchIn="ALL";this.AdvancedSearchCurrentPage=0;this.AdvancedSearchInnerHtml="";this.AdvancedSearchStartSearch=false;this.AdvancedSearchActiveState=false;this.IssuePageCollection=null;this.AdvancedSearchMonitorNodes=null;this.AdvancedSearchVersion=1;this.Init=init;this.Proxy_onunload=proxy_onunload;this.Instance=instance;this.CheckPageCollection=checkPageCollection;this.SetCurrentIssue=setCurrentIssue;this.SetNewspaper=setNewspaper;this.SetCountry=setCountry;this.SetLanguage=setLanguage;this.Init();function init(){var win=window;try{while(win.parent!=win){if(win.parent.assInstance){this.proxy=window.parent.assInstance;}
win=win.parent;}}catch(E){};if(this.proxy!=null){if(typeof(pdcore)!="undefined"){pdcore.addToUnload(this.Proxy_onunload);}}}
function proxy_onunload(){this.proxy=null;}
function instance(){if(this.proxy){return this.proxy;}else{return this;}}
function checkPageCollection(issue,page1,page2){if(this.IssuePageCollection[issue]!=null){var array=this.IssuePageCollection[issue];for(var i=0;i<array.length;i++){if(array[i]==page1||array[i]==page2){return true;}}}
return false;}
function setCurrentIssue(issue){if(issue){var pdViewer=window.parent.PDViewer;if(pdViewer){var currentIssueDate=new Date();var currentIssueYear,currentIssueMonth,currentIssueDay;currentIssueYear=parseInt(issue.substr(4,4));if(issue.substr(8,1)=="0"){currentIssueMonth=parseInt(issue.substr(9,1))-1;}else{currentIssueMonth=parseInt(issue.substr(8,2))-1;}
if(issue.substr(10,1)=="0"){currentIssueDay=parseInt(issue.substr(11,1));}else{currentIssueDay=parseInt(issue.substr(10,2));}
currentIssueDate.setFullYear(currentIssueYear,currentIssueMonth,currentIssueDay);if(pdViewer.Catalog.is_loaded){var newspaper=pdViewer.Catalog.getNewspaper(issue.substr(0,4));if(newspaper){this.AdvancedSearch_StartDate=this.AdvancedSearch_StopDate=currentIssueDate;this.AdvancedSearch_dateMenuValue=this.AdvancedSearch_dateMenuValues.None;this.SetNewspaper(newspaper.cid,newspaper.name);}}}}}
function setNewspaper(newspaperCID,newspaperName){this.AdvancedSearch_NewspapersCollection.clear();this.AdvancedSearch_NewspapersCollection.add(newspaperName+"#"+newspaperCID,newspaperName);}
function setCountry(country){this.AdvancedSearch_NewspapersCollection.clear();this.AdvancedSearch_NewspapersCollection.add(country,country);}
function setLanguage(lang){this.AdvancedSearch_LanguagesCollection.clear();this.AdvancedSearch_LanguagesCollection.add(lang,lang);}}
var assInstance=new AdvancedSearchStorage();function getCountries(){var countries="";var newspapersCollection=assInstance.Instance().AdvancedSearch_NewspapersCollection;if(newspapersCollection){var items=newspapersCollection.getKeys();for(var idx=0;idx<items.length;idx++){if(items[idx].lastIndexOf("#")<0){if(countries.length<1){countries+=items[idx];}else{countries+=","+items[idx];}}}
if(countries.length>0){countries="&srchCountry="+encodeURIComponent(countries);}}
return countries;}
function getNewspapers(){var newspapers="";var newspapersCollection=assInstance.Instance().AdvancedSearch_NewspapersCollection;if(newspapersCollection){var items=newspapersCollection.getKeys();for(var idx=0;idx<items.length;idx++){var delIndex=items[idx].lastIndexOf("#");if(delIndex>0){if(newspapers.length<1){newspapers+=items[idx].substr(delIndex+1);}else{newspapers+=","+items[idx].substr(delIndex+1);}}}
if(newspapers.length>0){newspapers="&srchNewspaper="+encodeURIComponent(newspapers);}}
return newspapers;}
function getLanguages(){var langs="";var languagesCollection=assInstance.Instance().AdvancedSearch_LanguagesCollection;if(languagesCollection){var items=languagesCollection.toString();for(var idx=0;idx<items.length;idx++){if(langs.length<1){langs+=items[idx];}else{langs+=","+items[idx];}}
if(langs.length>0){langs="&srchLanguage="+encodeURIComponent(langs);}}
return langs;}
function getCIDs(){var pdViewer=window.parent.PDViewer;var arr=[];for(var idx=0;idx<pdViewer.Catalog.countries.length;idx++){var cat=pdViewer.Catalog.countries[idx];for(var idxNewspaper=0;idxNewspaper<cat.newspapers.length;idxNewspaper++){arr.push(cat.newspapers[idxNewspaper]);}}
return"&srchCids="+arr.join("");}
function getInputLanguage(){var languagesCollection=assInstance.Instance().AdvancedSearch_LanguagesCollection;if(languagesCollection){var items=languagesCollection.toString();if(items.length==1){return"&inputLanguage="+encodeURIComponent(items[0]);}}
return"";}
function waitScreen(){var textOriginal="Performing Search...";if(ResourceManager.isLoaded()){textOriginal=ResourceManager.getVal("SearchPanel.PerformingSearch",textOriginal);}
var arr=[];arr.push('<div style="background-color:#e5e5e5; position:relative;">');arr.push('<div style="position:absolute; top:250px; width:100%; text-align:center; font-size:24px; color:#666666; display: block;">'+textOriginal+'</div>');arr.push('</div>');pdcore.getElm("SearchResultPanel").innerHTML=arr.join("");window.document.body.style.cursor="wait";}
function convertDateToString(date){var temp;if(date.getYear()<1900){temp=date.getYear()+1900;}else{temp=date.getYear();}
temp+="-";if((date.getMonth()+1)<10){temp+="0";}
temp=temp+(date.getMonth()+1)+"-";if(date.getDate()<10){temp=temp+"0";}
return temp+date.getDate();}
function CallHttpHandler(){waitScreen();var serviceUrl;var data="srchOrderBy="+assInstance.Instance().AdvancedSearchSortOrder;if(assInstance.Instance().AdvancedSearchVersion==2){serviceUrl="services/AdvancedSearch_v2.ashx";}else{serviceUrl="services/AdvancedSearch.ashx";}
assInstance.Instance().AdvancedSearchActiveState=true;assInstance.Instance().IssuePageCollection=null;data+="&srchText="+encodeURIComponent(assInstance.Instance().AdvancedSearchText);if(assInstance.Instance().AdvancedSearchAuthor.length>0){data+="&srchAuthor="+encodeURIComponent(assInstance.Instance().AdvancedSearchAuthor);}
data+=getCountries();data+=getNewspapers();data+=getLanguages();data+=getInputLanguage();data+="&srchStartDate="+convertDateToString(assInstance.Instance().AdvancedSearch_StartDate);data+="&srchStopDate="+convertDateToString(assInstance.Instance().AdvancedSearch_StopDate);data+="&srchIn="+assInstance.Instance().AdvancedSearchIn;data+="&srchPage="+assInstance.Instance().AdvancedSearchCurrentPage;XmlRpc.submitPostData(serviceUrl,data,onDataLoaded);}
function getDateMenuValue(){if(pdcore.getElm("SearchDateMenu").checked==true){switch(pdcore.getElm("browseDateType").innerHTML){case assInstance.Instance().AdvancedSearch_dateMenuValues.Today:return assInstance.Instance().AdvancedSearch_dateMenuValues.Today;case assInstance.Instance().AdvancedSearch_dateMenuValues.Last3Days:return assInstance.Instance().AdvancedSearch_dateMenuValues.Last3Days;case assInstance.Instance().AdvancedSearch_dateMenuValues.ThisWeek:return assInstance.Instance().AdvancedSearch_dateMenuValues.ThisWeek;case assInstance.Instance().AdvancedSearch_dateMenuValues.ThisMonth:return assInstance.Instance().AdvancedSearch_dateMenuValues.ThisMonth;case assInstance.Instance().AdvancedSearch_dateMenuValues.Anytime:return assInstance.Instance().AdvancedSearch_dateMenuValues.Anytime;default:return assInstance.Instance().AdvancedSearch_dateMenuValues.Default;}}else{return assInstance.Instance().AdvancedSearch_dateMenuValues.None;}}
function AdvancedSearch_onClick(){assInstance.Instance().AdvancedSearchMode=true;assInstance.Instance().AdvancedSearchSimilarText="";assInstance.Instance().AdvancedSearchSimilarArticleCount=0;assInstance.Instance().AdvancedSearchArticleGuid=null;if(pdcore.getElm("tbSearch").value.length==pdcore.getElm("tbSearch").value.replace(/[^\s]/g,'').length){var textEmptySearchString="Search string cannot be empty or blank!";if(ResourceManager.isLoaded()){textEmptySearchString=ResourceManager.getVal("SearchPanel.EmptySearchString",textEmptySearchString);}
alert(textEmptySearchString);return;}
assInstance.Instance().AdvancedSearchSortOrder="Relevance";assInstance.Instance().AdvancedSearchText=pdcore.getElm("tbSearch").value;assInstance.Instance().AdvancedSearchAuthor=pdcore.getElm("tbAuthor").value;assInstance.Instance().AdvancedSearch_dateMenuValue=getDateMenuValue();assInstance.Instance().AdvancedSearchInInnerHtml=pdcore.getElm("dvSearchInId").innerHTML;assInstance.Instance().AdvancedSearchIn=getSearchType();assInstance.Instance().AdvancedSearchStartSearch=false;assInstance.Instance().AdvancedSearchCurrentPage=0;assInstance.Instance().AdvancedSearchInnerHtml=null;pdcore.getElm("SearchResultPanel").innerHTML="";CallHttpHandler();}
function TryDidYouMeanLink(newSearch){pdcore.getElm("tbSearch").value=decodeURIComponent(newSearch);AdvancedSearch_onClick();}
function ShowSimilarArticle_OnClick(description,ArticleGuid,ArticleCount,title,country){assInstance.Instance().IssuePageCollection=null;assInstance.Instance().AdvancedSearchActiveState=false;var uriRedirect="AdvancedSimilarSearch.aspx?guid="+ArticleGuid;uriRedirect+="&text="+encodeURIComponent(description);uriRedirect+="&count="+ArticleCount;uriRedirect+="&title="+encodeURIComponent(title);uriRedirect+="&country="+country;window.location=uriRedirect;}
function AdvancedSearchClear_onClick(){assInstance.Instance().AdvancedSearchMode=true;assInstance.Instance().AdvancedSearchSimilarText="";assInstance.Instance().AdvancedSearchSimilarArticleCount=0;assInstance.Instance().AdvancedSearchArticleGuid=null;assInstance.Instance().IssuePageCollection=null;assInstance.Instance().AdvancedSearchActiveState=false;assInstance.Instance().AdvancedSearchSortOrder=null;pdcore.getElm('tbSearch').value="";assInstance.Instance().AdvancedSearchText=null;pdcore.getElm('tbAuthor').value="";assInstance.Instance().AdvancedSearchAuthor=null;assInstance.Instance().AdvancedSearch_NewspapersCollection.clear();fillNewspapersMenuBox("selectedNewspapersMenuBox");assInstance.Instance().AdvancedSearch_LanguagesCollection.clear();fillLanguagesMenuBox("selectedLanguagesMenuBox");assInstance.Instance().AdvancedSearch_dateMenuValue=assInstance.Instance().AdvancedSearch_dateMenuValues.Default;selectDateMenuItem(pdcore.getElm('browseBy3Days'));SearchDate_OnClick(true);assInstance.Instance().AdvancedSearchInInnerHtml=null;assInstance.Instance().AdvancedSearchIn=null;pdcore.getElm("headlineImg").alt="Remove";pdcore.getElm("headlineImg").src=imagedir+"i_remove.gif";pdcore.getElm("bodyImg").alt="Remove";pdcore.getElm("bodyImg").src=imagedir+"i_remove.gif";assInstance.Instance().AdvancedSearchCurrentPage=0;assInstance.Instance().AdvancedSearchStartSearch=false;assInstance.Instance().AdvancedSearchInnerHtml=null;pdcore.getElm("SearchResultPanel").innerHTML="";}
function sortResult_onClick(sortingOrder){assInstance.Instance().AdvancedSearchSortOrder=sortingOrder;assInstance.Instance().AdvancedSearchCurrentPage=0;assInstance.Instance().AdvancedSearchInnerHtml=null;pdcore.getElm("SearchResultPanel").innerHTML="";CallHttpHandler();}
function btPrevious_onClick(){assInstance.Instance().AdvancedSearchCurrentPage=assInstance.Instance().AdvancedSearchCurrentPage-1;assInstance.Instance().AdvancedSearchInnerHtml=null;pdcore.getElm("SearchResultPanel").innerHTML="";CallHttpHandler();}
function btSetCurrent_onClick(idx){assInstance.Instance().AdvancedSearchCurrentPage=idx;assInstance.Instance().AdvancedSearchInnerHtml=null;pdcore.getElm("SearchResultPanel").innerHTML="";CallHttpHandler();}
function btNext_onClick(){assInstance.Instance().AdvancedSearchCurrentPage=assInstance.Instance().AdvancedSearchCurrentPage+1;assInstance.Instance().AdvancedSearchInnerHtml=null;pdcore.getElm("SearchResultPanel").innerHTML="";return CallHttpHandler();}
function startDateMenuItem(){var start=new Date();var stop=new Date();var stopdate=stop.getTime();stopdate+=3600*1000*24;stop.setTime(stopdate);var startdate=start.getTime();switch(assInstance.Instance().AdvancedSearch_dateMenuValue){case assInstance.Instance().AdvancedSearch_dateMenuValues.Today:setDataFields(start,stop);pdcore.getElm("browseDateType").innerHTML=assInstance.Instance().AdvancedSearch_dateMenuValues.Today;break;case assInstance.Instance().AdvancedSearch_dateMenuValues.Last3Days:startdate-=3*3600*1000*24;start.setTime(startdate);setDataFields(start,stop);pdcore.getElm("browseDateType").innerHTML=assInstance.Instance().AdvancedSearch_dateMenuValues.Last3Days;break;case assInstance.Instance().AdvancedSearch_dateMenuValues.ThisWeek:startdate-=7*3600*1000*24;start.setTime(startdate);setDataFields(start,stop);pdcore.getElm("browseDateType").innerHTML=assInstance.Instance().AdvancedSearch_dateMenuValues.ThisWeek;break;case assInstance.Instance().AdvancedSearch_dateMenuValues.ThisMonth:startdate-=30*3600*1000*24;start.setTime(startdate);setDataFields(start,stop);pdcore.getElm("browseDateType").innerHTML=assInstance.Instance().AdvancedSearch_dateMenuValues.ThisMonth;break;case assInstance.Instance().AdvancedSearch_dateMenuValues.Anytime:startdate-=currentSubscriptionLength*3600*1000*24;start.setTime(startdate);setDataFields(start,stop);pdcore.getElm("browseDateType").innerHTML=assInstance.Instance().AdvancedSearch_dateMenuValues.Anytime;break;case assInstance.Instance().AdvancedSearch_dateMenuValues.None:pdcore.getElm("dtFrom").value=ResourceManager.formatDate("Search.DateFormat",assInstance.Instance().AdvancedSearch_StartDate,"yyyy-MM-dd");pdcore.getElm("dtTo").value=ResourceManager.formatDate("Search.DateFormat",assInstance.Instance().AdvancedSearch_StopDate,"yyyy-MM-dd");SearchDate_OnClick(false);break;}}
function LoadSearchResult(){if(assInstance.Instance().AdvancedSearchText){pdcore.getElm("tbSearch").value=assInstance.Instance().AdvancedSearchText;}else{pdcore.getElm("tbSearch").value="";}
fillNewspapersMenuBox("selectedNewspapersMenuBox");fillLanguagesMenuBox("selectedLanguagesMenuBox");startDateMenuItem();if(assInstance.Instance().AdvancedSearchAuthor){pdcore.getElm("tbAuthor").value=assInstance.Instance().AdvancedSearchAuthor;}else{pdcore.getElm("tbAuthor").value="";}
if(assInstance.Instance().AdvancedSearchInInnerHtml){pdcore.getElm("dvSearchInId").innerHTML=assInstance.Instance().AdvancedSearchInInnerHtml;}
if(assInstance.Instance().AdvancedSearchInnerHtml){if(assInstance.Instance().AdvancedSearchText.length!=assInstance.Instance().AdvancedSearchText.replace(/[^\s]/g,'').length||!assInstance.Instance().AdvancedSearchMode){onDataLoaded(assInstance.Instance().AdvancedSearchInnerHtml);}}}
function AdvancedSearch_onLoad(){if(assInstance.Instance().AdvancedSearchText||!assInstance.Instance().AdvancedSearchMode){if(assInstance.Instance().AdvancedSearchMode){pdcore.getElm("tbSearch").value=assInstance.Instance().AdvancedSearchText;}
assInstance.Instance().AdvancedSearchSortOrder="Relevance";fillNewspapersMenuBox("selectedNewspapersMenuBox");fillLanguagesMenuBox("selectedLanguagesMenuBox");if(assInstance.Instance().AdvancedSearchAuthor){pdcore.getElm("tbAuthor").value=assInstance.Instance().AdvancedSearchAuthor;}else{assInstance.Instance().AdvancedSearchAuthor="";}
startDateMenuItem();assInstance.Instance().AdvancedSearchIn="ALL";assInstance.Instance().AdvancedSearchCurrentPage=0;assInstance.Instance().AdvancedSearchStartSearch=false;assInstance.Instance().AdvancedSearchInnerHtml=null;pdcore.getElm("SearchResultPanel").innerHTML="";if(assInstance.Instance().AdvancedSearchText.length==assInstance.Instance().AdvancedSearchText.replace(/[^\s]/g,'').length&&assInstance.Instance().AdvancedSearchMode){return;}else{CallHttpHandler();return;}}else{LoadSearchResult();}}
function MonitorAdvancedSearch_onLoad(textencode){assInstance.Instance().AdvancedSearchText=textencode;if(assInstance.Instance().AdvancedSearchText||!assInstance.Instance().AdvancedSearchMode){if(assInstance.Instance().AdvancedSearchMode){pdcore.getElm("tbSearch").value=assInstance.Instance().AdvancedSearchText;}
assInstance.Instance().AdvancedSearchSortOrder="Relevance";fillNewspapersMenuBox("selectedNewspapersMenuBox");fillLanguagesMenuBox("selectedLanguagesMenuBox");if(assInstance.Instance().AdvancedSearchAuthor){pdcore.getElm("tbAuthor").value=assInstance.Instance().AdvancedSearchAuthor;}else{assInstance.Instance().AdvancedSearchAuthor="";}
startDateMenuItem();assInstance.Instance().AdvancedSearchIn="ALL";assInstance.Instance().AdvancedSearchCurrentPage=0;assInstance.Instance().AdvancedSearchStartSearch=false;assInstance.Instance().AdvancedSearchInnerHtml=null;pdcore.getElm("SearchResultPanel").innerHTML="";if(assInstance.Instance().AdvancedSearchText.length==assInstance.Instance().AdvancedSearchText.replace(/[^\s]/g,'').length&&assInstance.Instance().AdvancedSearchMode){return;}else{CallHttpHandler();return;}}else{LoadSearchResult();}}
DialogWin={image_dir:"images/",templatepage:"showtemplate.aspx",templatepage4templates:"showtemplate4templates.aspx",printRes:"Print",init:function(){pdcore.addToUnload(DialogWin.unload);},unload:function(){var t=DialogWin;if(t.elm)t.elm.onkeydown=null;if(t.titleElm)t.titleElm.ondblclick=null;t.elm=null;t.titleElm=null;t.titleTextElm=null;t.frm=null;},showTemplate:function(id,title){this.showUrl(this.templatepage+"?template="+id,title);},showTemplate4Templates:function(id,title,sx,sy,isnew){this.showUrl(this.templatepage4templates+"?template="+id+(isnew?"&disablecss=true":""),title,sx,sy,isnew);},showUrl:function(url,title,sx,sy,isnew){var t=this;title=title||"&nbsp;";if(!t.elm)t.create(url,title,isnew,sy);t.setTitle(title);pdcore.setFrmLocation("content_window_frame_dw",url);if(sx!=undefined&&sy!=undefined)
t.setSize(sx,sy);else
t.setDefaultSize();pdcore.focus("content_window_frame_dw");},hide:function(){pdcore.moveTo(DialogWin.elm,-10000,-10000);},print:function(){if(DialogWin.elm)
pdcore.print("content_window_frame_dw");},maximize:function(){var t=DialogWin;if(!t.maximized){t.maximized=true;pdcore.moveTo(t.elm,0,0);pdcore.setSize(t.elm,"100%","100%");}else t.setDefaultSize();},setDefaultSize:function(){this.setSize(600,500);},setSize:function(sx,sy){var elm=this.elm;this.maximized=false;var bw=pdcore.bodyWidth(),bh=pdcore.bodyHeight(),w=Math.min(bw-50,sx),h=Math.min(bh-50,sy),x=(bw-w)/2,y=(bh-h)/2;pdcore.moveTo(elm,x,y);pdcore.setSize(elm,w,h);},setTitle:function(title){pdcore.setText(this.titleTextElm,title);},create:function(url,title,isnew,sy){var t=this;t.elm=pdcore.createElm(null,"DIV","absolute");t.elm.style.zIndex=9999;if(!isnew)
t.elm.className="popmenu";if(isnew)
t.elm.innerHTML=["<table width='100%' height='100%' border=0 cellspacing=0 cellpadding=0><tr><td>","<div class='cbox-t' id='content_window_title_dw'><span></span><div></div><a href='javascript:;' onclick='DialogWin.hide()' class='cbox-i-close' /></div>","</td></tr><tr><td>","<div class='cbox-c1'><div class='cbox-c2'>","<iframe height='"+sy+"' frameborder='0' width='100%' scrolling='auto' id='content_window_frame_dw' src='"+url+"' name='content_window_frame_dw' hspace='0' vspace='0' border='0' marginheight='0' marginwidth='0'></iframe>","</div></div>","</td></tr><tr><td>","<div class='cbox-b' id='boxBottom'><div></div></div>","</td></tr></table>"].join('');else
t.elm.innerHTML=["<table width='100%' height='100%' border=0 cellspacing=0 cellpadding=0>","<tr><td class=popmenu_cover><table id=content_window_title_dw border=0 cellspacing=0 cellpadding=0>","<tr><td nowrap id='content_window_title_text_dw'>"+(title||"&nbsp;")+"</td><td width=20>","<img onclick='DialogWin.hide();' src='"+DialogWin.image_dir+"p_x.gif' width=20 height=22 border=0>","</td></tr></table></td></tr>","<tr><td class='panel_main_div_table_toptd'>","<a style='margin-left:20px;' href='javascript:DialogWin.print();'><img width='17' height='16' src='"+DialogWin.image_dir+"i_16_print.gif' border=0 align=absbottom>&nbsp;"+(t.printRes||"Print")+"</a>","</td></tr><tr><td>","<iframe id='content_window_frame_dw' src='"+url+"' name='content_window_frame_dw' width='100%' height='100%' hspace=0 vspace=0 border=0 frameborder=0 scrolling=auto marginheight=0 marginwidth=0></iframe>","</td></tr></table>"].join('');t.titleElm=pdcore.getElm("content_window_title_dw");t.titleTextElm=pdcore.getElm("content_window_title_text_dw");t.frm=pdcore.getFrm("content_window_frame_dw");if(t.titleElm){if(window.Drag)Drag.turnOnAutodrag(t.titleElm,t.elm);if(!isnew)
t.titleElm.ondblclick=DialogWin.maximize;}
t.elm.onkeydown=function(evt){if(pdcore.events.isEsc(evt)){DialogWin.hide();pdcore.events.preventBubble(evt);}}}}
DialogWin.init();
function Calendar(){this.currentID="";this.currentDatePass=null;this.tableCalendar="calendar";this.calDate=new Date();this.calStartActiveDate=new Date();}
Calendar.prototype.setDate=function setDate(day,month,year){this.calDate.setYear(year);this.calDate.setMonth(month);this.calDate.setDate(day);}
Calendar.prototype.setDateValue=function setDate(value){this.currentDatePass=value;this.calDate=this.currentDatePass;this.update();}
Calendar.prototype.setMonth=function setMonth(month){if(month<0){month=11;this.calDate.setYear(this.calDate.getYear()-1);}else if(month>11){month=0;this.calDate.setYear(this.calDate.getYear()+1);}
this.calDate.setMonth(month);if(this.calDate.getMonth()!=month){this.calDate.setDate(0);}
this.update();}
Calendar.prototype.setYear=function setYear(year){this.calDate.setYear(year);this.update();}
Calendar.prototype.setDay=function setDay(day){this.calDate.setDate(day);this.update();}
Calendar.prototype.incMonth=function incMonth(){this.setMonth(this.calDate.getMonth()+1);}
Calendar.prototype.decMonth=function decMonth(){this.setMonth(this.calDate.getMonth()-1);}
Calendar.prototype.selectDay=function selectDay(cell){if(cell.className!='cal_grey'){var day=cell.innerHTML;this.setDay(day);}}
Calendar.prototype.update=function update(){var chkDate=new Date(this.calDate);var calendar=pdcore.getElm(this.tableCalendar);var tmpDate=new Date(this.calDate);tmpDate.setDate(1);var first_day=tmpDate.getDay();tmpDate.setMonth(tmpDate.getMonth()+1);tmpDate.setDate(0);var last_day=tmpDate.getDate();tmpDate.setDate(1-first_day);var day_number=tmpDate.getDate();var selected_day=this.calDate.getDate();var cell;var i=0,j=2;for(;i<first_day;day_number++,i++){cell=calendar.rows[j].cells[i];cell.innerHTML=day_number;cell.className='cal_grey';}
for(day_number=1;day_number<=last_day;day_number++,i++){if(i>=7){j++;i=0;}
cell=calendar.rows[j].cells[i];chkDate.setDate(day_number);if(chkDate.getTime()>=this.calStartActiveDate.getTime()){if(selected_day==day_number){cell.className='cal_selected';}else{cell.className='cal';}}else{cell.className='cal_grey';}
cell.innerHTML=day_number;}
for(day_number=1;j<calendar.rows.length-1||i<7;day_number++,i++){if(i>=7){j++;i=0;}
cell=calendar.rows[j].cells[i];cell.innerHTML=day_number;cell.className='cal_grey';}
var year=this.calDate.getYear();if(year<1900){year+=1900;}
pdcore.getElm('month').value=this.calDate.getMonth();pdcore.getElm('year').value=year;}
Calendar.prototype.acceptInput=function acceptInput(){if(!this.calDate){this.calDate=this.calStartActiveDate;}else{if(this.calDate.getTime()<this.calStartActiveDate.getTime()){this.calDate=this.calStartActiveDate;}}
if(this.currentDatePass){this.currentDatePass=this.calDate;this.currentDatePass=null;}
if(this.currentID!=""){pdcore.getElm(this.currentID).value=ResourceManager.formatDate("Search.DateFormat",this.calDate,"yyyy-MM-dd");}
this.currentID="";pdcore.getElm(CALENDAR.tableCalendar).style.display="none";}
Calendar.prototype.cancelInput=function cancelInput(){this.currentID="";this.currentDatePass=null;pdcore.getElm(CALENDAR.tableCalendar).style.display="none";pdcore.getElm(CALENDAR.tableCalendar).style.top=0;}
