/** Adding another file here? Make sure that you also add it to the development cheat sheet below!! **/
/*
 * jQuery 1.2.6 - New Wave Javascript
 *
 * Copyright (c) 2008 John Resig (jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2008/07/23 14:58:33 $
 * $Rev: 5685 $
 */
(function(){var _jQuery=window.jQuery,_$=window.$;var jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);};var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,isSimple=/^.[^:#\[\.]*$/,undefined;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem){if(elem.id!=match[3])return jQuery().find(selector);return jQuery(elem);}selector=[];}}else
return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(jQuery.makeArray(selector));},jquery:"1.2.6",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value===undefined)return this[0]&&jQuery[type||"attr"](this[0],name);else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else
return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else
selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector=='string'?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)return value;values.push(value);}}return values;}else
return(this[0].value||"").replace(/\r/g,"");}return undefined;}if(value.constructor==Number)value+='';return this.each(function(){if(this.nodeType!=1)return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=jQuery.makeArray(value);jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else
this.value=value;});},html:function(value){return value==undefined?(this[0]?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)data=jQuery.data(this[0],key);return data===undefined&&parts[1]?this.data(parts[0]):data;}else
return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script"))scripts=scripts.add(elem);else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.fn.init.prototype=jQuery.fn;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}function now(){return+new Date;}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==i){target=this;--i;}for(;i<length;i++)if((options=arguments[i])!=null)for(var name in options){var src=target[name],copy=options[name];if(target===copy)continue;if(deep&&copy&&typeof copy=="object"&&!copy.nodeType)target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)target[name]=copy;}return target;};var expando="jQuery"+now(),uuid=0,windowData={},exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{};jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/^[\s[]?function/.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)script.text=data;else
script.appendChild(document.createTextNode(data));head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])jQuery.cache[id]={};if(data!==undefined)jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])break;if(!name)jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)elem.removeAttribute(expando);}delete jQuery.cache[id];}},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length==undefined){for(name in object)if(callback.apply(object[name],args)===false)break;}else
for(;i<length;)if(callback.apply(object[i++],args)===false)break;}else{if(length==undefined){for(name in object)if(callback.call(object[name],name,object[name])===false)break;}else
for(var value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else
jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;function color(elem){if(!jQuery.browser.safari)return false;var ret=defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=style.outline;style.outline="0 solid black";style.outline=save;}if(name.match(/float/i))name=styleFloat;if(!force&&style&&style[name])ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle&&!color(elem))ret=computedStyle.getPropertyValue(name);else{var swap=[],stack=[],a=elem,i=0;for(;a&&color(a);a=a.parentNode)stack.unshift(a);for(;i<stack.length;i++)if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}ret=name=="display"&&swap[stack.length-1]!=null?"none":(computedStyle&&computedStyle.getPropertyValue(name))||"";for(i=0;i<swap.length;i++)if(swap[i]!=null)stack[i].style.display=swap[i];}if(name=="opacity"&&ret=="")ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)return;if(elem.constructor==Number)elem+='';if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined,msie=jQuery.browser.msie;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem[name]=value;}if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))return elem.getAttributeNode(name).nodeValue;return elem[name];}if(msie&&notxml&&name=="style")return jQuery.attr(elem.style,"cssText",value);if(set)elem.setAttribute(name,""+value);var attr=msie&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}if(msie&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||array.split||array.setInterval||array.call)ret[0]=array;else
while(i)ret[--i]=array[i];}return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)if(array[i]===elem)return i;return-1;},merge:function(first,second){var i=0,elem,pos=first.length;if(jQuery.browser.msie){while(elem=second[i++])if(elem.nodeType!=8)first[pos++]=elem;}else
while(elem=second[i++])first[pos++]=elem;return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)if(!inv!=!callback(elems[i],i))ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!=null)ret[ret.length]=value;}return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing"}});jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return i<m[3]-0;},gt:function(a,i,m){return i>m[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false,re=quickChild,m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}if(m=="+")break;}}ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}if(m[1]==".")r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}r=tmp;}ret=r;}t=t.replace(re2,"");}}if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}if(t)ret=[];if(ret&&context==ret[0])ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)if(n.nodeType==1)n.nodeIndex=c++;merge[id]=true;}var add=false;if(first==0){if(node.nodeIndex==last)add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")fn=fn[m[2]];if(typeof fn=="string")fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=this.proxy(fn,function(){return fn.apply(this,arguments);});handler.data=data;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){if(typeof jQuery!="undefined"&&!jQuery.event.triggered)return jQuery.event.handle.apply(arguments.callee.elem,arguments);});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))for(var type in events)this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event){data.unshift({type:type,target:elem,preventDefault:function(){},stopPropagation:function(){},timeStamp:now()});data[0][expando]=true;}data[0].type=type;if(exclusive)data[0].exclusive=true;var handle=jQuery.data(elem,"handle");if(handle)val=handle.apply(elem,data);if((!fn||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val,ret,namespace,all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);namespace=event.type.split(".");event.type=namespace[0];namespace=namespace[1];all=!namespace&&!event.exclusive;handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||handler.type==namespace){event.handler=handler;event.data=handler.data;ret=handler.apply(this,arguments);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}return val;},fix:function(event){if(event[expando]==true)return event;var originalEvent=event;event={originalEvent:originalEvent};var 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 timeStamp toElement type view wheelDelta which".split(" ");for(var i=props.length;i;i--)event[props[i]]=originalEvent[props[i]];event[expando]=true;event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};event.timeStamp=event.timeStamp||now();if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=event.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},proxy:function(fn,proxy){proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;event.type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){return this[0]&&jQuery.event.trigger(type,data,this[0],false,fn);},toggle:function(fn){var args=arguments,i=1;while(i<args.length)jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else
jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}if(numStyles===undefined)numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}jQuery.ready();})();}jQuery.event.add(window,"load",jQuery.ready);}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!='string')return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=now();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{url:location.href,global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,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(s){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="GET"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");var remote=/^(?:\w+:)?\/\/([^\/?#]+)/;if(s.dataType=="script"&&type=="GET"&&remote.test(s.url)&&remote.exec(s.url)[1]!=location.host){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(s.username)xhr.open(type,s.url,s.async,s.username,s.password);else
xhr.open(type,s.url,s.async);try{if(s.data)xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;xhr.abort();return false;}if(s.global)jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xhr)&&"error"||s.ifModified&&jQuery.httpNotModified(xhr,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s.dataFilter);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else
jQuery.handleError(s,xhr,status);complete();if(s.async)xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xhr){xhr.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xhr,s]);}function complete(){if(s.complete)s.complete(xhr,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url]||jQuery.browser.safari&&xhr.status==undefined;}catch(e){}return false;},httpData:function(xhr,type,filter){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(filter)data=filter(data,type);if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
s.push(encodeURIComponent(j)+"="+encodeURIComponent(jQuery.isFunction(a[j])?a[j]():a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall),p,hidden=jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return opt.complete.call(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.call(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(elem){type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",jQuery.makeArray(array));}return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].call(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:jQuery.fx.speeds[opt.duration])||jQuery.fx.speeds.def;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.call(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.call(this.elem,this.now,this);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)if(!timers[i]())timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=now();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done)this.options.complete.call(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.extend(jQuery.fx,{speeds:{slow:600,fast:200,def:400},step:{scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}}});jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),css=jQuery.curCSS,fixed=css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||css(offsetChild,"position")=="absolute"))||(mozilla&&css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l,10)||0;top+=parseInt(t,10)||0;}return results;};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom";jQuery.fn["inner"+name]=function(){return this[name.toLowerCase()]()+num(this,"padding"+tl)+num(this,"padding"+br);};jQuery.fn["outer"+name]=function(margin){return this["inner"+name]()+num(this,"border"+tl+"Width")+num(this,"border"+br+"Width")+(margin?num(this,"margin"+tl)+num(this,"margin"+br):0);};});})();
/*
 * This now allows a random ID to be passed in to 
 * allow for inPageNavigation.js to use this.
 * See example of use at /gifts/redeem.html
 */
function getBackground(li, id) {
	var ret = "http://cloud.globalgiving.org/img/navigation/globalgiving/";
	if(li.className.match(/\bover\b/)) {
		ret += "over";
	} else if(li.className!=null && li.className.match(/\bselected\b/)) {
		ret += "selected";
	} else {
	    ret += "unselected"	
	}
	ret += "/" + id + ".png";
	return ret;
}

$(document).ready(function(){
	$("#nav_main li").bind("revert", function() {
		var li = $(this).get(0);
		$(this).find("a img").attr("src", getBackground(li, li.id));
	});

	$("#nav_main li").bind("mouseenter", function() {
		if (!$(this).hasClass("selected")) {
			$(this).addClass("over");
		}
		$(this).siblings(".over").removeClass("over");
		$("#nav_main li").trigger("revert");
	});

	$("#nav_main ul").bind("mouseleave", function() {
		if (!$(this).hasClass("selected")) {
			$("#nav_main li.over").removeClass("over");
		}
		$("#nav_main li").trigger("revert");
	});
});

/* ------------------------------------------------------------ 
   Copyright (c) 2007 ManyFutures, Inc. All rights reserved.
   ------------------------------------------------------------ 
   FILE: globalgiving.js
   DESCRIPTION: Site wide javascript functions for globalgiving.
   We try to place all (most) javascript into one file that will
   be downloaded once and cached for all pages.
   ------------------------------------------------------------ */

/* ********************* MAIN ONLOAD ** MAIN ONLOAD ***************** */

/*
 * This is the main onload function that will call others
 */

function pageOnLoad() {
	// Look for queued up Listener functions to call, now that page is loaded
	if (window.onloadListeners) {
		for ( var i = 0; i < window.onloadListeners.length; i++) {
			var func = window.onloadListeners[i];
			func.call();
		}
	}
}

function onDocumentReady() {
	// alert('The cobrand is :'+getCobrandFromURL());
	grabRefCode();
	checkLogin(); // this lives in ggajax.js
}

try {
	$(document).ready( function() {
		onDocumentReady();
	});
} catch (err) {
	// oh well
}  

function insertCurrentPageURL(){
	var currentLocation = escape(document.location); 
	var loginUrl='<a href="/dy/v2/login/form.html?andthen='+currentLocation+'">login</a>';
	var loginUrlBird ='<a href="/dy/v2/login/form.html?andthen='+currentLocation+'"><img src="/img/icons/login.gif" alt="Login" class="icon_topnav"/></a>'; 
	$('#loginRef').html(loginUrl);
	$('#loginRefBird').html(loginUrlBird);
}

/** ******************* Browse Page - Expand/Collapse Items ***************** */
function toggleItem(strElementID) {
	if (document.getElementById("panel" + strElementID).style.display == "none") {
		expandItem(strElementID);
	} else {
		collapseItem(strElementID);
	}
}

function expandItem(strElementID) {
	document.getElementById("panel" + strElementID).style.display = "block";
	document.getElementById("image" + strElementID).src = "/img/icons/collapse.gif";
}
function collapseItem(strElementID) {
	document.getElementById("panel" + strElementID).style.display = "none";
	document.getElementById("image" + strElementID).src = "/img/icons/expand.gif";
}

/* ********************* GENERAL ** GENERAL ***************** */

/*
 * Note: as of 4/18/06 - additional functionality added to the onload to: Parse
 * the query string of the URL looking for 'rf=xxxx' If found, a ggRefCode
 * Cookie is created (or overwritten) with the contents being xxxx. The cookie
 * will expire in 30 days. This is to facilitate identifying donations as from a
 * certain source. The referring URL (from a google adword, or referral from
 * another site) Must contain the query string "?rf=xxxx", to be recognized. The
 * giving cart will add this refcode to each giving cart item in the promotion
 * code.
 * 
 * Note: as of 4/25/06 - this used to be in a forcewww() onload script don't
 * need this anymore, can be handled by apache. so took out url ref code
 * checking and put in own function.
 */

function grabRefCode() {

	// Check for a referral code in the query string...
	// parse the query string on this page, and see if it has an rf=*
	// if so, put the * in cookie called ggRefCode
	var query = location.search.substring(1);
	var pairs = query.split("&"); // split pairs by ampersand 
	var noRefCode = true;
	for ( var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf("=");
		if (pos == -1)
			continue;
		var argname = pairs[i].substring(0, pos).toLowerCase();
		if (argname.toLowerCase() == "rf") {
			var value = pairs[i].substring(pos + 1);
			assignRefAndConversionCode(value, false); 
			noRefCode = false;
			//setCookie("ggRefCode", value, 365, "/"); 
			//setCookie("ggConversionCode", value, 30, "/");
			//alert(getCookie('ggConversionCode')); 
		} 
	}
	if(noRefCode){
		assignRefAndConversionCode(null, false);
	}
}

/** * For Value Outcomes * */
function showMore(projectId) {
	document.getElementById("lessValueOutcomes" + projectId).style.display = "none";
	document.getElementById("moreValueOutcomesButton" + projectId).style.display = "block";

	$("#moreValueOutcomes" + projectId).slideDown(200);
	//$("#lessValueOutcomes" + projectId).parent().hide();
	//$("#lessValueOutcomes" + projectId).parent().siblings().hide();
}

function showLess(projectId) {
	document.getElementById("lessValueOutcomes" + projectId).style.display = "block";
	document.getElementById("moreValueOutcomes" + projectId).style.display = "none";
	document.getElementById("moreValueOutcomesButton" + projectId).style.display = "none";

	//$("#lessValueOutcomes" + projectId).parent().show();
	//$("#lessValueOutcomes" + projectId).parent().siblings().show();
}


/**
 * this function will print (called from receipt.wm) the receipt but hide the
 * survey fields first, then re-show them.
 */
function printReceipt() {
	var surv = document.getElementById('rcpt_survey');
	if (surv != null) {
		surv.style.cssText = "display:none"; // hide the survey
		window.print();
		surv.style.cssText = "disiplay:block"; // un-hide the survey
	} else {
		window.print();
	}
}

/*
 * Function called on every page to check if the user is logged in or not. If
 * they are logged, we display their display name, handed to me by the cookie.
 */

// Popup a help window
function showhelp(url) {
	var width = 400;
	var height = 500;
	var name = 'HelpWindow';
	popup2(url, name, width, height);
}

/**
 * this determines a cobrand id from the location path NOTE: if cobrand id is
 * cidi, this returns gg Because this is used to determine cookie names for
 * login tokens And gg and CIDI want to share a common login All other cobrands
 * have individual login. TODO: Need to implement special code for cobrands that
 * have their own URL (ie. not globalgiving/cb/<cbid>
 */

function getCobrandFromURL() {
	var result = 'gg';
	var path = location.pathname;
	if (path == null || path.length < 3) {
		if (location.hostname.indexOf("globalgiving") > -1)
			return result;
		else if (location.hostname.indexOf("globalgrandparenting") > -1)
			return result; // same as gg
		// else its a different URL/cobrand, figure it out!!!
	} else {
		if (path.indexOf("/dy/v2/admin/") > -1) {
			var re = "dy\\/v2\\/admin\\/[^\\/]+\\/";
			var matches = path.match(re);
			if (matches != null && matches.length == 1)
				result = matches[0].substring(12, matches[0].length - 1);
			else
				result = 'gg';
		}
		else if (path.indexOf("/dy/v2/" > -1))
		{
			//TODO: we need to handle all the various combinations of cobrands on the struts2 side, along 
			//with the exception cases for gg.. but forcing to gg for now until we have a better way to deal with this
			result = 'gg';
		}
		else if (path.indexOf("/dy/") > -1) {
			// find the html portion
			// var re = /(\/.*)+\/(.+)\.html/;
			var re = /[^\/]+\.html/;
			var matches = path.match(re);
			if (matches != null && matches.length == 1)
				result = matches[0].substring(0, matches[0].length - 5);
			else
				result = 'gg';
		} else if (path.indexOf("/cb/") > -1) {
			// find the cb in path
			var re = /\/cb\/(\w+)\// ;
			var matches = path.match(re);
			result = matches[1];
		}
		if (result == 'cidi')
			result = 'gg'; // cidi and gg are the same!!
	    if(result.indexOf("challenge")!=-1) // added to make sure user cookie is found if on a leaderboard
			result='gg';
		return result;
	}
}

/* ********************* COOKIES CHECK FOR LOGIN BOX ****************** */

/*
 * DISCLAIMER: THESE JAVASCRIPT FUNCTIONS ARE SUPPLIED 'AS IS', WITH NO WARRANTY
 * EXPRESSED OR IMPLIED. YOU USE THEM AT YOUR OWN RISK. NEITHER PAUL STEPHENS
 * NOR PC PLUS MAGAZINE ACCEPTS ANY LIABILITY FOR ANY LOSS OR DAMAGE RESULTING
 * FROM THEIR USE, HOWEVER CAUSED.
 * 
 * Paul Stephens' NetScape-based cookie-handling library
 * 
 * http://web.ukonline.co.uk/paul.stephens/index.htm
 * 
 * TO USE THIS LIBRARY, INSERT ITS CONTENTS IN A <script></script> BLOCK IN THE
 * <HEAD> SECTION OF YOUR WEB PAGE SOURCE, BEFORE ANY OTHER JAVASCRIPT ROUTINES.
 * 
 * Feel free to use this code, but please leave this comment block in.
 * 
 */

function setCookie(name, value, lifespan, access_path) {

	var cookietext = name + "=" + escape(value)
	if (lifespan != null) {
		var today = new Date()
		var expiredate = new Date()
		expiredate.setTime(today.getTime() + 1000 * 60 * 60 * 24 * lifespan)
		cookietext += "; expires=" + expiredate.toGMTString()
	}
	if (access_path != null) {
		cookietext += "; PATH=" + access_path
	}
	document.cookie = cookietext
	return null
}

function setDatedCookie(name, value, expire, access_path) {
	var cookietext = name + "=" + escape(value)
			+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
	if (access_path != null) {
		cookietext += "; PATH=" + access_path
	}
	document.cookie = cookietext
	return null
}

/**
 * Get the value of a cookie. If the cookie does not exist, return 'null'.
 * 
 * Use this function instead of 'getCookie()' as this function is more
 * appropriately/accurately named.
 */
function getCookieValue(Name) {
	var search = Name + "="
	var CookieString = document.cookie
	var result = null
	if (CookieString.length > 0) {
		offset = CookieString.indexOf(search)
		if (offset != -1) {
			offset += search.length
			end = CookieString.indexOf(";", offset)
			if (end == -1)
				end = CookieString.length;
			// result = CookieString.substring(offset,end);
			// alert('[getCookieValue]encoded="'+result+'",unencoded="'+decodeURIComponent(result)+'"');
			result = decodeURIComponent(CookieString.substring(offset, end))

		}
	}
	return result;
}

/**
 * Check if a cookie exists at all. Value may still be blank (i.e. an empty
 * string). Function returns a boolean - true if the cookie exists; otherwise,
 * false.
 */
function userHasCookie(CookieName) {
	var cookieValue = getCookieValue(CookieName)
	if (cookieValue == null)
		return false
	return true
}

/**
 * This function should really be called getCookieValue(), because it returns a
 * cookie's value, not a cookie object itself.
 */
function getCookie(Name) {
	return getCookieValue(Name)
}

/**
 * Get a cookie value ONLY for specified path
 */
function getCookieValue(Name, Path) {
	var search = Name + "="
	var CookieString = document.cookie
	var result = null
	if (CookieString.length > 0) {
		offset = CookieString.indexOf(search)
		if (offset != -1) {
			offset += search.length
			end = CookieString.indexOf(";", offset)
			if (end == -1)
				end = CookieString.length;
			// result = unescape(CookieString.substring(offset, end))
			// result = CookieString.substring(offset,end);
			// alert('[getCookieValue]encoded="'+result+'",unencoded="'+decodeURIComponent(result)+'"');
			result = decodeURIComponent(CookieString.substring(offset, end))

		}
	}
	return result;
}
/**
 * Remove a cookie.
 */
function deleteCookie(Name, Path) {
	setCookie(Name, "Deleted", -1, Path)
}

/* ********************* VALUE OUTCOMES ***************** */

function focusTextBox(form) {
	form.amount.focus();
}

function clearTextBox(form) {
	if (form && form.amount) {
		form.amount.value = '';
	}
}

function validateAmt(myform, elementId) {
	if (!validateNumber(myform.amount, false, 'Donation amount', true, 0, 10,
			10000)) {
		myform.amount.select();

		if (document.getElementById(elementId)) {
			if (myform.amount > 10000) {
				document.getElementById(elementId).innerHTML = "Gift cards must be less than $10,000.";
			} else {
				document.getElementById(elementId).innerHTML = "Gift cards must be at least $10.";
			}
		}
		setTimeout( function() {
			myform.amount.focus()
		}, 10);
		return false;
	} else
		return true;
}

function validateOtherAmt(f) {
	if (f.vo_id.value == -1) // validate amount?
	{
		var x = f.amount.value
		x = x.replace(",", "");
		var anum = /(^\d+$)|(^\d+\.\d+$)/
		if (anum.test(x)) {
			// alert("pass test numeric");
		} else {
			// alert("fail test numeric");
			alert("Donation amount must be a whole number greater than US $10.");
			f.amount.value = '';
			f.amount.focus();
			return false;
		}
		if (x >= 10) {
			// alert("pass test >= 10");
		} else {
			// alert("fail test >= 10");
			alert("Donation amount must be a whole number greater than US $10.");
			setTimeout( function() {
				f.amount.focus()
			}, 10);
			f.amount.focus();
			return false;
		}
	}
	return true;
}

/* ********************* EMAIL ** EMAIL ***************** */

/*
 * Functions used to mask email addresses throughout website. Variations on
 * subject line, body or email address style
 */

function mkaddrexternal(addr) {
	document.write('<a href=\"mailto:' + addr + '\">' + addr + '</a>');
}

function mkaddr5(addr, subj, body, label) {
	document.write('<a class="menutab" href=\"mailto:' + addr + '?subject='
			+ subj + '&body=' + body + '\">' + label + '</a>');
}

function mkaddr4(addr, subj, body, label) {
	site = "globalgiving.org";
	document.write('<a href=\"mailto:' + addr + '@' + site + '?subject=' + subj
			+ '&body=' + body + '\">' + label + '</a>');
}

function mkaddr3(addr, label, font) {
	site = "globalgiving.org";
	document.write('<a class=\"' + font + '\" href=\"mailto:' + addr + '@'
			+ site + '\">' + label + '</a>');
}

function mkaddr2(addr, label) {
	site = "globalgiving.org";
	document.write('<a href=\"mailto:' + addr + '@' + site + '\">' + label
			+ '</a>');
}

function mkaddr1(addr, subj) {
	site = "globalgiving.org";
	label = addr + '@' + site;
	document.write('<a href=\"mailto:' + addr + '@' + site + '?subject=' + subj
			+ '\">' + label + '</a>');
}

function mkaddr(addr) {
	site = "globalgiving.org";
	mkaddr2(addr, addr + '@' + site);
}

function protectaddr_projpage(addr, domain, label) {
	document.write('<a href=\"mailto:' + addr + '@' + domain + '\">' + label
			+ '</a>');
}

function protectaddr(addr, domain, label) {
	document.write('<a href=\"mailto:' + addr + '@' + domain + '\">' + label
			+ '</a>');
}

function protectaddr2(addr, domain) {
	document.write('<a href=\"mailto:' + addr + '@' + domain + '\">' + addr
			+ '@' + domain + '</a>');
}

function emailafriend(body, url, lbl) {
	document.write('<a href="mailto:?body=' + escape(body)
			+ 'Check it out at http://www.globalgiving.org/' + url + '">' + lbl
			+ '</a>');
}

function tellafriend(body, lbl) {
	document
			.write('<a href="mailto:?body='
					+ escape(body)
					+ 'Check it out and consider making a donation at http://www.globalgiving.org/'
					+ '\">' + lbl + '</a>');
}

function emailprofile(subject, body, url, lbl) {
	document.write('<a href="mailto:?subject=' + subject + '&body=' + body
			+ escape(url) + ' ">' + lbl + '</a>');
}

function emailsubject(addr, subject, lbl) {
	site = "globalgiving.org"
	document.write('<a href=\"mailto:' + addr + '@' + site + '?subject='
			+ subject + '">' + lbl + '</a>');
}

function emailjob(addr, subject) {
	site = "globalgiving.org"
		document.write('<a href=\"mailto:' + addr + '@' + site + '?subject='
				+ subject + '">' + addr + '@' + site + '</a>');
}

/* ********************* POP UPS ** POP UPS ***************** */

/*
 * Functions that call up a pop-up window. Settings vary for new window. all
 * force focus back to the popup
 */

// simple browser window without features
function popup(url, name, width, height) {
	settings = "toolbar=no,location=no,directories=no,"
			+ "status=no,menubar=no,scrollbars=yes," + "resizable=yes,width="
			+ width + ",height=" + height;
	var myname = name.replace(/ /g, '_'); // no spaces in window name!

	MyNewWindow = window.open(url, myname, settings);
	MyNewWindow.focus();
}

// simple browser window with only a scrollbar
function popup2(url, name, width, height) {
	var settings = "scrollbars,width=" + width + ",height=" + height;
	var myname = name.replace(/ /g, '_'); // no spaces in window name!
	MyNewWindow = window.open(url, myname, settings);
	MyNewWindow.focus();
}

// same as above but with different settings
function popup3(url, name, ht, wd) {
	settings = "toolbar=no,location=no,directories=no,"
			+ "status=no,menubar=no,scrollbars=yes," + "resizable=no,width="
			+ wd + ",height=" + ht;
	var myname = name.replace(/ /g, '_'); // no spaces in window name!
	pop = window.open(url, myname, settings);
	pop.focus();
}

// fully customizable version
function popup4(url, name, settings) {
	var myname = name.replace(/ /g, '_'); // no spaces in window name!
	pop = window.open(url, myname, settings);
	pop.focus();
}

// simple browser window without features and page position
function popup5(url, name, width, height, top, left) {
	settings = "toolbar=no,location=no,directories=no,"
			+ "status=no,menubar=no,scrollbars=1," + "resizable=yes,width="
			+ width + ",height=" + height + ",top=" + top + ",left=" + left;

	var myname = name.replace(/ /g, '_'); // no spaces in window name!
	MyNewWindow = window.open(url, myname, settings);
	MyNewWindow.focus();
}

// simple browser window with only a scrollbar and page position
function popup6(url, name, width, height, top, left) {
	settings = "toolbar=no,location=no,directories=no,"
			+ "status=no,menubar=no,scrollbars=yes," + "resizable=no,width="
			+ width + ",height=" + height + ",top=" + top + ",left=" + left;
	var myname = name.replace(/ /g, '_'); // no spaces in window name!

	MyNewWindow = window.open(url, myname, settings);
	MyNewWindow.focus();
}

/* ********************* DONATIONS ** DONATIONS ***************** */

/*
 * The following are several functions used in the donation pages. They range
 * from taking data out of the URL to display on page to creating hyperlinks to
 * giftany functions and comments for verisign.
 */

// This function lets us grab data out of the URL
function getUrlParm(url, parmname) {
	qndx = url.indexOf("?");
	if (qndx < 0)
		return null;
	parmndx = url.indexOf(parmname, qndx + 1);
	if (parmndx < 0)
		return null;
	eqndx = url.indexOf("=", parmndx);
	if (eqndx < 0)
		return null;
	termndx = url.indexOf("&", eqndx);
	if (termndx < 0) {
		termndx = url.indexOf("#", eqndx);
		if (termndx < 0) {
			return unescape(url.substring(eqndx + 1));
		}
	}
	return unescape(url.substring(eqndx + 1, termndx));
}

// Test to make sure entered donation amount is valid
function is_a_num(number) {
	var tester = number * 1;
	// Check to make sure field is not blank
	if ((number == null) || (number.length == 0)) {
		alert("Please enter a donation amount");
		return false;
	}
	// Check to make sure number is not negative or 0
	if (number < 1) {
		alert("Please enter a positive donation amount");
		return false;
	}
	// Check to make sure number is indeed a number
	if (isNaN(tester) == true) {
		alert("Please enter a valid donation amount");
		return false;
	}
	return true;
}

// Create comment field for verisign and submit verisign form
function descvalue() {
	var url = window.location.href
	// Gathering variables needed for comment field
	var projid = getUrlParm(url, "pid");
	var projtitle = getUrlParm(url, "ptitle");
	var donation = document.amt.AMOUNT.value;
	// Converting data from checkboxes into variables
	if (document.amt.ANON.checked) {
		var anonymous = "a";
	} else {
		var anonymous = "p";
	}
	if (document.amt.NEWSL.checked) {
		var newsletter = "r";
	} else {
		var newsletter = "u";
	}
	// Creating the verisign comment and description field
	document.amt.DESCRIPTION.value = (unescape(projtitle + " (" + projid + ")"));
	document.amt.COMMENT1.value = ("d:-1:" + projid + ":" + anonymous + ":"
			+ newsletter + ":" + donation);
	// Submiting form if donation amount is a valid number
	if (is_a_num(donation) == true) {
		document.amt.submit();
	}
}
function trim(pString) {
	return pString.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
function removeAllSpaces(pString) {
	return pString.replace(/\s+/g, '');
}
function removeAllCommas(pString) {
	return pString.replace(/,+/g, '');
}

/*
 * This function takes several parameters and a DOM element to validate its
 * value is a number. It will validate decimal numbers with specified precision,
 * or] whole numbers with an optional trailing ".00" to handle currency. The
 * parameters: pComponent - reference to the HTML Dom element to be validated
 * showAlert - pass in true or false to tell function whether it should set
 * focus on pComponent and display a javascript alert if no pass. pLabel - the
 * string to prepend to the error message (usually the descriptive field label).
 * pWhole - boolean (true or false) if the number to be validated is integer
 * only pPrecision - applies only if pWhole is false, the number if decimal
 * places (maximum) allowed. pMin - the minimum value allowed for this field
 * pMax - the maximum value allowed for this field
 */
function validateNumber(pComponent, showAlert, pLabel, pWhole, pPrecision,
		pMin, pMax) {
	pComponent.value = removeAllSpaces(pComponent.value);

	var amount = removeAllCommas(pComponent.value);
	var msg;
	var reFloat;
	var valFloat = parseFloat(amount);
	if (isNaN(valFloat)) // first validate entered value is a number
	{
		if (showAlert) {
			alert(pLabel + " is required to be a number between " + pMin
					+ " and " + pMax + ".");
			pComponent.select();
			setTimeout( function() {
				pComponent.focus()
			}, 10);
		}
		return false;
	}
	if (pWhole) // whole number (integer)
	{
		msg = pLabel + " must be an Integer between " + pMin + " and " + pMax
				+ ".";
		// this regexp allows optional ".00" after the number
		reFloat = /^-?[\d,]*\.?0{0,2}$/;
	} else // decimal number with pPrecision decimal places
	{
		msg = pLabel + " must be a decimal number with " + pPrecision
				+ " decimal places between " + pMin + " and " + pMax + ".";
		reFloat = new RegExp("^-?[\\d,]*\\.?\\d{0," + pPrecision + "}$");
	}
	if (!(reFloat.test(amount))) {
		if (showAlert) {
			alert(msg);
			pComponent.select();
			setTimeout( function() {
				pComponent.focus()
			}, 10);
		}
		return false;
	}
	if (valFloat < pMin || valFloat > pMax) // validate between min and max
	{
		if (showAlert) {
			alert(msg);
			pComponent.select();
			setTimeout( function() {
				pComponent.focus()
			}, 10);
		}
		return false;
	}
	return true;
}

// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersOnly(myfield, e, dec) {
	var key;
	var keychar;

	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);

	// control keys
	if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13)
			|| (key == 27))
		return true;

	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
		return true;

	// decimal point jump
	else if (dec && (keychar == ".")) {
		myfield.form.elements[dec].focus();
		return false;
	} else
		return false;
}

// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function currencyOnly(myfield, e, dec) {
	var key;
	var keychar;

	if (window.event) {
		key = window.event.keyCode;
	} else if (e) {
		key = e.which;
	} else {
		return true;
	}

	keychar = String.fromCharCode(key);

	// control keys
	if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13)
			|| (key == 27)) {
		return true;
	}
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1)) {
		return true;
	} else {
		// allow one decimal point
		if ("." == keychar || "," == keychar) {
			return true;
		} else {
			return false;
		}
	}
}

// CREATE A MAILTO URL OR MAILTO ANCHOR TAG
function createMailto(sourceForm, targetField, urlType) {
	var to = sourceForm.to.value;
	var cc = sourceForm.cc.value;
	var bcc = sourceForm.bcc.value;
	var subject = sourceForm.subject.value;
	var body = sourceForm.body.value;
	var linkText = sourceForm.linkText.value;

	if (linkText == "") {
		linkText = "Link Text";
	}

	var urltext = "";

	// IF THE VALUE IS SET, INCLUDE IT IN THE URL
	if (to != "") {
		urltext += to;
	} else {
		alert("Sorry, you must fill out the 'To' field");
		sourceForm.to.focus();
		return (1);
	}
	if (cc != "") {
		urltext = addDelimiter(urltext);
		urltext += "CC=" + cc;
	}
	if (bcc != "") {
		urltext = addDelimiter(urltext);
		urltext += "BCC=" + bcc;
	}
	if (subject != "") {
		urltext = addDelimiter(urltext);
		urltext += "Subject=" + escape(subject);
	}
	if (body != "") {
		urltext = addDelimiter(urltext);
		urltext += "Body=" + escape(body);
	}
	if (urlType == "url") {
		urltext = "mailto:" + urltext;
	} else {
		urltext = "<A HREF=\"mailto:" + urltext + "\">" + linkText + "</A>";
	}

	// PUT THE NEW URL IN THE FORM FIELD
	targetField.value = urltext;

	// GIVE THE FIELD FOCUS AND HIGHLIGHT THE TEXT --
	// TO FACILITATE EASY COPYING AND PASTING OF THE NEW URL
	targetField.focus();
	targetField.select();
	return (1);
}

// ADD THE "?" OR "&" NAME/VALUE SEPARATOR CHARACTER
function addDelimiter(inputString) {
	var inString = inputString;

	// IF '?' NOT FOUND, THEN THIS IS THE FIRST NAME/VALUE PAIR
	if (inString.indexOf("?") == -1) {
		inString += "?";
	}
	// ELSE IT'S A SUBSEQUENT NAME/VALUE PAIR, SO ADD THE '&' CHARACTER
	else {
		inString += "&";
	}
	return inString;
}

// TEST THE MAILTO URL -- ASSIGN THE URL TO THE DOCUMENT LOCATION
// TO POP UP THE MESSAGE WINDOW
function testMailto(loc) {
	var doc = loc;

	// IF MAILTO URL IS EMBEDDED IN AN ANCHOR TAG
	if (doc.indexOf("HREF=") != -1) {
		// EXTRACT THE MAILTO URL FROM THE ANCHOR TAG
		var doc = doc.substring(doc.indexOf("HREF=") + 6, doc.indexOf(">") - 1);
	}

	// ASSIGN THE MAILTO URL TO THE DOCUMENT (THIS WILL POP UP A MAIL WINDOW)
	window.location = doc;
}

function viewMailto(mailtoText) {
	alert("URL:\n\n" + mailtoText);
}


/*
 * ********************* VALIDATION FOR RECEIPT FEEDBACK SURVEY
 * *****************
 */

/**
 * Sets the Maxlength for the Text Area, use by calling this in the textarea's
 * onkeyup and onkeydown.
 */
function textCounter(field, maxlimit, displayid) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	}
	if (displayid != null && document.getElementById(displayid) != null) {
		var count = maxlimit - field.value.length;
		document.getElementById(displayid).innerHTML = count + '&nbsp;characters remaining';
	}
}

function checkboxReceiptValidate() {
	// set var checkbox_choice to false
	var checkbox_choice1 = false;
	var checkbox_choice2 = false;
	var checkbox_choice3 = false;
	var checkbox_choice4 = false;
	var checkbox_choice5 = false;
	var checkbox_choice6 = false;
	var comments_choice7 = false;
	// Check if any of the values are true
	if (document.formRecptSurvey.a1.checked) {
		checkbox_choice1 = true;
	}
	if (document.formRecptSurvey.a2.checked) {
		checkbox_choice2 = true;
	}
	if (document.formRecptSurvey.a3.checked) {
		checkbox_choice3 = true;
	}
	if (document.formRecptSurvey.a4.checked) {
		checkbox_choice4 = true;
	}
	if (document.formRecptSurvey.a5.checked) {
		checkbox_choice5 = true;
	}
	if (document.formRecptSurvey.a6.checked) {
		checkbox_choice6 = true;
	}
	if (document.formRecptSurvey.a7.value.length > 0) {
		comments_choice7 = true;
	}

	if (!checkbox_choice1 && !checkbox_choice2 && !checkbox_choice3
			&& !checkbox_choice4 && !checkbox_choice5 && !checkbox_choice6
			&& !comments_choice7) {
		alert("Please select at least one answer and/or\nprovide comments to submit your response.")
		return (false);
	}
	return (true);
}


/** ******************************** */
/*
 * Client-side access to querystring name=value pairs
 * http://adamv.com/dev/javascript/querystring Version 1.2.3 22 Jun 2005 Adam
 * Vandenberg
 */
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get = Querystring_get

	if (qs == null)
		qs = location.search.substring(1, location.search.length)

	if (qs.length == 0)
		return

		// Turn <plus> back to <space>
		// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
		qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &

	// split out each name=value pair
	for ( var i = 0; i < args.length; i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name

		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null)
		default_ = null;

	var value = this.params[key]
	if (value == null)
		value = default_;

	return value
}

// remove spaces
function removeSpaces(string) {
	return string.replace(/\s*/g, '');
}

/**
 * escape characters for json replace single characters with escaped characters:
 * replace \ with \\. \n with \\n, \r with \\r, and " with \\" So that the
 * server side can decode the string into JSONString
 */
function jsonEscape(string) {
	return string.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g,
			"\\r").replace(/"/g, '\\"');
}
/* method for determining which refcode/conversion cookie to set 
   this follows basic logic as requested by Michael 
   refcode cookie: valid 365 days, conversion code cookie: session cookie
   if (refode && no refcode cookie) set both conversion and refcode to refcode 
   if (recode && refcode cookie) only set conversioncode cookie to  new refcode
   if (no refcode) if(ref code cookie) set conversion code cookie to referrer ELSE set refcode and conversion code cookie to referrer 
   if (no refcode &&  no referrer && no cookie) do nothing
   the boolean of forceConverionCode allows to explicitely set a conversion code from a landing page
*/    
function assignRefAndConversionCode(refCode, forceConversionCode){ 
	var GG_REF_CODE ="ggRefCode";
	var GG_CONVERSION_CODE = "ggConversionCode";
	var hasRefCode = refCode!=null;   
	var hasRefCodeCookie = getCookieValue(GG_REF_CODE)!=null; 
	var hasConversionCodeCookie = forceConversionCode ? false : getCookieValue(GG_CONVERSION_CODE)!=null; 

	var refCodeValueToWrite = hasRefCodeCookie ? getCookieValue(GG_REF_CODE) : refCode;
	var conversionCodeValueToWrite = hasRefCode ? refCode : refCodeValueToWrite;

	var referrer = document.referrer; 
	var notGG =  referrer.indexOf("globalgiving")==-1;  
	notGG = notGG ? true : referrer.indexOf("globalgiving") > 17;   // allows for local.globalgiving and columbine.globalgiving to be detected
	if(!hasRefCode){ 
		if(!referrer=="" && notGG) {
			//alert("referred from: " + document.referrer); 
			refCodeValueToWrite = hasRefCodeCookie ? getCookieValue(GG_REF_CODE) : referrer;
			conversionCodeValueToWrite = referrer;   	   
		} 
	} 
	if(notGG && !hasRefCodeCookie && refCodeValueToWrite != null){
		setUnescapedCookie(GG_REF_CODE, refCodeValueToWrite, 365, "/");  
		//alert("set ref code cookie, \ncode=" + getCookieValue(GG_CONVERSION_CODE)+ " refocode="+getCookieValue(GG_REF_CODE));
	}
	if(notGG && conversionCodeValueToWrite != null)  { 
		setUnescapedCookie(GG_CONVERSION_CODE, conversionCodeValueToWrite, null, "/");
		//alert("set conversion code cookie, \ncode=" + getCookieValue(GG_CONVERSION_CODE)+ " refocode="+getCookieValue(GG_REF_CODE)); 
	}
	// this is a conditional to make sure we convert 
	// the current refcode cookie to a 1 year cookie
	var now = new Date();
	var cutOffDate = new Date(2009,4,15);
	var forceRefCodeCookie = now < cutOffDate;
	if(notGG && hasRefCodeCookie && forceRefCodeCookie){
		setUnescapedCookie(GG_REF_CODE, getCookieValue(GG_REF_CODE), 365, "/"); 	
	}
}
function setUnescapedCookie(name, value, lifespan, access_path) {

	var cookietext = name + "=" + value
	if (lifespan != null) {
		var today = new Date()
		var expiredate = new Date()
		expiredate.setTime(today.getTime() + 1000 * 60 * 60 * 24 * lifespan)
		cookietext += "; expires=" + expiredate.toGMTString()
	}
	if (access_path != null) {
		cookietext += "; PATH=" + access_path
	}
	document.cookie = cookietext
	return null
}

/** 
 *
 * ajax toolkit for globalgiving
 * @author srogers
 * @since 05/01/2006
 *
 * encapsulate all code for Ajax calls in object
 * DEPENDS ON JQUERY, so that script lib must also be included to use:
 * jquery-1.2.5.js
 * 
 */
 
/**
 * Create Array to hold events to fire upon window.onload
 * @see globalgiving.js pageOnLoad() method
 */ 
window.onloadListeners=new Array();
window.addOnloadListener = function(listener) {
  window.onloadListeners[window.onloadListeners.length]=listener;
}

/*****************************************************************
 *  CALLBACK FUNCTIONS
 *****************************************************************/

/**
 * callback function to load login info
 */
function showLogin(loginmsg)
{
	$(".loginInfo").remove();
	
//  alert('In showLogin()');
  var status = loginmsg.getElementsByTagName("status")[0].firstChild.nodeValue;
  if (status=='SUCCESS')
  {
  	// process login "name" from cookie
  	var name = getCookieValue(getCobrandFromURL()+'LoginName');
  	setLoggedIn(name);
	var loginInfo = loginmsg.getElementsByTagName("loginInfo");
	if (loginInfo != null)
	{
	
		var createdPeLink = false;
		var toAppend="";
		for(var pos=0;pos < loginInfo.length;pos++)
		{
			var dynLabel = loginInfo[pos].getElementsByTagName("label")[0].firstChild.nodeValue;
			var dynValue = loginInfo[pos].getElementsByTagName("value")[0].firstChild.nodeValue;
			var iconVal = "";
			if (dynLabel == 'admin')
			{
				iconVal='<a href="'+ dynValue +'"><img src="/img/icons/lock.gif" class="icon_topnav" alt="Admin Console"></a>';
			}
			
			if (dynLabel == 'pe' || dynLabel == 'pe admin')
			{
				if (!createdPeLink)
				{
					if (dynLabel == 'pe')
					{
						iconVal ='<a href="'+ dynValue +'"><img src="/img/icons/form_edit.gif" class="icon_topnav" alt="project entry (pe)"></a>';	
					}
					else
					{
						iconVal ='<a href="'+ dynValue +'"><img src="/img/icons/form_edit.gif" class="icon_topnav" alt="pe admin"></a>';
					}
					
					toAppend+='<li class="loginInfo">' + iconVal + '<a href="' + dynValue + '">' + dynLabel + '</a></li>';					
					createdPeLink = true;
				}
			}
			else
			{
				toAppend+='<li class="loginInfo">' + iconVal + '<a href="' + dynValue + '">' + dynLabel + '</a></li>';
			}
		}

		$("#loggedindiv > ul").prepend(toAppend);
	}  	  	
  	
  	if(document.getElementById('dual_box')!=null)
  	{
  	   document.getElementById('overlay_login').style.cssText="display:none;";
  	   document.getElementById('dual_box').style.cssText="display:none;";
  	 }
  }
  else
  {
  	// process the failure message
  	var msg = loginmsg.getElementsByTagName("message")[0].firstChild.nodeValue;
    document.getElementById('login_err').innerHTML = msg;
  	document.getElementById('loggedindiv').style.cssText = "display:none;";
    document.getElementById('nologindiv').style.cssText = "display:inline;";
    if(document.getElementById('overlay_login')!=null)
    {
      document.getElementById('overlay_login').innerHTML=msg;
 	}
  }
  // disable the "loading" image.	
  document.getElementById('loadinglogin').style.cssText = "display:none;";
} 
/**
 * Call Back Function to logout user, after server call
 */
function logMeOut()
{
   setNotLoggedIn();
   location.href=location.protocol+"//"+location.host+"/index.html";	// redirect user to the home page.
}
/**
 * Call Back function to show that password was sent
 * expects a bit of xml here
 */
function showPasswd2(passwdmsg)
{
  var msg = passwdmsg.getElementsByTagName("message")[0].firstChild.nodeValue;
  document.getElementById('login_err').innerHTML = msg;
  // disable the "loading" image.	
  //document.getElementById('loadinglogin').style.cssText = "display:none;";
}
/**
 * callback function to show a vote
 */
function showVote(votemsg)
{
    var msgid = votemsg.getElementsByTagName("msgid")[0].firstChild.nodeValue;
    var result = votemsg.getElementsByTagName("result")[0].firstChild.nodeValue;
    var vote = votemsg.getElementsByTagName("vote");
    var elem = document.getElementById('message'+msgid);
    elem.innerHTML = result;
    document.getElementById('voteno'+msgid).checked=false;
    document.getElementById('voteyes'+msgid).checked=false;
    // see if the user has already voted
    if (vote && vote.length > 0)
    {
       // make the voting readonly, and redisplay the users vote
       document.getElementById('voteno'+msgid).setAttribute("disabled",true);
       document.getElementById('voteyes'+msgid).setAttribute("disabled",true);
       document.getElementById('commenttext'+msgid).setAttribute("readOnly","true");
       document.getElementById('commenttext'+msgid).style.cssText = "background-color:#D4D0C8;height:45px; width:280px;";
       document.getElementById('voteonit'+msgid).style.cssText = "display:none;";
       var answer = vote[0].getElementsByTagName("radio")[0].firstChild.nodeValue;
       var comment = vote[0].getElementsByTagName("comment")[0].firstChild.nodeValue;
       document.getElementById('vote'+answer+msgid).checked=true;
       document.getElementById('commenttext'+msgid).innerHTML = comment;
       document.getElementById('label'+msgid).innerHTML = "Thank you for your vote. Your comments are helpful to us.";
       //document.getElementById('commentBox'+msgid).style.cssText = "display:none;";
    }
    else  // enable the submit button
    {
       document.getElementById('voteonit'+msgid).style.cssText = "display:inline;float:left;";
    }
     document.getElementById('voteonit'+msgid).removeAttribute("disabled");
    // Now build the list of comments....
    var commentList = votemsg.getElementsByTagName("comments");
    showComments(msgid, commentList);
}
/**
 * function to show comments
 */
function showComments(msgid, comments)
{
   var cbid = document.getElementById('cbid'+msgid).value;
   removeComments(msgid);
   for (var i=0;i<comments.length;i++)
   {
      var commenttext = comments[i].getElementsByTagName("comment")[0].firstChild.nodeValue;
      var username = comments[i].getElementsByTagName("username")[0].firstChild.nodeValue;
      var userid = comments[i].getElementsByTagName("userid")[0].firstChild.nodeValue;
      var commdt = comments[i].getElementsByTagName("date")[0].firstChild.nodeValue;
      var commid = comments[i].getElementsByTagName("id")[0].firstChild.nodeValue;

      var table=document.getElementById("rptCommentsArea"+msgid);

	  var table_body = null;
	  var new_row = null;
      if (i < 3)	// only first 3 go in this table
      {
         table_body = document.getElementById("onebody"+msgid);
      }
      else
      {
         table_body = document.getElementById("morebody"+msgid);
      }      
      if (i !=0 ) // if it is NOT the first row, add a comment separator
      {
         new_row = table_body.insertRow(table_body.rows.length);
         createImageRow(new_row);
      }         
      //Displays the user name with links to their profile
      new_row = table_body.insertRow(table_body.rows.length);
      createLinkRow(new_row, username,commdt,userid);
      new_row = table_body.insertRow(table_body.rows.length);
      createCommentRow(new_row, commenttext);
      new_row = table_body.insertRow(table_body.rows.length);
      createReportRow(new_row, commid, cbid);
   } // end for loop
   if (comments.length > 3) // need to activate the show all
   {
       document.getElementById("moreLink"+msgid).style.cssText = "display:inline;position:relative;top:-4pt;";
   }  
}

function showMoreComments(msgid)
{
   var isIE = navigator.appVersion.indexOf("MSIE")>0;
   var isNav = navigator.appVersion.indexOf("Nav")>0;
   if (isIE==true)
   {
     document.getElementById("moreLink"+msgid).style.cssText = "display:none;";
     document.getElementById("moreCommentsArea"+msgid).style.cssText = "display:inline;position:relative;top:-4.5pt;";
   }
   else
   {
     document.getElementById("moreLink"+msgid).style.cssText = "display:none;";
     document.getElementById("moreCommentsArea"+msgid).style.cssText = "display:inline;position:relative;top:-7.5pt;";
   }
}

/**
 * This function is placed in an array to be called upon window.onload, to initialize
 * Progress Report votes, when a projd template is loaded.
 */
function loadVote(node, query)
{
  
   var onloadFunc = function() {
   	 $.post("/dy/prvote/loadx?"+query, function(data) { showVote(data); }, "xml" );
   }
   $(document).ready(onloadFunc);
}

/**
 * This function Sends the VOTE to the server, and has a callback using showvote
 *
 */
function castVote(msgid)
{
   var projid = document.getElementById('projid'+msgid).value;
   var cbid = document.getElementById('cbid'+msgid).value;
   var voteNo = document.getElementById('voteno'+msgid);
   var voteYes = document.getElementById('voteyes'+msgid);
   var comment = document.getElementById('commenttext'+msgid).value;
   if (!voteNo.checked && !voteYes.checked)
   {
     alert('Please take a moment to tell us if this Progress Report was valuable '
       +'by choosing "yes" or "no".\nComments are optional but welcome!  Thanks!');
     //debugButton(document.getElementById('voteonit'+msgid));
     document.getElementById('voteonit'+msgid).removeAttribute("disabled");
     return false;
   }
   else
   {
   	 // cobble a JSON object together...
   	 var jsontxt = '{ msgid: '+msgid+', cbid: "'+cbid+'", projid: '+projid+', vote: "'+(voteNo.checked?"no":"yes")+'" ';
   	 if (comment.length > 0)
   	 {
   	 	// escape the entered text for special characters that json pukes on
   	 	jsontxt = jsontxt + ', commenttext: "'+jsonEscape(comment)+'"';
   	 }
   	 jsontxt = jsontxt + '}';
   	 //alert('the jsontxt getting posted via jquery is >>>'+jsontxt+'<<<');
   	 $.post("/dy/prvote/votex2", { jsonvote: jsontxt }, function(data) { showVote(data); }, "xml" );
   	 
   }
   return true;		// dont submit the form... for now anyway.
}

/** 
 * this function checks the key pressed on an input filed, and returns
 * true if the the enter key (13), or false otherwise
 */
function isEnterKey(event)
{
  var e = event || window.event;
  var thisKey = e.charCode || e.keyCode;
  if (thisKey == 13)
  {
    return true;
  }
  else
  {
    return false;
  }
}

function checkLogin()
{
   
   // look for Session Cookie with LoginName - indicates if user has logged in.
   var cbid = getCobrandFromURL();
   var loginName = getCookieValue(cbid+'LoginName');
   if (loginName != null && userHasCookie(cbid+'_globalgive') )
   {
      // update the login box without a serverside ajax call
      setLoggedIn(loginName);
      // disable the "loading" image.	
      if (document.getElementById('loadinglogin')) {
         document.getElementById('loadinglogin').style.cssText = "display:none;";
      }
      // check if this is new registered user, and if so, send event to omniture
      if (userHasCookie('ggnewuser'))
      {
         // talk to ominture
         clearOmnVars();
         s=s_gi(s_account);  // set our omniture RSID
         s.linkTrackVars='events';
         s.linkTrackEvents='event4';
         s.events='event4';
         s.tl(this,'o','Register New User');
         deleteCookie('ggnewuser','/');
      }  
   }
   else
   {
      if (userHasCookie(cbid+'_rememberMe'))
      {
         // make serverside Ajax call and validate from this cookie
         var url = "/dy/j_spring_security_check?xautologin=true";
         $.get(url, function(data) { showLogin(data); }, "xml");
      }
      else		// User is just plain not logged in/
      {
    	 var ftlSetName = $('#login_name').text();
    	 if (ftlSetName != null && ftlSetName != "" && ftlSetName.length > 0) {
    		 setLoggedIn(ftlSetName);
    	 } else {
	         setNotLoggedIn();
    	 }

    	 // disable the "loading" image.	
    	 if (document.getElementById('loadinglogin')) {
    		 document.getElementById('loadinglogin').style.cssText = "display:none;";
    	 }
      }
   }
}

function setLoggedIn(name)
{
   //alert('encoded="'+name+'",unencoded="'+decodeURIComponent(name)+'"');
   if (document.getElementById('login_name')) {
      document.getElementById('login_name').innerHTML = 'Welcome, ' + decodeURIComponent(name) + "!";
   }
   if (document.getElementById('nologindiv')) {
      document.getElementById('nologindiv').style.cssText = "display:none;";
   }
   if (document.getElementById('loggedindiv')) {
      document.getElementById('loggedindiv').style.cssText = "display:inline;";
   }
}
function setNotLoggedIn()
{
   // future, we may name diff cookies for diff cobrands...
   var cbid = getCobrandFromURL();
   deleteCookie(cbid+'_rememberMe','/');
   deleteCookie(cbid+'_globalgive','/');
   deleteCookie(cbid+'LoginName', '/');
   if (document.getElementById('loggedindiv') != null) {
      document.getElementById('loggedindiv').style.cssText = "display:none;";
   }
   //document.getElementById('login_err').innerHTML = "";  // clear any message
   if (document.getElementById('nologindiv') != null) {
      document.getElementById('nologindiv').style.cssText = "display:inline;";
   }
}
function Logout()
{
   // enable the "loading" image.	
   document.getElementById('loadinglogin').style.cssText = "display:inline;";
   //var url = "/dy/login/gg.html?cmd=xlogout";
   var url = "/dy/j_spring_security_logout?xlogout=true";
   $.get(url, logMeOut);
   return false;
}
function sendMyPassword(fieldName)
{
   if (fieldName == null) {
      fieldName = 'login_email';
   }
   if (document.getElementById(fieldName)) {
	   var emailaddr = document.getElementById(fieldName).value;
	   if (emailaddr.length == 0)
	   {
	      alert('Please enter your email address to have your password sent to you.');
	      return false;
	   }
	   else
	   {
	      // enable the "loading" image.	
	//      document.getElementById('loadinglogin').style.cssText = "display:inline;";
	      var url = "/dy/login/gg.html?cmd=xpassword&email="+encodeURIComponent(emailaddr);
	      $.get(url, function(data) { showPasswd2(data); }, "xml");
	   }
   }
   return false;		// dont submit the form... for now anyway.
}
/**
 * This function creates the rows and cells in the table and sets their attributes
 */
function createCommentRow(row, rptComments)
{
   row.setAttribute("valign","top");
   row.setAttribute("align","left");
   var tdcell=row.insertCell(row.cells.length);
   tdcell.colSpan=2;
   tdcell.setAttribute("width","510");
  
   var lines = rptComments.split("\n");
   for (var i = 0; i < lines.length; i++)
   {
     if (i > 0)
     {
       var linebr = document.createElement("br");
       tdcell.appendChild(linebr);
     }
     var cell_data=document.createTextNode(lines[i]);
     tdcell.appendChild(cell_data);
   }
}

function createImageRow(row)
{
   var tdcell=row.insertCell(row.cells.length);
   tdcell.colSpan=2;
   var voteimage=document.createElement("img");
   voteimage.setAttribute("src","/img/css_images/vote_divide.gif");
   voteimage.setAttribute("align","middle");
   voteimage.setAttribute("height","13");
   voteimage.setAttribute("width","212");
   
   tdcell.appendChild(voteimage);
}

function createReportRow(row, commid, cbid)
{
   var tdcell=row.insertCell(row.cells.length);
   tdcell.colSpan=2;
   tdcell.setAttribute("align","right");
   var reportimg=document.createElement("img");
   reportimg.setAttribute("src","/img/icons/report_comment.gif");
   reportimg.style.cssText='margin-right:3pt;';
   reportimg.setAttribute("height","10");
   reportimg.setAttribute("width","10");
   var reportit=document.createElement("a");
   reportit.setAttribute("href","javascript:popup2('/dy/prvote/report?comment="+commid+"&cbid="+cbid+"', 'Win1', 600, 600)");
   reportit.appendChild(document.createTextNode("report this comment as inappropriate"));

   tdcell.appendChild(reportimg); 
   tdcell.appendChild(reportit);
}

/**
 * This function creates links dynamically for the user profiles 
 */
function createLinkRow(row, userName, voteDate, node)
{
   row.setAttribute("valign","top");
   row.setAttribute("align","left");
  
   //creates profile link for usernames
   var cell=row.insertCell(row.cells.length);
   cell.setAttribute("width","50%");   
   var cell_data=document.createElement("a");
   cell_data.setAttribute("id" ,node);
   var userid=cell_data.getAttribute("id");
   if (node!=-1)
   {
      cell_data.setAttribute("href","/dy/profile/gg.html?cmd=preview&ruserid="+userid);
   }
  
   cell_data.appendChild(document.createTextNode(userName));
   cell_data.setAttribute("target","_blank");
   cell.appendChild(cell_data);
   
   //sets the date
   var dtcell = row.insertCell(row.cells.length);
   dtcell.className = "";
   dtcell.setAttribute("width","50%");
   dtcell.setAttribute("align","right");
   var dtcell_data = document.createTextNode(voteDate);
   dtcell.appendChild(dtcell_data);
}


/**
 *  Login for progress report vote function 
 */
function voteLogin()
{
   var emailaddr=document.getElementById('loginEmail').value;
   var passwd=document.getElementById('loginPasswd').value;
   var rememb=false;
   
   if (emailaddr.length == 0 || passwd.length == 0)
   {
      alert('Please enter both your email address and password to login.');
      return false;
   }
   else
   {
      //var url = "/dy/login/gg.html?cmd=xlogin&email="+emailaddr+"&passwd="+escape(passwd)+"&rempass="+rememb;
	   var url = "/dy/j_spring_security_check?xlogin=true&email="+emailaddr+"&passwd="+escape(passwd)+"&rempass="+rememb;
      // send the login attempt to the server
      $.get(url, function(data) { showLogin(data); }, "xml");
   }
   return false;	
}

/**
 *  Cancel login for progress report vote function 
 */
function cancelLogin()
{
   var cancelTarget=document.getElementById('dual_box');	
   cancelTarget.style.cssText='display:none';
}


 /**
  * Signup for the progress report vote comments
  */
 function voteSignUp()
 {
    var emailaddr=document.getElementById('accountEmail').value;
    var aliasname=document.getElementById('accountAlias').value;
    var passwd=document.getElementById('accountPasswd').value;
    var passwd2=document.getElementById('accountPasswd2').value;
    var fname=document.getElementById('accountFname').value;
    var lname=document.getElementById('accountLname').value;
    var rememb=false;
    
    if(emailaddr.length==0||passwd.length==0||aliasname==0)
    {
       alert('Please make sure you have entered all the required fields correctly');
       return false;
    }
    else
    {
       var url="/dy/j_spring_security_check?show=createAccount&xlogin=true&email="+emailaddr+"&passwd="+escape(passwd)+"&passwd2="+escape(passwd2)+"&alias="+aliasname+"&fname="+fname+"&lname="+lname;
       //var url="/dy/login/gg.html?cmd=xsignup&email="+emailaddr+"&passwd="+escape(passwd)+"&passwd2="+escape(passwd2)+"&alias="+aliasname+"&fname="+fname+"&lname="+lname;
       $.get(url, function(data) { showSignUp(data); }, "xml");
    }	    
    return false;
 }
 
 function showSignUp(loginmsg)
 {
    var status = loginmsg.getElementsByTagName("status")[0].firstChild.nodeValue;
    var rememb=false;
    
    if (status=='SUCCESS')
    {
       /*var emailaddr=loginmsg.getElementsByTagName("email")[0].firstChild.nodeValue;
       var passwd=loginmsg.getElementsByTagName("passwd")[0].firstChild.nodeValue;
       //var new_url = "/dy/login/gg.html?cmd=xlogin&email="+emailaddr+"&passwd="+escape(passwd)+"&rempass="+rememb;
       var new_url = "/dy/j_spring_security_check?xlogin=true&uauser.email="+emailaddr+"&uauser.passwd="+escape(passwd)+"&rempass="+rememb;
       $.get(new_url, function(data) { showLogin(data); }, "xml");*/
    	
    	showLogin(loginmsg);
    }
    else 
    {
    	var errorMessage = loginmsg.getElementsByTagName("message")[0].firstChild.nodeValue;
    	alert("Could not create account:\n\n" +errorMessage);
    	
       /*var errors= loginmsg.getElementsByTagName("err_email");
       if (loginmsg.getElementsByTagName("err_email"))
       {
         if (loginmsg.getElementsByTagName("err_email").length>=1)
         {
            var erremail = loginmsg.getElementsByTagName("err_email")[0].firstChild.nodeValue;
            document.getElementById('err_email').innerHTML=erremail;
         }
         else
            document.getElementById('err_email').style.cssText="display:none";
       }
       if (loginmsg.getElementsByTagName("err_passwd"))
       {
         if (loginmsg.getElementsByTagName("err_passwd").length>=1)
         {
           var errpasswd = loginmsg.getElementsByTagName("err_passwd")[0].firstChild.nodeValue;
           document.getElementById('err_passwd').innerHTML=errpasswd;
         }
         else
             document.getElementById('err_passwd').style.cssText="display:none";
       }
       if (loginmsg.getElementsByTagName("err_lname"))
       {
          if (loginmsg.getElementsByTagName("err_lname").length>=1)
          {
            var errlname = loginmsg.getElementsByTagName("err_lname")[0].firstChild.nodeValue;
            document.getElementById("err_lname").innerHTML=errlname;
          }
          else
             document.getElementById('err_lname').style.cssText="display:none";
       }
       if (loginmsg.getElementsByTagName("err_fname"))
       {
          if (loginmsg.getElementsByTagName("err_fname").length>=1)
          {
            var errfname = loginmsg.getElementsByTagName("err_fname")[0].firstChild.nodeValue;
            document.getElementById("err_fname").innerHTML=errfname;
          }
          else
            document.getElementById('err_fname').style.cssText="display:none";
       }
       if (loginmsg.getElementsByTagName("err_alias"))
       {
         if (loginmsg.getElementsByTagName("err_alias").length>=1)
         {
            var erralias = loginmsg.getElementsByTagName("err_alias")[0].firstChild.nodeValue;
            document.getElementById("err_alias").innerHTML=erralias;
         }
         else
            document.getElementById('err_alias').style.cssText="display:none";
       }
       if (loginmsg.getElementsByTagName("err_passwd2"))
       {
         if (loginmsg.getElementsByTagName("err_passwd2").length>=1)
         {
            var errpasswd2=loginmsg.getElementsByTagName("err_passwd2")[0].firstChild.nodeValue; 
            document.getElementById("err_passwd2").innerHTML=errpasswd2;
         }
         else
            document.getElementById('err_passwd2').style.cssText="display:none";
       }*/
    }
 }
/**
 * Checks to see if the user is logged in 
 */	
function checkLog(msgid,e)
{
   var cbid = getCobrandFromURL();
   var loginName = getCookieValue(cbid+'LoginName');
   var targetID=document.getElementById('dual_box');
   if (loginName != null && userHasCookie(cbid+'_globalgive') )
   {
     return castVote(msgid);
   }
   else 
   {
   	 alertCoord(e);
     document.getElementById('voteonit'+msgid).removeAttribute("disabled");
   }
   return false;
 }

/**
 * returns the x and y coordinates of the cursor
 */
function alertCoord(e) 
{
	 var targetID=document.getElementById('dual_box');
	 var ieflag;
	 if ( !e ) 
	 {
	   if ( window.event ) 
	   {
	      //Internet Explorer
	      e = window.event;
	    } 
	    else 
	    {
	      //total failure, we have no way of referencing the event
	      return;
	    }
	  }
	  if ( typeof( e.pageX ) == 'number' ) 
	  {
	    //most browsers
	    ieflag=false;
	    var xcoord = e.pageX;
	    var ycoord = e.pageY;
	  }
	  else if ( typeof( e.clientX ) == 'number' ) 
	  {
	    ieflag=true;
	    var xcoord = e.clientX;
	    var ycoord = e.clientY;
	    var badOldBrowser = ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) ||
	     ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ||
	     ( navigator.vendor == 'KDE' )
	  }
	  if ( !badOldBrowser ) 
	  {
	    if ( document.body && 
	       ( document.body.scrollLeft || document.body.scrollTop ) ) 
	    {
	        //IE 4, 5 & 6 (in non-standards compliant mode)
	        xcoord += document.body.scrollLeft;
	        ycoord += document.body.scrollTop;
	    }
	    else if ( document.documentElement && 
	            ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
	    {
	        //IE 6 (in standards compliant mode)
	        xcoord += document.documentElement.scrollLeft;
	        ycoord += document.documentElement.scrollTop;
	     }
	     moveLogin(targetID,xcoord,ycoord,ieflag);
	   }
	   else 
	   {
	     //total failure, we have no way of obtaining the mouse coordinates
	     return;
	   }
   //window.alert('Mouse coordinates are ('+xcoord+','+ycoord+')');
}

function moveLogin(targetId,xcoord,ycoord,flag)
{
  var id=targetId;
  with(targetId.style)
  {
    display = "block";
    position = "absolute";
    if (!flag)
    {
      left = (xcoord)/2+400+"px"; // used to be 200, changed to 400 to move aside from video in project updates, geapi 20/10/2008
      top = (ycoord)/2-60+"px";
      zIndex=90;
      opacity='0.9';
    }
    else
    {
      left=(xcoord)-100+"px";
      top=(ycoord)-300+"px";
    }
  }  // end with
}


function accountCreate()
{
	var swapAccountlink=document.getElementById("dual_box_create_account_link");
	var swapbox=document.getElementById("dual_box_create_account");
	
	if (swapAccountlink.style.cssText.value=="display:none")
	{
	  swapAccountlink.style.cssText="display:inline";
	  swapbox.style.cssText="display:none";
	}
	else 
	{
	  swapAccountlink.style.cssText="display:none";
	  swapbox.style.cssText="display:inline";
	}
 }

/**
 * remove table rows from the comments display section of progress reports.
 * @param the msgid of the progress report
 */ 
function removeComments(msgid)
{
   var tbodyone=document.getElementById('onebody'+msgid);
   var tbodymore=document.getElementById('morebody'+msgid);
   while(tbodyone.rows.length > 0)
   {
      tbodyone.deleteRow(0);
   }
   while(tbodymore.rows.length > 0)
   {
      tbodymore.deleteRow(0);
   }
   return;  
}

 
// debug function
function debugButton(butt_elem)
{
   var nodes=butt_elem.childNodes;
   alert('has '+nodes.length+' children Nodes!');
   var attr = butt_elem.attributes;
   alert('has '+attr.length+' attributes!');
   alert('butt_elem isdisabled='+butt_elem.isDisabled);
}


/*
 * jQuery blockUI plugin
 * Version 2.10 (10/22/2008)
 * @requires jQuery v1.2.3 or later
 *
 * Examples at: http://malsup.com/jquery/block/
 * Copyright (c) 2007-2008 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
 */

;(function($) {

if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
    alert('blockUI requires jQuery v1.2.3 or later!  You are using v' + $.fn.jquery);
    return;
}

// global $ methods for blocking/unblocking the entire page
$.blockUI   = function(opts) { install(window, opts); };
$.unblockUI = function(opts) { remove(window, opts); };

// plugin method for blocking element content
$.fn.block = function(opts) {
    return this.each(function() {
        if ($.css(this,'position') == 'static')
            this.style.position = 'relative';
        if ($.browser.msie) 
            this.style.zoom = 1; // force 'hasLayout'
        install(this, opts);
    });
};

// plugin method for unblocking element content
$.fn.unblock = function(opts) {
    return this.each(function() {
        remove(this, opts);
    });
};

$.blockUI.version = 2.09; // 2nd generation blocking at no extra cost!

// override these in your code to change the default behavior and style
$.blockUI.defaults = {
    // message displayed when blocking (use null for no message)
    message:  '<h1>Please wait...</h1>',
    
    // styles for the message when blocking; if you wish to disable
    // these and use an external stylesheet then do this in your code:
    // $.blockUI.defaults.css = {};
    css: { 
        padding:        0,
        margin:         0,
        width:          '30%', 
        top:            '40%', 
        left:           '35%', 
        textAlign:      'center', 
        color:          '#000', 
        border:         '3px solid #aaa',
        backgroundColor:'#fff',
        cursor:         'wait'
    },
    
    // styles for the overlay
    overlayCSS:  { 
        backgroundColor:'#000', 
        opacity:        '0.6' 
    },
    
    // z-index for the blocking overlay
    baseZ: 1000,
    
    // set these to true to have the message automatically centered
    centerX: true, // <-- only effects element blocking (page block controlled via css above)
    centerY: true,
    
    // allow body element to be stetched in ie6; this makes blocking look better
    // on "short" pages.  disable if you wish to prevent changes to the body height
    allowBodyStretch: true,
    
    // be default blockUI will supress tab navigation from leaving blocking content;
    constrainTabKey: true,
    
    // fadeOut time in millis; set to 0 to disable fadeout on unblock
    fadeOut:  400,
    
    // if true, focus will be placed in the first available input field when
    // page blocking
    focusInput: true,
    
    // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
    applyPlatformOpacityRules: true,
    
    // callback method invoked when unblocking has completed; the callback is
    // passed the element that has been unblocked (which is the window object for page
    // blocks) and the options that were passed to the unblock call:
    //     onUnblock(element, options)
    onUnblock: null,
    
    // don't ask (if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493)
    quirksmodeOffsetHack: 4
};

// private data and functions follow...

var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent);
var pageBlock = null;
var pageBlockEls = [];

function install(el, opts) {
    var full = (el == window);
    var msg = opts && opts.message !== undefined ? opts.message : undefined;
    opts = $.extend({}, $.blockUI.defaults, opts || {});
    opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
    var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
    msg = msg === undefined ? opts.message : msg;

    // remove the current block (if there is one)
    if (full && pageBlock) 
        remove(window, {fadeOut:0}); 
    
    // if an existing element is being used as the blocking content then we capture
    // its current place in the DOM (and current display style) so we can restore
    // it when we unblock
    if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
        var node = msg.jquery ? msg[0] : msg;
        var data = {};
        $(el).data('blockUI.history', data);
        data.el = node;
        data.parent = node.parentNode;
        data.display = node.style.display;
        data.position = node.style.position;
        data.parent.removeChild(node);
    }
    
    var z = opts.baseZ;
    
    // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
    // layer1 is the iframe layer which is used to supress bleed through of underlying content
    // layer2 is the overlay layer which has opacity and a wait cursor
    // layer3 is the message content that is displayed while blocking
    
    var lyr1 = ($.browser.msie) ? $('<iframe class="blockUI" style="z-index:'+ z++ +';border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="javascript:false;"></iframe>')
                                : $('<div class="blockUI" style="display:none"></div>');
    var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ z++ +';cursor:default;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
    var lyr3 = full ? $('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';position:fixed"></div>')
                    : $('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');

    // if we have a message, style it
    if (msg) 
        lyr3.css(css);

    // style the overlay
    if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform))) 
        lyr2.css(opts.overlayCSS);
    lyr2.css('position', full ? 'fixed' : 'absolute');
    
    // make iframe layer transparent in IE
    if ($.browser.msie) 
        lyr1.css('opacity','0.0');

    $([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
    
    // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
    var expr = $.browser.msie && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
    if (ie6 || expr) {
        // give body 100% height
        if (full && opts.allowBodyStretch && $.boxModel)
            $('html,body').css('height','100%');

        // fix ie6 issue when blocked element has a border width
        if ((ie6 || !$.boxModel) && !full) {
            var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
            var fixT = t ? '(0 - '+t+')' : 0;
            var fixL = l ? '(0 - '+l+')' : 0;
        }

        // simulate fixed position
        $.each([lyr1,lyr2,lyr3], function(i,o) {
            var s = o[0].style;
            s.position = 'absolute';
            if (i < 2) {
                full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"')
                     : s.setExpression('height','this.parentNode.offsetHeight + "px"');
                full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
                     : s.setExpression('width','this.parentNode.offsetWidth + "px"');
                if (fixL) s.setExpression('left', fixL);
                if (fixT) s.setExpression('top', fixT);
            }
            else if (opts.centerY) {
                if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
                s.marginTop = 0;
            }
        });
    }
    
    // show the message
    lyr3.append(msg).show();
    if (msg && (msg.jquery || msg.nodeType))
        $(msg).show();

    // bind key and mouse events
    bind(1, el, opts);
        
    if (full) {
        pageBlock = lyr3[0];
        pageBlockEls = $(':input:enabled:visible',pageBlock);
        if (opts.focusInput)
            setTimeout(focus, 20);
    }
    else
        center(lyr3[0], opts.centerX, opts.centerY);
};

// remove the block
function remove(el, opts) {
    var full = el == window;
    var data = $(el).data('blockUI.history');
    opts = $.extend({}, $.blockUI.defaults, opts || {});
    bind(0, el, opts); // unbind events
    var els = full ? $('body').children().filter('.blockUI') : $('.blockUI', el);
    
    if (full) 
        pageBlock = pageBlockEls = null;

    if (opts.fadeOut) {
        els.fadeOut(opts.fadeOut);
        setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
    }
    else
        reset(els, data, opts, el);
};

// move blocking element back into the DOM where it started
function reset(els,data,opts,el) {
    els.each(function(i,o) {
        // remove via DOM calls so we don't lose event handlers
        if (this.parentNode) 
            this.parentNode.removeChild(this);
    });
    if (data && data.el) {
        data.el.style.display = data.display;
        data.el.style.position = data.position;
        data.parent.appendChild(data.el);
        $(data.el).removeData('blockUI.history');
    }
    if (typeof opts.onUnblock == 'function')
        opts.onUnblock(el,opts);
};

// bind/unbind the handler
function bind(b, el, opts) {
    var full = el == window, $el = $(el);
    
    // don't bother unbinding if there is nothing to unbind
    if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked'))) 
        return;
    if (!full) 
        $el.data('blockUI.isBlocked', b);
        
    // bind anchors and inputs for mouse and key events
    var events = 'mousedown mouseup keydown keypress click';
    b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);

// former impl...
//    var $e = $('a,:input');
//    b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
};

// event handler to suppress keyboard/mouse events when blocking
function handler(e) {
    // allow tab navigation (conditionally)
    if (e.keyCode && e.keyCode == 9) {
        if (pageBlock && e.data.constrainTabKey) {
            var els = pageBlockEls;
            var fwd = !e.shiftKey && e.target == els[els.length-1];
            var back = e.shiftKey && e.target == els[0];
            if (fwd || back) {
                setTimeout(function(){focus(back)},10);
                return false;
            }
        }
    }
    // allow events within the message content
    if ($(e.target).parents('div.blockMsg').length > 0)
        return true;
        
    // allow events for content that is not being blocked
    return $(e.target).parents().children().filter('div.blockUI').length == 0;
};

function focus(back) {
    if (!pageBlockEls) 
        return;
    var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
    if (e) 
        e.focus();
};

function center(el, x, y) {
    var p = el.parentNode, s = el.style;
    var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
    var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
    if (x) s.left = l > 0 ? (l+'px') : '0';
    if (y) s.top  = t > 0 ? (t+'px') : '0';
};

function sz(el, p) { 
    return parseInt($.css(el,p))||0; 
};

})(jQuery);

/* 	author: Georg Apitz
	version: 1.0
	date: 8/12/2008
	script to pop-up and exitSurvey modal dialog,
	in collaboration with Michael Nolan    
	modified 11/19/2008 by geapi to include session cookie
	and reduce sample rate to 5% for site wide distribution*/
$(document).ready(function() { 
  $('#okbutt').click(function() {
    $.unblockUI();
	openExitSurveyPopup();
    return false;
  }); 
  $('#cancelbutt').click(function() { 
    $.unblockUI(); 
	setCookie('surveycookie', 'no', 720, '/');
    return false; 
  }); 
});
function showExitSurveyPopUp(){
	/* KC 7/1/09: Reduced to 1% */
	var odds = 1;
	var chance = Math.floor(Math.random() * 101);
	if (chance <= odds){
		if(getCookieValue('surveycookie')==null && getCookieValue('exitSurvey')==null){
				$.blockUI({ message: $('#exitSurvey'), css: { width: '400px', background:'#f2f5f4' } }); 
		}
	}
	/*if(getCookieValue('exitSurvey')!=null){
	 	alert("already made choice for exit survey, not again!");
	}*/
	var cookietext = "exitSurvey = shown";
	document.cookie = cookietext;
}
var popupWin = null;
function openExitSurveyPopup() {
	var url = "/pop-ups/exitSurveyPopup.htm"
	popupWin = open("", "popupWin", "width=500,height=400, location=no,dependent=no,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=yes" );
	//placing a cookie valid six months in future for people who say YES
	setCookie('surveycookie', 'yes', 180, '/');
	if( !popupWin || popupWin.closed || !popupWin.doSomething ) {
		popupWin = window.open( url, "popupWin", "width=500,height=400,location=yes" );
	}
	else popupWin.focus();
}
 
jQuery.fn.supersleight = function(settings) {
	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: '/css/patches/x.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			jQuery(this).find('*').andSelf().each(function(i,obj) {
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
					self.css('position', 'relative');
				};
			});
		};
	});
};

/** Adding a file here? Add it below too! **/

/** DEVELOPMENT CHEAT SHEET: Copy and paste the following into the header where commonScripts.js is and regenerate the site **/
/**
<script type="text/javascript" language="javascript" src="/javascript/jquery/jquery-1.2.6.min.js" ></script>
<script type="text/javascript" language="javascript" src="/javascript/navigation.js"></script>
<script type="text/javascript" language="javascript" src="/javascript/globalgiving.js"></script>
<script type="text/javascript" language="javascript" src="/javascript/ggajax.js"></script>
<script type='text/javascript' language='javascript' src='/javascript/jquery/jquery.blockUI.js'></script>
<script type='text/javascript' language='javascript' src='/javascript/exitSurvey.js'></script>
**/
