
 //  lib/jquery-1.3.2.min 

/*
 * jQuery JavaScript Library v1.3.2
 * http://jquery.com/
 *
 * Copyright (c) 2009 John Resig
 * Dual licensed under the MIT and GPL licenses.
 * http://docs.jquery.com/License
 *
 * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
 * Revision: 6246
 */
(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F<J;F++){var G=M[F];if(G.selected){K=o(G).val();if(H){return K}L.push(K)}}return L}return(E.value||"").replace(/\r/g,"")}return g}if(typeof K==="number"){K+=""}return this.each(function(){if(this.nodeType!=1){return}if(o.isArray(K)&&/radio|checkbox/.test(this.type)){this.checked=(o.inArray(this.value,K)>=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G<E;G++){L.call(K(this[G],H),this.length>1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H<I;H++){if((G=arguments[H])!=null){for(var F in G){var K=J[F],L=G[F];if(J===L){continue}if(E&&L&&typeof L==="object"&&!L.nodeType){J[F]=o.extend(E,K||(L.length!=null?[]:{}),L)}else{if(L!==g){J[F]=L}}}}}return J};var b=/z-?index|font-?weight|opacity|zoom|line-?height/i,q=document.defaultView||{},s=Object.prototype.toString;o.extend({noConflict:function(E){l.$=p;if(E){l.jQuery=y}return o},isFunction:function(E){return s.call(E)==="[object Function]"},isArray:function(E){return s.call(E)==="[object Array]"},isXMLDoc:function(E){return E.nodeType===9&&E.documentElement.nodeName!=="HTML"||!!E.ownerDocument&&o.isXMLDoc(E.ownerDocument)},globalEval:function(G){if(G&&/\S/.test(G)){var F=document.getElementsByTagName("head")[0]||document.documentElement,E=document.createElement("script");E.type="text/javascript";if(o.support.scriptEval){E.appendChild(document.createTextNode(G))}else{E.text=G}F.insertBefore(E,F.firstChild);F.removeChild(E)}},nodeName:function(F,E){return F.nodeName&&F.nodeName.toUpperCase()==E.toUpperCase()},each:function(G,K,F){var E,H=0,I=G.length;if(F){if(I===g){for(E in G){if(K.apply(G[E],F)===false){break}}}else{for(;H<I;){if(K.apply(G[H++],F)===false){break}}}}else{if(I===g){for(E in G){if(K.call(G[E],E,G[E])===false){break}}}else{for(var J=G[0];H<I&&K.call(J,H,J)!==false;J=G[++H]){}}}return G},prop:function(H,I,G,F,E){if(o.isFunction(I)){I=I.call(H,F)}return typeof I==="number"&&G=="curCSS"&&!b.test(E)?I+"px":I},className:{add:function(E,F){o.each((F||"").split(/\s+/),function(G,H){if(E.nodeType==1&&!o.className.has(E.className,H)){E.className+=(E.className?" ":"")+H}})},remove:function(E,F){if(E.nodeType==1){E.className=F!==g?o.grep(E.className.split(/\s+/),function(G){return !o.className.has(F,G)}).join(" "):""}},has:function(F,E){return F&&o.inArray(E,(F.className||F).toString().split(/\s+/))>-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+"></"+T+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!O.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!O.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!O.indexOf("<td")||!O.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!O.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!o.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/<tbody/i.test(S),N=!O.indexOf("<table")&&!R?L.firstChild&&L.firstChild.childNodes:Q[1]=="<table>"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E<F;E++){if(H[E]===G){return E}}return -1},merge:function(H,E){var F=0,G,I=H.length;if(!o.support.getAll){while((G=E[F++])!=null){if(G.nodeType!=8){H[I++]=G}}}else{while((G=E[F++])!=null){H[I++]=G}}return H},unique:function(K){var F=[],E={};try{for(var G=0,H=K.length;G<H;G++){var J=o.data(K[G]);if(!E[J]){E[J]=true;F.push(K[G])}}}catch(I){F=K}return F},grep:function(F,J,E){var G=[];for(var H=0,I=F.length;H<I;H++){if(!E!=!J(F[H],H)){G.push(F[H])}}return G},map:function(E,J){var F=[];for(var G=0,H=E.length;G<H;G++){var I=J(E[G],G);if(I!=null){F[F.length]=I}}return F.concat.apply([],F)}});var C=navigator.userAgent.toLowerCase();o.browser={version:(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(C),opera:/opera/.test(C),msie:/msie/.test(C)&&!/opera/.test(C),mozilla:/mozilla/.test(C)&&!/(compatible|webkit)/.test(C)};o.each({parent:function(E){return E.parentNode},parents:function(E){return o.dir(E,"parentNode")},next:function(E){return o.nth(E,2,"nextSibling")},prev:function(E){return o.nth(E,2,"previousSibling")},nextAll:function(E){return o.dir(E,"nextSibling")},prevAll:function(E){return o.dir(E,"previousSibling")},siblings:function(E){return o.sibling(E.parentNode.firstChild,E)},children:function(E){return o.sibling(E.firstChild)},contents:function(E){return o.nodeName(E,"iframe")?E.contentDocument||E.contentWindow.document:o.makeArray(E.childNodes)}},function(E,F){o.fn[E]=function(G){var H=o.map(this,F);if(G&&typeof G=="string"){H=o.multiFilter(G,H)}return this.pushStack(o.unique(H),E,G)}});o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(E,F){o.fn[E]=function(G){var J=[],L=o(G);for(var K=0,H=L.length;K<H;K++){var I=(K>0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}});
/*
 * Sizzle CSS Selector Engine - v0.9.3
 *  Copyright 2009, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa<ab.length;aa++){if(ab[aa]===ab[aa-1]){ab.splice(aa--,1)}}}}}return ab};F.matches=function(T,U){return F(T,null,null,U)};F.find=function(aa,T,ab){var Z,X;if(!aa){return[]}for(var W=0,V=I.order.length;W<V;W++){var Y=I.order[W],X;if((X=I.match[Y].exec(aa))){var U=RegExp.leftContext;if(U.substr(U.length-1)!=="\\"){X[1]=(X[1]||"").replace(/\\/g,"");Z=I.find[Y](X,T,ab);if(Z!=null){aa=aa.replace(I.match[Y],"");break}}}}if(!Z){Z=T.getElementsByTagName("*")}return{set:Z,expr:aa}};F.filter=function(ad,ac,ag,W){var V=ad,ai=[],aa=ac,Y,T,Z=ac&&ac[0]&&Q(ac[0]);while(ad&&ac.length){for(var ab in I.filter){if((Y=I.match[ab].exec(ad))!=null){var U=I.filter[ab],ah,af;T=false;if(aa==ai){ai=[]}if(I.preFilter[ab]){Y=I.preFilter[ab](Y,aa,ag,ai,W,Z);if(!Y){T=ah=true}else{if(Y===true){continue}}}if(Y){for(var X=0;(af=aa[X])!=null;X++){if(af){ah=U(af,Y,X,aa);var ae=W^!!ah;if(ag&&ah!=null){if(ae){T=true}else{aa[X]=false}}else{if(ae){ai.push(af);T=true}}}}}if(ah!==g){if(!ag){aa=ai}ad=ad.replace(I.match[ab],"");if(!T){return[]}break}}}if(ad==V){if(T==null){throw"Syntax error, unrecognized expression: "+ad}else{break}}V=ad}return aa};var I=F.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(T){return T.getAttribute("href")}},relative:{"+":function(aa,T,Z){var X=typeof T==="string",ab=X&&!/\W/.test(T),Y=X&&!ab;if(ab&&!Z){T=T.toUpperCase()}for(var W=0,V=aa.length,U;W<V;W++){if((U=aa[W])){while((U=U.previousSibling)&&U.nodeType!==1){}aa[W]=Y||U&&U.nodeName===T?U||false:U===T}}if(Y){F.filter(T,aa,true)}},">":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){var W=Y.parentNode;Z[V]=W.nodeName===U?W:false}}}else{for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){Z[V]=X?Y.parentNode:Y.parentNode===U}}if(X){F.filter(U,Z,true)}}},"":function(W,U,Y){var V=L++,T=S;if(!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("parentNode",U,V,W,X,Y)},"~":function(W,U,Y){var V=L++,T=S;if(typeof U==="string"&&!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("previousSibling",U,V,W,X,Y)}},find:{ID:function(U,V,W){if(typeof V.getElementById!=="undefined"&&!W){var T=V.getElementById(U[1]);return T?[T]:[]}},NAME:function(V,Y,Z){if(typeof Y.getElementsByName!=="undefined"){var U=[],X=Y.getElementsByName(V[1]);for(var W=0,T=X.length;W<T;W++){if(X[W].getAttribute("name")===V[1]){U.push(X[W])}}return U.length===0?null:U}},TAG:function(T,U){return U.getElementsByTagName(T[1])}},preFilter:{CLASS:function(W,U,V,T,Z,aa){W=" "+W[1].replace(/\\/g,"")+" ";if(aa){return W}for(var X=0,Y;(Y=U[X])!=null;X++){if(Y){if(Z^(Y.className&&(" "+Y.className+" ").indexOf(W)>=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return U<T[3]-0},gt:function(V,U,T){return U>T[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W<T;W++){if(Y[W]===Z){return false}}return true}}}},CHILD:function(T,W){var Z=W[1],U=T;switch(Z){case"only":case"first":while(U=U.previousSibling){if(U.nodeType===1){return false}}if(Z=="first"){return true}U=T;case"last":while(U=U.nextSibling){if(U.nodeType===1){return false}}return true;case"nth":var V=W[2],ac=W[3];if(V==1&&ac==0){return true}var Y=W[0],ab=T.parentNode;if(ab&&(ab.sizcache!==Y||!T.nodeIndex)){var X=0;for(U=ab.firstChild;U;U=U.nextSibling){if(U.nodeType===1){U.nodeIndex=++X}}ab.sizcache=Y}var aa=T.nodeIndex-ac;if(V==0){return aa==0}else{return(aa%V==0&&aa/V>=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V<T;V++){U.push(X[V])}}else{for(var V=0;X[V];V++){U.push(X[V])}}}return U}}var G;if(document.documentElement.compareDocumentPosition){G=function(U,T){var V=U.compareDocumentPosition(T)&4?-1:U===T?0:1;if(V===0){hasDuplicate=true}return V}}else{if("sourceIndex" in document.documentElement){G=function(U,T){var V=U.sourceIndex-T.sourceIndex;if(V===0){hasDuplicate=true}return V}}else{if(document.createRange){G=function(W,U){var V=W.ownerDocument.createRange(),T=U.ownerDocument.createRange();V.selectNode(W);V.collapse(true);T.selectNode(U);T.collapse(true);var X=V.compareBoundaryPoints(Range.START_TO_END,T);if(X===0){hasDuplicate=true}return X}}}}(function(){var U=document.createElement("form"),V="script"+(new Date).getTime();U.innerHTML="<input name='"+V+"'/>";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="<a href='#'></a>";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="<p class='TEST'></p>";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="<div class='test e'></div><div class='test'></div>";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1&&!ac){T.sizcache=Y;T.sizset=W}if(T.nodeName===Z){X=T;break}T=T[U]}ad[W]=X}}}function S(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1){if(!ac){T.sizcache=Y;T.sizset=W}if(typeof Z!=="string"){if(T===Z){X=true;break}}else{if(F.filter(Z,[T]).length>0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z<U;Z++){F(T,V[Z],W)}return F.filter(X,W)};o.find=F;o.filter=F.filter;o.expr=F.selectors;o.expr[":"]=o.expr.filters;F.selectors.filters.hidden=function(T){return T.offsetWidth===0||T.offsetHeight===0};F.selectors.filters.visible=function(T){return T.offsetWidth>0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F<E.length){o.event.proxy(G,E[F++])}return this.click(o.event.proxy(G,function(H){this.lastToggle=(this.lastToggle||0)%F;H.preventDefault();return E[this.lastToggle++].apply(this,arguments)||false}))},hover:function(E,F){return this.mouseenter(E).mouseleave(F)},ready:function(E){B();if(o.isReady){E.call(document,o)}else{o.readyList.push(E)}return this},live:function(G,F){var E=o.event.proxy(F);E.guid+=this.selector+G;o(document).bind(i(G,this.selector),this.selector,E);return this},die:function(F,E){o(document).unbind(i(F,this.selector),E?{guid:E.guid+this.selector+F}:null);return this}});function c(H){var E=RegExp("(^|\\.)"+H.type+"(\\.|$)"),G=true,F=[];o.each(o.data(this,"events").live||[],function(I,J){if(E.test(J.type)){var K=o(H.target).closest(J.data)[0];if(K){F.push({elem:K,fn:J})}}});F.sort(function(J,I){return o.data(J.elem,"closest")-o.data(I.elem,"closest")});o.each(F,function(){if(this.fn.call(this.elem,H,this.fn.data)===false){return(G=false)}});return G}function i(F,E){return["live",F,E.replace(/\./g,"`").replace(/ /g,"|")].join(".")}o.extend({isReady:false,readyList:[],ready:function(){if(!o.isReady){o.isReady=true;if(o.readyList){o.each(o.readyList,function(){this.call(document,o)});o.readyList=null}o(document).triggerHandler("ready")}}});var x=false;function B(){if(x){return}x=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);o.ready()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);o.ready()}});if(document.documentElement.doScroll&&l==l.top){(function(){if(o.isReady){return}try{document.documentElement.doScroll("left")}catch(E){setTimeout(arguments.callee,0);return}o.ready()})()}}}o.event.add(l,"load",o.ready)}o.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error").split(","),function(F,E){o.fn[E]=function(G){return G?this.bind(E,G):this.trigger(E)}});o(l).bind("unload",function(){for(var E in o.cache){if(E!=1&&o.cache[E].handle){o.event.remove(o.cache[E].handle.elem)}}});(function(){o.support={};var F=document.documentElement,G=document.createElement("script"),K=document.createElement("div"),J="script"+(new Date).getTime();K.style.display="none";K.innerHTML='   <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("<div/>").append(M.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H<F;H++){var E=o.data(this[H],"olddisplay");this[H].style.display=E||"";if(o.css(this[H],"display")==="none"){var G=this[H].tagName,K;if(m[G]){K=m[G]}else{var I=o("<"+G+" />").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H<F;H++){this[H].style.display=o.data(this[H],"olddisplay")||""}return this}},hide:function(H,I){if(H){return this.animate(t("hide",3),H,I)}else{for(var G=0,F=this.length;G<F;G++){var E=o.data(this[G],"olddisplay");if(!E&&E!=="none"){o.data(this[G],"olddisplay",o.css(this[G],"display"))}}for(var G=0,F=this.length;G<F;G++){this[G].style.display="none"}return this}},_toggle:o.fn.toggle,toggle:function(G,F){var E=typeof G==="boolean";return o.isFunction(G)&&o.isFunction(F)?this._toggle.apply(this,arguments):G==null||E?this.each(function(){var H=E?G:o(this).is(":hidden");o(this)[H?"show":"hide"]()}):this.animate(t("toggle",3),G,F)},fadeTo:function(E,G,F){return this.animate({opacity:G},E,F)},animate:function(I,F,H,G){var E=o.speed(F,H,G);return this[E.queue===false?"each":"queue"](function(){var K=o.extend({},E),M,L=this.nodeType==1&&o(this).is(":hidden"),J=this;for(M in I){if(I[M]=="hide"&&L||I[M]=="show"&&!L){return K.complete.call(this)}if((M=="height"||M=="width")&&this.style){K.display=o.css(this,"display");K.overflow=this.style.overflow}}if(K.overflow!=null){this.style.overflow="hidden"}K.curAnim=o.extend({},I);o.each(I,function(O,S){var R=new o.fx(J,K,O);if(/toggle|show|hide/.test(S)){R[S=="toggle"?L?"show":"hide":S](I)}else{var Q=S.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),T=R.cur(true)||0;if(Q){var N=parseFloat(Q[2]),P=Q[3]||"px";if(P!="px"){J.style[O]=(N||1)+P;T=((N||1)/R.cur(true))*T;J.style[O]=T+P}if(Q[1]){N=((Q[1]=="-="?-1:1)*N)+T}R.custom(T,N,P)}else{R.custom(T,S,"")}}});return true})},stop:function(F,E){var G=o.timers;if(F){this.queue([])}this.each(function(){for(var H=G.length-1;H>=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J<K.length;J++){if(!K[J]()){K.splice(J--,1)}}if(!K.length){clearInterval(n);n=g}},13)}},show:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());o(this.elem).show()},hide:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(H){var G=e();if(H||G>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})();

 //  foresee-alive 

var ForeSee = {
    'version': '2.4.1',
    'Date:': '12/07/2008',
    'enabled': true,
    'files': '/include/foresee/',
    'id': 'M0A5pMJ15ch0AxIJMdEwgA==',
    'sites': [{
        path: '.',
        cookie: 'session',
        domain: 'npr.org'
    }]
};
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
function fsr$setAlive(){
    var time = new Date().getTime();
    document.cookie = 'foresee.alive=' + time + ';path=/' + ';domain=' + ForeSee.site.domain + ';';
}

(function(){
    var sites = ForeSee.sites;
    for (var i = 0, l = sites.length; i < l; i++) {
        if (document.location.href.match(sites[i].path)) {
            ForeSee.siteid = i;
            ForeSee.site = ForeSee.sites[ForeSee.siteid];
            if (ForeSee.site.files) {
                ForeSee.files = ForeSee.site.files;
            }
            break;
        }
    }
    if (!window['fsr$timer']) {
        fsr$setAlive();
        window['fsr$timer'] = setInterval(fsr$setAlive, 1000);
    }
})();


 //  reg/jquery-reg-plugins 

/**
 * ILazarte
 * 4/11/2008
 * JQuery, hoooah!
 */
/**
 * Simple Tab Panel
 * Very flexible since we can use css to make it left-aligned, right-aligned as desired.
 * This isn't totally complete yet, it's more a proof of concept.
 *
 * TODO Convert the usage of attrs to the data as appropriate.  Some attrs actually being selected against.
 * TODO Look go reduce css state complexity
 *
 * Reference on building a plugin:
 * http://blog.jeremymartin.name/2008/02/building-your-first-jquery-plugin-that.html
 */
(function($){
    $.fn.tabs = function(options){
    
        var defaults = {
            initTab: 1
        };
        
        options = $.extend(defaults, options);
        
        function getCurrentViewClass(item){
            if ($(item).hasClass('npr-tab-h-item-inactive')) {
                return 'npr-tab-h-item-inactive';
            }
            if ($(item).hasClass('npr-tab-h-item-active')) {
                return 'npr-tab-h-item-active';
            }
        }
        
        function updateTabsCss(item){
            $(item).addClass('npr-tab-h-item-active').removeClass('npr-tab-h-item-inactive').attr('viewCls', 'npr-tab-h-item-active').siblings().addClass('npr-tab-h-item-inactive').removeClass('npr-tab-h-item-active').attr('viewCls', 'npr-tab-h-item-inactive');
        }
        
        function switchPanel(sid, item){
            var hid = $(item).attr('headId');
            updateTabsCss(item);
            $(sid).find('.npr-tabs-d > li[dataId=' + hid + ']').show().siblings().hide();
        }
        
        return this.each(function(){
        
            var id = $(this).attr('id');
            var sid = '#' + id;
            
            /**
             * Initialize all the tabs on this page.
             */
            function init(){
                var count = 0;
                $(sid).find('.npr-tabs-h > li').each(function(){
                    var incr = count++;
                    $(this).addClass('npr-tab-h-items').addClass('npr-tab-h-item-' + incr).attr('headId', id + incr).css('cursor', 'pointer');
                    
                }).hover(function(){
                    var viewCls = getCurrentViewClass(this);
                    $(this).attr('viewCls', viewCls).removeClass(viewCls).addClass('npr-tab-h-item-hover');
                }, function(){
                    var viewCls = $(this).attr('viewCls');
                    $(this).removeClass('npr-tab-h-item-hover').addClass(viewCls);
                }).click(function(){
                    switchPanel(sid, this);
                });
                
                count = 0;
                $(sid).find('.npr-tabs-d > li').each(function(){
                    $(this).addClass('npr-tab-d-items');
                    $(this).attr('dataId', id + count++);
                });
                
                var query = '.npr-tabs-h > li:eq(' + options.initTab + ')';
                var initItem = $(sid).find(query).get();
                switchPanel(sid, initItem);
                $(sid).removeClass('init-hidden');
            }
            
            init();
        });
    };
})(jQuery);

/*
 * Username related functionality.
 */
(function($){
    
    /**
     * Static function which registers a click handler to check the nickname.
     * 
     * @param {Object} clickable A jquery for the item which will be clicked on..
     * @param {Object} nicknameInput A jquery for the nickname input tag.
     *     Must have a parent p tag in order to be able to position correctly.
     *     Creates a #nicknameresult to display and destroys it after the message. 
     */
    $.checkNickname = function(clickable, nicknameInput) {
        
        $(clickable)
            .click(function() {
                var inputEl = $(nicknameInput).get(0);
                var value = inputEl.value;
                var params = { public_user_nick_name : value };
                var render = function(result)
                {
                    var msg = '<div id="nicknameresult" class="activeerror">';
                    msg += 'Unable to check nickname.</div>';
                    switch (result) {
                        case true:
                            msg = '<div id="nicknameresult" class="activemsg">';
                            msg += 'This nickname is available</div>';
                            break;
                        case false:
                            msg = '<div id="nicknameresult" class="activeerror">';
                            msg += 'This nickname is not available</div>';
                            break;
                    }

                    var parent = $(inputEl).parent('p');
                    var offset = $(parent).offset();
                    var height = $(parent).height();
                    $(document.body).append(msg);

                    $('#nicknameresult')
                        .css('left', offset.left)
                        .css('top', offset.top + height)
                        .css('position', 'absolute');

                    setTimeout(function() {
                        var oncomplete = function() {
                            $('#nicknameresult').remove();
                        };
                        $('#nicknameresult').fadeOut("slow", oncomplete);
                    }, 4000);
                };

                $.ajax({
                    url: '/templates/reg/remoteValidateUsername.php',
                    type: 'GET',
                    data: params,
                    dataType: 'json',
                    timeout: 1500,
                    success: render});

                return false;
            });
    };
  
})(jQuery);

/**
 * Bind an even with a delay.
 * The delay will wait N miliseconds before executing the callback.
 * The key handler checks for keys above 60000 which is a Mac/Safari issue.
 * Down/Up apparently are 65532 and 3 or something like that.
 * Enter/Esc are the same as other browsers.
 * @param {Object} $
 */
(function($){

    $.fn.delay = function(options){
    
        var timer;
        function count(scope){
            if (timer !== null) {
                clearTimeout(timer);
            }
            var newFn = function(){
                options.fn.apply(scope);
            };
            timer = setTimeout(newFn, options.delay);
        }
        
        return this.each(function(){
            var obj = $(this);
            obj.bind(options.event, function(event){
                var ignoreKey = null;
                if (event.keyCode) {
                    ignoreKey = event.keyCode;
                } else if(event.which) {
                    ignoreKey = event.which;
                }
                if (ignoreKey &&
                    ignoreKey == 13 ||
                    ignoreKey == 27 || 
                    ignoreKey == 38 ||
                    ignoreKey == 40 ||
                    ignoreKey > 60000) {
                    event.preventDefault();
                } else {
                    count(this);
                }
            });
        });
    };
    
})(jQuery);

/**
 * Add the custom validators used by the reg process.
 * @see http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage
 * @param {Object} $
 */
(function($){
    
    /* allows us to include this file without requiring the validate plugin file */
    if (!$.validator) { return; }
    
    /**
     * Validates the email only if it is not empty.
     * Used required as well if you want the email to be required.
     * 
     * @see http://en.wikipedia.org/wiki/E-mail_address
     * @see http://en.wikibooks.org/wiki/JavaScript/Best_Practices
     * @param {Object} value
     * @param {Object} element
     */        

    $.validator.addMethod("rfc2822email", function(value, element){
    
        if (value === "") {
            return true;
        }
        
        var atSym = value.lastIndexOf("@");
        
        // no local-part
        if (atSym < 1) {
            return false;
        }
        // no domain
        if (atSym == value.length - 1) {
            return false;
        } 
        // there may only be 64 octets in the local-part
        if (atSym > 64) {
            return false;
        } 
        // there may only be 255 octets in the domain
        if (value.length - atSym > 255) {
            return false;
        } 
        // Is the domain plausible?
        var lastDot = value.lastIndexOf(".");
        
        // Check if it is a dot-atom such as example.com
        if (lastDot > atSym + 1 && lastDot < value.length - 1) {
            return true;
        }
        
        //  Check if could be a domain-literal.
        if (value.charAt(atSym + 1) == '[' && value.charAt(value.length - 1) == ']') {
            return true;
        }
        
        return false;
        
    }, "Please enter a valid email.");
    
    /**
     * valid first/last names.
     * Allows apostrophes.
     *
     * @param {Object} value
     * @param {Object} element
     */
    $.validator.addMethod("personname", function(value, element){
    
        var regex = /^[a-z\.' -]+$/i;
        if (value === "") {
            return true;
        }
        var passes = regex.test(value);
        
        return passes;
        
    }, "Please enter a valid name.");
    
    /**
     * Validator to check for valid user names.
     * Includes periods, and wordchar.
     *
     * @param {Object} value
     * @param {Object} element
     */
    $.validator.addMethod("nickname", function(value, element){
    
        var regex = /^[a-z0-9_]+$/i;
        if (value === "") {
            return true;
        }
        var passes = regex.test(value);
        
        return passes;
        
    }, "Please enter a valid nickname. Only letters, numbers, and the underscore character may be used.");
    
    /**
     * valid alpha string.
     * Allows apostrophes.
     *
     * @param {Object} value
     * @param {Object} element
     */
    $.validator.addMethod("alpha", function(value, element){
    
        var regex = /^[a-z]+$/i;
        if (value === "") {
            return true;
        }
        var passes = regex.test(value);
        
        return passes;
        
    }, "Please enter a valid alpha string.");
    
})(jQuery);

/**
 * ILazarte, 7/23
 * The version says 1.0.x, but seems to work fine in 1.x.x
 * Modified the source a little to have no side-effects.
 * @see http://plugins.jquery.com/project/cookie
 * 
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

(function($){

    $.cookie = function(name, value, options){
        if (typeof value != 'undefined') { // name and value given, set cookie
            options = options || {};
            if (value === null) {
                value = '';
                options.expires = -1;
            }
            var expires = '';
            if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                var date;
                if (typeof options.expires == 'number') {
                    date = new Date();
                    date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
                } else {
                    date = options.expires;
                }
                expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
            }
            // CAUTION: Needed to parenthesize options.path and options.domain
            // in the following expressions, otherwise they evaluate to undefined
            // in the packed version for some reason...
            var path = options.path ? '; path=' + (options.path) : '';
            var domain = options.domain ? '; domain=' + (options.domain) : '';
            var secure = options.secure ? '; secure' : '';
            document.cookie =[name,'=',encodeURIComponent(value),expires,path,domain,secure] .join('');
        } else { // only name given, get cookie
            var cookieValue = null;
            if (document.cookie && document.cookie !== '') {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i++) {
                    var cookie = $.trim(cookies[i]);
                    // Does this cookie string begin with the name we want?
                    if (cookie.substring(0, name.length + 1) == (name + '=')) {
                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
        }
    };        

    /**
     * Returns a ready to use newsletter id array.
     */
    $.newsletterscookie = function() {
        var cookie = $.cookie('nl');
        if (cookie === null) {
            return null;
        }
        return cookie.split(",");    
    };    

    /**
     * Returns a ready to use station array.
     */
    $.stationscookie = function() {
        var cookie = $.cookie('st');
        if (cookie === null) {
            return null;
        }
        return cookie.split(",");    
    };

    /**
     * Returns a ready to use Javascript object.
     */
    $.authcookie = function() {

        var obj = {};        
        var cookie = $.cookie('at');
        if (cookie === null) { return obj; }
        var items = cookie.split('&');
        for(var i = 0; i < items.length; i++) {
            var kv = items[i].split('=');
            var key = kv[0];
            var val = kv[1];
            switch (key) {
                case 'u':
                obj.userid = val;
                break;
                case 'a':
                obj.username = val;
                break;
                case 'e':
                obj.email = val;
                break;
                case 'f':
                obj.fname = val;
                break;
                case 'l':
                obj.lname = val;
                break;
                case 'g':
                obj.gender = val;
                break;
                default:
                obj[key] = val;
            } 
        }

        /*
         * Create a fullname field for convenience.
         * Do not create it if no valid values are found.
         */        
        if (obj.fname !== 'undefined') {
            obj.fullname = obj.fname;    
        } 
        if (obj.lname !== 'undefined') {
            if (obj.fullname) {
                obj.fullname += ' ' + obj.lname;
            } else {
                obj.fullname = obj.lname;
            }
        }

        return obj;
    };
    
})(jQuery);

(function($){
    /**
     * Grab the station ids from the hidden inputs.
     * Used in a legacy form integrations.
     */
    $.grabStationIds = function() {
        var stations = $('input[name="public_user_stations[]"]').get();
        var sids = [];
        for (var i = 0; i < stations.length; i++) {
            sids.push(stations[i].value);
        }                  
        var csv = sids.join(',');               
        return csv;
    };
    
})(jQuery);

(function($){

    /**
     * Simple function to check to see if an array has an element.
     * @param {Object} element
     * @param {Object} arr
     */
    $.arrayContains = function (element, arr) {
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] == element) {
                return true;
            }
        }
        return false;
    };
    
})(jQuery);    

/**
 * Simple login/logout event abstractions.
 * The code below could probably be made shorter, but eh.
 */
(function($){

    $.fn.login = function(callback){
        var fn = null;
        if (callback) {
            fn = function() {
                $(this).bind('login', callback);
            };
        } else {
            fn = function() {
                $(this).trigger('login');                    
            };                        
        }             
        return this.each(fn);
    };
    
    $.fn.logout = function(callback) {
        var fn = null;
        if (callback) {
            fn = function() { 
                $(this).bind('logout', callback);
            };
        } else {
            fn = function() {
                $(this).trigger('logout');
            };                        
        }                        
        return this.each(fn);
    };
    
})(jQuery);


 //  addNamespace 

function AddNamespace(namespacePath)
{
    var rootObject = window;
    var namespaceParts = namespacePath.split('.');
    
    for (var i = 0; i < namespaceParts.length; i++)
    {
        var currentPart = namespaceParts[i];
        
        if (!rootObject[currentPart])
        {
            rootObject[currentPart] = new Object();
        }
        
        rootObject = rootObject[currentPart];
    }
}

 //  jserrorhandling 

/* npr namespace */
AddNamespace('NPR.messaging');

NPR.messaging.constants = NPR.messaging.constants || {};
NPR.messaging.constants.UNKNOWN_JS_ISSUE = 1002;
NPR.messaging.constants.TEST_ISSUE = 1003;
NPR.messaging.constants.JAVASCRIPT_GENERAL_ISSUE = 1004;
NPR.messaging.constants.PLUCK_STORY_PAGE_COMMENTING_ERROR = 2002;
NPR.messaging.constants.PREVIEW_JS_ISSUE = 1039;
NPR.messaging.constants.SPONSORSHIP_ERROR = 1038;
NPR.messaging.constants.METRICS_ERROR = 1043;
NPR.messaging.constants.COMMUNITY_JS_ERROR = 1044;
NPR.messaging.constants.PLAYER_JS_ERROR = 1045;
NPR.messaging.constants.RSS_PODCAST_JS_ERROR = 1046;

NPR.messaging.constants.REG_JS_ERROR = 5002;

NPR.messaging.warning = function(_debugData, _function, _id) {
	NPR.messaging.logMessage(_debugData, _function, _id, 'unknown');
    return { };
};

NPR.messaging.exception = function(_e, _debugData, _function, _id) {
    if(_e.message.match('RequestBatch is undefined')===null) {
    	
    	_debugData += " {Exception: ";
    	var counter = 0;
    	for (var key in _e) {
			try {
				var value = _e[key];
				if (!$.isFunction(value)) {
					if (counter++ != 0) {
						_debugData += ",";
					}
					
					if (value.length > 255) {
						value = value.substring(0, 255) + "...";
					}
					
					_debugData += "{" + key + ":'" + value + "'}";
				}
			}
			catch (propEx) {
				// ignore
			}
		}
    	_debugData += "}";
    	
    	var lineNumber = 'unknown';
    	if (_e.lineNumber != null) {
    		lineNumber = _e.lineNumber;
    	}
    	
    	NPR.messaging.logMessage(_debugData, _function, _id, lineNumber);
     }
    return { };
};

window.onerror = function(message, url, lineNumber) {
	var fullMsg = "Window.OnError: " + message + " (" + url + ":" + lineNumber + ")";
	NPR.messaging.logMessage(fullMsg, "Window.OnError: " + message, NPR.messaging.constants.JAVASCRIPT_GENERAL_ISSUE, lineNumber);
	window.onerror = function () {
		return true;
	};
	return true; // prevents browser error messages
};

NPR.messaging.logMessage = function (_msg, _function, _id, _line) {
	try {
		
		var language = '';
		if($.browser.msie){
			language = navigator.browserLanguage;
		}else{
			language = window.navigator.language;
		}
	
		if (language.substring(0, 2).toLowerCase() != 'en')
		{
			return;
		}
		
		var message = {};
		message.msg = _msg;
		message.func = _function;
		message.id = _id;
		message.line = _line;
		message.agent = navigator.userAgent 
		message.url = window.location.href;
		
		var debugData = '';
		debugData = message.msg + ' | f: ' + message.func + ' | ' + message.agent + " | in URL: " + message.url;
		
		if(document.URL.indexOf("_DEBUG=1") > 0){
	    	$("#error").append('<div class="javascript">WWWERR ' + debugData + '</div>' );
	    }
	
		message = JSON.stringify(message);

		$.post("/templates/common/jslog.php", {type: 'Warning', message: message});
	}catch(e){}
};




 //  community/urlencode 

AddNamespace("NPR.community");

NPR.community.urlencode = function (str){
    // From Pluck
    var clean=""; 
    if(str.length>0){
        // we want to preserve links in the comments
        // so, after converting html tags to entities, change A tags back
        // the ? in the regexp makes the search a non-greedy search, which prevents the whole link from disappearing
        clean=str.replace(/</g,"&lt;");
        clean=clean.replace(/>/g,"&gt;");
        clean=clean.replace(/&lt;a(.*?)&gt;/g,"<a$1>");
        clean=clean.replace(/&lt;\/a&gt;/g,"</a>");
        clean=clean.replace(/\u2019/g,"&#8217;");
        clean=clean.replace(/\u201C/g,"&#8220;");
        clean=clean.replace(/\u201D/g,'"');
        clean=clean.replace(/([^"']|^)(https?:\/\/[\S]+)(\b|$)/gi,'$1<a href="$2">$2</a>');
        clean=clean.replace(/\r\n/g,"<br />");
        clean=clean.replace(/\n/g,"<br />");
    }
    return clean;
};


NPR.community.urldecode = function (str) {
    return str;
};

 //  community/story 

AddNamespace("NPR.community");

$(document).ready(function() {
    NPR.community.setCommentSortOrderFromCookie();
    NPR.community.loadStoryInformation();
    
    $('textarea[maxlength]').keyup(function(){ 
        if($(this).val().length > 1249){
            alert('Your comment has exceeded the maximum number of characters. Please keep your comment to fewer than 1250 characters.');
        }
        if($(this).val().length > $(this).attr('maxlength')){ 
            $(this).val($(this).val().substr(0, $(this).attr('maxlength'))); 
        } 
        if($(this).val().length > $(this).attr('maxlength') - 100){ 
            $(this).parent().find('.charsRemaining').html('You have ' + ($(this).attr('maxlength') - $(this).val().length) + ' characters remaining.'); 
        }
        else
        {
            $(this).parent().find('.charsRemaining').html('');
        }
    }); 
    var fbcAttemptsLeft = 100; // about 5 seconds of attempting to load the Facebook Connect code; after that give up.
    var fbcLoadable = function () {
        if(navigator.userAgent.indexOf('MSIE') === -1) { 
            return true;
        }
        try {
            if(document.namespaces) {
                return true;
            } else {
                return false;
            }
        } catch (e) {
            return false;
        }
    };
    NPR.community.attemptLoadOfFBC = function () {
        try {
            if(fbcLoadable()) {
                if(window.slFB) {  // testing this here rather than in fbcLoadable to avoid trying to load 20 times/sec if it's not there
                    slFB.init(function() {
                        $("#facebook_connect_wrapper").show();
                    });
                }
            } else {
                --fbcAttemptsLeft;
                if(fbcAttemptsLeft) { // only try this fbcAttemptsLeft more times.
                    setTimeout("NPR.community.attemptLoadOfFBC()", 50); // the first argument has to be globally visible; 1/20 second in between attempts.
                }
            }
        } catch (e) {
            NPR.messaging.exception(e, 'NPR.community.storyId = ' + NPR.community.storyId, 'NPR.community.attemptLoadOfFBC', NPR.messaging.constants.COMMUNITY_JS_ERROR);
        }
    };
    NPR.community.attemptLoadOfFBC();
    
    NPR.community.overlayIframeId = 'overlayIframe';
    
});

NPR.community.BLOG_SHUTDOWN_TIMEFRAME = 14;
NPR.community.MAX_COMMENTS_PER_PLUCK_REQUEST = 10;
NPR.community.MAX_FEATURED_COMMENTS_ON_PAGE = 3;
NPR.community.MAX_ABUSE_REPORTS_BEFORE_BLOCKING = 3;
NPR.community.sortOrder = 'TimeStampDescending';
NPR.community.viewerIsStaffOrEditor = false;

// the existence of this function means that we do not actually need any parsing of
// pPageNum or pCommentKey in the PHP (and possibly pageNum could also be moved to
// this, just to consolidate all the processing of similar things in one place).
NPR.community.setCommentVariables = function() {
    try {
        if(NPR.community.pluckPageNum!==undefined && NPR.community.pluckCommentKey!==undefined) {
            return;
        }
        // defaults up front in case we don't find  
        var pageMultiplier = NPR.community.numCommentToDisplay / NPR.community.MAX_COMMENTS_PER_PLUCK_REQUEST;
        NPR.community.pluckPageNum = (NPR.community.commentPageNum * pageMultiplier) - 1;
        NPR.community.pluckCommentKey = '';

        var urlArray = document.URL.split('?');
        if(urlArray.length>1) {
            var formArray = urlArray[1].split('&');
            for(var i=0; i<formArray.length; i++) {
                var paramArray = formArray[i].split('=');
                if(paramArray.length>1 && paramArray[0]==='pPageNum') {
                    NPR.community.pluckPageNum = parseInt(paramArray[1]);
                } else if(paramArray.length>1 && paramArray[0]==='pCommentKey') {
                    NPR.community.pluckCommentKey = paramArray[1];
                }
            }
        } 
    } catch(e) {
        NPR.messaging.exception(e, 'NPR.community.storyId = ' + NPR.community.storyId, 'NPR.community.setCommentVariables', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
}

NPR.community.loadStoryInformation = function(requestBatch) {
    try {
        if (requestBatch === null || requestBatch === undefined) {
            requestBatch = new RequestBatch();
        }

        if (NPR.community.storyId !== undefined) {
            var articleKey = new ArticleKey(String(NPR.community.storyId));
    
            // Get the article for the counts
            requestBatch.AddToRequest(articleKey);
            NPR.community.setCommentVariables(); // in case we got none from the page 
            NPR.community.currentPageInPluck = NPR.community.pluckPageNum;
            
            var commentPage = new CommentPage(articleKey, NPR.community.MAX_COMMENTS_PER_PLUCK_REQUEST, NPR.community.pluckPageNum, NPR.community.sortOrder);
            requestBatch.AddToRequest(commentPage);
            NPR.community.totalCommentsDisplayed = 0;
            NPR.community.totalCommentsProcessed = 0;
            NPR.community.useThisPluckPage = false; // for pageNavigation
            NPR.community.displayComments = true;
            if(NPR.community.pluckCommentKey!='') {
                NPR.community.displayComments = false; // until we see that commentkey
            }
    
            var viewerUserKey = new UserKey();
            requestBatch.AddToRequest(viewerUserKey);
    
            requestBatch.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.renderStoryComments);
        }
        else
        {
            NPR.messaging.warning('NPR.community.storyId not set, not loading story information', 'loadStoryInformation', NPR.messaging.constants.COMMUNITY_JS_ERROR);
        }
    } catch (e) {
        NPR.messaging.exception(e, 'NPR.community.storyId = ' + NPR.community.storyId, 'NPR.community.loadStoryInformation', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.renderRecommendationLinks = function(articleRecommendedByUser, numRecommendations, id) {
    try {
        var recommendationCntHref = document.getElementById(id);  
        
        if(recommendationCntHref !== null && recommendationCntHref !== undefined) {
            if (articleRecommendedByUser === true || articleRecommendedByUser === "True") {
                recommendationCntHref.innerHTML = '<a class="reced">Recommended (' + numRecommendations + ')</a>';
            }
            else {
                recommendationCntHref.innerHTML = '<a href="javascript: NPR.community.recommendStory();" class="recommend">Recommend (<span id="recommendationCnt">' + numRecommendations + '</span>)</a>';
            }  
        }
    } 
    catch (e) {
        NPR.messaging.exception(e, 'NPR.community.storyId = ' + NPR.community.storyId, 'renderRecommendationLinks', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.displayCommentError = function() {
    try {
        var commentBlock = document.getElementById('comments');
        commentBlock.innerHTML = "<h3>Community features and content, including commenting and recommending stories, are unavailable at this time. We apologize for the inconvenience. Please try this page later.</h3>";
    } 
    catch (e) {
        NPR.messaging.exception(e, 'NPR.community.storyId = ' + NPR.community.storyId, 'displayCommentError', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};


NPR.community.handleUserInfo = function(user) {
    try {
        NPR.community.viewerId = user.UserKey.Key;
        NPR.community.viewerIsStaffOrEditor = (user.UserTier === 'Staff' || user.UserTier === 'Editor');
        NPR.community.modifyDisplayBasedOnUserStatus(user);
    }
    catch (e) {
        NPR.messaging.exception(e, 'NPR.community.storyId = ' + NPR.community.storyId, 'handleUserInfo', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};


NPR.community.renderStoryComments = function(responseBatch) {
    try {
        if (responseBatch === undefined || responseBatch === null || responseBatch.Responses === undefined) {
            
            NPR.messaging.warning('No response batch', 'renderStoryComments', NPR.messaging.constants.COMMUNITY_JS_ERROR);
            NPR.community.displayCommentError();
            return;
        } else if(responseBatch.Messages[0].Message === "Down") {
            NPR.community.displayCommentError();
            return;
        }
        
        var article = responseBatch.Responses[0].Article;

        if (article !== null && article !== undefined) {
            NPR.community.handleUserInfo(responseBatch.Responses[2].User);
            NPR.community.pageArticle = article;

            var commentPage = responseBatch.Responses[1].CommentPage;
            NPR.community.pageArticle.commentPageNumberOfComments = commentPage.NumberOfComments;
            
            document.getElementById('comments').innerHTML = ''; // clear existing comments (e.g., if we're running via sorting change)
            NPR.community.renderCommentBatch(responseBatch, 1);
        } else { // story doesn't yet exist in Pluck
            NPR.community.renderRecommendationLinks(false, 0, 'recommendationCntHref');
            NPR.community.renderRecommendationLinks(false, 0, 'recommendationCntHref2');
            var user = responseBatch.Responses[1].User;
            NPR.community.modifyDisplayBasedOnUserStatus(user);
            $(".sortcomments").hide();
            $(".commentsarchive").hide();
        }
        
        if (NPR.community.pluckMTDate !== undefined) {
            var currentDate = new Date();       
            var blogPostDate = ((NPR.community.pluckMTDate - 100) + NPR.community.BLOG_SHUTDOWN_TIMEFRAME).toString();
            var storyCloseDate = new Date(blogPostDate.slice(0,4), blogPostDate.slice(4,6), blogPostDate.slice(6,8));
 
            if (storyCloseDate < currentDate) {
                $(".commentbox").html('<p class="closeddisc"><strong>Discussions for this story are now closed.</strong> Please see the <a href="http://help.npr.org/ics/support/default.asp?deptID=5670&task=knowledge&folderID=21">Community FAQ</a> for more information.</p>');
            }
            
        }
    } 
    catch (e) {
        NPR.messaging.exception(e, 'responseBatch.Responses.length = ' + responseBatch.Responses.length + ' and first message from pluck = ' + responseBatch.Messages[0].Message, 'renderStoryComments', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.renderStoryBasedOnArticle = function() {
    try {
        var article = NPR.community.pageArticle;
        var commentCntTop = document.getElementById('commentCnt');  
        if(commentCntTop !== null && commentCntTop !== undefined) {
            commentCntTop.innerHTML = "(" + article.commentPageNumberOfComments + ")";
        }    
        var commentCntBottom = document.getElementById('commentCnt2');  
        if(commentCntBottom !== null && commentCntBottom !== undefined) {
            commentCntBottom.innerHTML = "(" + article.commentPageNumberOfComments + ")";
        }    
        var commentCntArchiveLink = document.getElementById('commentCntArchive');
        if(commentCntArchiveLink !== null && commentCntArchiveLink !== undefined) {
            commentCntArchiveLink.innerHTML = "(" + article.commentPageNumberOfComments + ")";
        }    

        if (article.commentPageNumberOfComments <= NPR.community.numCommentToDisplay) {
            $(".commentsarchive").hide();
        }
        else {
            $(".commentsarchive").show();
        }
        var articleRecommendedByUser = article.Recommendations.CurrentUserHasRecommended;
        var numRecommendations = article.Recommendations.NumberOfRecommendations;

        NPR.community.renderRecommendationLinks(articleRecommendedByUser, numRecommendations, 'recommendationCntHref');
        NPR.community.renderRecommendationLinks(articleRecommendedByUser, numRecommendations, 'recommendationCntHref2');

        NPR.community.renderPageNavigation(article.commentPageNumberOfComments);
    } 
    catch (e) {
        NPR.messaging.exception(e, 'NPR.community.storyId = ' + NPR.community.storyId, 'renderStoryBasedOnArticle', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.requestFeaturedComments = function(incStoryId) {
    try {
        var storyId;
        if(incStoryId)
        {
            storyId = incStoryId;
        }
        else
        {
            storyId = NPR.community.storyId;
        }
        var requestBatch2 = new RequestBatch();                
        var numPerPage = NPR.community.MAX_FEATURED_COMMENTS_ON_PAGE;
        var onPage = 1;
        requestBatch2.AddToRequest(new CustomCollectionPage(new CustomCollectionKey('Featured' + String(storyId)), numPerPage, onPage, "PositionAscending"));                  
        requestBatch2.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.renderFeatureCommentsLinks);
    } 
    catch (e) {
        NPR.messaging.exception(e, 'NPR.community.storyId = ' + NPR.community.storyId, 'requestFeaturedComments', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.renderCommentBatch = function(responseBatch, responseIndex) {
    try {
        if (responseBatch === undefined || responseBatch === null || responseBatch.Responses === undefined) {
            NPR.messaging.warning('No response batch', 'renderCommentBatch', NPR.messaging.constants.COMMUNITY_JS_ERROR);
            return;
        }
        if(!responseIndex) {
            responseIndex = 0;
        }
        if (responseBatch.Responses.length > 0 && responseBatch.Responses[responseIndex]!==undefined) {
            var commentBlock = document.getElementById('comments');  
            var commentBlockHtml = "";  
            var commentPage = responseBatch.Responses[responseIndex].CommentPage;  

            for(var i=0; i < commentPage.Comments.length; i++) {  
                if(NPR.community.displayComments==true) {
                    if(NPR.community.totalCommentsDisplayed < NPR.community.numCommentToDisplay) {
                        commentBlockHtml += NPR.community.getCommentHtml(commentPage.Comments[i]);  
                        NPR.community.totalCommentsProcessed++;
                    } else if(!NPR.community.useThisPluckPage) {
                        NPR.community.useThisPluckPage = true;
                    } 
                } else if(NPR.community.pluckCommentKey==commentPage.Comments[i].CommentKey.Key) {
                    NPR.community.displayComments = true; // start displaying comments with the next one
                }
            }  
            commentBlock.innerHTML += commentBlockHtml;  
            if (commentPage.Comments.length > 0 && 
                NPR.community.totalCommentsProcessed < commentPage.NumberOfComments &&  // that's the TOTAL comments on this article
                NPR.community.totalCommentsDisplayed < NPR.community.numCommentToDisplay) {
                var requestBatch = new RequestBatch();
                var numCommentsToRequest = String(NPR.community.MAX_COMMENTS_PER_PLUCK_REQUEST);
                var articleKey = new ArticleKey(String(NPR.community.storyId));
                var commentPage = new CommentPage(articleKey, String(NPR.community.numCommentToDisplay), ++NPR.community.currentPageInPluck, NPR.community.sortOrder);
                requestBatch.AddToRequest(commentPage);
                requestBatch.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.renderCommentBatch);
            } else {
                NPR.community.renderStoryBasedOnArticle();
                if (NPR.community.commentPageNum === 1) {
                    NPR.community.requestFeaturedComments();
                }
                if (NPR.community.totalCommentsDisplayed < 2) {
                    $(".sortcomments").hide();
                }
                else {
                    $(".sortcomments").show();
                }
            }
        }
    } 
    catch (e) {
        NPR.messaging.exception(e, 'responseBatch.Responses.length = ' + responseBatch.Responses.length + ' and first message from pluck = ' + responseBatch.Messages[0].Message, 'renderRestOfTheComments', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};


NPR.community.renderFeatureCommentsLinks = function(responseBatch) {
    try {
        if (responseBatch === undefined || responseBatch === null || responseBatch.Responses === undefined) {
            NPR.messaging.warning('No response batch', 'renderFeatureCommentsLinks', NPR.messaging.constants.COMMUNITY_JS_ERROR);
            return;
        }
        var anyFeaturedComments = false;
        var insetSpan = $('#featuredCommentsMain' + NPR.community.storyId);
        insetSpan.empty();
        insetSpan.removeClass("container");
        if (responseBatch.Responses.length > 0) {
            var featuredCollection = responseBatch.Responses[0].CustomCollectionPage;
            if (featuredCollection !== null && featuredCollection !== undefined && featuredCollection.Items.length > 0) {
                insetSpan.show();
				insetSpan.addClass("container");
                insetSpan.append('<h3 class="conheader">Comments from the NPR Community</h3>');
                if(insetSpan !== null && insetSpan !== undefined) {
                    for (var f=0; f < featuredCollection.Items.length; f++) {  
                        var customItem = featuredCollection.Items[f];
                        if (customItem.CustomItem === undefined) {
                            continue;
                        }
                        
                        var comment = YAHOO.lang.JSON.parse(customItem.CustomItem.Content);
                        NPR.community.renderSingleFeaturedCommentsLink(comment.CommentKey.Key);
                        NPR.community.addFeaturedCommentToInset(comment,insetSpan);
                        anyFeaturedComments = true;
                    }
                    insetSpan.append('<p class="join"><a href="#commentBlock">Join the Discussion &raquo;</a></p>');
                    insetSpan.append('<div class="spacer">&nbsp;</div>');
                }    
            }
        }
        else {
            var requestBatch = new RequestBatch();            
            var createCollection = new AddCustomCollectionAction(new CustomCollectionKey('Featured' + String(NPR.community.storyId)), 'Featured Comments for ' + String(NPR.community.storyId));
            requestBatch.AddToRequest(createCollection);
            requestBatch.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.addFeatureCollectionComplete);
        }    
    } 
    catch (e) {
        NPR.messaging.exception(e, 'responseBatch.Responses.length = ' + responseBatch.Responses.length + ' and first message from pluck = ' + responseBatch.Messages[0].Message, 'renderFeatureCommentsLinks', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.modifyDisplayBasedOnUserStatus = function(user){
    try {
        if (user === null || user.UserTier === 'Anonymous') {
            $("#commentBoxNotLoggedIn").show();
            $("#commentBoxNeedMoreInfo").hide();
            $("#commentTextBox").attr("disabled","true");
            $("#commentTextBox").text(' ');
            $("#commentTextBox ~ input").attr("disabled","true");
            $("#commentTextBox").attr("title","Log in to leave a comment.");
            $("#facebook_connect_checkbox").attr("disabled","true"); // hiding in a div, not a sibling
        }
        else {
            if (user.ExtendedProfile.validForCommunity === 'true') {
                $("#commentBoxNotLoggedIn").hide();
                $("#commentBoxNeedMoreInfo").hide();
                $("#commentTextBox").removeAttr("disabled");
                $("#commentTextBox").text('');
                $("#commentTextBox ~ input").removeAttr("disabled");
                $("#commentTextBox").removeAttr("title");
                $("#facebook_connect_checkbox").removeAttr("disabled");
            }
            else {
                $("#commentBoxNotLoggedIn").hide();
                $("#commentBoxNeedMoreInfo").show();
                $("#commentTextBox").attr("disabled","true");
                $("#commentTextBox").text(' ');
                $("#commentTextBox ~ input").attr("disabled","true");
                $("#facebook_connect_checkbox").attr("disabled","true");
            }
        }
    } 
    catch (e) {
        NPR.messaging.exception(e, 'no extra info', 'modifyDisplayBasedOnUserStatus', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.addFeaturedCommentToInset = function(comment , inset) {
    try {
        var newCommentHtml = '<div class="bucketwrap featuredcomment" id="featuredComments' + comment.CommentedOnKey + '">';
        newCommentHtml += '<div class="buckettop">&nbsp;</div>';
        newCommentHtml += '<div class="bucket">';
        newCommentHtml += '<p>' + NPR.community.urldecode(comment.CommentBody) + '</p>';
        newCommentHtml += '</div>';
        newCommentHtml += '<div class="bucketbottom">&nbsp;</div>';
        newCommentHtml += '<p class="byline">'; 
        newCommentHtml += '<a href="/templates/community/persona.php?uid=' + comment.Author.UserKey.Key + '">';
        newCommentHtml += '&ndash;' + comment.Author.DisplayName + '</a></p>';  

        if (NPR.community.viewerIsStaffOrEditor === true) {
            newCommentHtml += '<div class="featinset">Staff: <a href="javascript: NPR.community.unfeatureCommentPartOne(\'' +  comment.CommentKey.Key  + '\');">Unfeature</a>';
            newCommentHtml += '</div>';
        }
        newCommentHtml += '</div>';
        inset.append(newCommentHtml);
    } 
    catch (e) {
        NPR.messaging.exception(e, 'failed on ' + comment.CommentKey.Key, 'addFeaturedCommentToInset', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.addFeatureCollectionComplete = function(responseBatch) {
    try {
        var message = responseBatch.Messages[0];
        if (message.Message !== 'ok') {  
            NPR.messaging.warning('Failed to create feature collection for story ID: ' + NPR.community.storyId + ' with message ' + message.Message, 'NPR.community.addFeatureCollectionComplete', NPR.messaging.constants.COMMUNITY_JS_ERROR);
        } 
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed to create feature collection for story ID: ' + NPR.community.storyId, 'NPR.community.addFeatureCollectionComplete', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.getCommentHtml = function(comment) {
    var html = '<-- Error occurred getting Comment HTML -->';
    try {
        if (comment.Author.IsBlocked === 'True' && comment.Author.UserKey.Key !== NPR.community.viewerId) {
            return '';
        }

        var mainDivClass = 'commentblock'; 
        var displayAbuseLink = true;
        var displayStaffTitle = false;
        if (NPR.community.totalCommentsDisplayed === 0) {
            mainDivClass = mainDivClass + ' topcomment';
        }
        NPR.community.totalCommentsDisplayed++;
        NPR.community.lastDisplayedCommentKey = comment.CommentKey.Key;
        
        if (comment.Author.UserTier === 'Staff' | comment.Author.UserTier === 'Editor') {
              mainDivClass = mainDivClass + ' staff';
              displayAbuseLink = false;
              displayStaffTitle = true;
        }

        html =  '<div class="' + mainDivClass + '">';  
        html += '<a href="/templates/community/persona.php?uid=' + comment.Author.UserKey.Key + '">';
        html += '<img  width="60" height="60" class="thumb60" alt="' + comment.Author.DisplayName + '" src="' + comment.Author.AvatarPhotoUrl + '"/></a>';  
        html += '<div class="commentinfo">';

        if (displayStaffTitle === true) {
           var userExtendedProfile = comment.Author.ExtendedProfile;
           var title = userExtendedProfile.StaffTitle;
           if (title === undefined) {
            title = '';
           }
           html += '<p class="stafftitle"><span class="staffhdr">NPR STAFF:</span> ' + title + '</p> ';
        }

        html += '<p class="commentbyline">'; 
        html += '<a href="/templates/community/persona.php?uid=' + comment.Author.UserKey.Key + '">';
        html += ' ' + comment.Author.DisplayName + '</a> wrote: </p>';  
        
        if (NPR.community.MAX_ABUSE_REPORTS_BEFORE_BLOCKING <= comment.AbuseReportCount) {
            html += '<p class="commentbody">This comment has been reported as inappropriate by the NPR community.</p>';  
        }
        else {
            html += '<p class="commentbody">' + NPR.community.urldecode(comment.CommentBody) + '</p>';  
        }        

        var datePosted = new Date(comment.PostedAtTime);
        html += '<p class="commentdate">' + datePosted.toLocaleString() + '</p>'; 
        html += '<div class="commentlinks">'  + "";  
        if (comment.CurrentUserHasRecommended !== "True") {
            html += '<p><span id="recommendStart' + comment.CommentKey.Key + '"><a href="javascript: NPR.community.recommendComment(\'' + comment.CommentKey.Key + '\');" class="rec">Recommend (<span id="recommend' + comment.CommentKey.Key + '">' + comment.NumberOfRecommendations + '</span>)</a></span></p>';  
        }
        else {
            html += '<p><a class="reced">Recommended (' + comment.NumberOfRecommendations + ')</a></p>';  
        }
        
        if (NPR.community.viewerIsStaffOrEditor === true) {
            html += '<div class="feat">Staff: <a id="featureSubmit' + comment.CommentKey.Key + '" href="javascript: NPR.community.renderFeatureCommentIframe(\'' +  comment.CommentKey.Key  + '\', \'' +  comment.CommentBody.replace(/'/g, "\\'").replace(/"/g,'&quot;')  + '\');">Feature this comment</a>';
            html += '<span id="featuredCommentGoesHere' + comment.CommentKey.Key + '"></span>';
            html += '</div>';
        }
        html += '</div><!-- CommentLinks -->';  

        if (displayAbuseLink === true) {
            html += '<div class="report">';
            if (comment.CurrentUserHasReportedAbuse !== "True") {
                html += '<p><a id="abuseLink' + comment.CommentKey.Key + '" href="javascript: NPR.community.renderAbuseIframe(\''+ comment.CommentKey.Key +'\')">Report abuse</a></p>';  
                html += '<span id="abuseGoesHere' + comment.CommentKey.Key + '"></span>';
            }
            else {
                html += '<p>Abuse Reported</p>';  
            }
            html += '</div><!-- report -->';  
        }
        html += '</div><!-- commentinfo -->';
        html += "<div class='spacer'>&nbsp;</div>";  
        html += '</div>';  
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed on comment ' + NPR.community.totalCommentsDisplayed-1 + ' for NPR.community.storyId = ' + NPR.community.storyId, 'NPR.community.getCommentHtml', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
    return html;  
};


NPR.community.setCommentSortOrderFromCookie = function() {
    var sortOrderCookieValue = get_cookie('sco');
    if (sortOrderCookieValue !== null)
    {
        NPR.community.sortOrder = sortOrderCookieValue;
    }
    $('#sortCommentsSelector').val(NPR.community.sortOrder);
}

NPR.community.sortComments = function(selectObject) {
    try {
        if (NPR.community.sortOrder !== selectObject.value) {  
            NPR.community.sortOrder = selectObject.value;
            setCookie('sco', 1, NPR.community.sortOrder)
            NPR.community.loadStoryInformation();
        }
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed to resort comments on NPR.community.storyId = ' + NPR.community.storyId, 'NPR.community.sortComments', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.recommendStory = function() {
    try {
        var requestBatch = new RequestBatch();

        var articleKey = new ArticleKey(String(NPR.community.storyId));
        var recommendArticleAction = new RecommendAction(articleKey);
        requestBatch.AddToRequest(recommendArticleAction);

        var cntOfRecommendations = 1;
        var recommendationsOnArticle = document.getElementById('recommendationCnt');  
        if(recommendationsOnArticle !== null && recommendationsOnArticle !== undefined) {
            var currentRecommendations = parseInt(recommendationsOnArticle.innerHTML);
            if (!isNaN(currentRecommendations)) {
                cntOfRecommendations += currentRecommendations;
            }
        }
        NPR.community.renderRecommendationLinks(true, cntOfRecommendations, 'recommendationCntHref');
        NPR.community.renderRecommendationLinks(true, cntOfRecommendations, 'recommendationCntHref2');
        
        requestBatch.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.recommendationOfStoryComplete);
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed recommending NPR.community.storyId = ' + NPR.community.storyId, 'NPR.community.recommendStory', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.recommendationOfStoryComplete = function(responseBatch) {
    try {
        var message = responseBatch.Messages[0];
        if (message.Message !== 'ok') {  
            NPR.messaging.warning('Failed to recommend story page ID: ' + NPR.community.storyId + ' with message ' + message.Message, 'NPR.community.recommendationOfStoryComplete', NPR.messaging.constants.COMMUNITY_JS_ERROR);
        } 
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed to recommend story page ID: ' + NPR.community.storyId, 'NPR.community.recommendationOfStoryComplete', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};


NPR.community.recommendComment = function(commentKeyAsString) {
    try {
        var requestBatch = new RequestBatch();

        var commentKey = new CommentKey(commentKeyAsString);
        var recommentCommentAction = new RecommendAction(commentKey);
        requestBatch.AddToRequest(recommentCommentAction);

        var cntOfRecommendations = 1;
        var recommendationOnComment = document.getElementById('recommend' + commentKeyAsString);  
        if(recommendationOnComment !== null && recommendationOnComment !== undefined) {
            cntOfRecommendations += parseInt(recommendationOnComment.innerHTML);
        }
        var recommendStart = document.getElementById('recommendStart' + commentKeyAsString);  
        if(recommendStart !== null && recommendStart !== undefined) {
            recommendStart.innerHTML = '<a class="reced">Recommended (' + cntOfRecommendations + ')</a>';
        }
        var recommendationEndHyperlinkOnComment = document.getElementById('recommendEndHyperlink' + commentKeyAsString);  
        if(recommendationEndHyperlinkOnComment !== null && recommendationEndHyperlinkOnComment !== undefined) {
            recommendationEndHyperlinkOnComment.innerHTML = "";
        }

        requestBatch.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.recommendationOfCommentComplete);
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed on comment ' + commentKeyAsString + ' for NPR.community.storyId = ' + NPR.community.storyId, 'NPR.community.recommendComment', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.recommendationOfCommentComplete = function(responseBatch) {
    try {
        var message = responseBatch.Messages[0];
        if (message.Message !== 'ok') {  
            NPR.messaging.warning('Failed to recommend comment on story page ID: ' + NPR.community.storyId + ' with message ' + message.Message, 'NPR.community.recommendationOfCommentComplete', NPR.messaging.constants.COMMUNITY_JS_ERROR);
        } 
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed to recommend comment on story page ID: ' + NPR.community.storyId, 'NPR.community.recommendationOfCommentComplete', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.unfeatureCommentPartOne = function(commentKeyAsString) {
    try {
        var requestBatch = new RequestBatch();

        var removeFromStoryFeatured = new RemoveFromCollectionAction( 
                                    new CustomCollectionKey('Featured' + String(NPR.community.storyId)),             
                                    new CustomItemKey(commentKeyAsString));
        requestBatch.AddToRequest(removeFromStoryFeatured);
        var removeFromAllFeatured = new RemoveFromCollectionAction( 
                                new CustomCollectionKey('Featured'),             
                                new CustomItemKey(commentKeyAsString)); 
                                
        requestBatch.AddToRequest(removeFromAllFeatured);                             
        NPR.community.loadStoryInformation(requestBatch); 
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed to UNfeature comment ' + commentKeyAsString + ' on story page ID: ' + NPR.community.storyId, 'NPR.community.unfeatureCommentPartOne', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.enterComment = function(storyId, storyTitle, commentTextBox) {
   try {
        var articleKey = new ArticleKey(String(storyId));  
        var pageUrl = document.location.href;  
        var encodedCommentBody = NPR.community.urlencode(commentTextBox.value);
        commentTextBox.value = '';
        var encodedStoryTitle = NPR.community.urlencode(storyTitle);
        
        var requestBatch = new RequestBatch();              
        var commentAction = new CommentAction(articleKey, pageUrl, encodedStoryTitle, encodedCommentBody);  
        requestBatch.AddToRequest(commentAction);  
        NPR.metrics.pageEvent('comment_added');
        // cache information required for facebook connect in the NPR.commmunity.fbInfo object.
        // first make sure to include the sc=fbc tracking
        var pageWithTracking;
        if (pageUrl.indexOf('sc=')<0 && pageUrl.indexOf('?')<0) {
            pageWithTracking = pageUrl+'?sc=fbc';
        } else if (pageUrl.indexOf('sc=')<0) {
            pageWithTracking = pageUrl+'&sc=fbc';
        } else {
            pageWithTracking = pageUrl.replace(/sc=/, "oldsc=")+'&sc=fbc';
        }
        NPR.community.fbInfo = {
                title: storyTitle,
                url: pageWithTracking,
                excerpt: '', // currently not sending any
                previewImages: [], // currently not sending any
                commentBody: encodedCommentBody
            };        
        requestBatch.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.commentEnteredRefreshPage);
   }catch (e) {
        NPR.messaging.exception(e, ' storyId = ' + storyId + ' pageUrl = ' + pageUrl + ' commentBody = ' + encodedCommentBody, 'NPR.community.enterComment', NPR.messaging.constants.COMMUNITY_JS_ERROR);
   }
};

NPR.community.commentEnteredRefreshPage = function(responseBatch) {
    try {
        var message = responseBatch.Messages[0].Message;
        if (message !== 'ok') {
            if (message.indexOf('CommentBody cannot be blank') > 0) {
                $(".commentingerrors").html('<h4>Comment is blank</h4><p>The comment you submitted seems to be blank. Please enter a comment, then click submit.</p>').show();
            }
            else if (message.indexOf('rapid posting of multiple comments') > 0) {
                $(".commentingerrors").html('<h4>Too many submissions</h4><p>Our system cannot accept several comments submitted at short intervals.  Please wait a minute or two and try to resubmit.</p>').show();
            }
            else if (message.indexOf('included words not permitted') > 0) {
                $(".commentingerrors").html('<h4>Inappropriate language</h4><p>Your comment may contain inappropriate language. The comment has not been accepted. Please edit your comment and re-submit.</p>').show();
            }
            else {
                NPR.messaging.warning('Failed entering a comment for story ID: ' + NPR.community.storyId + ' with message ' + message, 'NPR.community.commentEnteredRefreshPage', NPR.messaging.constants.COMMUNITY_JS_ERROR);
                $(".commentingerrors").html('<h4>SystemProblem</h4><p>Our system was unable to record your comment.  We apologize for the inconvenience.  Please try again later.</p>').show();
            }
        } 
        else {
            $(".commentingerrors").hide();
            if (NPR.community.commentPageNum > 1) {
                location.href = NPR.community.getBaseUrl() + '?storyId=' + NPR.community.storyId + '&pageNum=1';
            }
            else {
                NPR.community.sortOrder = 'TimeStampDescending';
                $('#sortCommentsSelector').val(NPR.community.sortOrder);
                NPR.community.loadStoryInformation(); 
            }
            if (window.slFB && document.getElementById('facebook_connect_checkbox').checked && slFB.connectEnabled()) { 
                // we use document.getElementById above because jquery strips ".checked" in favor of its own filters
                var fbInfo = NPR.community.fbInfo;
                slFB.submitArticleComment(fbInfo.title, fbInfo.url, fbInfo.excerpt, fbInfo.commentBody, fbInfo.previewImages, function () {
                    // if we have ie6, there's an issue with the facebook connect overlay that removes the ability to 
                    // click in the comment textarea or select text at all
                    // I saw an explanation to the effect that IE6 has a problem with some kinds of absolute positioning, but I don't
                    // know the likelihood that that's actually the problem here.
                    if(navigator.userAgent.indexOf('MSIE 6') !== -1) {
                        // if I understood why this happened, it could probably be fixed...
                        window.location.reload(); // but since I don't really, this works, if rather overkilly
                    }
                    return false;  // maybe we should put in a notification here?
                    // well, we don't have any easy way to know if something went wrong on FB's end, so I guess we shouldn't.
                }); 
            }            
        }
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed to enter comment on story page ID: ' + NPR.community.storyId, 'NPR.community.commentEnteredRefreshPage', NPR.messaging.constants.COMMUNITY_JS_ERROR);
        $(".commentingerrors").html('<h4>SystemProblem</h4><p>Our system was unable to record your comment.  We apologize for the inconvenience.  Please try again later.</p>').show();
    }
};

NPR.community.getBaseUrl = function () {
    try {    
        var strHref = window.location.href;
        if ( strHref.indexOf("?") > -1 ){
            return strHref.slice(0, strHref.indexOf("?"));
        }
        return strHref;
    } catch (e) {
        NPR.messaging.exception(e, 'no debug data', 'NPR.community.getBaseUrl', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.renderPageNavigation = function (totalNumberOfComments){
    try {    
        var totalPages = NPR.community.commentPageNum;    
        if(Math.ceil(totalNumberOfComments / NPR.community.MAX_COMMENTS_PER_PLUCK_REQUEST)>NPR.community.currentPageInPluck) {
            totalPages++;
        } else if(NPR.community.useThisPluckPage===true) { // still comments on this pluck page that we haven't gotten to
            totalPages++;
        } 
        
        if (totalPages === 1) {
            return;
        }
        // Assuming no more than 10 pages in the nav at any one time
        var firstPageInNav = (Math.floor((NPR.community.commentPageNum - 1) / 10) * 10) + 1;
        var lastPageInNav = Math.min((totalPages + 1), (firstPageInNav + 10));
        var html = "";

        if (NPR.community.commentPageNum > 1) {
            var previousPage = NPR.community.commentPageNum - 1;
            if(previousPage==1) {
                var previousPluckPage = 1;
            } else {
                var pluckPagesPerNPRPage = NPR.community.numCommentToDisplay / NPR.community.MAX_COMMENTS_PER_PLUCK_REQUEST;
                var previousPluckPage = NPR.community.pluckPageNum - pluckPagesPerNPRPage;
                if(NPR.community.useThisPluckPage===true) {
                    previousPluckPage--;
                }
            }
            html += '<li><a href="' + NPR.community.getBaseUrl() + '?storyId=' + NPR.community.storyId + '&pageNum=' + previousPage + '&pPageNum=' + previousPluckPage + '">Previous</a></li>';
        }
        for (var p = firstPageInNav; p < lastPageInNav; p++) {
            if (p === NPR.community.commentPageNum) {
                html += '<li><strong>' + p + '</strong></li>';
            }
            else {            
                html += '<li><a href="' + NPR.community.getBaseUrl() + '?storyId=' + NPR.community.storyId + '&pageNum=' + p + '">' + p + '</a></li>';
            }
        }
        if (NPR.community.commentPageNum < totalPages) {
            var nextPage = NPR.community.commentPageNum + 1;
            var nextPluckPage = NPR.community.currentPageInPluck;
            var commentKey = '';
            if(NPR.community.useThisPluckPage) {
                commentKey = '&pCommentKey='+NPR.community.lastDisplayedCommentKey;
            } else {
                nextPluckPage++;
            }
            var queryString = '?storyId=' + NPR.community.storyId + '&pageNum=' + nextPage + '&pPageNum=' + nextPluckPage + commentKey;

            var commentArchive = $('.commentsarchive a');
            if(commentArchive.length) { // '.commentsarchive a' is empty on comment archive pages
                var commentArchiveUrl = $('.commentsarchive a').attr('href');
                if(commentArchiveUrl.indexOf('javascript:')==0) {
                    var insertionPoint = commentArchiveUrl.lastIndexOf("')");
                    commentArchiveUrl = commentArchiveUrl.slice(0, insertionPoint) + queryString + commentArchiveUrl.slice(insertionPoint);
                    $('.commentsarchive a').attr('href', commentArchiveUrl);
                } else {
                    // update comment archive link with this queryString
                    $('.commentsarchive a').attr('href', commentArchiveUrl.split('?')[0] + queryString);
                }
            }
            html += '<li><a href="' + NPR.community.getBaseUrl() + queryString + '">Next</a></li>';
        }
        $("ul[name='pagenav']").html(html);
        return;
        
    } catch (e) {
    NPR.messaging.exception(e, ' storyId = ' + NPR.community.storyId + ' totalNumberOfComments = ' + totalNumberOfComments, 'NPR.community.renderPageNavigation', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.renderOverlay = function (src) {
    try {    
        var iframe = document.getElementById(NPR.community.overlayIframeId);
        if (!(iframe === null || iframe === undefined)) {
            iframe.parentNode.removeChild(iframe);
        }
        var guid = new Date().getTime();
        NPR.community.overlayIframeId = 'overlayIframe' + guid; // necessary to eliminate query caching in Safari
        $("#overlaysGoHere").html('<iframe id="' + NPR.community.overlayIframeId + '" src="' + src + 'guid=' + guid + '" marginheight="0" marginwidth="0" class="iframe" frameborder="0" scrolling="no"></iframe>');
    } catch (e) {
    NPR.messaging.exception(e, ' storyId = ' + NPR.community.storyId, 'NPR.community.renderOverlay', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.renderAbuseIframe = function (commentKey) {
    try {
        var iframe = document.getElementById(NPR.community.overlayIframeId);
        if (!(iframe === null || iframe === undefined)) {
            iframe.parentNode.removeChild(iframe);
        }
        var thespan = document.getElementById('abuseGoesHere' + commentKey);
        var guid = new Date().getTime();
        NPR.community.overlayIframeId = 'overlayIframe' + guid; // necessary to eliminate query caching in Safari
        thespan.innerHTML = '<iframe id="' + NPR.community.overlayIframeId + '" src="/templates/community/reportabuse.php?cmt=' + commentKey + '"  scrolling="no" frameborder="0" marginheight="0" marginwidth="0" class="ireportabuse"></iframe>';
    } catch (e) {
        NPR.messaging.exception(e, ' storyId = ' + NPR.community.storyId + ' abuseIframe for Comment = ' + commentKey.Key, 'NPR.community.renderAbuseIframe', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};


NPR.community.renderFeatureCommentIframe = function (commentKey, commentText) {
    try {
        var iframe = document.getElementById(NPR.community.overlayIframeId);
        if (!(iframe === null || iframe === undefined)) {
            iframe.parentNode.removeChild(iframe);
        }
        var thespan = document.getElementById('featuredCommentGoesHere' + commentKey);
        if (!(thespan === null || thespan === undefined)) {
            var guid = new Date().getTime();
            NPR.community.overlayIframeId = 'overlayIframe' + guid; // necessary to eliminate query caching in Safari
            thespan.innerHTML = '<iframe id="' + NPR.community.overlayIframeId + '" src="/templates/community/featureComment.php?cmt=' + commentKey + '&cmtText=' + escape(commentText)  + '&storyid=' + NPR.community.storyId + '&storytitle=' + NPR.community.storyTitle + '"  scrolling="no" frameborder="0" marginheight="0" marginwidth="0" class="ireportfeatured"></iframe>';
        }
    } catch (e) {
        NPR.messaging.exception(e, ' storyId = ' + NPR.community.storyId + ' featureIframe for Comment = ' + commentKey.Key, 'NPR.community.renderFeatureCommentIframe', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};


NPR.community.redrawAccountBanner = function () {
    try {
        var pElm = document.getElementById('loginPElm');
        NPR.community.drawAccountBanner(pElm);        
    } catch (e) {
        NPR.messaging.exception(e, ' in story.js', 'NPR.community.redrawAccountBanner', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};


 //  community/renderSingleFeaturedCommentsLink 

NPR.community.renderSingleFeaturedCommentsLink = function(commentKey) {
    try {
        var idForLink = 'featureSubmit' + commentKey;
        var a_href_link = document.getElementById(idForLink);
        if(a_href_link !== null && a_href_link !== undefined) {
            a_href_link.innerHTML = "Unfeature this comment";
            $(a_href_link).attr('href','javascript: NPR.community.unfeatureCommentPartOne(\'' +  commentKey + '\');');
        }
    } 
    catch (e) {
        NPR.messaging.exception(e, 'failed on ' + commentKey, 'renderSingleFeaturedCommentsLink', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};


 //  community/overlayConstants 

AddNamespace("NPR.community");

NPR.community.LOGIN = '/templates/reg/commentingLoginBucket.php?';
NPR.community.ADDITIONAL_INFO = '/templates/reg/commentingAdditionalInfoBucket.php?';
NPR.community.NOT_VERIFIED = '/templates/reg/commentingNotVerifiedBucket.php?';
NPR.community.REGISTER = '/templates/reg/commentingRegisterBucket.php?';
NPR.community.VERIFY_ONE = '/templates/reg/commentingVerifyOneBucket.php?';
NPR.community.VERIFY_TWO = '/templates/reg/commentingVerifyTwoBucket.php?';
NPR.community.VERIFY_TWO = '/templates/community/commentingVerifyTwoBucket.php?';
NPR.community.VERIFY_TWO = '/templates/reg/commentingVerifyTwoBucket.php?';
NPR.community.FEATURE_COMMENTS = '/templates/community/featureComment.php?';
NPR.community.ABUSE = '/templates/community/reportabuse.php?';

NPR.community.getClassForOverlay = function (overlayName) {
    if (overlayName.indexOf(NPR.community.LOGIN) > -1) {
            return 'login';
    }
    if (overlayName.indexOf(NPR.community.ADDITIONAL_INFO) > -1) {
            return 'addinfo';
    }
    if (overlayName.indexOf(NPR.community.NOT_VERIFIED) > -1) {
            return 'notverified';
    }
    if (overlayName.indexOf(NPR.community.REGISTER) > -1) {
            return 'register';
    }
    if (overlayName.indexOf(NPR.community.VERIFY_ONE) > -1) {
            return 'verify1';
    }
    if (overlayName.indexOf(NPR.community.VERIFY_TWO) > -1) {
            return 'verify2';
    }
    return 'login';
};

NPR.community.getHeightForOverlay = function (overlayName) {
    if (overlayName.indexOf(NPR.community.LOGIN) > -1) {
            return '250px';
    }
    if (overlayName.indexOf(NPR.community.ADDITIONAL_INFO) > -1) {
            return '300px';
    }
    if (overlayName.indexOf(NPR.community.NOT_VERIFIED) > -1) {
            return '200px';
    }
    if (overlayName.indexOf(NPR.community.REGISTER) > -1) {
            return '250px';
    }
    if (overlayName.indexOf(NPR.community.VERIFY_ONE) > -1) {
            return '170px';
    }
    if (overlayName.indexOf(NPR.community.VERIFY_TWO) > -1) {
            return '170px';
    }
    if (overlayName.indexOf(NPR.community.FEATURE_COMMENTS) > -1) {
            return '190px';
    }
    if (overlayName.indexOf(NPR.community.ABUSE) > -1) {
            return '190px';
    }    
    return '190px';
};


 //  community/drawAccountbanner 

AddNamespace("NPR.community");

NPR.community.drawAccountBanner = function (pElm) {
    try {
    	var userCookie = get_cookie('at');

        if (pElm == null)
        {
            return;
        }

        var standardLinks = '<a href="/stations/donate/?ps=sttn" class="donate hdrdonate">Donate</a><span class="hdrdonate"> | </span><a href="http://shop.npr.org/?utm_source=topnav&amp;utm_medium=topnav&amp;utm_campaign=topnav" class="shop">NPR Shop</a> | <a href="/templates/community/" class="comm">NPR Community</a> | ';

        //default if user not logged in
        pElm.innerHTML = standardLinks + '<a href="/templates/reg/login.php">Login</a> | <a href="/templates/reg">Register</a>';

        //read their cookie to see if they are logged in
        if (userCookie !== null) {
            var uid = null;
            var displayName = null;
            var cookieParts = userCookie.split("&");
            for (var index = 0; index < cookieParts.length; index++)
            {
                var argParts = cookieParts[index].split("=");
                if (argParts.length === 2) {
                    var key = argParts[0];
                    var value = argParts[1];

                    //userid
                    if (key === "u") {
                        uid = value;
                    }
                    // nickname or display name
                    if (key === "a") {
                        displayName = value.replace(/\+/g, ' ');
                    }
                    if (key === "tier") {
                        displayName = '<a href="/templates/community/persona.php?uid=' + uid + '">' + displayName + '</a>';
                    }
                }

            }

            if (uid !== null && displayName !== null) { 
                pElm.innerHTML = standardLinks + '<span class="user">Welcome, ' + displayName + '</span> | <a href="/templates/reg/manage-account.php?tab=your_account&uid=' + uid + '">Your Account</a> | <a href="/templates/reg/logout.php?returnUrl=' + document.location + '">Logout</a>';
            }
        }
    } catch (e) {
        NPR.messaging.exception(e, 'no extra debug', 'NPR.community.drawAccountBanner', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};


 //  community/accountbanner 

$(document).ready(function() {
    try {
        var pElm = document.getElementById('loginPElm');
        if (pElm !== undefined) {
            NPR.community.drawAccountBanner(pElm);
        }
        
    } catch (e) {
        NPR.messaging.exception(e, ' in accountbanner.js ', 'document.ready', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
});



 //  jsfuncs 

// popup window function, based on original code by James Craig
var sUserAgent = navigator.userAgent.toLowerCase();
var isOp = (sUserAgent.indexOf('opera')!=-1)?true:false;

// for old static pages, make sure we include the player javascript
try {NPR} catch (e) {document.write("<script type='text/javascript' src='/templates/javascript/player/player.js'></script>\n")};

function popUp(oAnchor,sProps,sWindow){
    var sUrl = '';
    if(typeof(oAnchor)=='string') sUrl = oAnchor;
    else {
        if(oAnchor.getAttribute) sUrl = oAnchor.getAttribute('href');
        if(sUrl=='') sUrl = oAnchor.href;
    }
    if(sUrl=='') return true;
    var sWindowName = sWindow?sWindow:'nprPopup';
    if(!sProps) sProps = null;
    if(sUrl) var oPopup = window.open(sUrl,sWindowName,sProps);
    if(oPopup && !isOp) oPopup.focus();
    return (oPopup)?false:true;
}
function setUserVars()
    {
        if(navigator.appName.indexOf('Internet Explorer') != -1)
            {
                window.isIE = true;
            }
        window.userPlatform = navigator.platform;
        if((window.userPlatform.indexOf("mac") != -1) || (window.userPlatform.indexOf("MAC") != -1) || (window.userPlatform.indexOf("Mac") != -1))
            {
                window.userPlatform = "mac";
            }
    }
setUserVars();
function adCompatible(mediaPreference)
    {
        /*returnVal = false;
        if(((window.isIE) && (window.userPlatform != "mac")) && ((mediaPreference == "WM") || (mediaPreference == "RM")) )
            {
                returnVal = true;
            }
        return returnVal;*/
        if (navigator.userAgent.indexOf("Windows\ NT\ 5.1") != -1)
        {
            // alert('Windows XP');
            return true;
        }
        else
        {
            //alert('Not Windows XP');
            return true;
        }
        // alert ('navigator.userAgent=' + navigator.userAgent);
        return true;
    }
function doAd(newURL, mediaPreference)
    {
        if(adCompatible(mediaPreference))
            {
                location.href=newURL + "&getUnderwriting=1";
            }
        else
            {
                location.href=newURL;
            }   
    }
function toNumericMonth(month)
    {
        var monthArray = new Object();
        monthArray["jan"] = 0;
        monthArray["feb"] = 1;
        monthArray["mar"] = 2;
        monthArray["apr"] = 3;
        monthArray["may"] = 4;
        monthArray["jun"] = 5;
        monthArray["jul"] = 6;
        monthArray["aug"] = 7;
        monthArray["sep"] = 8;
        monthArray["oct"] = 9;
        monthArray["nov"] = 10;
        monthArray["dec"] = 11;
        return monthArray[month.toLowerCase()];
    }
function toFullMonth(num)
    {
        var monthArray = new Object();
        monthArray[0] = "January";
        monthArray[1] = "February";
		monthArray[2] = "March";
		monthArray[3] = "April";
		monthArray[4] = "May";
		monthArray[5] = "June";
		monthArray[6] = "July";
		monthArray[7] = "August";
		monthArray[8] = "September";
		monthArray[9] = "October";
		monthArray[10] = "November";
		monthArray[11] = "December";
        return monthArray[num];
    }
function parseZero(valToUse)
    {
        if(valToUse.length > 1 && valToUse.charCodeAt(0) == 0)
            {
                valToUse = valToUse.substr(1, valToUse.length);
            }
        return valToUse;
    }
function setDate(dateToUse)
    {
        dateArray = dateToUse.split("-");
        dateToReturn = new Date();
        dateToReturn.setDate(parseZero(dateArray[0]));
        dateToReturn.setMonth(toNumericMonth(dateArray[1].toLowerCase()));
        dateToReturn.setYear(dateArray[2]);
        dateToReturn = Date.parse(dateToReturn);
        return dateToReturn;
    }
function compareDates(date1, date2)
    {
        date1 = setDate(date1);
        date2 = setDate(date2);
        returnVal = "after";
        if(date2 < date1)
            {
                returnVal = "before";           
            }
        return returnVal;
    }
function checkMediaPrefs(mediaPrefVals, valToTest)
    {
        match = false;
        for(i = 0; i < mediaPrefVals.length; i++)
            {
                if(mediaPrefVals[i] == valToTest)
                    {
                        match = true;
                    }
            }
        return match;
    }

function trimString(sInString) 
{
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function makePrefArray(mediaPreference)
{
    numRetArray = 0;
    retArray = new Array();
    temp = new Array();
    temp = mediaPreference.split(",");
    for(i = 0; i < temp.length; i++)
    {
        if(trimString(temp[i]) != "")
        {
            retArray[numRetArray] = temp[i].toUpperCase();
            numRetArray++;
        }    
    }
    return retArray;
}

function goNewURL(newURL, saURL, winTarget)
    {
        if(saURL == "")
            {
                saURL = newURL;
            }
        if(window.sa_onclick)
            {
                sa_onclick(saURL);
            }
        if(winTarget == "new")
            {
                window.open(newURL, '', "width=540,height=360,toolbar=none,location=none,menubar=none,status=none,resizable=yes");
            }
        else
            {
                location.href= newURL;
            }
    }
function getMedia(prgCode, showDate, segNum, mediaAvailable)
    {
        nprcookie = get_cookie('sauid');
        
        mediaAvailArray = makePrefArray(mediaAvailable);
        if((segNum == "all") || (segNum == "ALL"))
        {
            segNum = "";
        }
        if(checkMediaPrefs(mediaAvailArray, "RAM") && (!checkMediaPrefs(mediaAvailArray, "RM")) && (!checkMediaPrefs(mediaAvailArray, "WM")))
        {
            // only ram available
            goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg.php?prgCode=" + prgCode + "&showDate=" + showDate + "&segNum=" + segNum + "&mediaPref=RAM", "", "");
        }
        else if(checkMediaPrefs(mediaAvailArray, "RM") && !checkMediaPrefs(mediaAvailArray, "WM"))
        {
            // only real available
            goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg.php?prgCode=" + prgCode + "&showDate=" + showDate + "&segNum=" + segNum + "&mediaPref=RM", "", "");
        }
        else if(checkMediaPrefs(mediaAvailArray, "WM") && !checkMediaPrefs(mediaAvailArray, "RM"))
        {
            // only windows available
            if(nprcookie != null && nprcookie != "undefined")
            {
                goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg_wmref.php?prgCode=" + prgCode + "&showDate=" + showDate + "&segNum=" + segNum + "&mediaPref=WM&sauid=" + nprcookie, "", "");
            }
            else
            {
                goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg_wmref.php?prgCode=" + prgCode + "&showDate=" + showDate + "&segNum=" + segNum + "&mediaPref=WM", "", "");
            }
            
        }       
        else if((checkMediaPrefs(mediaAvailArray, "RAM") || checkMediaPrefs(mediaAvailArray, "RM")) && checkMediaPrefs(mediaAvailArray, "WM"))
        {
            // windows available and at least one of real or ram available

                    if(checkCookie("NPRMediaPref"))
                        {
                            mediaPreference = checkCookie("NPRMediaPref");
                            if(mediaPreference == "WM")
                            {
                                if(nprcookie != null && nprcookie != "undefined")
                                {
                                    newURL = "http://dev-amartin.npr.org/templates/dmg/dmg_wmref.php?prgCode=" + prgCode + "&showDate=" + showDate + "&segNum=" + segNum + "&mediaPref=" + mediaPreference + "&sauid=" + nprcookie;
                                }
                                else
                                {
                                    newURL = "http://dev-amartin.npr.org/templates/dmg/dmg_wmref.php?prgCode=" + prgCode + "&showDate=" + showDate + "&segNum=" + segNum + "&mediaPref=" + mediaPreference;
                                }
                            }
                            else
                            {
                                if(checkMediaPrefs(mediaAvailArray, "RAM"))
                                {
                                    newURL = "http://dev-amartin.npr.org/templates/dmg/dmg.php?prgCode=" + prgCode + "&showDate=" + showDate + "&segNum=" + segNum + "&mediaPref=RAM";
                                }
                                else
                                {
                                    newURL = "http://dev-amartin.npr.org/templates/dmg/dmg.php?prgCode=" + prgCode + "&showDate=" + showDate + "&segNum=" + segNum + "&mediaPref=" + mediaPreference;
                                } 
                            }
                            if(window.sa_onclick)
                                {
                                    sa_onclick(newURL);
                                }
                            doAd(newURL, mediaPreference);
                        }
                    else
                        {
                            goNewURL("http://dev-amartin.npr.org/templates/dmg/audioplayer.php?prgCode=" + prgCode + "&showDate=" + showDate + "&segNum=" + segNum, "", "new");
                        }
                

        }
    }
function getStaticMedia(URL, mediaPreference)
{
    sauid = checkCookie("sauid");
    referrer = document.referrer;

    mediaPrefVals = makePrefArray(mediaPreference);

    if(URL.indexOf("http://") != -1)
    {
        goNewURL(URL, '', '');
    }
    else if(URL.toUpperCase() == "NEWSCAST")
    {
        getNewsCast(); 
    }
    else if(URL.toUpperCase() == "PROGRAMSTREAM")
    {
        getProgramStream(); 
    }           
    else if((checkMediaPrefs(mediaPrefVals, "WM")) && (checkMediaPrefs(mediaPrefVals, "RM")))
    { 
        mediaPreference = checkCookie("NPRMediaPref");
        if((mediaPreference == false) || (mediaPreference == "RM"))
        {
            goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg.php?mediaURL=" + URL + "&mediaType=RM", URL, "");
        }
        else if(mediaPreference == "WM")    
        {
            goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg.php?mediaURL=" + URL + "&mediaType=WM", URL, "");
        }
    }
    else if((checkMediaPrefs(mediaPrefVals, "RM")) && (!checkMediaPrefs(mediaPrefVals, "WM")))
    {
        goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg.php?mediaURL=" + URL + "&mediaType=RM", URL, "");
    }
    else if((checkMediaPrefs(mediaPrefVals, "WM")) && (!checkMediaPrefs(mediaPrefVals, "RM")))
    {
        goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg.php?mediaURL=" + URL + "&mediaType=WM", URL, "");
    }

}
function getTopicMedia(topicId, topicName, mediaPreference)
    {
        topicName = escape(topicName);
        nprcookie = get_cookie('sauid');
        mediaPrefVals = makePrefArray(mediaPreference); 
        if(checkCookie("NPRMediaPref"))
            {
                mediaPreference = checkCookie("NPRMediaPref");
                newURL = "http://dev-amartin.npr.org/templates/dmg/dmg.php?topicId=" + topicId + "&topicName=" + topicName + "&mediaPref=" + mediaPreference;
                if(mediaPreference == "WM")
                {
                    if(nprcookie != null && nprcookie != "undefined")
                    {
                        newURL = "http://dev-amartin.npr.org/templates/dmg/dmg_wmref.php?topicId=" + topicId + "&topicName=" + topicName + "&mediaPref=" + mediaPreference + "&sauid=" + nprcookie;
                    }
                    else
                    {
                        newURL = "http://dev-amartin.npr.org/templates/dmg/dmg_wmref.php?topicId=" + topicId + "&topicName=" + topicName + "&mediaPref=" + mediaPreference;
                    }
                    
                }

                if(window.sa_onclick)
                    {
                        sa_onclick(newURL);
                    }
                doAd(newURL, mediaPreference);
            }
        else
            {
                goNewURL("http://dev-amartin.npr.org/templates/dmg/audioplayer.php?topicId=" + topicId + "&topicName=" + topicName, "", "new");
            }       
    }
function getLatestShow(prgCode)
    {
        if(checkCookie("NPRMediaPref"))
            {
                mediaPreference = checkCookie("NPRMediaPref");
                goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg.php?getLatestShow=true&prgCode=" + prgCode + "&NPRMediaPref=" + mediaPreference, "", "new");
            }
        else
            {
                goNewURL("http://dev-amartin.npr.org/templates/dmg/audioplayer.php?getLatestShow=true&prgCode=" + prgCode, "", "new");
            }
    }
function getFeaturedAudio(newURL)
    {
        nprcookie = get_cookie('sauid');
        if(checkCookie("NPRMediaPref"))
            {
                mediaPreference = checkCookie("NPRMediaPref");
                if(mediaPreference == "WM")
                    {
                        newURL += "&NPRMediaPref=WM";
                        newURL = replaceString(newURL, 'dmg.php', 'dmg_wmref.php'); 
                        if(nprcookie != null && nprcookie != "undefined")
                        {
                            newURL += "&sauid=" + nprcookie;
                        }
                        
                    }
                else
                    {
                        newURL += "&NPRMediaPref=RM";
                    }
                if(window.sa_onclick)
                    {
                        sa_onclick(newURL);
                    }
                doAd(newURL, mediaPreference);
            }
        else
            {
                //newURL += "&NPRMediaPref=RM";
                //goNewURL(newURL, "", "new");
                goNewURL("http://dev-amartin.npr.org/templates/dmg/audioplayer.php?newURL=" + newURL, '', 'new');
            }
    }
function getProgramStream()
    {
        NPR.Player.openPlayer(0,0,null,NPR.Player.Action.LIVE_STREAM, NPR.Player.Type.PROGRAM_STREAM, NPR.Player.Mode.FROM_FILE);
    }
function getNewsCast()
    {
        NPR.Player.openPlayer(0,0,null,NPR.Player.Action.PLAY_NOW, NPR.Player.Type.NEWSCAST, NPR.Player.Mode.FROM_FILE);
    }
function getMusicButton(songId, musicAudioFileName, prgCode)
    {
        if(checkCookie("NPRMediaPref"))
            {
                mediaPreference = checkCookie("NPRMediaPref");
                goNewURL("http://dev-amartin.npr.org/templates/dmg/dmg.php?getMusicButton=true&songId=" + songId + "&musicAudioFileName=" + musicAudioFileName + "&prgCode=" + prgCode + "&NPRMediaPref=" + mediaPreference, "", "");
            }
        else
            {
                goNewURL("http://dev-amartin.npr.org/templates/dmg/audioplayer.php?getMusicButton=true&songId=" + songId + "&musicAudioFileName=" + musicAudioFileName + "&prgCode=" + prgCode, '', "new");
            }
    }
//cookie code
function setCookie(cookieToSet, daysToExpiration, cookieValue)
    {
        var exp=new Date();
        exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * daysToExpiration));
        document.cookie=cookieToSet + "=" + cookieValue + "; path=/; domain=npr.org; expires=" + exp.toGMTString();
    }
function checkCookie(cookieToCheck)
    {
        var allcookies = document.cookie;
        var pos = allcookies.indexOf(cookieToCheck + "=");
        if(pos != -1)
            {
                var start = pos + cookieToCheck.length + 1;
                var end = allcookies.indexOf(";", start);
                if(end == -1)
                    {
                        end = allcookies.length;
                    }
                return allcookies.substring(start, end);
            }
        else
            {
                return false;
            }
    }
function killCookie(cookieToKill)
    {
        setCookie(cookieToKill, -1, '');
        
        if(cookieToKill == 'station') {
        	$('.ddstn').slideUp(250, function () {
				$('#header .headercontent').removeClass("dd_active");
			});
			$('#globalstationlocation').html("\n");
			$('#station_info').html("\n");
        }
    }


// --------------------------------------------------------
// replaceString
// --------------------------------------------------------
//  description:  GENERIC REPLACE STRING FUNCTION
//
//  parameters:   
//      repStr is the string that will have the replace done to it
//      stringToFind is the string searched for in the repStr (and replaced, when found)
//      stringToRep is the string to replace when the stringToFind is found
//
//  RETURN newStr - the modified "repStr"
// 
function replaceString(repStr, stringToFind, stringToRep)
    {
        sFind = 0;
        newStr = repStr;

        while (sFind != -1)
            {
                // FIND THE NEXT OCCURENCE OF THE stringToFind
                sFind = newStr.indexOf(stringToFind);

                // IF THERE IS AN OCCURENCE, PERFORM THE REPLACE
                if (sFind != -1)
                    {
                        startString = newStr.substring(0, sFind); // GET THE STRING BEFORE stringToFind
                        endString = newStr.substring(sFind +  stringToFind.length, newStr.length); // GET THE STRING AFTER stringToFind
                        newStr = startString + stringToRep + endString; // CAT THE STRING BEFORE AND AFTER stringToFind AND INSERT stringToRep IN BETWEEN
                    }
            }

        return newStr;  // RETURN VALUE AFTER REPLACES
    }

function set_cookie( name, value, expires, path, domain, secure ) 
{
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime( today.getTime() );

    /*
    if the expires variable is set, make the correct 
    expires time, the current script below will set 
    it for x number of days, to make it for hours, 
    delete * 24, for minutes, delete * 60 * 24
    */
    if ( expires )
    {
    expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date( today.getTime() + (expires) );

    document.cookie = name + "=" +escape( value ) +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
    ( ( path ) ? ";path=" + path : "" ) + 
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}

function get_cookie( name ) 
{
    
    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    if ( ( !start ) &&
    ( name != document.cookie.substring( 0, name.length ) ) )
    {
    return null;
    }
    if ( start == -1 ) return null;
    var end = document.cookie.indexOf( ";", len );
    if ( end == -1 ) end = document.cookie.length;
    return unescape( document.cookie.substring( len, end ) );
}
function get_source_code()
{
    var url = document.URL;
    var sc = url.match(/(&|\?)sc=(\w+)/);
    var sourceCode = url.match(/(&|\?)sourceCode=(\w+)/);
    var ft = url.match(/(&|\?)ft=(\w+)/);
    
    if(ft != null && ft[2] != null)
    {
        return '/sc=' + ft[2];
    }
    else if(sc != null && sc[2] != null)
    {
        return '/sc=' + sc[2];
    }
    else if(sourceCode != null && sourceCode[2] != null)
    {
        return '/sc=' + sourceCode[2];
    }
    else
    {
        return '';
    }    
}

function get_target()
{
    if(window.target != null)
    {
        return window.target;
    }
    else
    {
        return '';
    }
}

function getFinalPrefs(mediaPrefVals, valToTest)
{
    retPref = "";
    for(i = 0; i < mediaPrefVals.length; i++)
    {
        if(valToTest == "WM" && (mediaPrefVals[i] == "WM" || mediaPrefVals[i] == "WAX" || mediaPrefVals[i] == "ASX"))
        {
            retPref = mediaPrefVals[i];
        }
        else if(valToTest == "RM" && (mediaPrefVals[i] == "RM" || mediaPrefVals[i] == "RAM"))
        {
            retPref = mediaPrefVals[i];
        }
    }
    return retPref;
}

function choosePlayer(mediaAvailableVals, playerAvailableVals)
{
    countAvaPlayer = 0;
    avaMatchPlayer = "";
    for(i = 0; i < mediaAvailableVals.length; i++)
    {
        for(j=0; j < playerAvailableVals.length; j++)
        {
            if(mediaAvailableVals[i] == playerAvailableVals[j])
            {
                if(countAvaPlayer == 0)
                {
                    avaMatchPlayer = mediaAvailableVals[i];  
                    countAvaPlayer++;
                }
                else
                {
                    avaMatchPlayer += "," + mediaAvailableVals[i];
                }
            }
        }
    }
    return avaMatchPlayer;
}

function forceChoosePlayer(mediaAvailableVals)
{
    finalChoose = "";
    for(i = 0; i < mediaAvailableVals.length; i++)
    {
        if(mediaAvailableVals[i] == "WM" || mediaAvailableVals[i] == "ASX" || mediaAvailableVals[i] == "WAX")
        {
            finalChoose = mediaAvailableVals[i] ;
            break;
        }
        
    }
    
    if(finalChoose == "")
    {
        for(i = 0; i < mediaAvailableVals.length; i++)
        {
            if(mediaAvailableVals[i] == "RM" || mediaAvailableVals[i] == "RAM")
            {
                finalChoose = mediaAvailableVals[i];
                break;
            }    
        }
    }
    
    // here for mac machine user, need to reverse the preference order
    if(window.userPlatform == "mac" && finalChoose != "RM" && finalChoose != "RAM")
    {
        for(i = 0; i < mediaAvailableVals.length; i++)
        {
            if(mediaAvailableVals[i] == "RM" || mediaAvailableVals[i] == "RAM")
            {
                finalChoose = mediaAvailableVals[i];
                break;
            }    
        }
    }
    
    return finalChoose;
    
}

function getRandom(num)
{
    myRandomNum = '';
    for(myRandomNum = ''; myRandomNum.length < num; myRandomNum += Math.round(Math.random()*7));
    return myRandomNum;
}    
function getGUID()
{
    myGuid = get_cookie('GUID');
    if(myGuid == null || myGuid == "undefined")
    {
        for(myGuid = ''; myGuid.length < 32; myGuid += Math.round(Math.random()*7));
    }
    return myGuid;
}    

function popNewWindow(newURL)
{
    if(newURL)
    {
        popUp(newURL,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=340,height=492','player');    
    }
}

// Add extra RAM format if end user installed RM player, OR ASX, WAX if user installed WM player. 
//   The reason is that we want to make choosePlayer func to work.
//   Available audio type maybe RAM, WAX, ASX, so we have to match this.    
function addExtraMediaType(availableMediaTypeArray)
{
    returnArray = new Array();
    mCounter = 0;
    for(i=0; i < availableMediaTypeArray.length; i++)
    {
        returnArray[mCounter] = availableMediaTypeArray[i];
        mCounter++;
        if(availableMediaTypeArray[i] == "RM")
        {
            returnArray[mCounter] = "RAM";
            mCounter++;
            returnArray[mCounter] = "RA";
            mCounter++;
            returnArray[mCounter] = "RMM";
            mCounter++;
        }
        else if(availableMediaTypeArray[i] == "WM")
        {
            returnArray[mCounter] = "ASX";
            mCounter++;
            returnArray[mCounter] = "WAX";
            mCounter++;
        }
    }
    return returnArray;
}

function checkFileMediaType(mediaAvailArray)
{
    for(i=0; i < mediaAvailArray.length; i++)
    {
        if(mediaAvailArray[i] == 'WM' || mediaAvailArray[i] == 'ASX' || mediaAvailArray[i] == 'WMA' || mediaAvailArray[i] == 'RM' || mediaAvailArray[i] == 'RAM' || mediaAvailArray[i] == 'RA' || mediaAvailArray[i] == 'RMM')
        {
            return true;
        }
    }
    return false;

}

function launchPlayer(baseId, baseType, baseDate, accParameters, mediaAvailable)
{
    // error code: 
    //  1. -- File not found
    //  2. -- No WM and RM player installed
    //  3. -- Installed Player Not Match Available Audio Type
    
    errorCode = 0;

    // create pageId, random 10 digit number and GUID
    pageId = getRandom(8);
    random10 = getRandom(10);
    myGuid = getGUID();
    
    // audioMediaType defined in detect_wmrm_player.js and assigned in story_base or other base php page
    // get common meida type between available segment media type and available installed media type

    wAudioMediaType = 'WM,RM';
    mediaAvailArray = makePrefArray(mediaAvailable);     // available segment media type
    if(!checkFileMediaType(mediaAvailArray))
    {
        errorCode = 1;
    }
    audioMediaTypeArray = makePrefArray(wAudioMediaType); // available installed player type 
    audioMediaTypeArray = addExtraMediaType(audioMediaTypeArray);
    if(audioMediaTypeArray.length == 0)
    {
        errorCode = 2;
    }
    avaMatchPlayer = choosePlayer(mediaAvailArray, audioMediaTypeArray); // find the common part of above 2
    avaMatchPlayerArray = makePrefArray(avaMatchPlayer); // make this common part as a array for following use
    
    // now get end user prefered media type
    userMediaPreference = checkCookie("NPRMediaPref");
    
    newURL = "http://dev-amartin.npr.org/templates/dmg/popup.php?id=" + baseId + "&type=" + baseType + "&date=" + baseDate + "&au=1&pid=" + pageId + "&random=" + random10 + "&guid=" + myGuid + "&uaType=" + wAudioMediaType + "&aaType=" + mediaAvailable + "&upf=" + window.userPlatform + accParameters;
    if(baseType == 10)
    {
        newURL = "http://dev-amartin.npr.org/templates/dmg/popup.php?id=100&type=10&staticUrl=" + baseDate + "&au=1&pid=" + pageId + "&random=" + random10 + "&guid=" + myGuid + "&uaType=" + wAudioMediaType + "&aaType=" + mediaAvailable + "&upf=" + window.userPlatform  + accParameters;    
    }
    
    if(userMediaPreference)
    {
        // has preference, now check this preference available or not
        finalSelMediaType = getFinalPrefs(avaMatchPlayerArray, userMediaPreference);
        if(finalSelMediaType != "")
        {
            // Bingo, end user preference matched and launch the player to play the media
            newURL += "&mtype=" + finalSelMediaType;
            popNewWindow(newURL);
        }
        else
        {
            if(avaMatchPlayerArray.length > 0)  // end user media preference is different to available media type
            {
                // we choose player for end user
                forceChooseMedia = forceChoosePlayer(avaMatchPlayerArray);
                if(forceChooseMedia != "")
                {
                    // Bingo, we successfully chosen a player for end user
                    newURL += "&mtype=" + forceChooseMedia;
                    popNewWindow(newURL);
                    return;
                }

            }
            
            if(avaMatchPlayerArray.length == 0 && errorCode == 0) // the situation is audio has WM format and installed only RM player, or vice versa
            {
               errorCode = 3;
            }
            // pop up error message window
            newURL += "&errorCode=" + errorCode;
            popNewWindow(newURL);

        }
    }
    else
    {
        // End user has no preference. We are going to choose for them
        forceChooseMedia = forceChoosePlayer(avaMatchPlayerArray);
        if(forceChooseMedia != "")
        {
            // Bingo, we successfully chosen a player for end user
            newURL += "&mtype=" + forceChooseMedia;
            popNewWindow(newURL);
        }
        else    // we can not choose player for end user
        {
            // pop up error message window
            newURL += "&errorCode=" + errorCode;
            popNewWindow(newURL);
        }
    }
}


function launchPlayerError(baseId, baseType, baseDate, accParameters, mediaAvailable, error_id)
{
    // error code: 
    //  1. -- File not found
    //  2. -- No WM and RM player installed
    //  3. -- Installed Player Not Match Available Audio Type
    
    // create pageId, random 10 digit number and GUID
    pageId = getRandom(8);
    random10 = getRandom(10);
    myGuid = getGUID();
    
    // audioMediaType defined in detect_wmrm_player.js and assigned in story_base or other base php page
    // get common meida type between available segment media type and available installed media type
    errorCode = 0;
    mediaAvailable = "";
    switch(error_id)
    {
        case 1: // No audio file exist
            mediaAvailable = "DC";
            break;
        case 2: // Not install WM and RM player, File available in WM and RM
            window.audioMediaType = "";
            mediaAvailable = "RM,WM";
            break;
        case 3: // RM not installed, but RM file available
            window.audioMediaType = "WM";
            mediaAvailable = "RM";
            break;
        case 4: // WM not installed, but WM file available
            window.audioMediaType = "RM";
            mediaAvailable = "WM";
            break;
        case 5: // WM,RM installed, ONLY WM file available    
            window.audioMediaType = "RM,WM";
            mediaAvailable = "WM";
            break;
        case 6: // WM,RM installed, ONLY RM file available    
            window.audioMediaType = "RM,WM";
            mediaAvailable = "RM";
            break;
        case 7: // WM installed, WM,RM file available    
            window.audioMediaType = "WM";
            mediaAvailable = "WM,RM";
            break;
        case 8: // RM installed, WM,RM file available    
            window.audioMediaType = "RM";
            mediaAvailable = "WM,RM";
            break;
            
    }
    wAudioMediaType = window.audioMediaType;
    mediaAvailArray = makePrefArray(mediaAvailable);     // available segment media type
    if(!checkFileMediaType(mediaAvailArray))
    {
        errorCode = 1;
    }
    audioMediaTypeArray = makePrefArray(wAudioMediaType); // available installed player type 
    audioMediaTypeArray = addExtraMediaType(audioMediaTypeArray);
    if(audioMediaTypeArray.length == 0)
    {
        errorCode = 2;
    }
    avaMatchPlayer = choosePlayer(mediaAvailArray, audioMediaTypeArray); // find the common part of above 2
    avaMatchPlayerArray = makePrefArray(avaMatchPlayer); // make this common part as a array for following use
    
    // now get end user prefered media type
    userMediaPreference = checkCookie("NPRMediaPref");
    
    newURL = "http://dev-amartin.npr.org/templates/dmg/popup.php?id=" + baseId + "&type=" + baseType + "&date=" + baseDate + "&au=1&pid=" + pageId + "&random=" + random10 + "&guid=" + myGuid + "&uaType=" + wAudioMediaType + "&aaType=" + mediaAvailable + accParameters;
    
    if(userMediaPreference)
    {
        // has preference, now check this preference available or not
        finalSelMediaType = getFinalPrefs(avaMatchPlayerArray, userMediaPreference);
        if(finalSelMediaType != "")
        {
            // Bingo, end user preference matched and launch the player to play the media
            newURL += "&mtype=" + finalSelMediaType;
            popNewWindow(newURL);
        }
        else
        {
            if(avaMatchPlayerArray.length > 0)  // end user media preference is different to available media type
            {
                // we choose player for end user
                forceChooseMedia = forceChoosePlayer(avaMatchPlayerArray);
                if(forceChooseMedia != "")
                {
                    // Bingo, we successfully chosen a player for end user
                    newURL += "&mtype=" + forceChooseMedia;
                    popNewWindow(newURL);
                    return;
                }

            }
            
            if(avaMatchPlayerArray.length == 0 && errorCode == 0) // the situation is audio has WM format and installed only RM player, or vice versa
            {
               errorCode = 3;
            }
            // pop up error message window
            newURL += "&errorCode=" + errorCode;
            popNewWindow(newURL);

        }
    }
    else
    {
        // End user has no preference. We are going to choose for them
        forceChooseMedia = forceChoosePlayer(avaMatchPlayerArray);
        if(forceChooseMedia != "")
        {
            // Bingo, we successfully chosen a player for end user
            newURL += "&mtype=" + forceChooseMedia;
            popNewWindow(newURL);
        }
        else    // we can not choose player for end user
        {
            // pop up error message window
            newURL += "&errorCode=" + errorCode;
            popNewWindow(newURL);
        }
    }
}


/************************************************************************
 *  Get rul parameters
 ***********************************************************************/
function getURLParamArray()
{
    var aQueryString = new Array();
    var strHref = window.location.href;
    if( strHref.indexOf("?") > -1 )
    {
        var strQueryString = strHref.substr(strHref.indexOf("?"));
        var aQueryString = strQueryString.split("&");
    }
    return aQueryString;
}

function getURLParam(strParamName)
{
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 )
  {
    var strQueryString = strHref.substr(strHref.indexOf("?"));
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
    {
      if (aQueryString[iParam].indexOf(strParamName + "=") > -1 )
      {
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

// fix for ie6, forces the topnav rollover images to cache and not flicker  
try
{
  document.execCommand("BackgroundImageCache", false, true);
} 
catch(err) {}

function collectionToArray(col) {
    a = new Array();
    for (i = 0; i < col.length; i++)
        a[a.length] = col[i];
    return a;
}


function concatCollections(col1, col2)
{
    if (col1 == null)
    {
        return collectionToArray(col2);
    }
    else if (col2 == null)
    {
        return collectionToArray(col1);
    }
    else
    {
        return collectionToArray(col1).concat(collectionToArray(col2));
    }
    
}

// toggle function for quizzes (on story page, in html insert at bottom of pg)

function toggleDetails(num) 

{

            if(document.getElementById)

            { 

                        objRef = document.getElementById("descriptionTxt" + num);

                        expanderRef = document.getElementById("expander" + num);

 

                        if (objRef.className=="closeDiv")

                        {

                                    objRef.className = "openDiv";

                                    expanderRef.setAttribute("src", "http://media.npr.org/images/quiz_hide.gif");

                                    expanderRef.setAttribute("alt", "Hide Answer");

                        }

                        else if (objRef.className=="openDiv")

                        {

                                    objRef.className = "closeDiv";

                                    expanderRef.setAttribute("src", "http://media.npr.org/images/quiz_show.gif");

                                    expanderRef.setAttribute("alt", "Show Answer");

                        }

            }

}  


 //  ecommerce 

        var uniqueIdsHash = new Array();
        var currentOpenDiv = null;
    
    
        function openWindow(link)
        {
            var w  = window.open(link);
            w.focus();
            return false;
        }
    
        function getLink(url, text, className)
        {
            var ret = '<li><a href="' + url + '" onclick="return popUp(this,\'toolbar=yes,scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes\',\'npr\');" class="' + className + '">' + text + '</a></li>';
        
            //var ret = '<a href="javascript:void(0);" onclick="openWindow(\'' + url + '\');" class="' + className + '">' + text + '</a>';
            return ret;
        }
    
        function toggleEcommerceDiv(uniqueId, index, title, type)
        {           
            var amazonVendorLinks = document.getElementById('AmazonOnlyVendorLinks' + uniqueId  + '_' + index);
            var VendorLinks = document.getElementById('VendorLinks' + uniqueId + '_' + index);
            
            // show pop up window first
            var ecommerceDiv = document.getElementById("ecommerceDiv" + uniqueId + '_' + index);
            
            if(ecommerceDiv != null)
            {
	            if (currentOpenDiv != null && currentOpenDiv != ecommerceDiv)
	            {
	                currentOpenDiv.className= currentOpenDiv.className.replace("openDiv", "closeDiv");
	            }
	            
	            if (ecommerceDiv.className.indexOf("closeDiv") != -1)
	            {
	                ecommerceDiv.className = ecommerceDiv.className.replace("closeDiv", "openDiv");
	                currentOpenDiv = ecommerceDiv;
	            }
	            else
	            {
	                ecommerceDiv.className = ecommerceDiv.className.replace("openDiv", "closeDiv");
	                currentOpenDiv = null;
	            }
            }

            if ((amazonVendorLinks != null || VendorLinks != null) && uniqueId != -1 && uniqueIdsHash[uniqueId + '_' + index] == null)
            {
                if((amazonVendorLinks != null && amazonVendorLinks.innerHTML == null) || (VendorLinks != null && VendorLinks.innerHTML == null))
                {
                    showLoad(uniqueId, index);
                }    

                var url = "/templates/XMLQuery/AmazonLink.php?UPC=" + uniqueId + "&text=Amazon.com &raquo;&className=buyLink1";
                
                var vendorCodesRequester = getRequester();
                vendorCodesRequester.open("GET", url, true);
                
                vendorCodesRequester.onreadystatechange=function() {
                
                    var isAmazonOnly = document.getElementById('AmazonOnlyVendorLinks' + uniqueId  + '_' + index) != null;

                    if (vendorCodesRequester.readyState == 4 && vendorCodesRequester.status == 200)
                    {
                        response  = vendorCodesRequester.responseXML.documentElement;

                        var displayLinksSpan = null;

                        if (isAmazonOnly)
                        {
                            displayLinksSpan = document.getElementById('AmazonOnlyVendorLinks' + uniqueId + '_' + index);
                        }
                        else
                        {
                            displayLinksSpan = document.getElementById('VendorLinks' + uniqueId + '_' + index);
                        }

                        if (displayLinksSpan != null)
                        {
                            displayLinksSpan.innerHTML = "";

                            amazonLinks = response.getElementsByTagName("Amazon");
                            if (amazonLinks[0] != null && amazonLinks[0] != undefined && amazonLinks.length == 1 && amazonLinks[0].getElementsByTagName("link-npr").length > 0)
                            {
                                if (isAmazonOnly)
                                {
                                    // different link for World Cafe
                                    var link_url = amazonLinks[0].getElementsByTagName("link-wxpn")[0].firstChild.data;
                                    displayLinksSpan.innerHTML += getLink(link_url, 'Amazon.com &raquo;', 'buyLink1'); 
                                }   
                                else
                                {
                                    var link_url = amazonLinks[0].getElementsByTagName("link-npr")[0].firstChild.data;
                                    displayLinksSpan.innerHTML += getLink(link_url, 'Amazon.com &raquo;', 'buyLink1');
                                }                       
                            }
                            else if (amazonLinks[0] != null && amazonLinks[0] != undefined)
                            {
                                if (isAmazonOnly)
                                {
                                    // different link for World Cafe
                                    var link_url = amazonLinks[0].getElementsByTagName("link-query-wxpn")[0].firstChild.data + title.replace(/ /g,'+');
                                    displayLinksSpan.innerHTML += getLink(link_url, 'Amazon.com &raquo;', 'buyLink1'); 
                                }
                                else
                                {
                                    var link_url = amazonLinks[0].getElementsByTagName("link-query-npr")[0].firstChild.data + title.replace(/ /g,'+');
                                    displayLinksSpan.innerHTML += getLink(link_url, 'Amazon.com &raquo;', 'buyLink1'); 
                                }
                            }

                            if(amazonLinks[0] != null && amazonLinks[0] != undefined && amazonLinks.length == 1 && amazonLinks[0].getElementsByTagName("link-amazon-dl").length > 0)
                            {
                                var link_url = amazonLinks[0].getElementsByTagName("link-amazon-dl")[0].firstChild.data;
                                displayLinksSpan.innerHTML += getLink(link_url, 'Amazon MP3 &raquo;', 'buyLink1');
                            }


                            // for future iteration of itunes. Does not do fuzzy search for more than one result
                            itunesLinks = response.getElementsByTagName("iTunes");
                            if (itunesLinks.length == 1)
                            {
                                var link_url = itunesLinks[0].getElementsByTagName("link")[0].firstChild.data;
                                displayLinksSpan.innerHTML += getLink(link_url, 'iTunes &raquo;', 'buyLink3'); 
                            }
                        }
                        
                        stopLoad(uniqueId, index);
                    }
                    else
                    {
                        // ignore, regretfully. User doesn't need to know about this kind of problem. No easy way to inform developers.
                    }
                }
                
                vendorCodesRequester.send(null);
                uniqueIdsHash[uniqueId + '_' + index] = "on";   
            }
        }
        
        // browser independent way of getting XMLRequestObject
        function getRequester()
        {
            var requester = null;
        
            try
            {
                requester = new XMLHttpRequest();
            }
            catch (error)
            {
                 try
                 {
                   requester = new ActiveXObject("Microsoft.XMLHTTP");
                 }
                 catch (error)
                 {
                   return null;
                 }
            }
            
            return requester;
        }       


        function showLoad (uniqueId, index) {
            var wrapid = '#load2_'+ uniqueId + '_' + index;
            $(wrapid).show();
        }
        function stopLoad(uniqueId, index){
            var wrapid = '#load2_'+ uniqueId + '_' + index;
            $(wrapid).hide();
        }
        
        
    

 //  player/player 

RegisterNamespace('NPR.Player');
RegisterNamespace('NPR.Player.Action');
RegisterNamespace('NPR.Player.Type');
RegisterNamespace('NPR.Player.Mode');
  
NPR.Player.MediaPlayerWindow = null;

NPR.Player.Action.PLAY_NOW = 1;
NPR.Player.Action.ADD_TO_PLAYLIST = 2;
NPR.Player.Action.LIVE_STREAM = 3;

NPR.Player.Type.STORY = 1;
NPR.Player.Type.TOPIC = 2;
NPR.Player.Type.PROGRAM = 3;
NPR.Player.Type.NEWSCAST = 4;
NPR.Player.Type.PROGRAM_STREAM = 'live1';
NPR.Player.Type.BUTTON = 6;
NPR.Player.Type.MOST_EMAILED = 100;
NPR.Player.Type.MOST_EMAILED_MUSIC = 102;

NPR.Player.Type.LIVE_STREAM_2 = 'live2';
NPR.Player.Type.LIVE_STREAM_3 = 'live3';
NPR.Player.Type.LIVE_STREAM_4 = 'live4';
NPR.Player.Type.LIVE_STREAM_5 = 'live5';

NPR.Player.Type.STATIC_FILE_1 = 'static1';
NPR.Player.Type.STATIC_FILE_2 = 'static2';
NPR.Player.Type.STATIC_FILE_3 = 'static3';
NPR.Player.Type.STATIC_FILE_4 = 'static4';

NPR.Player.Mode.MODEL_FROM_FILE = 0;
NPR.Player.Mode.MODEL_FROM_DATABASE = 1;

NPR.Player.openPlayer = function(id, mediaId, dateString, action, type, mode) {

    try {
        mode = parseInt(mode);
        var islist = false;
        if (id > 0 &&
                (type == NPR.Player.Type.TOPIC 
                    || type == NPR.Player.Type.PROGRAM
                    || type == NPR.Player.Type.MOST_EMAILED
                    || type == NPR.Player.Type.MOST_EMAILED_MUSIC
                )
            ) {
            islist = true;
        }
    
        var cookieString = "?action=" + action + "&t=" + type + "&islist=" + islist
    
        if (id > 0) {
            cookieString += "&id=" + id;
        }
    
        if (mediaId > 0) {
            cookieString += "&m=" + mediaId;
        }   
    
        if (dateString != null) {
            cookieString += "&d=" + dateString;
        }   
        
        if (mode === NPR.Player.Mode.MODEL_FROM_DATABASE) {
            cookieString += "&live=" + NPR.Player.Mode.MODEL_FROM_DATABASE;
        }   
        
        if (action === NPR.Player.Action.ADD_TO_PLAYLIST) {
        	NPR.metrics.pageEvent(NPR.metrics.constants.ADD_TO_PLAYLIST);
        }
    
        diff = 9999999;
        date1 = new Date();
        date2 = null;
    
        if (NPR.Player.readCookie('playerWindowOpen') !== null) {
            date2 = new Date(NPR.Player.readCookie('playerWindowOpen'));
            diff  = date1-date2;
            //alert(diff);
        }
            
    
        // if we have a handle, and it's open, just call the window directly
        if (NPR.Player.MediaPlayerWindow !== null && !NPR.Player.MediaPlayerWindow.closed) {
            // alert("launching via direct");
            // NPR.Player.createCookie('playListItem',cookieString,1);
            try {
                NPR.Player.MediaPlayerWindow.addPlaylistItem(cookieString);
                NPR.Player.MediaPlayerWindow.focus();
            }
            catch (ex) {
                NPR.messaging.exception(ex, 'player.js', 'NPR.Player.openPlayer', NPR.messaging.constants.PLAYER_JS_ERROR);
                NPR.Player.createCookie('playListItem',cookieString,1);
            }
        }
        // if it's not open, and there's no cookie for the playlist, open a new window
        // the window will erase the cookie when it's closed
        else if (NPR.Player.readCookie('playerWindowOpen') === null
        || diff > 5000  ) {
            // alert("launching new window; diff=" + diff);
            // NPR.Player.createCookie('playListItem',cookieString,1);
            NPR.Player.MediaPlayerWindow = window.open('http://dev-amartin.npr.org/templates/player/mediaPlayer.html' + cookieString, '_player', 'height=590,width=770,status=yes,toolbar=no,menubar=no,location=no');        
            if (NPR.Player && NPR.Player.MediaPlayerWindow) {
                NPR.Player.MediaPlayerWindow.focus();
            }
        }
        // there is a player, but another parent window opened it.
        // we can't get a handle on it.
        // just set the cookie and hope for the best
        else {
            // alert("launching via cookie; diff=" + diff);
            NPR.Player.createCookie('playListItem',cookieString,1);
        }
    }
    catch (e) {
        NPR.messaging.exception(e, 'player.js', 'NPR.Player.openPlayer', NPR.messaging.constants.PLAYER_JS_ERROR);
    }
    return;
};

function RegisterNamespace(namespacePath) {
    var rootObject = window;
    var namespaceParts = namespacePath.split('.');
    
    for (var i = 0; i < namespaceParts.length; i++) {
        var currentPart = namespaceParts[i];
        
        if (!rootObject[currentPart]) {
            rootObject[currentPart] = new Object();
        }
        
        rootObject = rootObject[currentPart];
    }
};

NPR.Player.createCookie = function(thename,thevalue,days) {
    try {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = thename+"="+thevalue+expires+"; path=/";
    }
    catch (e) {
        NPR.messaging.exception(e, 'player.js', 'NPR.Player.createCookie', NPR.messaging.constants.PLAYER_JS_ERROR);
    }    
};

NPR.Player.readCookie = function(thename) {
    var nameEQ = thename + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0) === ' ') {
            c = c.substring(1,c.length);
        }
        if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
};


 //  metrics 

AddNamespace("NPR.metrics");

NPR.metrics.constants = {};
NPR.metrics.constants.SEARCH_CONDUCTED = 'event1';
NPR.metrics.constants.PAGEVIEW = 'event2';
NPR.metrics.constants.REGISTRATION = 'event3';
NPR.metrics.constants.PROMOTION = 'event4';
NPR.metrics.constants.LOGIN = 'event5';
NPR.metrics.constants.EMAIL_STORY = 'event9';
NPR.metrics.constants.NEWSLETTER_SUBSCRIBE = 'event10';
NPR.metrics.constants.NEWSLETTER_UNSUBSCRIBE = 'event11';
NPR.metrics.constants.COMMENT_ADDED = 'event13';
NPR.metrics.constants.CONTACT_US = 'event14';
NPR.metrics.constants.STATION_DRAWER_OPEN = 'event15';
NPR.metrics.constants.LISTEN_DRAWER_OPEN = 'event16';
NPR.metrics.constants.CLICK_RSS_LINK = 'event8';
NPR.metrics.constants.CLICK_PODCAST_LINK = 'event18';
NPR.metrics.constants.AUTO_REFRESH = 'event19';
NPR.metrics.constants.IMAGE_ENLARGEMENT = 'event22';
NPR.metrics.constants.ADD_TO_PLAYLIST = 'event23';
NPR.metrics.constants.SPONSOR_DRAWER_OPEN = 'event24';
NPR.metrics.constants.STATION_SEARCH = 'event27';
NPR.metrics.constants.STATION_SEARCH_DONATE = 'event28';
NPR.metrics.constants.STATION_LINK_CLICKED = 'event29';
NPR.metrics.constants.ERROR_PAGE_TYPE = 'errorPage';

if (typeof get_cookie === 'undefined') {
    get_cookie = function( name ) {    
        var start = document.cookie.indexOf( name + "=" );
        var len = start + name.length + 1;
        if ( ( !start ) &&
             ( name !== document.cookie.substring( 0, name.length ) ) ) {
            return null;
        }
        if ( start === -1 ) return null;
        var end = document.cookie.indexOf( ";", len );
        if ( end === -1 ) end = document.cookie.length;
        return unescape( document.cookie.substring( len, end ) );
    }
}

NPR.metrics.variables = {};

if(NPR.metrics.vscount != null) {
    NPR.metrics.vscount = NPR.metrics.vscount + 1;
    NPR.metrics.variables["logCount"] = NPR.metrics.vscount;
}
else { 
    NPR.metrics.vscount = 1;
}

NPR.metrics.host = "http://dev-amartin.npr.org";
if (document.location.href.indexOf("shop.npr.org") > -1) {
    NPR.metrics.host = "//v2.npr.org";
}
else if (document.location.href.indexOf("https:") > -1) {
    NPR.metrics.host = "https://v.npr.org";
}

NPR.metrics.variables["sw"] = screen.width;
NPR.metrics.variables["sh"] = screen.height;
NPR.metrics.variables["cd"] = screen.colorDepth;
NPR.metrics.variables["dr"] = document.referrer;
NPR.metrics.variables["cb"] = new Date().getTime();

NPR.metrics.getTags = function() {
    var vo = "";
    for ( vKey in NPR.metrics.variables ) {
        vo = vo+"&"+vKey+"="+escape(NPR.metrics.variables[vKey]);
    }

    if(NPR.metrics.vstag) {
        for (vKey in NPR.metrics.vstag) {
            if(vKey != 'title' && vKey != 'dt') {
            vo = vo+"&"+vKey+"="+ NPR.metrics.vstag[vKey];
            }
        }
    }
    else {
        NPR.metrics.vstag = {};
    }
    
    if(NPR.metrics.vstag.title) {
        var title = NPR.metrics.vstag.title;
    
        /*Begin kludge for Visual Science functionality*/
                title = unescape(title);
                title = escape(title);
        /*End kludge for Visual Science functionality */
        
        vo = vo+"&dt="+title;
    }
    else {
        vo = vo+"&dt="+escape(document.title);
    }

    var userCookie = get_cookie('at');
    //read their cookie to see if they are logged in
    if (userCookie !== null) {
        var cookieParts = userCookie.split("&");
        for (var index = 0; index < cookieParts.length; index++)
        {
            var argParts = cookieParts[index].split("=");
            if (argParts.length === 2) {
                var key = argParts[0];
                var value = argParts[1];

                //userid
                if (key === "u") {
                    var userHash = NPR.MD5(value);
                    vo = vo+"&userHash="+userHash;
                    NPR.metrics.vstag["userHash"]=userHash;
                }
                if (key === "tier") {
                    vo = vo+"&userTier="+value;
                    NPR.metrics.vstag["tier"]=value;
                }
            }
        }
    }
    
    var stationCookie = get_cookie('station');   
    NPR.metrics.vstag["preferredStation"]=stationCookie;
        
    return vo;
};

NPR.metrics.fixEncoding = function(oldString) {
    var newString = oldString.replace(/\+/g,' ');
    return decodeURIComponent(newString);
};

NPR.metrics.pageImpression = function() {
    var fc = new Image();
    fc.src = NPR.metrics.host + '/images/zag.gif?Log=1' + NPR.metrics.getTags();
    
    // Set Omniture Variables

    s.pageName="";
    
    s.server="";
    s.channel="";

    s.pageType="";
    if (NPR.metrics.vstag.omniturePageType) {
        s.pageType=NPR.metrics.vstag.omniturePageType;
    }

    var pageTitle = document.title;
    pageTitle = pageTitle.replace(/NPR\:/,'');
    pageTitle = pageTitle.replace(/NPR\s\:/,'');
    pageTitle = pageTitle.replace(/NPR\-/,'');
    pageTitle = pageTitle.replace(/NPR\s\-/,'');
    
    if(NPR.metrics.vstag.title) {
        pageTitle = NPR.metrics.fixEncoding(NPR.metrics.vstag["title"]);
    }
        
    s.pageName=pageTitle;
    s.prop3=pageTitle;
    
    if (NPR.metrics.vstag.storyId) {
        s.prop4=NPR.metrics.vstag["storyId"];
        
      
        //initialize click map plug-in
        if(s.prop4 === '1002')
        { 
        	s.setupDynamicObjectIDs();        
        }
    }
    else {
        s.prop4=0;
    }

    if(NPR.metrics.vstag.omnitureNamePrefix) {
        s.pageName=NPR.metrics.fixEncoding(NPR.metrics.vstag.omnitureNamePrefix) + s.pageName;
        s.prop3=s.pageName;
    }

    if(NPR.metrics.vstag.omnitureNameSuffix) {
        s.pageName=s.pageName + NPR.metrics.fixEncoding(NPR.metrics.vstag.omnitureNameSuffix);
        s.prop3=s.pageName;
    }
    
    if (NPR.metrics.vstag.text) { 
        s.prop1=NPR.metrics.fixEncoding(NPR.metrics.vstag["text"].toLowerCase());
        s.prop2="zero";  // default is no search results, will be overwritten below if > 0
        if (NPR.metrics.vstag.searchResults && NPR.metrics.vstag.searchResults > 0) {
            s.prop2=NPR.metrics.vstag["searchResults"];
        }
    }
        
    s.prop5=NPR.metrics.vstag["pageTypeId"];
    if (NPR.metrics.vstag.omnitureContentType) {
        s.prop5=NPR.metrics.vstag["omnitureContentType"];
    }

    // bug SFW-604
    if(!(NPR.metrics.vstag["primaryTopic"] || NPR.metrics.vstag["assignedTopics"])) { // undefined, null, empty, false -- all the same for this purpose
        switch(NPR.metrics.vstag["programId"]) {
            case '4':     // Performance Today
            case '19':    // Jazz Profiles
            case '20':    // JazzSet with Dee Dee Bridgewater
            case '24':    // Marian McPartland's Piano Jazz
            case '31':    // Symphonycast
            case '34':    // Thistle & Shamrock
            case '36':    // World of Opera
            case '37':    // All Songs Considered
            case '39':    // World Cafe
            case '43':    // From the Top
                NPR.metrics.vstag["primaryTopic"] = '1039'; // Music
                NPR.metrics.vstag["assignedTopics"] = '1039';
                break;
        }
    }
    
    s.prop6=document.location.hostname;
    s.prop7=NPR.metrics.vstag["primaryTopic"];
    s.prop8=NPR.metrics.vstag["tier"];
    s.prop12=NPR.metrics.vstag["howLongAgo"];
    s.prop13=NPR.metrics.vstag["userHash"];
    s.prop14=NPR.metrics.vstag["pageDepth"];
    s.prop15=NPR.metrics.vstag["segNum"];
    s.prop16=NPR.metrics.vstag["preferredStation"];
    s.channel=NPR.metrics.vstag["channel"];
    
    if(NPR.metrics.vstag.hierarchy) {
    	s.hier1 = NPR.metrics.fixEncoding(NPR.metrics.vstag["hierarchy"]);
    }
    
       
    // get the canoical url by figuring out the id query param and removing everything else  
    // just use the relative path, as well
    var idString = document.location.search.replace(/.*([?&]\w*id=\d+).*/i, "$1");
    idString = idString.replace(/^&/, '?');
    
    // bug 9813. Need to strip some suffix
    var idString4Prop17 = idString;
    idString4Prop17 = idString4Prop17.replace(/([?&]ps=[^?&#]+)/gi,"");
    idString4Prop17 = idString4Prop17.replace(/([?&]text=[^?&#]+)/gi,"");
    idString4Prop17 = idString4Prop17.replace(/([?&]pageDepth=[^?&#]+)/gi,"");
    idString4Prop17 = idString4Prop17.replace(/([?&]value[^?&#]+)/gi,"");
    idString4Prop17 = idString4Prop17.replace(/([?&]ft=[^?&#]+)/gi,"");
    idString4Prop17 = idString4Prop17.replace(/([?&]f=[^?&#]+)/gi,"");
    s.prop17 = document.location.pathname + idString4Prop17;
    s.prop18=NPR.metrics.vstag["assignedTopics"];
    s.prop19=NPR.metrics.vstag["date"];
    s.prop20=NPR.metrics.vstag["orgId"];
    s.prop21=NPR.metrics.vstag["programId"];
    s.prop22=NPR.metrics.vstag["searchProgramId"];
    s.prop23=NPR.metrics.vstag["searchTopicId"];
    s.prop24=NPR.metrics.vstag["storyLength"];
    if (NPR.metrics.vstag.byline) {
        s.prop30=NPR.metrics.fixEncoding(NPR.metrics.vstag["byline"]);
    }
    s.prop31=NPR.metrics.vstag["aggIds"];
    s.prop32=NPR.metrics.vstag["artists"];

    s.events="";
    if(NPR.metrics.vstag.omnitureEvent) {
        s.events=NPR.metrics.vstag.omnitureEvent;
    }


    // fixes bug 9793
    var psarray = document.URL.split('ps=');
    if(psarray.length>1)
    {
        var psvalue = psarray[1].split('&')[0];
        s.prop37=psvalue;
        s.eVar37=psvalue;
        s.events += (s.events?',':'')+NPR.metrics.constants.PROMOTION;
    }

    // bug SFW-433
    // we'll consider these in order, so add new ones with that in mind
    // we could probably do this as one giant regex, but this will be easier to understand later
    var regExps = [new RegExp('/programs/[^/]+/'),
                   new RegExp('/news/specials/[^/]+/'),
                   new RegExp('/blogs/[^/]+/'),
                   new RegExp('/.*/')];
    var uriexcerpt = false;
    var matchArray = false;
    var pathOnly = document.URL.split('npr.org', 2)[1];
    
    for(var ri=0;ri<regExps.length;ri++) {
        matchArray = regExps[ri].exec(pathOnly);
        if(matchArray && matchArray.length) {
            uriexcerpt = matchArray[0];
            break;
        }
    }
    
    if(uriexcerpt !== false) {
        s.prop33=uriexcerpt;
    }
        
    //SFW-2029
    s.prop45 = NPR.metrics.vstag["profileTier"];
    
    var products = [];
   
    if (NPR.metrics.vstag.aggIds && NPR.metrics.vstag.aggIds.length > 0) {
    	products.push(NPR.metrics.vstag["aggIds"]);
    }

    if (NPR.metrics.vstag.assignedTopics && NPR.metrics.vstag.assignedTopics.length > 0) {
    	products.push(NPR.metrics.vstag["assignedTopics"]);
    }

    if (NPR.metrics.vstag.byline && NPR.metrics.vstag.byline.length > 0) {
    	products.push(NPR.metrics.fixEncoding(NPR.metrics.vstag["byline"]));
    }

    if (NPR.metrics.vstag.artists && NPR.metrics.vstag.artists.length > 0) {
    	products.push(NPR.metrics.vstag["artists"]);
    }
    
    if (products.length > 0) {
    	var uniqueProducts = "";
    	
    	//only add unique values
    	for(var pi = 0; pi < products.length; pi++) {
    		if (uniqueProducts.indexOf(products[pi]) === -1){
    			uniqueProducts += products[pi] + ',';
    		}
    	}
    	
    	//remove the last comma
    	uniqueProducts = uniqueProducts.substring(0, uniqueProducts.length - 1);
    	s.products = ";" + uniqueProducts.replace(/,/g, ",;");
    }

    if(NPR.metrics.vstag.omniturePageName) {
        s.pageName=NPR.metrics.fixEncoding(NPR.metrics.vstag.omniturePageName);
        s.prop3=s.pageName;
    }

    //sfw-2004
    if(s.events.match(NPR.metrics.constants.EMAIL_STORY) !== null)
    {
	    s.prop41 = NPR.metrics.vstag["programId"];
	    s.prop42 = NPR.metrics.vstag["primaryTopic"];
	    s.prop34 = NPR.metrics.vstag["emailedURL"];
	    s.prop40 = NPR.metrics.vstag["ctRecipients"];
    }
    
    if(document.URL.indexOf("refresh=true")>-1) // fixes bug 9902
    {
        // should we do a call to NPR.metrics.pageEvent instead?
        s.events=NPR.metrics.constants.AUTO_REFRESH;
        s.linkTrackVars='events,prop17,eVar17';
        s.linkTrackEvents=NPR.metrics.constants.AUTO_REFRESH;
        s_code=s.tl(true, 'o', s.events);
    }
    else
    {
        s_code=s.t();
    }
};

NPR.metrics.pageEvent = function(vsEventName, thisObj) {
	
	if (vsEventName === 'comment_added') {
        var fc = new Image();
        fc.src = NPR.metrics.host + '/images/zag.gif?Log=1' + NPR.metrics.getTags() + "&event=" + vsEventName;

        s.linkTrackVars='events,prop17,eVar17';
        s.linkTrackEvents=NPR.metrics.constants.COMMENT_ADDED;
        s.events=NPR.metrics.constants.COMMENT_ADDED;
        s.tl(true,'o', NPR.metrics.constants.COMMENT_ADDED);
    }
	else if (vsEventName === 'nl-subscribe') {
        var fc = new Image();
        fc.src = NPR.metrics.host + '/images/zag.gif?Log=1' + NPR.metrics.getTags() + "&event=" + vsEventName;
    }
    else if (vsEventName === 'nl-unsubscribe') {
        var fc = new Image();
        fc.src = NPR.metrics.host + '/images/zag.gif?Log=1' + NPR.metrics.getTags() + "&event=" + vsEventName;
    }
    else if (vsEventName === 'station_search') {
    	s.linkTrackVars='events,prop17,eVar17,prop43,eVar43';
        s.linkTrackEvents=NPR.metrics.constants.STATION_SEARCH;
    	s.events=NPR.metrics.constants.STATION_SEARCH;
   	      	
        s.tl(thisObj,'o', NPR.metrics.constants.STATION_SEARCH_PERFORMED);
    }
    else if (vsEventName === 'station_search_donate') {
    	s.linkTrackVars='events,prop17,eVar17,prop43,eVar43';
        s.linkTrackEvents=NPR.metrics.constants.STATION_SEARCH_DONATE;
    	s.events=NPR.metrics.constants.STATION_SEARCH_DONATE;
   	      	
        s.tl(thisObj,'o', NPR.metrics.constants.STATION_SEARCH_PERFORMED);
    }
    else if (vsEventName === 'station_link_clicked') {
    	s.linkTrackVars='events,prop17,eVar17,eVar35';
        s.linkTrackEvents=NPR.metrics.constants.STATION_LINK_CLICKED;
    	s.events=NPR.metrics.constants.STATION_LINK_CLICKED;
    	
        s.tl(thisObj,'o', NPR.metrics.constants.STATION_LINK_CLICKED);
    }
    else if (vsEventName === NPR.metrics.constants.CLICK_RSS_LINK 		||
             vsEventName === NPR.metrics.constants.CLICK_PODCAST_LINK	||
             vsEventName === NPR.metrics.constants.IMAGE_ENLARGEMENT	||
             vsEventName === NPR.metrics.constants.ADD_TO_PLAYLIST		||
             vsEventName === NPR.metrics.constants.STATION_DRAWER_OPEN	||
             vsEventName === NPR.metrics.constants.LISTEN_DRAWER_OPEN	||
             vsEventName === NPR.metrics.constants.SPONSOR_DRAWER_OPEN) {
    	
        var fc = new Image();
        fc.src = NPR.metrics.host + '/images/zag.gif?Log=1' + NPR.metrics.getTags() + "&event=" + vsEventName;
        
        s.linkTrackVars='events,prop17,eVar17';
        s.linkTrackEvents=vsEventName;
        s.events=vsEventName;
        s.tl(true,'o', vsEventName);
    }
};

NPR.MD5 = function (string) {

    function RotateLeft(lValue, iShiftBits) {
        return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
    }

    function AddUnsigned(lX,lY) {
        var lX4,lY4,lX8,lY8,lResult;
        lX8 = (lX & 0x80000000);
        lY8 = (lY & 0x80000000);
        lX4 = (lX & 0x40000000);
        lY4 = (lY & 0x40000000);
        lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
        if (lX4 & lY4) {
            return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
        }
        if (lX4 | lY4) {
            if (lResult & 0x40000000) {
                return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
            } else {
                return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
            }
        } else {
            return (lResult ^ lX8 ^ lY8);
        }
     }

     function F(x,y,z) { return (x & y) | ((~x) & z); }
     function G(x,y,z) { return (x & z) | (y & (~z)); }
     function H(x,y,z) { return (x ^ y ^ z); }
    function I(x,y,z) { return (y ^ (x | (~z))); }

    function FF(a,b,c,d,x,s,ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function GG(a,b,c,d,x,s,ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function HH(a,b,c,d,x,s,ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function II(a,b,c,d,x,s,ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function ConvertToWordArray(string) {
        var lWordCount;
        var lMessageLength = string.length;
        var lNumberOfWords_temp1=lMessageLength + 8;
        var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
        var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
        var lWordArray=Array(lNumberOfWords-1);
        var lBytePosition = 0;
        var lByteCount = 0;
        while ( lByteCount < lMessageLength ) {
            lWordCount = (lByteCount-(lByteCount % 4))/4;
            lBytePosition = (lByteCount % 4)*8;
            lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
            lByteCount++;
        }
        lWordCount = (lByteCount-(lByteCount % 4))/4;
        lBytePosition = (lByteCount % 4)*8;
        lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
        lWordArray[lNumberOfWords-2] = lMessageLength<<3;
        lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
        return lWordArray;
    };

    function WordToHex(lValue) {
        var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
        for (lCount = 0;lCount<=3;lCount++) {
            lByte = (lValue>>>(lCount*8)) & 255;
            WordToHexValue_temp = "0" + lByte.toString(16);
            WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
        }
        return WordToHexValue;
    };

    function Utf8Encode(string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    };

    var x=Array();
    var k,AA,BB,CC,DD,a,b,c,d;
    var S11=7, S12=12, S13=17, S14=22;
    var S21=5, S22=9 , S23=14, S24=20;
    var S31=4, S32=11, S33=16, S34=23;
    var S41=6, S42=10, S43=15, S44=21;

    string = Utf8Encode(string);

    x = ConvertToWordArray(string);

    a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;

    for (k=0;k<x.length;k+=16) {
        AA=a; BB=b; CC=c; DD=d;
        a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
        d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
        c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
        b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
        a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
        d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
        c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
        b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
        a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
        d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
        c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
        b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
        a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
        d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
        c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
        b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
        a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
        d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
        c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
        b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
        a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
        d=GG(d,a,b,c,x[k+10],S22,0x2441453);
        c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
        b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
        a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
        d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
        c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
        b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
        a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
        d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
        c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
        b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
        a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
        d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
        c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
        b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
        a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
        d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
        c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
        b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
        a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
        d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
        c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
        b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
        a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
        d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
        c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
        b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
        a=II(a,b,c,d,x[k+0], S41,0xF4292244);
        d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
        c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
        b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
        a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
        d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
        c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
        b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
        a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
        d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
        c=II(c,d,a,b,x[k+6], S43,0xA3014314);
        b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
        a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
        d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
        c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
        b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
        a=AddUnsigned(a,AA);
        b=AddUnsigned(b,BB);
        c=AddUnsigned(c,CC);
        d=AddUnsigned(d,DD);
    }

    var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);

    return temp.toLowerCase();
}


 //  localize/zip_code 

function clearField()
	{
		if (document.go_local && document.go_local.txtSearchValue.value.toUpperCase().indexOf("LETTERS") > -1)
			{
				document.go_local.txtSearchValue.value = "";
			}
	}
	
function fillField()
	{
		if (document.go_local.txtSearchValue.value == "")
			{
				document.go_local.txtSearchValue.value = "Call Letters";
			}
	}
	
function zipUcase()
	{
		if (document.go_local.txtSearchValue.value!="Call Letters")
			{
				document.go_local.txtSearchValue.value = document.go_local.txtSearchValue.value.toUpperCase();
			}
	}
	
function href()
	{
		url = escape(window.location.href);
		//url = window.location.href;
		andFind = url.indexOf("&");
		startPos = 0;
		while (andFind > -1)
			{
				url = url.substring(startPos, andFind) + "%26" + url.substring(andFind + 1);
				andFind = url.indexOf("&");
			}
			
		var re = new RegExp (' ', 'gi') ;
		
		window.location.href = "http://www.npr.org/stations/?refUrl=" + url;
	}
	
function removeHref(cookieValue)
	{
		url = escape(window.location.href);
		andFind = url.indexOf("&");
		startPos = 0;
		while (andFind > -1)
			{
				url = url.substring(startPos, andFind) + "%26" + url.substring(andFind + 1);
				andFind = url.indexOf("&");
			}
			
		var re = new RegExp (' ', 'gi') ;
		
		window.location.href = "http://www.npr.org/stations/cookies/stations_kill_cookie.php?cookieValue=" + cookieValue + "&url=" + url;
	}

 //  peekaboo 

// JavaScript Document
		
var isDHTML = 0;
var isLayers = 0;
var isAll = 0;
var isID = 0;
 
if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
	if (document.all) {isAll = 1; isDHTML = 1;}
	else {
		browserVersion = parseInt(navigator.appVersion);
	if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
}}
 
function findDOM(objectID,withStyle) {
	if (withStyle == 1) {
	if (isID) { return (document.getElementById(objectID).style) ; }
	else {
	  if (isAll) { return (document.all[objectID].style); }
	else {
	  if (isLayers) { return (document.layers[objectID]); }
	};}
  }
  else {
	if (isID) { return (document.getElementById(objectID)) ; }
	else {
	  if (isAll) { return (document.all[objectID]); }
	else {
	  if (isLayers) { return (document.layers[objectID]); }
	};}
  }
} 



function setClass(objectID,newClass) {
	var dom = findDOM(objectID,0);
	 dom.className = newClass;
	 viewType = newClass;
};


 //  iTunes 

// The functionality in iTunesCallback was moved to iTunesCallback2
// iTunesCallback now makes a call to iTunesCallback2, but it does it
// via the jQuery ready function.   This was done to try to fix some timing
// problems that occurred in ie6.

function iTunesCallback(resultsObj, artistName, albumTitle){
  //return false;
  
  $(document).ready(function(){
	  iTunesCallback2(resultsObj, artistName, albumTitle);
	 });

  
  
}

function iTunesCallback(resultsObj, artistName, albumTitle){
    for (var index = 0; index < resultsObj.resultCount; index++)
    {
        var result = resultsObj.results[index];
        var songTitle = result.trackName;
        songTitle = songTitle.replace(/\s/g, '+');
        artistName = artistName.replace(/\s/g, '+');
        albumTitle = albumTitle.replace(/\s/g, '+');


        trackNum = result.trackNumber;

        var searchTerm = "iTunesARTIST_" + artistName + '_iTunesALBUM_' + albumTitle + "_iTunesTRACK_" + trackNum;
        searchTerm = searchTerm.toLowerCase();

        var elm = document.getElementById(searchTerm);


        if (elm)
        {
            var iTunesLink = generateLink(result.trackViewUrl);

            //add link to popup
            elm.href = iTunesLink;
            elm.innerHTML = "iTunes " + '&raquo;';

        }
        else
        {
            var searchTerm = "iTunesARTIST_" + artistName + '_iTunesALBUM_' + albumTitle + "_iTunesSONG_" + songTitle;
            searchTerm = searchTerm.toLowerCase();

            var elm = document.getElementById(searchTerm);

            if (elm)
            {
                var iTunesLink = generateLink(result.trackViewUrl);

                //add link to popup
                elm.href = iTunesLink;
                elm.innerHTML = "iTunes " + '&raquo;';
            }
            else
            {
                var searchTerm = "iTunesARTIST_" + artistName + '_iTunesALBUM_' + albumTitle;
                searchTerm = searchTerm.toLowerCase();

                var elm = document.getElementById(searchTerm);

                if (elm)
                {
                    var iTunesLink = generateLink(result.trackViewUrl);

                    //add link to popup
                    elm.href = iTunesLink;
                    elm.innerHTML = "iTunes " + '&raquo;';
                }
            }            
        }
    }

}

function generateLink(iTunesURL)
{
    iTunesURL = urlencode(urlencode(iTunesURL));

    var affiliateLink = "http://click.linksynergy.com/fs-bin/stat?id=tAyEACrv36k &offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=" + iTunesURL;

    return affiliateLink;
}

function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'

    var ret = str;

    ret = ret.toString();
    ret = encodeURIComponent(ret);
    ret = ret.replace(/%20/g, '+');

    return ret;
}


function iTunesCallbackNews(resultsObj, artistName, albumTitle){
	  //return false;
	  
	  $(document).ready(function(){
		  iTunesCallbackNews2(resultsObj, artistName, albumTitle);
		 });

	  
	  
	}

	function iTunesCallbackNews2(resultsObj, artistName, albumTitle){
	    for (var index = 0; index < resultsObj.resultCount; index++)
	    {
	        var result = resultsObj.results[index];
	        var songTitle = result.trackName;
	        songTitle = songTitle.replace(/\s/g, '+');
	        artistName = artistName.replace(/\s/g, '+');
	        albumTitle = albumTitle.replace(/\s/g, '+');


	        trackNum = result.trackNumber;

	        var searchTerm = "iTunesARTIST_" + artistName + '_iTunesALBUM_' + albumTitle + "_iTunesTRACK_" + trackNum;
	        searchTerm = searchTerm.toLowerCase();

	        var elm = document.getElementById(searchTerm);


	        if (elm)
	        {
	            var iTunesLink = generateLink(result.trackViewUrl);

	            //add link to popup
	            elm.href = iTunesLink;
	            elm.innerHTML = 'iTunes ' + '<span class="gtarrow">&gt;</span>';

	        }
	        else
	        {
	            var searchTerm = "iTunesARTIST_" + artistName + '_iTunesALBUM_' + albumTitle + "_iTunesSONG_" + songTitle;
	            searchTerm = searchTerm.toLowerCase();

	            var elm = document.getElementById(searchTerm);

	            if (elm)
	            {
	                var iTunesLink = generateLink(result.trackViewUrl);

	                //add link to popup
	                elm.href = iTunesLink;
	                elm.innerHTML = "iTunes " + '&raquo;';
	            }
	            else
	            {
	                var searchTerm = "iTunesARTIST_" + artistName + '_iTunesALBUM_' + albumTitle;
	                searchTerm = searchTerm.toLowerCase();

	                var elm = document.getElementById(searchTerm);

	                if (elm)
	                {
	                    var iTunesLink = generateLink(result.trackViewUrl);

	                    //add link to popup
	                    elm.href = iTunesLink;
	                    elm.innerHTML = "iTunes " + '&raquo;';
	                }
	            }            
	        }
	    }

	}




 //  omniture 

var s_account="nprdev";
var s=s_gi(s_account);
s.currencyCode="USD";
s.trackDownloadLinks=true;
s.trackExternalLinks=true;
s.trackInlineStats=true;
s.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx";
s.linkInternalFilters="javascript,npr.org";
s.linkLeaveQueryString=false;
s.linkTrackVars="None";
s.linkTrackEvents="None";

s.usePlugins=true;
function s_doPlugins(s) {
    /* External Campaign Tracking */
    if(!s.campaign) {
        s.campaign=s.getQueryParam('cmpid');
        if(!s.campaign && (s.getQueryParam('sc') || s.getQueryParam('cc'))) {
            var tempSCCC = s.getQueryParam('sc');
            var tempCC = s.campaign=s.getQueryParam('cc');
            if(tempCC != null && tempCC != 'undefined')
            var tempCCarr = tempCC.split('-');
            if(tempCCarr.length > 0)
            {
            	tempCC = tempCCarr[0];
            	s.prop26 = tempCCarr[1];
            	s.eVar26 = tempCCarr[1];
            }
            tempSCCC = tempSCCC + "__" + tempCC;
            s.campaign=tempSCCC;
        }    
        if(!s.campaign && (s.getQueryParam('ft') || s.getQueryParam('f'))) {
            var tempFTF = s.getQueryParam('ft');
            var tempF = s.campaign=s.getQueryParam('f');
            tempFTF = tempFTF + "__" + tempF;
            s.campaign=tempFTF;
        }    
        //s.campaign=s.getValOnce(s.campaign,'s_campaign',0);
        // eVar33 is deduped version of campaign
        s.eVar33=s.getValOnce(s.campaign,'s_var_33',0);

    }

    /* Set Page View Event */
    s.events=s.apl(s.events,'event2',',',2);

    /* Set Time Parting Variables - SAMPLE EST */
    var thisYearPerBrowser = (new Date).getFullYear();
    s.prop9=s.getTimeParting('h','-5',thisYearPerBrowser); // Set hour 
    s.prop10=s.getTimeParting('d','-5',thisYearPerBrowser); // Set day
    s.prop11=s.getTimeParting('w','-5',thisYearPerBrowser); // Set Weekend / Weekday

    /* Copy props to eVars */
    if(s.prop1&&!s.eVar1) s.eVar1=s.prop1;
    if(s.prop2&&!s.eVar2) s.eVar2=s.prop2;
    //SFW-745 eVar35 should not be set to pageName
    //if(s.pageName&&!s.eVar35) s.eVar35=s.pageName;
    if(s.prop3&&!s.eVar3) s.eVar3=s.prop3;
    if(s.prop4&&!s.eVar4) s.eVar4=s.prop4;
    if(s.prop5&&!s.eVar5) s.eVar5=s.prop5;
    if(s.prop6&&!s.eVar6) s.eVar6=s.prop6;
    if(s.prop7&&!s.eVar7) s.eVar7=s.prop7;
    if(s.prop8&&!s.eVar8) s.eVar8=s.prop8;
    if(s.prop9&&!s.eVar9) s.eVar9=s.prop9;
    if(s.prop10&&!s.eVar10) s.eVar10=s.prop10;
    if(s.prop11&&!s.eVar11) s.eVar11=s.prop11;
    if(s.prop12&&!s.eVar12) s.eVar12=s.prop12;
    if(s.prop13&&!s.eVar13) s.eVar13=s.prop13;
    if(s.prop15&&!s.eVar15) s.eVar15=s.prop15;
    if(s.prop16&&!s.eVar16) s.eVar16=s.prop16;
    if(s.prop17&&!s.eVar17) s.eVar17=s.prop17;
    // eVar18 is intentionally skipped here because 
    // prop18 is a list and evals can't be lists
    if(s.prop19&&!s.eVar19) s.eVar19=s.prop19;
    if(s.prop20&&!s.eVar20) s.eVar20=s.prop20;
    if(s.prop21&&!s.eVar21) s.eVar21=s.prop21;
    if(s.prop22&&!s.eVar22) s.eVar22=s.prop22;
    if(s.prop23&&!s.eVar23) s.eVar23=s.prop23;
    if(s.prop24&&!s.eVar24) s.eVar24=s.prop24;
    if(s.prop25&&!s.eVar25) s.eVar25=s.prop25;
    if(s.prop26&&!s.eVar26) s.eVar26=s.prop26;
    if(s.prop27&&!s.eVar27) s.eVar27=s.prop27;
    if(s.prop4&&!s.eVar28) s.eVar28=s.prop4;
    if(s.prop29&&!s.eVar29) s.eVar29=s.prop29;
    if(s.prop34&&!s.eVar34) s.eVar34=s.prop34;
    if(s.prop40&&!s.eVar40) s.eVar40=s.prop40;
    if(s.prop41&&!s.eVar41) s.eVar41=s.prop41;
    if(s.prop42&&!s.eVar42) s.eVar42=s.prop42;
    
    // eVar30-32 are intentionally skipped here because 
    // they are lists and evals can't be lists
}
s.doPlugins=s_doPlugins;
/************************** PLUGINS SECTION *************************/
/*
 * Plugin Utility: apl v1.1
 */
s.apl=new Function("L","v","d","u",""
+"var s=this,m=0;if(!L)L='';if(u){var i,n,a=s.split(L,d);for(i=0;i<a."
+"length;i++){n=a[i];m=m||(u==1?(n==v):(n.toLowerCase()==v.toLowerCas"
+"e()));}}if(!m)L=L?L+d+v:v;return L");

/*
 * Utility Function: split v1.5 - split a string (JS 1.0 compatible)
 */
s.split=new Function("l","d",""
+"var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x"
+"++]=l.substring(0,i);l=l.substring(i+d.length);}return a");

/*
 * Plugin: getValOnce 0.2 - get a value once per session or number of days
 */
s.getValOnce=new Function("v","c","e",""
+"var s=this,k=s.c_r(c),a=new Date;e=e?e:0;if(v){a.setTime(a.getTime("
+")+e*86400000);s.c_w(c,v,e?a:0);}return v==k?'':v");

/*
 * Plugin: getQueryParam 2.3
 */
s.getQueryParam=new Function("p","d","u",""
+"var s=this,v='',i,t;d=d?d:'';u=u?u:(s.pageURL?s.pageURL:s.wd.locati"
+"on);if(u=='f')u=s.gtfs().location;while(p){i=p.indexOf(',');i=i<0?p"
+".length:i;t=s.p_gpv(p.substring(0,i),u+'');if(t){t=t.indexOf('#')>-"
+"1?t.substring(0,t.indexOf('#')):t;}if(t)v+=v?d+t:t;p=p.substring(i="
+"=p.length?i:i+1)}return v");
s.p_gpv=new Function("k","u",""
+"var s=this,v='',i=u.indexOf('?'),q;if(k&&i>-1){q=u.substring(i+1);v"
+"=s.pt(q,'&','p_gvf',k)}return v");
s.p_gvf=new Function("t","k",""
+"if(t){var s=this,i=t.indexOf('='),p=i<0?t:t.substring(0,i),v=i<0?'T"
+"rue':t.substring(i+1);if(p.toLowerCase()==k.toLowerCase())return s."
+"epa(v)}return ''");

/*
 * Plugin: getTimeParting 1.3 - Set timeparting values based on time zone
 */

s.getTimeParting=new Function("t","z","y",""
+"dc=new Date('1/1/2000');f=15;ne=8;if(dc.getDay()!=6||"
+"dc.getMonth()!=0){return'Data Not Available'}else{;z=parseInt(z);"
+"if(y=='2009'){f=8;ne=1};gmar=new Date('3/1/'+y);dsts=f-gmar.getDay("
+");gnov=new Date('11/1/'+y);dste=ne-gnov.getDay();spr=new Date('3/'"
+"+dsts+'/'+y);fl=new Date('11/'+dste+'/'+y);cd=new Date();"
+"if(cd>spr&&cd<fl){z=z+1}else{z=z};utc=cd.getTime()+(cd.getTimezoneO"
+"ffset()*60000);tz=new Date(utc + (3600000*z));thisy=tz.getFullYear("
+");var days=['Sunday','Monday','Tuesday','Wednesday','Thursday','Fr"
+"iday','Saturday'];if(thisy!=y){return'Data Not Available'}else{;thi"
+"sh=tz.getHours();thismin=tz.getMinutes();thisd=tz.getDay();var dow="
+"days[thisd];var ap='AM';var dt='Weekday';var mint='00';if(thismin>3"
+"0){mint='30'}if(thish>=12){ap='PM';thish=thish-12};if (thish==0){th"
+"ish=12};if(thisd==6||thisd==0){dt='Weekend'};var timestring=thish+'"
+":'+mint+ap;var daystring=dow;var endstring=dt;if(t=='h'){return tim"
+"estring}if(t=='d'){return daystring};if(t=='w'){return en"
+"dstring}}};");

/*
 * DynamicObjectIDs v1.4: Setup Dynamic Object IDs based on URL
 */

s.setupDynamicObjectIDs=new Function(""
+"var s=this;if(!s.doi){s.doi=1;if(s.apv>3&&(!s.isie||!s.ismac||s.apv"
+">=5)){if(s.wd.attachEvent)s.wd.attachEvent('onload',s.setOIDs);else"
+" if(s.wd.addEventListener)s.wd.addEventListener('load',s.setOIDs,fa"
+"lse);else{s.doiol=s.wd.onload;s.wd.onload=s.setOIDs}}s.wd.s_semapho"
+"re=1}");
s.setOIDs=new Function("e",""
+"var s=s_c_il["+s._in+"],b=s.eh(s.wd,'onload'),o='onclick',x,l,u,c,i"
+",a=new Array;if(s.doiol){if(b)s[b]=s.wd[b];s.doiol(e)}if(s.d.links)"
+"{for(i=0;i<s.d.links.length;i++){l=s.d.links[i];c=l[o]?''+l[o]:'';b"
+"=s.eh(l,o);z=l[b]?''+l[b]:'';u=s.getObjectID(l);if(u&&c.indexOf('s_"
+"objectID')<0&&z.indexOf('s_objectID')<0){u=s.repl(u,'\"','');u=s.re"
+"pl(u,'\\n','').substring(0,97);l.s_oc=l[o];a[u]=a[u]?a[u]+1:1;x='';"
+"if(c.indexOf('.t(')>=0||c.indexOf('.tl(')>=0||c.indexOf('s_gs(')>=0"
+")x='var x=\".tl(\";';x+='s_objectID=\"'+u+'_'+a[u]+'\";return this."
+"s_oc?this.s_oc(e):true';if(s.isns&&s.apv>=5)l.setAttribute(o,x);l[o"
+"]=new Function('e',x)}}}s.wd.s_semaphore=0;return true");


/*
 * Plugin Utility: Replace v1.0
 */
s.repl=new Function("x","o","n",""
+"var i=x.indexOf(o),l=n.length;while(x&&i>=0){x=x.substring(0,i)+n+x."
+"substring(i+o.length);i=x.indexOf(o,i+l)}return x");
 

/* Configure Modules and Plugins */

s.loadModule("Media");
s.Media.autoTrack=false;
s.Media.trackVars="None";
s.Media.trackEvents="None";

/* DynamicObjectIDs config */
function s_getObjectID(o) {
        var ID=o.href;
        return ID;
}
s.getObjectID=s_getObjectID


/* WARNING: Changing any of the below variables will cause drastic
changes to how your visitor data is collected.  Changes should only be
made when instructed to do so by your account manager.*/
s.trackingServer="metrics.npr.org";
s.trackingServerSecure="smetrics.npr.org";
s.dc=122;

/****************************** MODULES *****************************/
/* Module: Media */
s.m_Media_c="='s_media_'+m._in+'_~=new Function(~m.ae(mn,l,\"'+p+'\",~;`H~o.'+f~o.Get~=function(~){var m=this~}^9 p');p=tcf(o)~setTimeout(~x,x!=2?p:-1,o)}~=parseInt(~m.s.d.getElementsByTagName~ersion"
+"Info~'`z_c_il['+m._in+'],~'o','var e,p=~QuickTime~if(~}catch(e){p=~s.wd.addEventListener~m.s.rep(~=new Object~layState~||^D~m.s.wd[f1]~Media~.name~Player '+~s.wd.attachEvent~'a','b',c~;o[f1]~tm.get"
+"Time()/1~m.s.isie~.current~,tm=new Date,~p<p2||p-p2>5)~m.e(n,1,o^F~m.close~i.lx~=v+',n,~){this.e(n,~MovieName()~);o[f~i.lo~m.ol~o.controls~load',m.as~==3)~script';x.~,t;try{t=~Version()~else~o.id~)"
+"{mn=~1;o[f7]=~Position~);m.~(x==~)};m.~&&m.l~l[n])~var m=s~!p){tcf~xc=m.s.~Title()~();~7+'~)}};m.a~\"'+v+';~3,p,o);~5000~return~i.lt~';c2='~Change~n==~',f~);i.~==1)~{p='~4+'=n;~()/t;p~.'+n)}~~`z.m_"
+"i('`P'`uopen`6n,l,p,b`7,i`L`Ya='',x;l`Bl)`3!l)l=1`3n&&p){`H!m.l)m.l`L;n=`Km.s.rep(`Kn,\"\\n\",''),\"\\r\",''),'--**--','')`3m.`y`b(n)`3b&&b.id)a=b.id;for (x in m.l)`Hm.l[x]`x[x].a==a)`b(m.l[x].n^Fn"
+"=n;i.l=l;i.p=p;i.a=a;i.t=0;i.s`B`V000);`c=0;^A=0;`h=0;i.e='';m.l[n]=i}};`b`6n`e0,-1`wplay`6n,o`7,i;i=`am`1`Ei`3m.l){i=m.l[\"'+`Ki.n,'\"','\\\\\"')+'\"]`3i){`H`c^Gm.e(i.n,3,-1^Fmt=`9i.m,^8)}}'^Fm(`w"
+"stop`6n,o`e2,o`we`6n,x,o`7,i=n`x&&m.l[n]?m.l[n]:0`Yts`B`V000),d='--**--'`3i){if `v3||(x!=`c&&(x!=2||`c^G)) {`Hx){`Ho<0&&^A>0){o=(ts-^A)+`h;o=o<i.l?o:i.l-1}o`Bo)`3`v2||x`l&&`h<o)i.t+=o-`h`3x!=3){i.e"
+"+=`v1?'S':'E')+o;`c=x;}`p `H`c!=1)`alt=ts;`h=o;m.s.pe='media';m.s.pev3=i.n+d+i.l+d+i.p+d+i.t+d+i.s+d+i.e+`v3?'E'+o:''`us.t(0,'`P^K`p{m.e(n,2,-1`ul[n]=0;m.s.fbr('`P^K}}^9 i};m.ae`6n,l,p,x,o,b){`Hn&&"
+"p`7`3!m.l||!m.`ym.open(n,l,p,b`ue(n,x,o^5`6o,t`7,i=`q?`q:o`Q,n=o`Q,p=0,v,c,c1,c2,^1h,x,e,f1,f2`0oc^E3`0t^E4`0s^E5`0l^E6`0m^E7`0c',tcf,w`3!i){`H!m.c)m.c=0;i`0'+m.c;m.c++}`H!`q)`q=i`3!o`Q)o`Q=n=i`3!`"
+"i)`i`L`3`i[i])^9;`i[i]=o`3!xc)^1b;tcf`1`F0;try{`Ho.v`D&&o`X`P&&`j)p=1`I0`8`3^0`1`F0`n`5`G`o`3t)p=2`I0`8`3^0`1`F0`n`5V`D()`3t)p=3`I0`8}}v=\"`z_c_il[\"+m._in+\"],o=`i['\"+i+\"']\"`3p^G^HWindows `P `R"
+"o.v`D;c1`dp,l,x=-1,cm,c,mn`3o){cm=o`X`P;c=`j`3cm&&c`rcm`Q?cm`Q:c.URL;l=cm.duration;p=c`X`t;n=o.p`M`3n){`H^D8)x=0`3n`lx=1`3^D1`N2`N4`N5`N6)x=2;}^B`Hx>=0)`2`A}';c=c1+c2`3`W&&xc){x=m.s.d.createElement"
+"('script');x.language='j`mtype='text/java`mhtmlFor=i;x.event='P`M^C(NewState)';x.defer=true;x.text=c;xc.appendChild(x`g6]`1c1+'`Hn`l{x=3;'+c2+'}`9`46+',^8)'`g6]()}}`Hp==2)^H`G `R(`5Is`GRegistered()"
+"?'Pro ':'')+`5`G`o;f1=f2;c`dx,t,l,p,p2,mn`3o`r`5`f?`5`f:`5URL^3n=`5Rate^3t=`5TimeScale^3l=`5Duration^J=`5Time^J2=`45+'`3n!=`44+'||`Z{x=2`3n!=0)x=1;`p `Hp>=l)x=0`3`Z`22,p2,o);`2`A`Hn>0&&`4^4>=10){`2"
+"^7`4^4=0}`4^4++;`4^I`45+'=p;`9^6`42+'(0,0)\",500)}'`U`1`T`g4]=-`s0`U(0,0)}`Hp`l^HReal`R`5V`D^3f1=n+'_OnP`M^C';c1`dx=-1,l,p,mn`3o`r`5^2?`5^2:`5Source^3n=`5P`M^3l=`5Length()/1000;p=`5`t()/1000`3n!=`4"
+"4+'){`Hn`lx=1`3^D0`N2`N4`N5)x=2`3^D0&&(p>=l||p==0))x=0`3x>=0)`2`A`H^D3&&(`4^4>=10||!`43+')){`2^7`4^4=0}`4^4++;`4^I^B`H`42+')`42+'(o,n)}'`3`O)o[f2]=`O;`O`1`T1+c2)`U`1`T1+'`9^6`41+'(0,0)\",`43+'?500:"
+"^8);'+c2`g4]=-1`3`W)o[f3]=`s0`U(0,0^5s`1'e',`El,n`3m.autoTrack&&`C){l=`C(`W?\"OBJECT\":\"EMBED\")`3l)for(n=0;n<l.length;n++)m.a(`y;}')`3`S)`S('on`k);`p `H`J)`J('`k,false)";
s.m_i("Media");

/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code='',s_objectID;function s_gi(un,pg,ss){var c="=fun@6(~){`Ks=^S~$h ~.substring(~.indexOf(~;@t~';`Bt`t~=new Fun@6(~.toLowerCase()~s_c_il['+s^sn+']~};s.~`m@t~.length~.toUpperCase~=new Object~s"
+".wd~','~){@t~')q='~.location~var ~s.pt(~dynamicAccount~link~s.apv~='+@y(~)@tx^m!Object$eObject.prototype$eObject.prototype[x])~);s.~Element~.getTime()~=new Array~ookieDomainPeriods~s.m_~referrer~.p"
+"rotocol~=new Date~BufferedRequests~}c$s(e){~visitor~;@X^js[k],255)}~=''~javaEnabled~conne@6^M~@0c_i~Name~:'')~onclick~}@t~else ~ternalFilters~javascript~s.dl~@Os.b.addBehavior(\"# default# ~=parseF"
+"loat(~'+tm.get~=='~cookie~s.rep(~s.^T~track~o@0oid~browser~.parent~window~colorDepth~String~while(~.host~.lastIndexOf('~s.sq~s.maxDelay~s.vl_g~r=s.m(f)?s[f](~for(~s.un~s.eo~&&s.~parseInt(~t=s.ot(o)"
+"~j='1.~#4URL~lugins~dynamicVariablePrefix~document~Type~Sampling~s.rc[un]~Download~Event~');~this~tfs~resolution~s.c_r(~s.c_w(~s.eh~s.isie~s.vl_l~s.vl_t~Height~t,h){t=t?t~tcf~isopera~ismac~escape(~"
+".href~screen.~s.fl(~Version~harCode~&&(~_'+~variableProvider~s.pe~)?'Y':'N'~:'';h=h?h~._i~e&&l$HSESSION'~f',~onload~name~home#4~objectID~}else{~.s_~s.rl[u~Width~s.ssl~o.type~Timeout(~ction~Lifetime"
+"~.mrq(\"'+un+'\")~sEnabled~;i++)~'){q='~&&l$HNONE'){~ExternalLinks~charSet~onerror~lnk~currencyCode~.src~s=s_gi(~etYear(~&&!~Opera~'s_~;try{~Math.~s.fsg~s.ns6~s.oun~InlineStats~Track~'0123456789~&&"
+"t~s[k]=~s.epa(~m._d~n=s.oid(o)~,'sqs',q);~LeaveQuery~')>=~'=')~)+'/~){n=~\",''),~vo)~s.sampled~=s.oh(o);~+(y<1900?~s.disable~ingServer~n]=~true~sess~campaign~lif~if(~'http~,100)~s.co(~x in ~s.ape~f"
+"fset~s.c_d~s.br~'&pe~s.gg(~s.gv(~s[mn]~s.qav~,'vo~s.pl~=(apn~Listener~\"s_gs(\")~vo._t~b.attach~d.create~=s.n.app~(''+~!='~'||t~'+n~s()+'~){p=~():''~a):f(~+1))~a['!'+t]~){v=s.n.~channel~un)~.target"
+"~o.value~g+\"_c\"]~\".tl(\")~etscape~(ns?ns:~s_')t=t~k',s.bc~omePage~s.d.get~')<~||!~[b](e);~m[t+1](~return~mobile~height~events~random~code~'MSIE ~rs,~un,~,pev~floor(~atch~s.num(~[\"s_\"+~s.c_gd~s"
+".dc~s.pg~,'lt~.inner~transa~;s.gl(~\"m_\"+n~idt='+~page~Group,~.fromC~sByTag~?'&~+';'~t&&~1);~){s.~[t]=~>=5)~[t](~=l[n];~!a[t])~~s._c=@Nc';`F=^1`5!`F`hn){`F`hl`U;`F`hn=0;}s^sl=`F`hl;s^sn=`F`hn;s^sl"
+"[s^s@os;`F`hn++;s.m`0m){`2$Gm)`4'{$d0`Afl`0x,l){`2x?$Gx)`30,l):x`Aco`0o`H!o)`2o;`Kn`E,x;^B@xo)@tx`4'select$d0&&x`4'filter$d0)n[x]=o[x];`2n`Anum`0x){x`e+x;^B`Kp=0;p<x`C;p++)@t(@V')`4x`3p,p$O<0)`20;`"
+"21`Arep=s_r;@y`0x`1,h=@VABCDEF',i,c=s.@E,n,l,e,y`e;c=c?c`D$M`5x){x`e+x`5c`tAUTO'^m'').c^lAt){^Bi=0;i<x`C@A{c=x`3i,i+#Bn=x.c^lAt(i)`5n>127){l=0;e`e;^4n||l<4){e=h`3n%16,n%16+1)+e;n=(n-n%16)/16;l++}y+"
+"='%u'+e}`Bc`t+')y+='%2B';`my+=^gc)}x=y^zx=x?`v^g''+x),'+`G%2B'):x`5x&&c^Eem==1&&x`4'%u$d0&&x`4'%U$d0){i=x`4'%^R^4i>=0){i++`5h`38)`4x`3i,i+1)`D())>=0)`2x`30,i)+'u00'+x`3i);i=x`4'%',i)}}}}`2x`Aepa`0x"
+"`1;`2x?un^g`v''+x,'+`G ')):x`Apt`0x,d,f,a`1,t=x,z=0,y,r;^4t){y=t`4d);y=y<0?t`C:y;t=t`30,y);^At,$Nt,a)`5r)`2r;z+=y+d`C;t=x`3z,x`C);t=z<x`C?t:''}`2''`Aisf`0t,a){`Kc=a`4':')`5c>=0)a=a`30,c)`5t`30,2)`t"
+"$Z`32);`2(t!`e@W==a)`Afsf`0t,a`1`5`La,`G,'is^ut))@Q+=(@Q!`e?`G`j+t;`20`Afs`0x,f`1;@Q`e;`Lx,`G,'fs^uf);`2@Q`Ac_d`e;$vf`0t,a`1`5!$tt))`21;`20`Ac_gd`0`1,d=`F`J^5^w,n=s.fpC`V,p`5!n)n=s.c`V`5d@L$0@gn?^F"
+"n):2;n=n>2?n:2;p=d^6.')`5p>=0){^4p>=0&&n>1$Ld^6.',p-#Bn--}$0=p>0&&`Ld,'.`Gc_gd^u0)?d`3p):d}}`2$0`Ac_r`0k`1;k=@y(k);`Kc=' '+s.d.`u,i=c`4' '+k+@e,e=i<0?i:c`4';',i),v=i<0?'':@Yc`3i+2+k`C,e<0?c`C:e));`"
+"2v$H[[B]]'?v:''`Ac_w`0k,v,e`1,d=$v(),l=s.`u@7,t;v`e+v;l=l?$Gl)`D$M`5^t@Ct=(v!`e?^Fl?l:0):-60)`5t){e`Z;e.setTime(e`T+(t*1000))}`lk@Cs.d.`u=k+'`Pv!`e?v:'[[B]]')+'; path=/;'+(^t?' expires='+e.toGMT^3("
+")#9`j+(d?' domain='+d#9`j;`2^Vk)==v}`20`Aeh`0o,e,r,f`1,b='s^ne+'^ns^sn,n=-1,l,i,x`5!^Xl)^Xl`U;l=^Xl;^Bi=0;i<l`C&&n<0;i++`Hl[i].o==o&&l[i].e==e)n=i`ln<0@gi;l[n]`E}x#Gx.o=o;x.e=e;f=r?x.b:f`5r||f){x.b"
+"=r?0:o[e];x.o[e]=f`lx.b){x.o[b]=x.b;`2b}`20`Acet`0f,a,t,o,b`1,r,^d`5`O>=5^m!s.^e||`O>=7)){^d`7's`Gf`Ga`Gt`G`Ke,r@O^A$Na)`br=s.m(t)?s#Fe):t(e)}`2r^Rr=^d(s,f,a,t)^z@ts.^f^Eu`4$n4@d0)r=s.m(b)?s[b](a):"
+"b(a);else{^X(`F,'@F',0,o);^A$Na`Reh(`F,'@F',1)}}`2r`Ag^Tet`0e`1;`2`w`Ag^Toe`7'e`G`Ks=`9,c;^X(^1,\"@F\",1`Re^T=1;c=s.t()`5c)s.d.write(c`Re^T=0;`2@p'`Rg^Tfb`0a){`2^1`Ag^Tf`0w`1,p=w^0,l=w`J;`w=w`5p&&p"
+"`J!=l&&p`J^5==l^5){`w=p;`2s.g^Tf(`w)}`2`w`Ag^T`0`1`5!`w){`w=`F`5!s.e^T)`w=s.cet('g^T^u`w,'g^Tet',s.g^Toe,'g^Tfb')}`2`w`Amrq`0u`1,l=@1],n,r;@1]=0`5l)^Bn=0;n<l`C;n++){r#Gs.mr(0,0,r.r,0,r.t,r.u)}`Abr`"
+"0id,rs`1`5@m`a$e^W@Nbr',rs))$1l=rs`Aflush`a`0`1;s.fbr(0)`Afbr`0id`1,br=^V@Nbr')`5!br)br=$1l`5br`H!@m`a)^W@Nbr`G'`Rmr(0,0,br)}$1l=0`Amr`0@q,q,$oid,ta,u`1,dc=$w,t1=s.`x@n,t2=s.`x@nSecure,ns=s.`c`ispa"
+"ce,un=u?u:$Ys.f$S,unc=`v$p'_`G-'),r`E,l,imn=@Ni^n($S,im,b,e`5!rs){rs=@u'+(@3?'s'`j+'://'+(t1?(@3@W2?t2:t1):($Y(@3?'102':unc))+'.'+($w?$w:112)+'.2o7.net')@fb/ss/'+^C+'/'+(s.$i?'5.1':'1'@fH.17/'+@q+'"
+"?AQB=1&ndh=1'+(q?q`j+'&AQE=1'`5^Y@Ls.^f`H`O>5.5)rs=^j$o4095);`mrs=^j$o2047)`lid){$1(id,rs);$h}`ls.d.images&&`O>=3^m!s.^e||`O>=7)^m@R<0||`O>=6.1)`H!s.rc)s.rc`E`5!^O){^O=1`5!s.rl)s.rl`E;@1n]`U;set@5'"
+"@t^1`hl)^1.`9@8',750)^zl=@1n]`5l){r.t=ta;r.u=un;r.r=rs;l[l`C]=r;`2''}imn+='^n^O;^O++}im=`F[imn]`5!im)im=`F[im@onew Image;im@0l=0;im.^v`7'e`G^S@0l=1`5^1`hl)^1.`9@8^Rim@I=rs`5rs`4$2=@d0^m!ta||ta`t_se"
+"lf$Ia`t_top'||(`F.^w@Wa==`F.^w))){b=e`Z;^4!im@0l&&e`T-b`T<500)e`Z}`2''}`2'<im'+'g sr'+'c=\"'+rs+'\" width=1 $j=1 border=0 alt=\"\">'`Agg`0v`1`5!`F['s^nv])`F['s^nv]`e;`2`F['s^nv]`Aglf`0t,a`Ht`30,2)`"
+"t$Z`32);`Ks=^S,v=$3t)`5v)s#Dv`Agl`0v`1`5$x)`Lv,`G,'gl^u0)`Agv`0v`1;`2s['vpm^nv]?s['vpv^nv]:(s[v]?s[v]`j`Ahavf`0t,a`1,b=t`30,4),x=t`34),n=^Fx),k='g^nt,m='vpm^nt,q=t,v=s.`N@UVa$oe=s.`N@U^Qs,mn;@X$4t)"
+"`5s.@G||^D||^p`H^p^Epe`30,4)$H@G_'){mn=^p`30,1)`D()+^p`31)`5$5){v=$5.`xVars;e=$5.`x^Qs}}v=v?v+`G+^Z+`G+^Z2:''`5v@L`Lv,`G,'is^ut))s[k]`e`5t`t$k'&&e)@Xs.fs(s[k],e)}s[m]=0`5t`t^K`ID`6`cID`Ivid`6^I@Bg'"
+"`d`Bt`t`X@Br'`d`Bt`tvmk`Ivmt`6@E@Bce'`5s[k]&&s[k]`D()`tAUTO')@X'ISO8859-1';`Bs[k]^Eem==2)@X'UTF-8'}`Bt`t`c`ispace`Ins`6c`V`Icdp`6`u@7`Icl`6^o`Ivvp`6@H`Icc`6$R`Ich`6#0@6ID`Ixact`6@r`Iv0`6^U`Is`6^2`I"
+"c`6`o^k`Ij`6`f`Iv`6`u@9`Ik`6`z@2`Ibw`6`z^b`Ibh`6`g`Ict`6^x`Ihp`6p^J`Ip';`B$tx)`Hb`tprop`Ic$J;`Bb`teVar`Iv$J;`Bb`thier@Bh$J`d`ls[k]@W$H`N`i'@W$H`N^M')$6+='&'+q+'`Ps[k]);`2''`Ahav`0`1;$6`e;`L^a,`G,'h"
+"av^u0);`2$6`Alnf`0^c`8^r`8:'';`Kte=t`4@e`5t@We>0&&h`4t`3te$O>=0)`2t`30,te);`2''`Aln`0h`1,n=s.`N`is`5n)`2`Ln,`G,'ln^uh);`2''`Altdf`0^c`8^r`8:'';`Kqi=h`4'?^Rh=qi>=0?h`30,qi):h`5#Ah`3h`C-(t`C$O`t.'+t)"
+"`21;`20`Altef`0^c`8^r`8:''`5#Ah`4t)>=0)`21;`20`Alt`0h`1,lft=s.`N^PFile^Ms,lef=s.`NEx`n,@s=s.`NIn`n;@s=@s?@s:`F`J^5^w;h=h`8`5s.`x^PLinks&&lf#A`Llft,`G$yd^uh))`2'd'`5s.`x@D&&h`30,1)$H# '^mlef||@s)^m!"
+"lef||`Llef,`G$ye^uh))^m!@s$e`L@s,`G$ye^uh)))`2'e';`2''`Alc`7'e`G`Ks=`9,b=^X(^S,\"`k\"`R@G=@w^S`Rt(`R@G=0`5b)`2^S$f`2@p'`Rbc`7'e`G`Ks=`9,f,^d`5s.d^Ed.all^Ed.all.cppXYctnr)$h;^D=e@I`S?e@I`S:e$T;^d`7"
+"\"s\",\"`Ke@O@t^D^m^D.tag`i||^D^0`S||^D^0Node))s.t()`b}\");^d(s`Reo=0'`Roh`0o`1,l=`F`J,h=o^h?o^h:'',i,j,k,p;i=h`4':^Rj=h`4'?^Rk=h`4'/')`5h^mi<0||(j>=0&&i>j)||(k>=0&&i>k))$Lo`Y&&o`Y`C>1?o`Y:(l`Y?l`Y"
+"`j;i=l.path^w^6/^Rh=(p?p+'//'`j+(o^5?o^5:(l^5?l^5`j)+(h`30,1)$H/'?l.path^w`30,i<0?0:i@f'`j+h}`2h`Aot`0o){`Kt=o.tag`i;t=t@W`D?t`D$M`5t`tSHAPE')t`e`5t`Ht`tINPUT'&&@4&&@4`D)t=@4`D();`B!#Ao^h)t='A';}`2"
+"t`Aoid`0o`1,^G,p,c,n`e,x=0`5t@L`y$Lo`Y;c=o.`k`5o^h^mt`tA$I`tAREA')^m!c$ep||p`8`4'`o$d0))n@k`Bc@g`vs.rep(`vs.rep$Gc,\"\\r@h\"\\n@h\"\\t@h' `G^Rx=2}`B$U^mt`tINPUT$I`tSUBMIT')@g$U;x=3}`Bo@I@W`tIMAGE')"
+"n=o@I`5n){`y=^jn@v;`yt=x}}`2`y`Arqf`0t,un`1,e=t`4@e,u=e>=0?`G+t`30,e)+`G:'';`2u&&u`4`G+un+`G)>=0?@Yt`3e$O:''`Arq`0un`1,c=un`4`G),v=^V@Nsq'),q`e`5c<0)`2`Lv,'&`Grq^u$S;`2`L$p`G,'rq',0)`Asqp`0t,a`1,e="
+"t`4@e,q=e<0?'':@Yt`3e+1)`Rsqq[q]`e`5e>=0)`Lt`30,e),`G@b`20`Asqs`0$pq`1;^7u[u@oq;`20`Asq`0q`1,k=@Nsq',v=^Vk),x,c=0;^7q`E;^7u`E;^7q[q]`e;`Lv,'&`Gsqp',0);`L^C,`G@bv`e;^B@x^7u`Q)^7q[^7u[x]]+=(^7q[^7u[x"
+"]]?`G`j+x;^B@x^7q`Q&&^7q[x]^mx==q||c<2)){v+=(v#8'`j+^7q[x]+'`Px);c++}`2^Wk,v,0)`Awdl`7'e`G`Ks=`9,r=@p,b=^X(`F,\"^v\"),i,o,oc`5b)r=^S$f^Bi=0;i<s.d.`Ns`C@A{o=s.d.`Ns[i];oc=o.`k?\"\"+o.`k:\"\"`5(oc`4$"
+"B<0||oc`4\"@0oc(\")>=0)&&oc`4$W<0)^X(o,\"`k\",0,s.lc);}`2r^R`Fs`0`1`5`O>3^m!^Y$es.^f||`O#E`Hs.b^E$D^Q)s.$D^Q('`k',s.bc);`Bs.b^Eb.add^Q$A)s.b.add^Q$A('clic$a,false);`m^X(`F,'^v',0,`Fl)}`Avs`0x`1,v=s"
+".`c^N,g=s.`c^N#5k=@Nvsn^n^C+(g?'^ng`j,n=^Vk),e`Z,y=e.g@K);e.s@Ky+10@l1900:0))`5v){v*=100`5!n`H!^Wk,x,e))`20;n=x`ln%10000>v)`20}`21`Adyasmf`0t,m`H#Am&&m`4t)>=0)`21;`20`Adyasf`0t,m`1,i=t?t`4@e:-1,n,x"
+"`5i>=0&&m){`Kn=t`30,i),x=t`3i+1)`5`Lx,`G,'dyasm^um))`2n}`20`Auns`0`1,x=s.`MSele@6,l=s.`MList,m=s.`MM$s,n,i;^C=^C`8`5x&&l`H!m)m=`F`J^5`5!m.toLowerCase)m`e+m;l=l`8;m=m`8;n=`Ll,';`Gdyas^um)`5n)^C=n}i="
+"^C`4`G`Rfun=i<0?^C:^C`30,i)`Asa`0un`1;^C=un`5!@S)@S=un;`B(`G+@S+`G)`4$S<0)@S+=`G+un;^Cs()`Am_i`0n,a`1,m,f=n`30,1),r,l,i`5!`Wl)`Wl`E`5!`Wnl)`Wnl`U;m=`Wl[n]`5!a&&m&&m._e@Lm^s)`Wa(n)`5!m){m`E,m._c=@Nm"
+"';m^sn=`F`hn;m^sl=s^sl;m^sl[m^s@om;`F`hn++;m.s=s;m._n=n;m._l`U('_c`G_in`G_il`G_i`G_e`G_d`G_dl`Gs`Gn`G_r`G_g`G_g1`G_t`G_t1`G_x`G_x1`G_l'`Rm_l[@om;`Wnl[`Wnl`C]=n}`Bm._r@Lm._m){r=m._r;r._m=m;l=m._l;^B"
+"i=0;i<l`C@A@tm[l[i]])r[l[i]]=m[l[i]];r^sl[r^s@or;m=`Wl[@or`lf==f`D())s[@om;`2m`Am_a`7'n`Gg`G@t!g)g=#2;`Ks=`9,c=s[$V,m,x,f=0`5!c)c=`F$u$V`5c&&s_d)s[g]`7\"s\",s_ft(s_d(c)));x=s[g]`5!x)x=`F$ug];m=`Wi("
+"n,1)`5x){m^s=f=1`5(\"\"+x)`4\"fun@6\")>=0)x(s);`m`Wm(\"x\",n,x)}m=`Wi(n,1)`5@Zl)@Zl=@Z=0;`pt();`2f'`Rm_m`0t,n,d){t='^nt;`Ks=^S,i,x,m,f='^nt`5`Wl&&`Wnl)^Bi=0;i<`Wnl`C@A{x=`Wnl[i]`5!n||x==n){m=`Wi(x)"
+"`5m[t]`Ht`t_d')`21`5d)m#Fd);`mm#F)`lm[t+1]@Lm[f]`Hd)$gd);`m$g)}m[f]=1}}`20`AloadModule`0n,u,d,l`1,m,i=n`4':'),g=i<0?#2:n`3i+1),o=0,f,c=s.h?s.h:s.b,^d`5i>=0)n=n`30,i);m=`Wi(n)`5(l$e`Wa(n,g))&&u^Ed&&"
+"c^E$E`S`Hd){@Z=1;@Zl=1`l@3)u=`vu,@u:`Ghttps:^Rf`7'e`G`9.m_a(\"$J+'\",\"'+g+'\")^R^d`7's`Gf`Gu`Gc`G`Ke,o=0@Oo=s.$E`S(\"script\")`5o){@4=\"text/`o\"`5f)o.^v=f;o@I=u;c.appendChild(o)}`bo=0}`2o^Ro=^d(s"
+",f,u,c)}`mm=`Wi(n);m._e=1;`2m`Avo1`0t,a`Ha[t]||$P)^S#Da[t]`Avo2`0t,a`H#H{a#D^S[t]`5#H$P=1}`Adlt`7'`Ks=`9,d`Z,i,vo,f=0`5`pl)^Bi=0;i<`pl`C@A{vo=`pl[i]`5vo`H!`Wm(\"d\")||d`T-$C>=^8){`pl[i]=0;s.t(@i}`m"
+"f=1}`l`pi)clear@5`pi`Rdli=0`5f`H!`pi)`pi=set@5`pt,^8)}`m`pl=0'`Rdl`0vo`1,d`Z`5!@ivo`E;`L^9,`G$72',@i;$C=d`T`5!`pl)`pl`U;`pl[`pl`C]=vo`5!^8)^8=250;`pt()`At`0vo,id`1,trk=1,tm`Z,sed=Math&&@P$l?@P$r@P$"
+"l()*10000000000000):tm`T,@q='s'+@P$rtm`T/10800000)%10+sed,y=tm.g@K),vt=tm.getDate(@f`sMonth(@f'@ly+1900:y)+' `sHour$K:`sMinute$K:`sSecond$K `sDay()+' `sTimezoneO@z(),^d,^T=s.g^T(),ta`e,q`e,qs`e,$m`"
+"e,vb`E#1^9`Runs()`5!s.td){`Ktl=^T`J,a,o,i,x`e,c`e,v`e,p`e,bw`e,bh`e,^H0',k=^W@Ncc`G@p',0^q,hp`e,ct`e,pn=0,ps`5^3&&^3.prototype){^H1'`5j.m$s){^H2'`5tm.setUTCDate){^H3'`5^Y^E^f&&`O#E^H4'`5pn.toPrecis"
+"ion){^H5';a`U`5a.forEach){^H6';i=0;o`E;^d`7'o`G`Ke,i=0@Oi=new Iterator(o)`b}`2i^Ri=^d(o)`5i&&i.next)^H7'}}}}`l`O>=4)x=^iwidth+'x'+^i$j`5s.isns||s.^e`H`O>=3$Q`f(^q`5`O>=4){c=^ipixelDepth;bw=`F$z@2;b"
+"h=`F$z^b}}$8=s.n.p^J}`B^Y`H`O>=4$Q`f(^q;c=^i^2`5`O#E{bw=s.d.^L`S.o@z@2;bh=s.d.^L`S.o@z^b`5!s.^f^Eb){^d`7's`Gtl`G`Ke,hp=0`qh$b\");hp=s.b.isH$b(tl)?\"Y\":\"N\"`b}`2hp^Rhp=^d(s,tl);^d`7's`G`Ke,ct=0`qc"
+"lientCaps\");ct=s.b.`g`b}`2ct^Rct=^d(s)}}}`mr`e`l$8)^4pn<$8`C&&pn<30){ps=^j$8[pn].^w@v#9`5p`4ps)<0)p+=ps;pn++}s.^U=x;s.^2=c;s.`o^k=j;s.`f=v;s.`u@9=k;s.`z@2=bw;s.`z^b=bh;s.`g=ct;s.^x=hp;s.p^J=p;s.td"
+"=1`l@i{`L^9,`G$72',vb);`L^9,`G$71',@i`ls.useP^J)s.doP^J(s);`Kl=`F`J,r=^T.^L.`X`5!s.^I)s.^I=l^h?l^h:l`5!s.`X@Ls._1_`X#C`X=r;s._1_`X=1}`Wm('g')`5(vo&&$C)$e`Wm('d')`Hs.@G||^D){`Ko=^D?^D:s.@G`5!o)`2'';"
+"`Kp=$4'#4`i'),w=1,^G,@a,x=`yt,h,l,i,oc`5^D&&o==^D){^4o@Ln@W$HBODY'){o=o^0`S?o^0`S:o^0Node`5!o)`2'';^G;@a;x=`yt}oc=o.`k?''+o.`k:''`5(oc`4$B>=0&&oc`4\"@0oc(\")<0)||oc`4$W>=0)`2''}ta=n?o$T:1;h@ki=h`4'"
+"?^Rh=s.`N@c^3||i<0?h:h`30,i);l=s.`N`i?s.`N`i:s.ln(h);t=s.`N^M?s.`N^M`8:s.lt(h)`5t^mh||l))q+=$2=@G^n(t`td$I`te'?@y(t):'o')+(h?$2v1`Ph)`j+(l?$2v2`Pl)`j;`mtrk=0`5s.`x@T`H!p$L$4'^I^Rw=0}^G;i=o.sourceIn"
+"dex`5$3'^y')@g$3'^y^Rx=1;i=1`lp&&n@W)qs='&pid`P^jp,255))+(w#8p#3w`j+'&oid`P^jn@v)+(x#8o#3x`j+'&ot`Pt)+(i#8oi='+i`j}`l!trk@Lqs)`2'';@j=s.vs(sed)`5trk`H@j)$m=s.mr(@q,(vt#8t`Pvt)`j+s.hav()+q+(qs?qs:s."
+"rq(^C)),0,id,ta);qs`e;`Wm('t')`5s.p_r)s.p_r(`R`X`e}^7(qs);^z`p(@i;`l@i`L^9,`G$71',vb`R@G=^D=s.`N`i=s.`N^M=`F@0^y=s.ppu=^p=^pv1=^pv2=^pv3`e`5$x)`F@0@G=`F@0eo=`F@0`N`i=`F@0`N^M`e`5!id@Ls.tc#Ctc=1;s.f"
+"lush`a()}`2$m`Atl`0o,t,n,vo`1;s.@G=@wo`R`N^M=t;s.`N`i=n;s.t(@i}`5pg){`F@0co`0o){`K@J\"_\",1,#B`2@wo)`Awd@0gs`0$S{`K@J$p1,#B`2s.t()`Awd@0dc`0$S{`K@J$p#B`2s.t()}}@3=(`F`J`Y`8`4@us@d0`Rd=^L;s.b=s.d.bo"
+"dy`5$c`S#7`i#Ch=$c`S#7`i('HEAD')`5s.h)s.h=s.h[0]}s.n=navigator;s.u=s.n.userAgent;@R=s.u`4'N$X6/^R`Kapn$F`i,v$F^k,ie=v`4$n'),o=s.u`4'@M '),i`5v`4'@M@d0||o>0)apn='@M';^Y$9`tMicrosoft Internet Explore"
+"r'`Risns$9`tN$X'`R^e$9`t@M'`R^f=(s.u`4'Mac@d0)`5o>0)`O`rs.u`3o+6));`Bie>0){`O=^Fi=v`3ie+5))`5`O>3)`O`ri)}`B@R>0)`O`rs.u`3@R+10));`m`O`rv`Rem=0`5^3#6^l){i=^g^3#6^l(256))`D(`Rem=(i`t%C4%80'?2:(i`t%U0"
+"100'?1:0))}s.sa(un`Rvl_l='^K,`cID,vmk,ppu,@E,`c`ispace,c`V,`u@7,#4`i,^I,`X,@H';^a=^Z+',^o,$R,server,#4^M,#0@6ID,purchaseID,@r,state,zip,$k,products,`N`i,`N^M';^B`Kn=1;n<51;n++)^a+=',prop$J+',eVar$J"
+"+',hier$J;^Z2=',^U,^2,`o^k,`f,`u@9,`z@2,`z^b,`g,^x,pe$q1$q2$q3,p^J';^a+=^Z2;^9=^a+',$i,`c^N,`c^N#5`MSele@6,`MList,`MM$s,`x^PLinks,`x@D,`x@T,`N@c^3,`N^PFile^Ms,`NEx`n,`NIn`n,`N@UVa$o`N@U^Qs,`N`is,@G"
+",eo';$x=pg#1^9)`5!ss)`Fs()",
w=window,l=w.s_c_il,n=navigator,u=n.userAgent,v=n.appVersion,e=v.indexOf('MSIE '),m=u.indexOf('Netscape6/'),a,i,s;if(un){un=un.toLowerCase();if(l)for(i=0;i<l.length;i++){s=l[i];if(s._c=='s_c'){if(s.oun==un)return s;else if(s.fs&&s.sa&&s.fs(s.oun,un)){s.sa(un);return s}}}}
w.s_r=new Function("x","o","n","var i=x.indexOf(o);if(i>=0&&x.split)x=(x.split(o)).join(n);else while(i>=0){x=x.substring(0,i)+n+x.substring(i+o.length);i=x.indexOf(o)}return x");
w.s_d=new Function("x","var t='`^@$#',l='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',d,n=0,b,k,w,i=x.lastIndexOf('~~');if(i>0){d=x.substring(0,i);x=x.substring(i+2);while(d){w=d;i"
+"=d.indexOf('~');if(i>0){w=d.substring(0,i);d=d.substring(i+1)}else d='';b=(n-n%62)/62;k=n-b*62;k=t.substring(b,b+1)+l.substring(k,k+1);x=s_r(x,k,w);n++}for(i=0;i<5;i++){w=t.substring(i,i+1);x=s_r(x"
+",w+' ',w)}}return x");
w.s_fe=new Function("c","return s_r(s_r(s_r(c,'\\\\','\\\\\\\\'),'\"','\\\\\"'),\"\\n\",\"\\\\n\")");
w.s_fa=new Function("f","var s=f.indexOf('(')+1,e=f.indexOf(')'),a='',c;while(s>=0&&s<e){c=f.substring(s,s+1);if(c==',')a+='\",\"';else if((\"\\n\\r\\t \").indexOf(c)<0)a+=c;s++}return a?'\"'+a+'\"':"
+"a");
w.s_ft=new Function("c","c+='';var s,e,o,a,d,q,f,h,x;s=c.indexOf('=function(');while(s>=0){s++;d=1;q='';x=0;f=c.substring(s);a=s_fa(f);e=o=c.indexOf('{',s);e++;while(d>0){h=c.substring(e,e+1);if(q){i"
+"f(h==q&&!x)q='';if(h=='\\\\')x=x?0:1;else x=0}else{if(h=='\"'||h==\"'\")q=h;if(h=='{')d++;if(h=='}')d--}if(d>0)e++}c=c.substring(0,s)+'new Function('+(a?a+',':'')+'\"'+s_fe(c.substring(o+1,e))+'\")"
+"'+c.substring(e+1);s=c.indexOf('=function(')}return c;");
c=s_d(c);if(e>0){a=parseInt(i=v.substring(e+5));if(a>3)a=parseFloat(i)}else if(m>0)a=parseFloat(u.substring(m+10));else a=parseFloat(v);if(a>=5&&v.indexOf('Opera')<0&&u.indexOf('Opera')<0){w.s_c=new Function("un","pg","ss","var s=this;"+c);return new s_c(un,pg,ss)}else s=new Function("un","pg","ss","var s=new Object;"+s_ft(c)+";return s");return s(un,pg,ss)}



 //  rsspodcast 

// rss/podcast bucket
$(document).ready(function(){

        $('.podicon').click(function() {
            try {
                $('.podbox').hide();
                $('.feed ul li').css("z-index", "0");
                $(this).parent('li').css("z-index", "90");
                $(this).siblings('.podbox').show();
                NPR.metrics.pageEvent(NPR.metrics.constants.CLICK_PODCAST_LINK);
                return false;
            }
            catch (e) {
                NPR.messaging.exception(e, 'podicon onclick', 'rsspodcast.js', NPR.messaging.constants.RSS_PODCAST_JS_ERROR);
            }
    });

        $('.closethis').click(function() {
            try {
                $('.podbox').hide();
                return false;
            }
            catch (e) {
                NPR.messaging.exception(e, 'closethis onclick', 'rsspodcast.js', NPR.messaging.constants.RSS_PODCAST_JS_ERROR);
            }
    });

        $('.subitunes,.subzune').click(function() {
            try {
                $('.podbox').hide();
            }
            catch (e) {
                NPR.messaging.exception(e, 'subitunes or subzune onclick', 'rsspodcast.js', NPR.messaging.constants.RSS_PODCAST_JS_ERROR);
            }
    });

        $('.podurl').focus(function() {
            try {
                if(this.value == this.defaultValue) {
                        this.select();
                }
            }
            catch (e) {
                NPR.messaging.exception(e, 'podurl focus', 'rsspodcast.js', NPR.messaging.constants.RSS_PODCAST_JS_ERROR);
            }
        }); 

        $('.rssicon').click(function() {
            try {
                NPR.metrics.pageEvent(NPR.metrics.constants.CLICK_RSS_LINK);
            }
            catch (e) {
                NPR.messaging.exception(e, 'rssicon onclick', 'rsspodcast.js', NPR.messaging.constants.RSS_PODCAST_JS_ERROR);
            }
    });
});


 //  lib/jquery.easing.1.3 

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */

 //  lib/jScrollPane-1.2.3.min 

(function(A){A.jScrollPane={active:[]};A.fn.jScrollPane=function(C){C=A.extend({},A.fn.jScrollPane.defaults,C);var B=function(){return false};return this.each(function(){var O=A(this);O.css("overflow","hidden");var X=this;if(A(this).parent().is(".jScrollPaneContainer")){var Ac=C.maintainPosition?O.position().top:0;var L=A(this).parent();var d=L.innerWidth();var Ad=L.outerHeight();var M=Ad;A(">.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown",L).remove();O.css({top:0})}else{var Ac=0;this.originalPadding=O.css("paddingTop")+" "+O.css("paddingRight")+" "+O.css("paddingBottom")+" "+O.css("paddingLeft");this.originalSidePaddingTotal=(parseInt(O.css("paddingLeft"))||0)+(parseInt(O.css("paddingRight"))||0);var d=O.innerWidth();var Ad=O.innerHeight();var M=Ad;O.wrap(A("<div></div>").attr({className:"jScrollPaneContainer"}).css({height:Ad+"px",width:d+"px"}));A(document).bind("emchange",function(Ae,Af,p){O.jScrollPane(C)})}if(C.reinitialiseOnImageLoad){var N=A.data(X,"jScrollPaneImagesToLoad")||A("img",O);var G=[];if(N.length){N.each(function(p,Ae){A(this).bind("load",function(){if(A.inArray(p,G)==-1){G.push(Ae);N=A.grep(N,function(Ag,Af){return Ag!=Ae});A.data(X,"jScrollPaneImagesToLoad",N);C.reinitialiseOnImageLoad=false;O.jScrollPane(C)}}).each(function(Af,Ag){if(this.complete||this.complete===undefined){this.src=this.src}})})}}var o=this.originalSidePaddingTotal;var l={height:"auto",width:d-C.scrollbarWidth-C.scrollbarMargin-o+"px"};if(C.scrollbarOnLeft){l.paddingLeft=C.scrollbarMargin+C.scrollbarWidth+"px"}else{l.paddingRight=C.scrollbarMargin+"px"}O.css(l);var m=O.outerHeight();var i=Ad/m;if(i<0.99){var H=O.parent();H.append(A("<div></div>").attr({className:"jScrollPaneTrack"}).css({width:C.scrollbarWidth+"px"}).append(A("<div></div>").attr({className:"jScrollPaneDrag"}).css({width:C.scrollbarWidth+"px"}).append(A("<div></div>").attr({className:"jScrollPaneDragTop"}).css({width:C.scrollbarWidth+"px"}),A("<div></div>").attr({className:"jScrollPaneDragBottom"}).css({width:C.scrollbarWidth+"px"}))));var z=A(">.jScrollPaneTrack",H);var P=A(">.jScrollPaneTrack .jScrollPaneDrag",H);if(C.showArrows){var g;var Ab;var S;var r;var j=function(){if(r>4||r%4==0){y(u+Ab*b)}r++};var K=function(p){A("html").unbind("mouseup",K);g.removeClass("jScrollActiveArrowButton");clearInterval(S)};var Z=function(){A("html").bind("mouseup",K);g.addClass("jScrollActiveArrowButton");r=0;j();S=setInterval(j,100)};H.append(A("<a></a>").attr({href:"javascript:;",className:"jScrollArrowUp"}).css({width:C.scrollbarWidth+"px"}).html("Scroll up").bind("mousedown",function(){g=A(this);Ab=-1;Z();this.blur();return false}).bind("click",B),A("<a></a>").attr({href:"javascript:;",className:"jScrollArrowDown"}).css({width:C.scrollbarWidth+"px"}).html("Scroll down").bind("mousedown",function(){g=A(this);Ab=1;Z();this.blur();return false}).bind("click",B));var Q=A(">.jScrollArrowUp",H);var J=A(">.jScrollArrowDown",H);if(C.arrowSize){M=Ad-C.arrowSize-C.arrowSize;z.css({height:M+"px",top:C.arrowSize+"px"})}else{var s=Q.height();C.arrowSize=s;M=Ad-s-J.height();z.css({height:M+"px",top:s+"px"})}}var w=A(this).css({position:"absolute",overflow:"visible"});var D;var Y;var b;var u=0;var V=i*Ad/2;var a=function(Ae,Ag){var Af=Ag=="X"?"Left":"Top";return Ae["page"+Ag]||(Ae["client"+Ag]+(document.documentElement["scroll"+Af]||document.body["scroll"+Af]))||0};var f=function(){return false};var v=function(){n();D=P.offset(false);D.top-=u;Y=M-P[0].offsetHeight;b=2*C.wheelSpeed*Y/m};var E=function(p){v();V=a(p,"Y")-u-D.top;A("html").bind("mouseup",T).bind("mousemove",h);if(A.browser.msie){A("html").bind("dragstart",f).bind("selectstart",f)}return false};var T=function(){A("html").unbind("mouseup",T).unbind("mousemove",h);V=i*Ad/2;if(A.browser.msie){A("html").unbind("dragstart",f).unbind("selectstart",f)}};var y=function(Ae){Ae=Ae<0?0:(Ae>Y?Y:Ae);u=Ae;P.css({top:Ae+"px"});var Af=Ae/Y;w.css({top:((Ad-m)*Af)+"px"});O.trigger("scroll");if(C.showArrows){Q[Ae==0?"addClass":"removeClass"]("disabled");J[Ae==Y?"addClass":"removeClass"]("disabled")}};var h=function(p){y(a(p,"Y")-D.top-V)};var q=Math.max(Math.min(i*(Ad-C.arrowSize*2),C.dragMaxHeight),C.dragMinHeight);P.css({height:q+"px"}).bind("mousedown",E);var k;var R;var I;var t=function(){if(R>8||R%4==0){y((u-((u-I)/2)))}R++};var Aa=function(){clearInterval(k);A("html").unbind("mouseup",Aa).unbind("mousemove",e)};var e=function(p){I=a(p,"Y")-D.top-V};var U=function(p){v();e(p);R=0;A("html").bind("mouseup",Aa).bind("mousemove",e);k=setInterval(t,100);t()};z.bind("mousedown",U);H.bind("mousewheel",function(Ae,Ag){v();n();var Af=u;y(u-Ag*b);var p=Af!=u;return !p});var F;var W;function c(){var p=(F-u)/C.animateStep;if(p>1||p<-1){y(u+p)}else{y(F);n()}}var n=function(){if(W){clearInterval(W);delete F}};var x=function(Af,p){if(typeof Af=="string"){$e=A(Af,O);if(!$e.length){return}Af=$e.offset().top-O.offset().top}H.scrollTop(0);n();var Ae=-Af/(Ad-m)*Y;if(p||!C.animateTo){y(Ae)}else{F=Ae;W=setInterval(c,C.animateInterval)}};O[0].scrollTo=x;O[0].scrollBy=function(Ae){var p=-parseInt(w.css("top"))||0;x(p+Ae)};v();x(-Ac,true);A("*",this).bind("focus",function(Ah){var Ag=A(this);var Aj=0;while(Ag[0]!=O[0]){Aj+=Ag.position().top;Ag=Ag.offsetParent()}var p=-parseInt(w.css("top"))||0;var Ai=p+Ad;var Af=Aj>p&&Aj<Ai;if(!Af){var Ae=Aj-C.scrollbarMargin;if(Aj>p){Ae+=A(this).height()+15+C.scrollbarMargin-Ad}x(Ae)}});if(location.hash){x(location.hash)}A(document).bind("click",function(Ae){$target=A(Ae.target);if($target.is("a")){var p=$target.attr("href");if(p.substr(0,1)=="#"){x(p)}}});A.jScrollPane.active.push(O[0])}else{O.css({height:Ad+"px",width:d-this.originalSidePaddingTotal+"px",padding:this.originalPadding});O.parent().unbind("mousewheel")}})};A.fn.jScrollPane.defaults={scrollbarWidth:10,scrollbarMargin:5,wheelSpeed:18,showArrows:false,arrowSize:0,animateTo:false,dragMinHeight:1,dragMaxHeight:99999,animateInterval:100,animateStep:3,maintainPosition:true,scrollbarOnLeft:false,reinitialiseOnImageLoad:false};A(window).bind("unload",function(){var C=A.jScrollPane.active;for(var B=0;B<C.length;B++){C[B].scrollTo=C[B].scrollBy=null}})})(jQuery);

 //  globalnav 

$(document).ready(function(){

	jQuery.easing.def = 'easeOutQuad';
	
	var speed = 250;
	
	reinitialiseScrollPane = function() {
		$('.stationdata').jScrollPane({showArrows:true, scrollbarWidth:13});
	}
											
	updatePane = function () {
		
		// strip out classname
		var lnkClasses = $(this).attr("class");
		var lnkClass = lnkClasses.substr(0, lnkClasses.length - 7);
		
		// check to see if clicked link is already selected
		var lnkSelected = $('.stationnav .selected')[0];
		if (!(lnkSelected === this)) {

	
			// remove selected class from current link
			$('.stationnav .selected').addClass("flyout").removeClass("selected");
			
			// add selected class
			$(this).removeClass("flyout").addClass("selected");
	
			// set all station data to display none
			$('.stationdata .selected').removeClass("selected");  
			
			// move the arrow
			var lnkArr = $('.stationnav a');
			var numLinks = lnkArr.length;
	
			var i = 0;
			for (i=0;i<numLinks;i++) {
				if (this === lnkArr[i]) {
					break;
				}
			}
			/* calculate the numper of pix to absolutely position the arrow from the top
				numPix = (index of link * line-height of listitems) + default top position of arrow
			*/
			numPix = (i * 20) + 13;
			$('.stationdata_arrow').animate({"top": numPix+"px"}, speed, function() {
				reinitialiseScrollPane();
			});
			
			// show the correct info in the scroll window
			switch (lnkClass)
			{
			case "lnkaudio":
			$('.sd_audio').addClass("selected");
			break;
			case "lnkpodcast":
			$('.sd_podcast').addClass("selected");
			break;
			case "lnknewsfeed":
			$('.sd_newsfeed').addClass("selected");
			break;
			case "lnkcommunity":
			$('.sd_community').addClass("selected");
			break;
			}
			
		} //end if
		
	} //end updatePane
	
	
	// localization
	
	$('#header .support .tab a').toggle(function() { 
		$('.ddstn').slideDown(speed);
		reinitialiseScrollPane();
		$('#header .headercontent').addClass("dd_active");
		NPR.metrics.pageEvent(NPR.metrics.constants.STATION_DRAWER_OPEN);
	}, function() { 
		$('.ddstn').slideUp(speed, function () {
			$('#header .headercontent').removeClass("dd_active");
		});
	}); 
	
	$('.ddstn .closemenu').click(function() {
		$('#header .support .tab a').click();
	}); 



	// news programs drawer
	
	$('#nav li.navprograms a').click(function() {
		if ($('#menuprograms').css("display") === "none") {
			$('#menulisten').slideUp(speed, function() {
				$('li.navlisten').css('background-color', '#333');
				$('li.navlisten a').removeClass("selected");
				$('li.navprograms').css('background-color', '#ccc');
				$('li.navprograms a').addClass("selected");
				$('#menuprograms').slideDown(speed, "easeInQuad");
			});
		} else {
			$('#menuprograms').slideUp(speed, function() {
				$('li.navprograms').css('background-color', '#000');
				$('li.navprograms a').removeClass("selected");
			});
		}
	});
	
	$('#menuprograms .closemenu').click(function() {
		$('li.navprograms a').click();
	});
	
	
	
	// news listen drawer
	
	$('#nav li.navlisten a').click(function() {
		if ($('#menulisten').css("display") === "none") {
			$('#menuprograms').slideUp(speed, function() {
				$('li.navprograms').css('background-color', '#000');
				$('li.navprograms a').removeClass("selected");
				$('li.navlisten').css('background-color', '#80bdc4');
				$('li.navlisten a').addClass("selected");
				$('#menulisten').slideDown(speed, "easeInQuad");
				NPR.metrics.pageEvent(NPR.metrics.constants.LISTEN_DRAWER_OPEN);
			});
		} else {
			$('#menulisten').slideUp(speed, function() {
				$('li.navlisten').css('background-color', '#333');
				$('li.navlisten a').removeClass("selected");
			});
		}
	});
	
	$('#menulisten .closemenu').click(function() {
		$('li.navlisten a').click();
	}); 
	
	
	
	// music features dropdown
	
	$("#music_nav .topics ul.main a.features, #tab_features, #dd_features").hover(function () {
		var shimWidth = $("#dd_features").width() - 16;
		var shimHeight = $("#dd_features").height() - 16;
		
		$(".dd_shim").css({'width' : shimWidth, 'height' : shimHeight, 'left' : '68px'});
		$("#tab_features, #dd_features").css({'left' : '60px'});
	}, function () {
		$(".dd_shim, #tab_features, #dd_features").css({'left' : '-5000px'});
	});
	
	// music concerts dropdown
	
	$("#music_nav .topics ul.main a.concerts, #tab_concerts, #dd_concerts").hover(function () {
		var shimWidth = $("#dd_concerts").width() - 16;
		var shimHeight = $("#dd_concerts").height() - 16;
		
		$(".dd_shim").css({'width' : shimWidth, 'height' : shimHeight, 'left' : '171px'});
		$("#tab_concerts, #dd_concerts").css({'left' : '163px'});
	}, function () {
		$(".dd_shim, #tab_concerts, #dd_concerts").css({'left' : '-5000px'});
	});
	
	// music programs dropdown
	
	$("#music_nav .topics ul.main a.programs, #tab_programs, #dd_programs").hover(function () {
		var shimWidth = $("#dd_programs").width() - 16;
		var shimHeight = $("#dd_programs").height() - 16;
		
		$(".dd_shim").css({'width' : shimWidth, 'height' : shimHeight, 'left' : '478px'});
		$("#tab_programs, #dd_programs").css({'left' : '471px'});
	}, function () {
		$(".dd_shim, #tab_programs, #dd_programs").css({'left' : '-5000px'});
	});
	
	
	
});


 //  fontsize 

$(document).ready(function(){

	var savedTextSize = checkCookie("NPRTextSize");
	
	switch(savedTextSize) {
		case "1":
			$('#storytext, .childstory, .transcript').css('font-size', '1em');
			break;
		case "2":
			$('#storytext, .childstory, .transcript').css('font-size', '1.1em');
			break;
		case "3":
			$('#storytext, .childstory, .transcript').css('font-size', '1.2em');
			break;
		default:
			break;
	}
	
	$(".textsize .normal").click(function () { 
		$('#storytext, .childstory, .transcript').css('font-size', '1em');
		setCookie("NPRTextSize", 100, "1");
	});
	$(".textsize .big").click(function () { 
		$('#storytext, .childstory, .transcript').css('font-size', '1.1em');
		setCookie("NPRTextSize", 100, "2");
	});
	$(".textsize .bigger").click(function () {
		$('#storytext, .childstory, .transcript').css('font-size', '1.2em');
		setCookie("NPRTextSize", 100, "3");
	});

});

 //  sharepop 

$(document).ready(function(){

	$("a.share").click(function() {
		var sharePop = $(this).parents(".storytoolswrap").children(".sharepop");
		var shareSelected = $(this).parents(".storytoolswrap").children(".shareselected");
		$(sharePop).add(shareSelected).show();
		
		$(sharePop).add(shareSelected).hover(function () {
			$(sharePop).add(shareSelected).show();
		}, function () {
			$(sharePop).add(shareSelected).hide();
		});
		
	});
	
	$(".shareselected a").click(function () {
		var sharePop = $(this).parents(".storytoolswrap").children(".sharepop");
		var shareSelected = $(this).parents(".storytoolswrap").children(".shareselected");
		$(sharePop).add(shareSelected).hide();
	});
	
	
});

 //  enlarge 

$(document).ready(function() {
	
	var zoomStatus = 0;
	var directory = 'http://media.npr.org/chrome/news/enlarge';
	
	// this will begin failing when MSIE 10 comes out.
    var IEposition = navigator.userAgent.indexOf('MSIE');
    if (IEposition === -1 || parseInt(navigator.userAgent.substr(IEposition+5, 1)) > 6) {
        var zoomExt = 'png';
    } else {
        var zoomExt = 'gif';
    }
	
	//var zoomExt = $.browser.msie ? 'gif' : 'png';
    var zoomHtml = '<div id="zoom_overlay" class="zoom_overlayBG"></div> \
				<div id="zoom" style="display:none;"> \
                  <table id="zoom_table"> \
                    <tbody> \
                      <tr> \
                        <td class="tl" style="background:url(' + directory + '/tl.' + zoomExt + ') 0 0 no-repeat; width:20px; height:20px; overflow:hidden;" /> \
                        <td class="tm" style="background:url(' + directory + '/tm.' + zoomExt + ') 0 0 repeat-x; height:20px; overflow:hidden;" /> \
                        <td class="tr" style="background:url(' + directory + '/tr.' + zoomExt + ') 100% 0 no-repeat; width:20px; height:20px; overflow:hidden;" /> \
                      </tr> \
                      <tr> \
                        <td class="ml" style="background:url(' + directory + '/ml.' + zoomExt + ') 0 0 repeat-y; width:20px; overflow:hidden;" /> \
                        <td class="mm" style="background:#fff; vertical-align:top; padding:10px;"> \
                          <div id="zoom_content"> \
                          </div> \
                        </td> \
                        <td class="mr" style="background:url(' + directory + '/mr.' + zoomExt + ') 100% 0 repeat-y;  width:20px; overflow:hidden;" /> \
                      </tr> \
                      <tr> \
                        <td class="bl" style="background:url(' + directory + '/bl.' + zoomExt + ') 0 100% no-repeat; width:20px; height:20px; overflow:hidden;" /> \
                        <td class="bm" style="background:url(' + directory + '/bm.' + zoomExt + ') 0 100% repeat-x; height:20px; overflow:hidden;" /> \
                        <td class="br" style="background:url(' + directory + '/br.' + zoomExt + ') 100% 100% no-repeat; width:20px; height:20px; overflow:hidden;" /> \
                      </tr> \
                    </tbody> \
                  </table> \
                  <a href="javascript:;" title="Close" id="zoom_close" style="position:absolute; top:0; left:0;"> \
                    <img src="' + directory + '/closebox.' + zoomExt + '" alt="Close" style="border:none; margin:0; padding:0;" /> \
                  </a> \
				  <a href="javascript:;" title="Close" class="closezoom">close</a> \
                </div>';
				
	$('body').append(zoomHtml);
	
	doImageEnlargement = function (e) {
		
		var yCoord = e.pageY - 150;
		
		// get the width of the image
		var content_div = $(this).parents('.bucketwrap').children('.enlarge_html');
		var measure_div = $(this).parents('.bucketwrap').children('.enlarge_measure');
		var imgWidth = $(measure_div).width();
		var imgHeight = $(measure_div).height();
		
		
		// constrain to max width of 650px or max height of 500px
		if (imgWidth > imgHeight) {
			if (imgWidth > 650) {imgWidth=650}
		} else {
			if (imgHeight > 650) {imgHeight=650}
			$(measure_div).children('img:first').css("height", imgHeight+"px");
			imgWidth = $(measure_div).width();
		}
		
		// put the enlargement HTML into #zoom_content and constrain width
		$('#zoom_content').html($(measure_div).html() + $(content_div).html()).css("width", imgWidth+"px");
		$('#zoom_content').children('img:first').css("width", imgWidth+"px");
		
		//console.log($("#zoom").height());
		//console.log($("#zoom").width());
		
		centerZoom(yCoord);
		loadZoom();
		
		NPR.metrics.pageEvent(NPR.metrics.constants.IMAGE_ENLARGEMENT);
		
	};

	$('a.enlargeicon, img.enlarge').click(doImageEnlargement);


	
	$('#zoom_overlay, #zoom').click(function () {
		disableZoom();
	});
	

	function loadZoom() {
		//loads popup only if it is disabled
		if(zoomStatus==0){
			$("#zoom_overlay").show();
			$("#zoom").show();
			zoomStatus = 1;
		}
	}
	
	function disableZoom() {
		//disables popup only if it is enabled
		if(zoomStatus==1){
			$("#zoom_overlay").hide();
			$("#zoom").hide();
			zoomStatus = 0;
		}
	}
	
	//centering popup
	function centerZoom(yCoord) {
		
		//request data for centering
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var zoomHeight = $("#zoom").height();
		var zoomWidth = $("#zoom").width();
		
		
		var width       = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
		var height      = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
		var x           = window.pageXOffset || (window.document.documentElement.scrollLeft || window.document.body.scrollLeft);
		var y           = window.pageYOffset || (window.document.documentElement.scrollTop || window.document.body.scrollTop);
		var window_size = {'width':width, 'height':height, 'x':x, 'y':y}

		var width              = zoomWidth + 0;
		var height             = zoomHeight + 0;
		var d                  = window_size;
		
		// ensure that newTop is at least 0 so it doesn't hide close button
		var newTop             = Math.max((d.height/2) - (height/2) + y, 0);
		var newLeft            = (d.width/2) - (width/2);
		
		var fromTop = y + ((d.height/2) - (height/2));
		
		//centering
		$("#zoom").css({
		"position": "absolute",
		"top": fromTop,
		"left": newLeft
		});
		
		//only need force for IE6
		$("#zoom_overlay").css({
		"height": windowHeight
		});
	
	}
	
	
	
});


 //  json2-min 

if(!this.JSON){JSON=function(){function f(n){return n<10?'0'+n:n;}
Date.prototype.toJSON=function(key){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapeable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapeable.lastIndex=0;return escapeable.test(string)?'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==='string'){return c;}
return'\\u'+('0000'+
(+(a.charCodeAt(0))).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(typeof value.length==='number'&&!(value.propertyIsEnumerable('length'))){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
return{stringify:function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});},parse:function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+
(+(a.charCodeAt(0))).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');}};}();}

 //  community/featureComment 

NPR.community.featureCommentPartOne = function(commentKeyAsString) {
    try {
        var requestBatch = new RequestBatch();

        // We need to get the comment object itself to continue 
        var commentKey = new CommentKey(commentKeyAsString);

        requestBatch.AddToRequest(commentKey);
        
        requestBatch.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.featureCommentPartTwo);
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed to feature comment ' + commentKeyAsString + ' on story page ID: ' + NPR.community.storyId, 'NPR.community.featureCommentPartOne', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.featureCommentPartTwo = function(responseBatch) {
    try {
        if (responseBatch.Responses.length > 0) {
            var requestBatch = new RequestBatch();

            var comment = responseBatch.Responses[0].Comment;
            if (comment === null || comment === undefined) {
                NPR.messaging.warning('Failed to get a comment when trying to feature comment on story page ID: ' + NPR.community.storyId + ' msg: ' + responseBatch.Messages[0].Message, 'NPR.community.featureCommentPartTwo', NPR.messaging.constants.COMMUNITY_JS_ERROR);
                return;
            }            
            comment.CommentBody = $('#comm').val();
            var jsonComment = YAHOO.lang.JSON.stringify(comment);
            var allFeaturedListItem = new UpdateCustomItemAction(new CustomItemKey(comment.CommentKey.Key), 
                                       String(NPR.community.storyId), 
                                       'text/json', 
                                       NPR.community.storyTitle,
                                       jsonComment,
                                       false);  // So this new Custom Item doesn't show up on anyone's persona page
            requestBatch.AddToRequest(allFeaturedListItem);

            var featuredList = new CustomCollectionKey('Featured' + String(NPR.community.storyId));

            var addToFeaturedList = new InsertIntoCollectionAction(featuredList, new CustomItemKey(comment.CommentKey.Key), 0);
            requestBatch.AddToRequest(addToFeaturedList);

            NPR.community.renderSingleFeaturedCommentsLink(comment.CommentKey.Key);

            var allFeaturedList = new InsertIntoCollectionAction(new CustomCollectionKey('Featured'),
                                       new CustomItemKey(comment.CommentKey.Key), 0);
            requestBatch.AddToRequest(allFeaturedList);
            requestBatch.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.featureCommentFinished);
        }
        else {
            NPR.messaging.warning('Failed to get even one response when trying to feature comment on story page ID: ' + NPR.community.storyId + ' msg: ' + responseBatch.Messages[0].Message, 'NPR.community.featureCommentPartTwo', NPR.messaging.constants.COMMUNITY_JS_ERROR);
        } 
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed to feature comment on story page ID: ' + NPR.community.storyId, 'NPR.community.featureCommentPartTwo', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.featureCommentFinished = function(responseBatch) {
    try {
        var message = responseBatch.Messages[0];
        if (message.Message !== 'ok') {  
            NPR.messaging.warning('Failed to create feature collection for story ID: ' + NPR.community.storyId + ' with message ' + message.Message, 'NPR.community.featureCommentFinished', NPR.messaging.constants.COMMUNITY_JS_ERROR);
        } 
        else {
            window.parent.NPR.community.loadStoryInformation(); 
        }
        NPR.community.closeTheOverlayIframe();
    }
    catch (e) {
        NPR.messaging.exception(e, 'Failed to create feature collection for story ID: ' + NPR.community.storyId, 'NPR.community.featureCommentFinished', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.requestPromoFeaturedComments = function(incStoryId) {
    try {
        var storyId = incStoryId;
        var requestBatch2 = new RequestBatch();                
        var numPerPage = 1;
        var onPage = 1;
        requestBatch2.AddToRequest(new CustomCollectionPage(new CustomCollectionKey('Featured' + String(storyId)), numPerPage, onPage, "PositionDescending"));                  
        requestBatch2.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.renderPromoFeatureCommentsLinks);
    } 
    catch (e) {
        NPR.messaging.exception(e, 'NPR.community.storyId = ' + NPR.community.storyId, 'requestPromoFeaturedComments', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.renderPromoFeatureCommentsLinks = function(responseBatch) {
    try {
        if (responseBatch === undefined || responseBatch === null || responseBatch.Responses === undefined) {
            NPR.messaging.warning('No response batch', 'renderPromoFeatureCommentsLinks', NPR.messaging.constants.COMMUNITY_JS_ERROR);
            return;
        }
        var anyFeaturedComments = false;
        if (responseBatch.Responses.length > 0) {
            var featuredCollection = responseBatch.Responses[0].CustomCollectionPage;
            if (featuredCollection !== null && featuredCollection !== undefined && featuredCollection.Items.length > 0) {
                var storyId = responseBatch.Responses[0].CustomCollectionPage.CustomCollectionKey.Key;
                storyId = storyId.split("Featured")[1];
                var containerDiv = $('#featuredCommentsPromo' + storyId);
                if(containerDiv !== null && containerDiv !== undefined) {
                    for (var f=0; f < featuredCollection.Items.length; f++) {  
                        var customItem = featuredCollection.Items[f];
                        if (customItem.CustomItem === undefined) {
                            continue;
                        }
                        
                        var comment = JSON.parse(customItem.CustomItem.Content);                        
                        var newCommentHtml = '<div class="buckettop">&nbsp;</div>';
                        newCommentHtml += '<div class="bucket">';
                        newCommentHtml += '<p>' + NPR.community.urldecode(comment.CommentBody) + '</p>';
                        newCommentHtml += '</div>';
                        newCommentHtml += '<div class="bucketbottom">&nbsp;</div>';
                        newCommentHtml += '<p class="byline">Comment from '; 
                        newCommentHtml += '<a href="/templates/community/persona.php?uid=' + comment.Author.UserKey.Key + '">';
                        newCommentHtml += comment.Author.DisplayName + '</a> on</p>';  
                        containerDiv.append(newCommentHtml);
                        anyFeaturedComments = true;
                    }
                }    
            }
        }
        else {
            NPR.messaging.warning('No featured comments in promoted story', 'renderPromoFeatureCommentsLinks', NPR.messaging.constants.PLUCK_STORY_PAGE_COMMENTING_ERROR);
        }
    } 
    catch (e) {
        NPR.messaging.exception(e, 'responseBatch.Responses.length = ' + responseBatch.Responses.length + ' and first message from pluck = ' + responseBatch.Messages[0].Message, 'renderPromoFeatureCommentsLinks', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
};

NPR.community.populatePromoStoryCommentCount = function(storyId) {
    var requestBatch = new RequestBatch();
    
    var articleKey = new ArticleKey(String(storyId));
    requestBatch.AddToRequest(articleKey);
    
    requestBatch.BeginRequest(NPR.community.sitelifeServerURL, NPR.community.renderPromoStoryCommentCount);
}

NPR.community.renderPromoStoryCommentCount = function(responseBatch) {
    try {
        if (responseBatch === undefined || 
            responseBatch === null || 
            responseBatch.Responses === undefined) {
            
            NPR.messaging.warning('No response batch', 'renderPromoStoryCommentCount', NPR.messaging.constants.COMMUNITY_JS_ERROR);
            return;
        }
        
        if (responseBatch.Responses.length > 0) {
            var article = responseBatch.Responses[0].Article;
            var numComments = article.Comments.NumberOfComments;
            var storyId = article.ArticleKey.Key;
            
            var commentCntHref = document.getElementById('promoCom' + storyId);
            if(commentCntHref !== null && commentCntHref !== undefined) {
                commentCntHref.innerHTML = numComments + ' Comments';
            }
        }
    } catch (e) {
        NPR.messaging.exception(e, 'renderPromoStoryCommentCount Data: responseBatch length = ' + responseBatch.Responses.length, 'NPR.community.renderPromoStoryCommentCount', NPR.messaging.constants.COMMUNITY_JS_ERROR);
    }
}

 //  programHeader 

$(document).ready(function() {
	try {
		var subHeader = "";
		if($('#headerLocation,#storyspantheme01')) {
			var progHeaders = $('#headerLocation .progheader, #storyspantheme01 .progheader');
			if(progHeaders.length > 0) {
				var progHeader = progHeaders[0];
				var headerLinks = progHeader.getElementsByTagName('li');
				if(headerLinks.length > 0) {
					var currentUrl = document.location.href;
					var pound = currentUrl.indexOf('#');
					if(pound > -1)
					{
						currentUrl = currentUrl.substr(0, pound);
					}
					var testUrl = currentUrl;
					
					for(var i = 0; i < headerLinks.length; i++) {
						var links = headerLinks[i].getElementsByTagName('a');
						if(links[0]) {
							var tempUrl = links[0].href;
							if(testUrl.indexOf(tempUrl) > -1) {
								headerLinks[i].className = 'selected';
								if(links[0].childNodes.length > 0) {
									if(links[0].childNodes[0].nodeValue && links[0].childNodes[0].nodeValue != "") {	
										subHeader = links[0].childNodes[0].nodeValue;
									}
								}
								break;
							}
						}
					}
				}
			}
		}
		
		if(subHeader != "") {
			if($('#headerLocation,#storyspantheme01')) {
				$('#headerLocation .progheader h1:first, #storyspantheme01 .progheader h1:first').append(' <span class="sub">' + subHeader + '</span>');
			}
		}
	} catch(e) {
		NPR.messaging.exception(e, 'programHeader.js', '$(document).ready', NPR.messaging.constants.JAVASCRIPT_GENERAL_ISSUE);
	}
});

 //  twitterfeed 

AddNamespace("NPR.twitter");

NPR.twitter.updateList = function(twitters) {

  var statusHTML = [];
  
  try {
	  
	  if (twitters.length > 0) {
		  var divName = "twitter_list_" + twitters[0].user.screen_name;
		  
		  for (var i=0; i<twitters.length; i++){
			var username = twitters[i].user.screen_name;
			var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
			  return '<a href="'+url+'">'+url+'</a>';
			}).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
			  return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
			});
			statusHTML.push('<li><span>'+status+'</span> <a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id+'">'+NPR.twitter.relative_time(twitters[i].created_at)+'</a></li>');
		  }
		  document.getElementById(divName).innerHTML = statusHTML.join('');
	  }
  
  } catch (e) {
	NPR.messaging.exception(e, 'updating: '  + divName, 'NPR.twitter.updateList', NPR.messaging.constants.JAVASCRIPT_GENERAL_ISSUE);
  }
  
}

NPR.twitter.relative_time = function(time_value) {
	
  try {
	  
	  var values = time_value.split(" ");
	  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
	  var parsed_date = Date.parse(time_value);
	  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
	  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
	  delta = delta + (relative_to.getTimezoneOffset() * 60);
	
	  if (delta < 60) {
		return 'less than a minute ago';
	  } else if(delta < 120) {
		return 'about a minute ago';
	  } else if(delta < (60*60)) {
		return (parseInt(delta / 60)).toString() + ' minutes ago';
	  } else if(delta < (120*60)) {
		return 'about an hour ago';
	  } else if(delta < (24*60*60)) {
		return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
	  } else if(delta < (48*60*60)) {
		return '1 day ago';
	  } else {
		return (parseInt(delta / 86400)).toString() + ' days ago';
	  }
  
  } catch (e) {
    NPR.messaging.exception(e, 'time_value: '  + time_value, 'NPR.twitter.relative_time', NPR.messaging.constants.JAVASCRIPT_GENERAL_ISSUE);
  }
  
}