(function(){var glow;var commentEmpty="Please enter a comment",commentTooLong="Your comment is too long",getElementById=document.getElementById;window.vision=window.vision||{};vision.comments={version:"1_2",theme:"default",order:"DESC",source:null,maxChars:1000,currentPage:1,requestedPage:1,highestPageVisited:1,totalPages:1,totalComments:null,pagesInCache:0,commentsInPage:10,queryEnginePageSize:this.commentsInPage*2,queryEnginePage:1,queryengineData:{},cache:[],cacheContainsAllData:false,onLoad:function(){},getPopups:function(){var poplinks=document.getElementsByTagName("a"),i,len;for(i=0,len=poplinks.length;i<len;i++){if(poplinks[i].className=="popup"){poplinks[i].onclick=function(){return vision.comments.pop(this.href)}}}},init:function(){vision.comments.getPopups();vision.comments.addClose();vision.comments.validateComplaint();if(glow.isSupported){if(document.getElementById("vision-comments-form")){document.getElementById("vision-comments-form").onsubmit=vision.comments.submitForm}if(document.getElementById("vision-comments-view")&&vision.comments.hidePagination==0){vision.comments.initPagination();vision.comments.onLoad()}if(document.getElementById("complain-1")){vision.comments.getTerms()}if(vision.comments.recommendAssets){vision.comments.recommend.init()}}},pop:function(url){newwindow=window.open(url,"name","height=300,width=210,resizable=yes,scrollbar=auto");if(window.focus){newwindow.focus()}return false},getTerms:function(){var poplinks=document.getElementsByTagName("a"),i,len;for(i=0,len=poplinks.length;i<len;i++){if(poplinks[i].className=="popup"){poplinks[i].onclick=function(){return vision.comments.popTerms(this.href)}}}},popTerms:function(url){newwindow=window.open(url,"terms","height=auto,width=auto,resizable=yes,scrollbars=yes");if(window.focus){newwindow.focus()}return false},addClose:function(){var closable=document.getElementById("content");if(closable){var parent=closable.parentNode;var parentName=parent.id;if(parentName=="complain-1"||parentName=="complain-3"){var p=document.createElement("p");closable.appendChild(p);newpara=closable.lastChild;newpara.id="close";newpara.innerHTML='<a href="#" onclick="window.close();">Close this window</a>'}}},validateComplaint:function(){var button=document.getElementsByTagName("input"),parent,parentName;for(var i=0;i<button.length;i++){if(button[i].type=="submit"){parent=button[i].parentNode;parentName=parent.className;button[i].onclick=function(){if(parentName=="vision-comments-submitcomplaint"){var complaint=document.getElementById("message");if(complaint.value==""){alert("Please enter a reason for flagging this comment.");return false}else{return true}}else{return true}}}}},submitForm:function(){var formRef=document.forms["vision-comments-form"],sSource=formRef.source.value;sComment=(formRef["vision-comments-message"])?(formRef["vision-comments-message"]).value:"";sLocation=(formRef["vision-comments-location"])?(formRef["vision-comments-location"]).value:"";sName=(formRef["vision-comments-name"])?(formRef["vision-comments-name"]).value:"";sChoice=(formRef.choice)?(formRef.choice).value:"";sSummary=(formRef.summary)?(formRef.summary).value:"";if((sComment=="")&&(vision.comments.commentfield=="required")){alert(vision.comments.nocommentwarning)}else{if((sName=="")&&(vision.comments.namefield=="required")){alert(vision.comments.nonamewarning)}else{if((sLocation=="")&&(vision.comments.locationfield=="required")){alert(vision.comments.nolocationwarning)}else{if(sComment.length>vision.comments.maxChars){alert(vision.comments.longcommentwarning)}else{var getRef=glow.net.post("/apps/vision/"+vision.comments.version+"/comments/","L2REndPage=/apps/vision/comments/includes/end.sssi&message="+sComment+"&name="+sName+"&location="+sLocation+"&source="+sSource+"&choice="+sChoice+"&summary="+sSummary,{onLoad:function(response){var elCommentsForm=document.getElementById("vision-comments-form");var formHtml=elCommentsForm.innerHTML;var html="<h3>"+vision.comments.thanks+" "+sName+"!</h3><p>"+vision.comments.thankstext+'</p><p class="disclaimer">'+vision.comments.disclaimer+"</p>"+response.text();html=html.replace(/css\/\(none\)\/f/,"css/"+vision.comments.theme+"/f");elCommentsForm.innerHTML=html;document.getElementById("vision-comments-backToForm").innerHTML=vision.comments.backtext;document.getElementById("vision-comments-backToForm").onclick=function(){elCommentsForm.innerHTML=formHtml;if(document.getElementById("vision-comments-message")){document.getElementById("vision-comments-message").value=""}if(document.getElementById("vision-comments-name")){document.getElementById("vision-comments-name").value=""}if(document.getElementById("vision-comments-location")){document.getElementById("vision-comments-location").value=""}}},onError:function(response){alert("Error getting file: "+response.statusText())}})}}}}return false},initPagination:function(){var htmlNavBoth='<p class="back" title="'+vision.comments.backtext+'"><a href="#vision-comments-view" onclick="vision.comments.getComments(\'back\');"><span></span>'+vision.comments.backtext+'</a></p><p class="forward" title="'+vision.comments.nexttext+'"><a href="#vision-comments-view" onclick="vision.comments.getComments(\'next\');"><span></span>'+vision.comments.nexttext+"</a></p>",htmlNavNone='<p class="back backoff" title="'+vision.comments.backtext+'"><span></span>'+vision.comments.backtext+'</p><p class="forward forwardoff" title="'+vision.comments.nexttext+'"><span></span>Next</p>',htmlNavBack='<p class="back" title="'+vision.comments.backtext+'"><a href="#vision-comments-view" onclick="vision.comments.getComments(\'back\');"><span></span>'+vision.comments.backtext+'</a></p><p class="forward forwardoff" title="'+vision.comments.nexttext+'"><span></span>'+vision.comments.nexttext+"</p></p>",htmlNavNext='<p class="back backoff" title="'+vision.comments.backtext+'"><span></span>'+vision.comments.backtext+'</p><p class="forward" title="'+vision.comments.nexttext+'"><a href="#vision-comments-view" onclick="vision.comments.getComments(\'next\');"><span></span>'+vision.comments.nexttext+"</a></p>";var elNav=document.createElement("div"),comments=vision.comments;elNav.id="vision-comments-nav";var elemView=document.getElementById("vision-comments-view");var aDivs=elemView.getElementsByTagName("div");for(var i=0;i<aDivs.length;i++){if(aDivs[i].className=="bl"){var insertionPoint=aDivs[i]}}elemView.insertBefore(elNav,insertionPoint);var htmlNav=htmlNavNext;if(comments.totalComments<=comments.commentsInPage){var htmlNav=htmlNavNone}comments.totalPages=Math.ceil(comments.totalComments/comments.commentsInPage);document.getElementById("vision-comments-nav").innerHTML=htmlNav;document.getElementById("vision-comments-addtitle").innerHTML=vision.comments.viewtitle+' <span id="vision-comments-pagecount">'+vision.comments.currentPage+" / "+vision.comments.totalPages+"</span>";comments.getQueryengineDataQuiet()},getComments:function(button){var comments=vision.comments,requestedPage;if(button=="next"){requestedPage=vision.comments.currentPage+1}else{requestedPage=vision.comments.currentPage-1}if((comments.pagesInCache>0&&requestedPage>comments.totalPages)||requestedPage==0){return}if(button=="next"){comments.currentPage++;if(comments.currentPage>comments.highestPageVisited){comments.highestPageVisited=comments.currentPage}}else{comments.currentPage--}comments.displayCommentsFromCache();if(button!="back"&&!comments.cacheContainsAllData){comments.getQueryengineDataQuiet()}return false},getQueryengineDataQuiet:function(){var comments=vision.comments,getRef=glow.net.get("/apps/ifl/apps/vision/"+vision.comments.version+"/comments/queryengine?pagesize="+vision.comments.queryEnginePageSize+";page="+vision.comments.queryEnginePage+";sort_1=id;sortsense_1="+vision.comments.order+";attrib_1=source;oper_1="+vision.comments.match+";val_1_1="+vision.comments.source+";OutputFormat=JSON;OutputContent=ISO-8859-1",{onLoad:function(response){comments.queryengineData=eval("("+response.text()+")");var oData=vision.comments.queryengineData;comments.cache=comments.cache.concat(oData.RECORD);for(var i=0;i<vision.comments.cache.length;i++){comments.cache[i].submit_date=comments.cache[i].submit_date.slice(0,10)}comments.totalPages=Math.ceil(oData.total_hits/comments.commentsInPage);comments.pagesInCache=Math.ceil(comments.cache.length/comments.commentsInPage);comments.queryEnginePage++;if(comments.pagesInCache==comments.totalPages){comments.cacheContainsAllData=true}},onError:function(response){alert("Error getting file: "+response.statusText())}})},displayCommentsFromCache:function(){var elComments=document.getElementById("vision-comments-view"),topHTML='<div class="tl"></div><div class="tr"></div><div class="top"></div>',titleHTML='<h2 id="vision-comments-addtitle">'+vision.comments.viewtitle+' <span id="vision-comments-pagecount">'+vision.comments.currentPage+" / "+vision.comments.totalPages+"</span></h2>",bottomHTML='<div class="bl"></div><div class="br"></div><div class="bottom"></div>',comments=vision.comments;var firstComment=(comments.currentPage-1)*comments.commentsInPage;var lastComment=firstComment+comments.commentsInPage;if(lastComment>comments.totalComments){lastComment=comments.totalComments}var commentHTML="",locationHtml="";for(var i=firstComment;i<lastComment;i++){if(i%2==0){commentClass="comment alt"}else{commentClass="comment"}if(comments.cache[i].location){locationHtml=', <span class="adr"><span class="locality">'+comments.cache[i].location+"</span></span>"}else{locationHtml=""}commentHTML+='<div class="'+commentClass+'"><cite><span class="vcard"><span class="fn">'+(comments.cache[i].name||"Anonymous")+"</span>"+locationHtml+'</span>  <span class="date">'+comments.cache[i].submit_date.slice(0,10)+'</span></span></cite><p class="comment-text">'+comments.cache[i].message+'</p><p class="flag"><a target="_blank" class="popup" href="'+vision.comments.complainturl+"?id="+comments.cache[i].id+'">'+vision.comments.flagtext+"</a></p></div>"}var htmlNavBoth='<p class="back" title="'+vision.comments.backtext+'"><a href="#vision-comments-view" onclick="vision.comments.getComments(\'back\');"><span></span>'+vision.comments.backtext+'</a></p><p class="forward" title="'+vision.comments.nexttext+'"><a href="#vision-comments-view" onclick="vision.comments.getComments(\'next\');"><span></span>'+vision.comments.nexttext+"</a></p>",htmlNavNone='<p class="back backoff" title="'+vision.comments.backtext+'"><span></span>'+vision.comments.backtext+'</p><p class="forward forwardoff" title="'+vision.comments.nexttext+'"><span></span>'+vision.comments.nexttext+"</p>",htmlNavBack='<p class="back" title="'+vision.comments.backtext+'"><a href="#vision-comments-view" onclick="vision.comments.getComments(\'back\');"><span></span>'+vision.comments.backtext+'</a></p><p class="forward forwardoff" title="'+vision.comments.nexttext+'"><span></span>'+vision.comments.nexttext+"</p></p>",htmlNavNext='<p class="back backoff" title="'+vision.comments.backtext+'"><span></span>'+vision.comments.backtext+'</p><p class="forward" title="'+vision.comments.nexttext+'"><a href="#vision-comments-view" onclick="vision.comments.getComments(\'next\');"><span></span>'+vision.comments.nexttext+"</a></p>";if(comments.currentPage==1){var htmlNav=htmlNavNext}else{if(comments.currentPage==vision.comments.totalPages){var htmlNav=htmlNavBack}else{var htmlNav=htmlNavBoth}}var linksHTML='<div id="vision-comments-nav">'+htmlNav+"</div>";elComments.innerHTML=topHTML+titleHTML+commentHTML+linksHTML+bottomHTML;comments.getPopups();vision.comments.onLoad()},recommend:{init:function(){glow.dom.get(".recommendasset").each(function(){this.onclick=vision.comments.recommend.send})},send:function(){var elem=this;glow.net.get("",{onLoad:function(response){var html="<h3>"+vision.comments.recommendAssetsThanks+"</h3><p>"+vision.comments.recommendAssetsThankstext+"</p>";elem.innerHTML=html},onError:function(response){alert("Error getting file: "+response.statusText())}});return false}}};gloader.load(["glow","1","glow.dom","glow.events","glow.data","glow.net"],{async:true,onLoad:function(glowInstance){glow=glowInstance;glow.ready(vision.comments.init)}})})();