ArticleViewer={articlePages:[],articleFlag:false,articleMain:null,articleMainHandle:null,documentArticleFlag:null,documentArticleFlagWrapper:null,documentContainer:null,articleFlagText:null,actionCatalyts:false,article:null,articles:null,articleTocUrl:"/Article.action",articleTextUrl:"/Article.action?article_id=",initialized:false,loadComplete:true,active:false,hashParamName:"article_id",preloadedArticle:false,init:function(){if(ArticleViewer.initialized===false){ArticleViewer.articleMain=$("#layer1");
ArticleViewer.articleMainHandle=$("#layer1_handle");
ArticleViewer.documentArticleFlag=$("#documentArticleFlag");
ArticleViewer.documentArticleFlagWrapper=$("#documentArticleFlagWrapper");
ArticleViewer.articleFlagText=$("#articleFlagText");
ArticleViewer.documentContainer=$("#documentContainer");
ArticleViewer.Toc.init();
ArticleViewer.Articles.init();
ArticleViewer.Content.init();
ArticleViewer.Comment.init();
ArticleViewer.preloadCheck();
initialized=true
}},preloadCheckWithArticleId:function(A){$("#fit_view").click();
ArticleViewer.show();
ArticleViewer.Content.content_wrapper.html('<img class="busy" src="/images/misc/ajax-loader.gif" border="0" style="margin-top:60%;margin-left:45%;" alt="loading" />');
DataSwitch.get({url:DocumentProperties.getDocumentUrl()+ArticleViewer.articleTextUrl+A,cache:false,success:function(B){ArticleViewer.showPreloadedArticle(B,A)
}})
},preloadCheck:function(){var B=document.location.href.indexOf(ArticleViewer.hashParamName)!=-1;
if(B){var A=document.location.href.replace(/.*article_id=(\d+)(.*)/,"$1");
DataSwitch.get({url:DocumentProperties.getDocumentUrl()+ArticleViewer.articleTextUrl+A,cache:false,success:function(C){ArticleViewer.showPreloadedArticle(C,A)
}})
}},showArticleFlag:function(B){if(ArticleViewer.articleData){var C;
var A;
ArticleViewer.documentArticleFlag.hide();
$.each(ArticleViewer.articleData.articles,function(){var F=$(this);
for(i=0;
i<$(this)[0].pgs.length;
i++){var E=0;
var D=false;
C=$(this)[0].pgs[i];
if(PageModel.pageMode==2){if(B%2==0){E=B-1
}else{E=B+1
}if((PageController.getPageByFolio(C)==B)||(PageController.getPageByFolio(C)==E)){D=true
}}else{if(PageController.getPageByFolio(C)==B){D=true
}}if(D==true){A=$(this)[0].article_id;
ArticleViewer.documentArticleFlag.show();
ArticleViewer.documentArticleFlagWrapper.corners("top-left top-right");
ArticleViewer.documentArticleFlag.unbind("click").bind("click",function(){ArticleViewer.articleFlag=true;
if(ArticleViewer.articleFlagText.text()=="Open Article"){ArticleViewer.articleFlagText.text("Close Article");
ArticleViewer.preloadCheckWithArticleId(A)
}else{ArticleViewer.articleFlagText.text("Open Article");
ArticleViewer.hide()
}});
break
}}})
}},showPreloadedArticle:function(B,A){ArticleViewer.Content.processArticleData(B);
ArticleViewer.Content.show();
ArticleViewer.Content.adjustDisplaySize();
ArticleViewer.initPageNavigationButtonBehaviors();
ArticleViewer.updateHash(A);
ArticleViewer.active=true;
ArticleViewer.preloadedArticle=A;
if(ArticleViewer.articles&&ArticleViewer.articles.hasOwnProperty(A)){ArticleViewer.finalizePreloadedArticleSetup()
}},finalizePreloadedArticleSetup:function(){ArticleViewer.setArticle(ArticleViewer.preloadedArticle);
ArticleViewer.action_catalyst=true;
$("#curPageNumber").text(ArticleViewer.article.pgs[0]);
if(ArticleViewer.articleFlag!=true){PageController.handleGoToPage(PageController.getPageByFolio(ArticleViewer.article.pgs[0]))
}ArticleViewer.preloadedArticle=false
},getArticleIdByPageFolio:function(A){if(ArticleViewer.articles){for(var B in ArticleViewer.articles){if(ArticleViewer.articles[B].hasOwnProperty("pgs")&&$.inArray(Number(A),ArticleViewer.articles[B]["pgs"])!=-1){return B
}}}return false
},getArticleIdByPageNumber:function(A){if(ArticleViewer.articles){for(var B in ArticleViewer.articles){if(ArticleViewer.articles[B].hasOwnProperty("pgs")&&$.inArray(parseInt(A,10),ArticleViewer.articles[B]["pgs"])!=-1){return B
}}}return false
},show:function(){ArticleViewer.active=true;
ArticleViewer.articleMain.show();
ArticleViewer.articleFlagText.text("Close Article")
},hide:function(A){ArticleViewer.active=false;
if(ArticleViewer.articleMain!=null){ArticleViewer.articleMain.hide()
}if(ArticleViewer.articleFlagText!=null){ArticleViewer.articleFlagText.text("Open Article")
}},setArticle:function(A){if(ArticleViewer.article&&ArticleViewer.article.article_id==A){return 
}ArticleViewer.article=typeof A!="undefined"&&ArticleViewer.articles.hasOwnProperty(A)?ArticleViewer.articles[A]:ArticleViewer.getArticleByIndex(0)
},getArticleByIndex:function(A){var C=0;
for(var B in ArticleViewer.articles){if(C==A){return ArticleViewer.articles[B]
}C++
}return null
},initPageNavigationButtonBehaviors:function(){$(".nextArticlePage").unbind("click").bind("click",ArticleViewer.nextArticle);
$(".prevArticlePage").unbind("click").bind("click",ArticleViewer.prevArticle)
},nextArticle:function(C){C.preventDefault();
C.stopPropagation();
try{if(ArticleViewer.article){var B=$("#"+ArticleViewer.article.article_id,$(ArticleViewer.Toc.article_toc)).next();
if(B.length){ArticleViewer.articleFlag=false;
ArticleViewer.preloadCheckWithArticleId(B[0].id);
return 
}throw"Going to first article"
}}catch(A){ArticleViewer.firstArticle(C)
}},prevArticle:function(B){B.preventDefault();
B.stopPropagation();
try{if(ArticleViewer.article){var C=$("#"+ArticleViewer.article.article_id,$(ArticleViewer.Toc.article_toc)).prev();
if(C.length){ArticleViewer.articleFlag=false;
ArticleViewer.preloadCheckWithArticleId(C[0].id);
return 
}}throw"Going to last article"
}catch(A){ArticleViewer.lastArticle(B)
}},updateHash:function(C){var E=ArticleViewer.hashParamName;
var A=new RegExp("([^&?"+E+"]+)(&?"+E+"=[\\d]+)(.*)");
var D=document.location.hash;
var B="";
if(C===false){var B=D.replace(A,"$1$3")
}else{if(D.indexOf(E)!=-1){B=D.replace(A,"$1&"+E+"="+C+"$3")
}else{B=D.length>0?D+"&"+E+"="+C:E+"="+C
}}$.ajaxHistory.update(B.replace("#",""))
}};
ArticleViewer.Content={wrapper:null,content_wrapper:null,contentMain:null,template:null,min_font_size:10,default_font_size:16,max_font_size:24,go_to_comments_link:null,close_article_viewer_link:null,comment_submit_button:null,font_sizer_links:null,commentFormHeight:175,doScrollToComments:false,init:function(){var B=ArticleViewer.documentContainer.width()/2-20;
var A=ArticleViewer.documentContainer.position().left+B+25;
var C=ArticleViewer.documentContainer.position().top+40;
ArticleViewer.Content.wrapper=$("#article",PageModel.documentContainerDiv);
ArticleViewer.Content.content_wrapper=$("#article_content_wrapper",this.wrapper);
ArticleViewer.Content.contentMain=$("#article_content");
ArticleViewer.Content.initToolLinks();
ArticleViewer.Content.adjustDisplaySize();
ArticleViewer.articleMain.css("left",A);
ArticleViewer.articleMain.css("top",C)
},show:function(){this.wrapper.css({display:"block"})
},hide:function(){ArticleViewer.Content.wrapper.css("display","none")
},initToolLinks:function(){$("#close").bind("click",function(A){if(A){A.preventDefault();
A.stopPropagation()
}ArticleViewer.hide()
});
ArticleViewer.articleMain.draggable({zIndex:20,ghosting:false,opacity:0.7,handle:"#layer1_handle"});
this.comment_submit_button=$("#comment_submit",ArticleViewer.Content.wrapper);
this.go_to_comments_link=$("#article_comment_quicklink");
this.add_comments_link=$("#addArticleComment");
this.add_comments_link_bottom=$("#addArticleCommentBottom");
this.comment_submit_button.bind("click.create_comment",ArticleViewer.Comment.create);
this.go_to_comments_link.bind("click.scrollToComments",ArticleViewer.Content.scrollToComments);
this.add_comments_link.bind("click.scrollToAddComments",ArticleViewer.Content.scrollToAddComments);
this.add_comments_link_bottom.bind("click.scrollToAddComments",ArticleViewer.Content.scrollToAddComments);
$(".comment_reply a").live("click.comment_reply",ArticleViewer.Comment.initiateCommentReply)
},scrollToComments:function(C){if(C){C.preventDefault();
C.stopPropagation()
}var B=$("#article_content_inner",this.wrapper);
if($("#comments",this.wrapper).get(0)!=null){var A=$("#comments",this.wrapper).get(0).offsetTop-60
}else{var A=$("#addCommentTitle",this.wrapper).get(0).offsetTop-60
}if(B.scrollTop()<A){$("#article_content").animate({scrollTop:A},300)
}},scrollToAddComments:function(C){if(C){C.preventDefault();
C.stopPropagation()
}var B=$("#article_content_inner",this.wrapper);
var A=$("#addCommentTitle",this.wrapper).get(0).offsetTop-60;
if(B.scrollTop()<A){$("#article_content").animate({scrollTop:A},300)
}},processArticleData:function(A){ArticleViewer.Content.changeArticles(A);
ArticleViewer.Content.initToolLinks();
ArticleViewer.Comment.init()
},changeArticles:function(B){var A=this;
ArticleViewer.Content.content_wrapper.html(B);
ArticleViewer.Content.adjustDisplaySize();
ArticleViewer.Toc.updateSelectedItem();
ArticleViewer.action_catalyst=true;
if(ArticleViewer.Content.doScrollToComments===true){ArticleViewer.Content.scrollToComments()
}if(ArticleViewer.article&&$.inArray(parseInt(PageController.currentPage,10),ArticleViewer.article.pgs)==-1){if(ArticleViewer.articleFlag!=true){PageController.handleGoToFolio(ArticleViewer.article.pgs[0])
}}setTimeout(function(){ArticleViewer.action_catalyst=false
},200)
},adjustDisplaySize:function(){var C;
if(PageModel.pageMode==1){C=ArticleViewer.documentContainer.width()-20
}else{C=ArticleViewer.documentContainer.width()/2-20
}var D=ArticleViewer.documentContainer.height()-45;
ArticleViewer.articleMain.css({width:C,height:D});
ArticleViewer.Content.wrapper.css({width:C-2,height:D-40});
$("#article_content").height(ArticleViewer.articleMain.height()-ArticleViewer.articleMainHandle.height()-$("#article_title").height()-50);
var E=$("#articleTab").width();
if(E>0){$(".artTab1").addClass("b1");
$(".artTab1").css({width:E-8,top:"-4px",left:"-1px"});
$(".artTab2").addClass("b2");
$(".artTab2").css({width:E-8,top:"-4px",left:"-1px"});
$(".artTab3").addClass("b3");
$(".artTab3").css({width:E-4,top:"-4px",left:"-1px"});
$(".artTab4").addClass("b4");
$(".artTab4").css({width:E-2,top:"-4px",left:"-1px"})
}var B=ArticleViewer.articleMainHandle.height();
var A=D-B-6;
if(C>0){$(".b1div").addClass("b1");
$(".b1div").css({width:C-8,top:"-4px",left:"-1px"});
$(".b2div").addClass("b2");
$(".b2div").css({width:C-8,top:"-4px",left:"-1px"});
$(".b3div").addClass("b3");
$(".b3div").css({width:C-4,top:"-4px",left:"-1px"});
$(".b4div").addClass("b4");
$(".b4div").css({width:C-2,top:"-4px",left:"-1px"});
$(".b1div_bottom").addClass("b1");
$(".b1div_bottom").css({width:C-8,top:A,left:"-1px"});
$(".b2div_bottom").addClass("b2");
$(".b2div_bottom").css({width:C-8,top:A,left:"-1px"});
$(".b3div_bottom").addClass("b3");
$(".b3div_bottom").css({width:C-4,top:A,left:"-1px"});
$(".b4div_bottom").addClass("b4");
$(".b4div_bottom").css({width:C-2,top:A,left:"-1px"})
}}};
ArticleViewer.Toc={selected:null,wrapper:"#tableOfContents",default_toc:"#tableOfContents ol:first",article_toc:"#articleToc",init:function(){DataSwitch.get({url:DocumentProperties.getDocumentUrl()+ArticleViewer.articleTocUrl,cache:false,success:function(B){$(ArticleViewer.Toc.wrapper).append(B);
var A=[];
$("#drawer_articles").children().each(function(){var D=$(this);
var C={article_id:D.children()[0].innerHTML,title:D.children()[1].innerHTML,pgs:D.children()[2].innerHTML.split(",")};
A.push(C)
});
ArticleViewer.articleData={articles:A};
ArticleViewer.showArticleFlag(PageController.currentPage)
}})
},setupTocClick:function(){$(ArticleViewer.Toc.article_toc).unbind("click.article_toc_click",ArticleViewer.Toc.articleTocClick).bind("click.article_toc_click",ArticleViewer.Toc.articleTocClick)
},show:function(){if($(ArticleViewer.Toc.article_toc).is(":hidden")){Scroller.destroyAll();
$(ArticleViewer.Toc.default_toc).addClass("hidden");
$(ArticleViewer.Toc.article_toc).removeClass("hidden");
ViewHelper.makeScrollable();
ArticleViewer.Toc.setupTocClick()
}},hide:function(){$(ArticleViewer.Toc.default_toc).removeClass("hidden");
$(ArticleViewer.Toc.article_toc).addClass("hidden");
ViewHelper.makeScrollable()
},articleTocClick:function(C){var B=$(C.target);
if(ArticleViewer.articles){while(!$(B).is(ArticleViewer.Toc.article_toc)){if(B.is("a")){var A=B.attr("id").replace("article_","");
if(!isNaN(A)){ArticleViewer.setArticle(A);
ArticleViewer.article.show();
ArticleViewer.show();
C.preventDefault();
C.stopPropagation();
return 
}}B=$(B).parent()
}}else{return false
}},updateSelectedItem:function(){if(ArticleViewer.article){var A=ArticleViewer.article.article_id;
if(ArticleViewer.Toc.selected){ArticleViewer.Toc.selected.removeClass("active")
}ArticleViewer.Toc.selected=$("#article_"+A,ArticleViewer.Toc.article_toc).addClass("active")
}}};
ArticleViewer.Articles={init:function(){var D=0;
var A=[];
var B=[];
var C=setInterval(function(){if(ArticleViewer.articleData){clearInterval(C);
if(ArticleViewer.articleData.hasOwnProperty("articles")&&ArticleViewer.articleData.articles.length>0){ArticleViewer.articles={};
for(var E=0;
E<ArticleViewer.articleData.articles.length;
E++){ArticleViewer.articles[ArticleViewer.articleData.articles[E]["article_id"]]=clone(ArticleViewer.Article);
ArticleViewer.articles[ArticleViewer.articleData.articles[E]["article_id"]].init(ArticleViewer.articleData.articles[E])
}ArticleViewer.loadComplete=true;
if(ArticleViewer.preloadedArticle!==false){A.push(ArticleViewer.finalizePreloadedArticleSetup)
}A.push(ArticleViewer.Articles.buildArticlePagesArray);
ViewHelper.schedule(A,ArticleViewer.Articles)
}}else{if(D>=10){ArticleViewer.loadComplete=true;
clearInterval(C)
}}D++
},500)
},buildArticlePagesArray:function(){var A=ArticleViewer.articles;
for(var B in A){if(A[B].hasOwnProperty("pgs")){ArticleViewer.articlePages=ArticleViewer.articlePages.concat(A[B].pgs)
}}}};
ArticleViewer.Article={init:function(A){for(prop in A){if(A.hasOwnProperty(prop)){this[prop]=A[prop]
}}},show:function(){var A=this;
A.getArticleContent()
},getArticleContent:function(){var A=this;
var B=location.pathname;
if(B.substring(B.length-1)=="/"){B=B.substring(0,B.length-1)
}ArticleViewer.Content.adjustDisplaySize();
ArticleViewer.Content.content_wrapper.html('<img class="busy" src="/images/misc/ajax-loader.gif" border="0" style="margin-top:30%;margin-left:40%;" alt="loading" />');
DataSwitch.get({url:B+ArticleViewer.articleTextUrl+A.article_id,cache:false,success:ArticleViewer.Content.processArticleData})
}};
ArticleViewer.Comment={commentFields:{},init:function(){var A=CookieManager.get("comment_name");
$(".comment_input",ArticleViewer.Content.wrapper).each(function(){$(this).data("required",$(this).hasClass("required"));
$(this).data("default",$(this).val());
ArticleViewer.Comment.commentFields[$(this).attr("id")]=$(this);
ArticleViewer.Comment.attachBehaviors.call(this)
});
if(A){$("#comment_name",ArticleViewer.Content.wrapper).val(A)
}},create:function(C){var D=ArticleViewer.Comment.commentFields;
var I=true;
for(var F in D){var A=ArticleViewer.Comment.commentFields[F];
var B=A.val();
if(A.data("required")===true&&(B==""||A.data("default")==B)){I=false;
break
}}if(I===true){var E=D.comment_parent_id.val()||0;
var H="<CommentRequest><articleId>"+ArticleViewer.article.article_id+"</articleId><comment>"+D.comment_text.val()+"</comment><subject></subject><name></name><commentId>0</commentId><parentId>"+E+"</parentId></CommentRequest>";
var G=location.pathname;
if(G.substring(G.length-1)=="/"){G=G.substring(0,G.length-1)
}DataSwitch.post({url:G+"/WSComments.xml",processData:false,contentType:"text/xml",data:H,success:function(J){ArticleViewer.article.show();
ArticleViewer.Comment.resetFields(true);
$("#comment_parent_id",ArticleViewer.Content.wrapper).val("");
ArticleViewer.Content.doScrollToComments=true
},error:function(){ArticleViewer.Comment.showCommentResponse("error")
}})
}else{alert("you must complete all fields to post a comment.")
}},resetFields:function(B){var A=ArticleViewer.Comment.commentFields;
for(var C in A){ArticleViewer.Comment.resetField.call(A[C],B)
}},resetField:function(C){var A=$(this).val();
var B=typeof C!="undefined"?C:false;
if(A==""||B===true){$(this).val($(this).data("default"))
}},fieldBlur:function(){ArticleViewer.Comment.resetField.call($(this))
},fieldFocus:function(){var A=$(this).val();
if(A==$(this).data("default")){$(this).val("")
}},attachBehaviors:function(){$(this).unbind("focus.comment_blur",ArticleViewer.Comment.fieldFocus).bind("focus.comment_blur",ArticleViewer.Comment.fieldFocus);
$(this).unbind("blur.comment_blur",ArticleViewer.Comment.fieldBlur).bind("blur.comment_blur",ArticleViewer.Comment.fieldBlur)
},initiateCommentReply:function(E){E.preventDefault();
E.stopPropagation();
if($(this).parents("div").next(".comment_reply_text").is(":hidden")){$(this).text("close");
$(this).parents("div").next(".comment_reply_text").append("<fieldset><input id='comment_parent_id' class='comment_input' type='hidden' value='' /><textarea id='comment_text' class='comment_input required'></textarea><div id='comment_submit' class='gradient_button'><span>SUBMIT</span></div></fieldset>");
$(".comment_reply_text").hide();
var C=CookieManager.get("comment_name");
$(".comment_input",$(this).parents("div").next(".comment_reply_text")).each(function(){$(this).data("required",$(this).hasClass("required"));
$(this).data("default",$(this).val());
ArticleViewer.Comment.commentFields[$(this).attr("id")]=$(this);
ArticleViewer.Comment.attachBehaviors.call(this)
});
if(C){$("#comment_name",ArticleViewer.Content.wrapper).val(C)
}$(this).parents("div").next(".comment_reply_text").show();
ArticleViewer.Content.initToolLinks();
var B=$(this).attr("href").split("/");
var D=B[B.length-1];
var A=$(this).closest("div.comment");
var F=A.find("h3").text();
$("#comment_parent_id",ArticleViewer.Content.wrapper).val(D);
$("#comment_subject",ArticleViewer.Content.wrapper).val("re: "+F);
return false
}else{$(this).text("reply");
$(this).parents("div").next(".comment_reply_text").find("fieldset").remove();
$(this).parents("div").next(".comment_reply_text").hide()
}},closeCommentReply:function(A){},showCommentResponse:function(A){var B=A=="success"?$("#comment_success",ArticleViewer.Content.wrapper).html():$("#comment_error",ArticleViewer.Content.wrapper).html();
$(ViewHelper.shadowWrap(B,"black")).dialog({height:300,width:400,modal:false,close:function(){$(this).dialog("destroy").remove()
},open:function(){PageElements.dialogs.comment_response={id:"comment_response",link_active:false,dialog_active:true}
},resizable:false})
}};