var $v="";function FlagTip($t)
{if(!confirm('This comment will be flagged as offensive.  Are you sure?'))
return;var requester;try{requester=new XMLHttpRequest();}
catch(error){try{requester=new ActiveXObject("Microsoft.XMLHTTP");}
catch(error){return false;}}
requester.open("GET","/Support/Flag.aspx?tipid="+$t);requester.send(null);y=document.getElementById("spanTipFlagHref"+$t);y.visible=false;y.style.display="none";y=document.getElementById("spanTipFlagged"+$t);y.style.display="inline";y.textContent="This comment has been flagged.";}
function r($t,$r){$.ajax({type:"POST",url:"/Support/SetRating.aspx",data:"tipid="+$t+"&value="+$r});$v+=";"+$t+";";return false;}
function rA($t,$r){$.ajax({type:"POST",url:"/Support/SetRating.aspx",data:"t=4&ArticleId="+$t+"&Value="+$r,success:function(results){eval(results);$('.Details .Rating .Stars').fadeOut(300,function(){$(this).html(rating.image).fadeIn();});}});var star=document.getElementById('RatingCount');star.innerHTML=parseInt(star.innerHTML)+1;$v+=";"+$t+";";return false;}
function ratingsOver($a,$n){if($v.indexOf(";"+$a+";")>=0)return;for($i=1;$i<6;$i++)
document.getElementById($a+"_"+$i).src=($i<=$n)?"/images/stars/star-hover.gif":"/images/stars/star-nohover.gif";}
function ratingsOut($a,$p1,$p2,$p3,$p4,$p5){if($v.indexOf(";"+$a+";")>=0)return;var y=document.getElementById($a+"_1");y.src="/images/stars/star-1-"+$p1+".gif";y=document.getElementById($a+"_2");y.src="/images/stars/star-1-"+$p2+".gif";y=document.getElementById($a+"_3");y.src="/images/stars/star-1-"+$p3+".gif";y=document.getElementById($a+"_4");y.src="/images/stars/star-1-"+$p4+".gif";y=document.getElementById($a+"_5");y.src="/images/stars/star-1-"+$p5+".gif";}
function ismaxlength(obj)
{var mlength=obj.getAttribute?parseInt(obj.getAttribute("maxlength")):"";if(obj.getAttribute&&obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength);}
function bindPostCommentLink(articleID)
{var self=this;this.articleID=articleID;$("#postComment").bind("click",function(){$(this).unbind("click");if($(this).hasClass("Button2a")){$(this).removeClass("Button2a").addClass("Button1a").find(".text").html("Posting Comment");}else if($(this).hasClass("Button2Size1")){$(this).removeClass("Button2Size1").addClass("Button1Size1").html("Posting Comment");}
self.postComment($(this));})
this.postComment=function(button){if(validateComment()){$.getJSON('ajax/Common.aspx',{method:"PostComment",articleID:self.articleID,comment:$("#MemberComment").val()},function(response){var totalCount=$("#TotalComments");if(totalCount)
{totalCount=parseInt(totalCount.html());$("#TotalComments").html(totalCount+1)}
if($(".Comment").length>0)
$(".Comment:first").before(response.Html);else
$(".Main.PostComment.Section").before("<div id=\"comments\" class=\"Main Comments Section\">"+response.Html+"</div>");button.bind("click",function(){button.unbind("click").removeClass("Button2a").addClass("Button1a");self.postComment(button);});if(button.hasClass("Button1a")){button.removeClass("Button1a").addClass("Button2a").find(".text").html("Post a Comment");}else if(button.hasClass("Button1Size1")){button.removeClass("Button1Size1").addClass("Button2Size1").html("Post a Comment");}
document.getElementById("MemberComment").value=String.empty;if($("#postToFacebook:checked").val()!=null)
{var images=[];if(response.ItemThumbnailUrl!=undefined&&response.ItemThumbnailUrl!="")
images=[{"src":response.ItemThumbnailUrl,"href":document.location.href}]
var variables={'Title':response.Title,'URL':document.location.href,'Excerpt':response.ArticleIntroduction,'Comment_Body':response.UserComment,'images':images};FB.Connect.showFeedDialog("63205862906",variables,null,null,FB.FeedStorySize.shortStory,FB.RequireConnect.promptConnect);}})}}}
function validateComment()
{if($("#MemberComment").val()=="")
{if($(".error-msg").length==0)
$("#MemberComment").before("<span class=\"error-msg\">There was an error in your request, please try again.</span>");return false;}
else
{$(".error-msg").remove();return true;}}
$(document).ready(TB_init);function TB_init(){$("a.thickbox").click(function(event){event.preventDefault();this.blur();var caption=this.title||this.name||"";var group=this.rel||false;TB_show(caption,this.href,group);});}
function TB_show(caption,url,rel){if(!$("#TB_HideSelect").length){$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");$("#TB_overlay").click(TB_remove);}
$(window).scroll(TB_position);TB_overlaySize();$("body").append("<div id='TB_load'><img src='http://i.ehow.com/images/loadinganimation.gif' /></div>");TB_load_position();var baseURL=url.match(/(.+)?/)[1]||url;var imageURL=/\.(jpe?g|png|gif|bmp)/gi;if(baseURL.match(imageURL)){var dummy={caption:"",url:"",html:""};var prev=dummy,next=dummy,imageCount="";if(rel){function getInfo(image,id,label){return{caption:image.title,url:image.href,html:"<span id='TB_"+id+"'>&nbsp;&nbsp;<a href='#'>"+label+"</a></span>"}}
var imageGroup=$("a[@rel="+rel+"]").get();var foundSelf=false;for(var i=0;i<imageGroup.length;i++){var image=imageGroup[i];var urlTypeTemp=image.href.match(imageURL);if(image.href==url){foundSelf=true;imageCount="Image "+(i+1)+" of "+(imageGroup.length);}else{if(foundSelf){next=getInfo(image,"next","Next &gt;");break;}else{prev=getInfo(image,"prev","&lt; Prev");}}}}
imgPreloader=new Image();imgPreloader.onload=function(){imgPreloader.onload=null;var pagesize=TB_getPageSize();var x=pagesize[0]-150;var y=pagesize[1]-150;var imageWidth=imgPreloader.width;var imageHeight=imgPreloader.height;if(imageWidth>x){imageHeight=imageHeight*(x/imageWidth);imageWidth=x;if(imageHeight>y){imageWidth=imageWidth*(y/imageHeight);imageHeight=y;}}else if(imageHeight>y){imageWidth=imageWidth*(y/imageHeight);imageHeight=y;if(imageWidth>x){imageHeight=imageHeight*(x/imageWidth);imageWidth=x;}}
TB_WIDTH=imageWidth+30;TB_HEIGHT=imageHeight+60;$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>"+"<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>"+imageCount+prev.html+next.html+"</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div>");$("#TB_closeWindowButton").click(TB_remove);function buildClickHandler(image){return function(){$("#TB_window").remove();$("body").append("<div id='TB_window'></div>");TB_show(image.caption,image.url,rel);return false;};}
var goPrev=buildClickHandler(prev);var goNext=buildClickHandler(next);if(prev.html){$("#TB_prev").click(goPrev);}
if(next.html){$("#TB_next").click(goNext);}
document.onkeydown=function(e){if(e==null){keycode=event.keyCode;}else{keycode=e.which;}
switch(keycode){case 27:TB_remove();break;case 190:if(next.html){document.onkeydown=null;goNext();}
break;case 188:if(prev.html){document.onkeydown=null;goPrev();}
break;}}
TB_position();$("#TB_load").remove();$("#TB_ImageOff").click(TB_remove);$("#TB_window").css({display:"block"});}
imgPreloader.src=url;}else{var queryString=url.match(/\?(.+)/)[1];var params=TB_parseQuery(queryString);TB_WIDTH=(params['width']*1)+30;TB_HEIGHT=(params['height']*1)+40;var ajaxContentW=TB_WIDTH-30,ajaxContentH=TB_HEIGHT-45;if(url.indexOf('TB_iframe')!=-1){urlNoQuery=url.split('TB_');$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent' style='width:"+(ajaxContentW+29)+"px;height:"+(ajaxContentH+17)+"px;' onload='TB_showIframe()'> </iframe>");}else{$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");}
$("#TB_closeWindowButton").click(TB_remove);if(url.indexOf('TB_inline')!=-1){$("#TB_ajaxContent").html($('#'+params['inlineId']).html());TB_position();$("#TB_load").remove();$("#TB_window").css({display:"block"});}else if(url.indexOf('TB_iframe')!=-1){TB_position();if(frames['TB_iframeContent']==undefined){$("#TB_load").remove();$("#TB_window").css({display:"block"});$(document).keyup(function(e){var key=e.keyCode;if(key==27){TB_remove()}});}}else{$("#TB_ajaxContent").load(url,function(){TB_position();$("#TB_load").remove();$("#TB_window").css({display:"block"});});}}
$(window).resize(TB_position);document.onkeyup=function(e){if(e==null){keycode=event.keyCode;}else{keycode=e.which;}
if(keycode==27){TB_remove();}}}
function TB_showIframe(){$("#TB_load").remove();$("#TB_window").css({display:"block"});}
function TB_remove(){$("#TB_imageOff").unbind("click");$("#TB_overlay").unbind("click");$("#TB_closeWindowButton").unbind("click");$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').remove();});$("#TB_load").remove();return false;}
function TB_position(){var pagesize=TB_getPageSize();var arrayPageScroll=TB_getPageScrollTop();var style={width:TB_WIDTH,left:(arrayPageScroll[0]+(pagesize[0]-TB_WIDTH)/2),top:(arrayPageScroll[1]+(pagesize[1]-TB_HEIGHT)/2)};$("#TB_window").css(style);}
function TB_overlaySize(){if(window.innerHeight&&window.scrollMaxY||window.innerWidth&&window.scrollMaxX){yScroll=window.innerHeight+window.scrollMaxY;xScroll=window.innerWidth+window.scrollMaxX;var deff=document.documentElement;var wff=(deff&&deff.clientWidth)||document.body.clientWidth||window.innerWidth||self.innerWidth;var hff=(deff&&deff.clientHeight)||document.body.clientHeight||window.innerHeight||self.innerHeight;xScroll-=(window.innerWidth-wff);yScroll-=(window.innerHeight-hff);}else if(document.body.scrollHeight>document.body.offsetHeight||document.body.scrollWidth>document.body.offsetWidth){yScroll=document.body.scrollHeight;xScroll=document.body.scrollWidth;}else{yScroll=document.body.offsetHeight;xScroll=document.body.offsetWidth;}
$("#TB_overlay").css({"height":yScroll,"width":xScroll});$("#TB_HideSelect").css({"height":yScroll,"width":xScroll});}
function TB_load_position(){var pagesize=TB_getPageSize();var arrayPageScroll=TB_getPageScrollTop();$("#TB_load").css({left:(arrayPageScroll[0]+(pagesize[0]-100)/2),top:(arrayPageScroll[1]+((pagesize[1]-100)/2))}).css({display:"block"});}
function TB_parseQuery(query){if(!query)
return{};var params={};var pairs=query.split(/[;&]/);for(var i=0;i<pairs.length;i++){var pair=pairs[i].split('=');if(!pair||pair.length!=2)
continue;params[unescape(pair[0])]=unescape(pair[1]).replace(/\+/g,' ');}
return params;}
function TB_getPageScrollTop(){var yScrolltop;var xScrollleft;if(self.pageYOffset||self.pageXOffset){yScrolltop=self.pageYOffset;xScrollleft=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop||document.documentElement.scrollLeft){yScrolltop=document.documentElement.scrollTop;xScrollleft=document.documentElement.scrollLeft;}else if(document.body){yScrolltop=document.body.scrollTop;xScrollleft=document.body.scrollLeft;}
arrayPageScroll=new Array(xScrollleft,yScrolltop)
return arrayPageScroll;}
function TB_getPageSize(){var de=document.documentElement;var w=window.innerWidth||self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;var h=window.innerHeight||self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight
arrayPageSize=new Array(w,h)
return arrayPageSize;}
$.ux.behavior("CitySearch",{initialize:function(){this.getResults();},showLoading:function(){this.element.html("");this.element.css("background","url(/ui/images/legacy/ticker1.gif) no-repeat center center").css("height","40px");},hideLoading:function(){this.element.css("background","none").css("height","auto");},getResults:function(){var self=this;this.showLoading();$.getJSON("/api/citysearch.aspx",{search:this.options.search,where:this.options.location,max:this.options.maxResults},function(data){self.options.location=data.location;self.populateResults(data);});},changeLocation:function(location){this.options.location=location;this.getResults();},populateResults:function(response){this.hideLoading();this.element.template(this.options.jsTemplateId,{loc:response.location,results:response.ads});},onclick:$.delegate({'a.jsChangeLocation':function(element,event){this.changeLocation(this.element.find("input").val());},'input':function(element,event){element.select();}}),onkeydown:$.delegate({'input':function(element,event){if(event.keyCode==13){this.changeLocation(element.val());}}})},{jsTemplateId:"tmpCitySearch",search:"",location:"",maxResults:5});