/* -------------------------------------------------- *
 * ToggleVal 2.1
 * Updated: 1/16/09
 * -------------------------------------------------- *
 * Author: Aaron Kuzemchak
 * URL: http://aaronkuzemchak.com/
 * Copyright: 2008-2009 Aaron Kuzemchak
 * License: MIT License
** -------------------------------------------------- */

(function($){$.fn.toggleVal=function(theOptions){if(!theOptions||typeof(theOptions)=="object"){theOptions=$.extend({focusClass:"tv-focused",changedClass:"tv-changed",populateFrom:"default",text:null,removeLabels:false},theOptions)}else if(typeof(theOptions)=="string"&&theOptions.toLowerCase()=="destroy"){var destroy=true}return this.each(function(){if(destroy){$(this).unbind("focus.toggleval").unbind("blur.toggleval").removeData("defText");return false}var defText="";switch(theOptions.populateFrom){case"alt":defText=$(this).attr("alt");$(this).val(defText);break;case"label":defText=$("label[for='"+$(this).attr("id")+"']").text();$(this).val(defText);break;case"custom":defText=theOptions.text;$(this).val(defText);break;default:defText=$(this).val()}$(this).addClass("toggleval").data("defText",defText);if(theOptions.removeLabels==true){$("label[for='"+$(this).attr("id")+"']").remove()}$(this).bind("focus.toggleval",function(){if($(this).val()==$(this).data("defText")){$(this).val("")}$(this).addClass(theOptions.focusClass).removeClass(theOptions.changedClass)}).bind("blur.toggleval",function(){if($(this).val()==""){$(this).val($(this).data("defText"))}$(this).removeClass(theOptions.focusClass);if($(this).val()!=$(this).data("defText")){$(this).addClass(theOptions.changedClass)}else{$(this).removeClass(theOptions.changedClass)}})})}})(jQuery);



if ( navigator.userAgent.indexOf("MSIE") != -1 )
{
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{
		var ieversion = new Number(RegExp.$1);
		
		// temporarily disable IE8 until dd roundies support it.
		if ( ieversion != 8 )
		{
			/* DD Roundies */
			var DD_roundies={ns:'DD_roundies',IE6:false,IE7:false,IE8:false,IEversion:function(){if(document.documentMode!=8&&document.namespaces&&!document.namespaces[this.ns]){this.IE6=true;this.IE7=true}else if(document.documentMode==8){this.IE8=true}},querySelector:document.querySelectorAll,selectorsToProcess:[],imgSize:{},createVmlNameSpace:function(){if(this.IE6||this.IE7){document.namespaces.add(this.ns,'urn:schemas-microsoft-com:vml')}if(this.IE8){document.writeln('<?import namespace="'+this.ns+'" implementation="#default#VML" ?>')}},createVmlStyleSheet:function(){var a,printStyleSheet;a=document.createElement('style');a.setAttribute('media','screen');document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);if(a.styleSheet){a=a.styleSheet;a.addRule(this.ns+'\\:*','{behavior:url(#default#VML)}');a.addRule(this.ns+'\\:shape','position:absolute;');a.addRule('img.'+this.ns+'_sizeFinder','behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;');this.styleSheet=a;printStyleSheet=document.createElement('style');printStyleSheet.setAttribute('media','print');document.documentElement.firstChild.insertBefore(printStyleSheet,document.documentElement.firstChild.firstChild);printStyleSheet=printStyleSheet.styleSheet;printStyleSheet.addRule(this.ns+'\\:*','{display: none !important;}');printStyleSheet.addRule('img.'+this.ns+'_sizeFinder','{display: none !important;}')}else{this.styleSheet=a}},addRule:function(a,b,c){if(typeof b=='undefined'||b===null){b=0}if(b.constructor.toString().search('Array')==-1){b=b.toString().replace(/[^0-9 ]/g,'').split(' ')}for(var i=0;i<4;i++){b[i]=(!b[i]&&b[i]!==0)?b[Math.max((i-2),0)]:b[i]}if(this.styleSheet){if(this.styleSheet.addRule){var d=a.split(',');for(var i=0;i<d.length;i++){this.styleSheet.addRule(d[i],'behavior:expression(DD_roundies.roundify.call(this, ['+b.join(',')+']))')}}else if(c){var e=b.join('px ')+'px';this.styleSheet.appendChild(document.createTextNode(a+' {border-radius:'+e+'; -moz-border-radius:'+e+';}'));this.styleSheet.appendChild(document.createTextNode(a+' {-webkit-border-top-left-radius:'+b[0]+'px '+b[0]+'px; -webkit-border-top-right-radius:'+b[1]+'px '+b[1]+'px; -webkit-border-bottom-right-radius:'+b[2]+'px '+b[2]+'px; -webkit-border-bottom-left-radius:'+b[3]+'px '+b[3]+'px;}'))}}else if(this.IE8){this.selectorsToProcess.push({'selector':a,'radii':b})}},readPropertyChanges:function(a){switch(event.propertyName){case'style.border':case'style.borderWidth':case'style.padding':this.applyVML(a);break;case'style.borderColor':this.vmlStrokeColor(a);break;case'style.backgroundColor':case'style.backgroundPosition':case'style.backgroundRepeat':this.applyVML(a);break;case'style.display':a.vmlBox.style.display=(a.style.display=='none')?'none':'block';break;case'style.filter':this.vmlOpacity(a);break;case'style.zIndex':a.vmlBox.style.zIndex=a.style.zIndex;break}},applyVML:function(a){a.runtimeStyle.cssText='';this.vmlFill(a);this.vmlStrokeColor(a);this.vmlStrokeWeight(a);this.vmlOffsets(a);this.vmlPath(a);this.nixBorder(a);this.vmlOpacity(a)},vmlOpacity:function(a){if(a.currentStyle.filter.search('lpha')!=-1){var b=a.currentStyle.filter;b=parseInt(b.substring(b.lastIndexOf('=')+1,b.lastIndexOf(')')),10)/100;for(var v in a.vml){a.vml[v].filler.opacity=b}}},vmlFill:function(a){if(!a.currentStyle){return}else{var b=a.currentStyle}a.runtimeStyle.backgroundColor='';a.runtimeStyle.backgroundImage='';var c=(b.backgroundColor=='transparent');var d=true;if(b.backgroundImage!='none'||a.isImg){if(!a.isImg){a.vmlBg=b.backgroundImage;a.vmlBg=a.vmlBg.substr(5,a.vmlBg.lastIndexOf('")')-5)}else{a.vmlBg=a.src}var e=this;if(!e.imgSize[a.vmlBg]){var f=document.createElement('img');f.attachEvent('onload',function(){this.width=this.offsetWidth;this.height=this.offsetHeight;e.vmlOffsets(a)});f.className=e.ns+'_sizeFinder';f.runtimeStyle.cssText='behavior:none; position:absolute; top:-10000px; left:-10000px; border:none;';f.src=a.vmlBg;f.removeAttribute('width');f.removeAttribute('height');document.body.insertBefore(f,document.body.firstChild);e.imgSize[a.vmlBg]=f}a.vml.image.filler.src=a.vmlBg;d=false}a.vml.image.filled=!d;a.vml.image.fillcolor='none';a.vml.color.filled=!c;a.vml.color.fillcolor=b.backgroundColor;a.runtimeStyle.backgroundImage='none';a.runtimeStyle.backgroundColor='transparent'},vmlStrokeColor:function(a){a.vml.stroke.fillcolor=a.currentStyle.borderColor},vmlStrokeWeight:function(a){var c=['Top','Right','Bottom','Left'];a.bW={};for(var b=0;b<4;b++){a.bW[c[b]]=parseInt(a.currentStyle['border'+c[b]+'Width'],10)||0}},vmlOffsets:function(c){var e=['Left','Top','Width','Height'];for(var d=0;d<4;d++){c.dim[e[d]]=c['offset'+e[d]]}var f=function(a,b){a.style.left=(b?0:c.dim.Left)+'px';a.style.top=(b?0:c.dim.Top)+'px';a.style.width=c.dim.Width+'px';a.style.height=c.dim.Height+'px'};for(var v in c.vml){var g=(v=='image')?1:2;c.vml[v].coordsize=(c.dim.Width*g)+', '+(c.dim.Height*g);f(c.vml[v],true)}f(c.vmlBox,false);if(DD_roundies.IE8){c.vml.stroke.style.margin='-1px';if(typeof c.bW=='undefined'){this.vmlStrokeWeight(c)}c.vml.color.style.margin=(c.bW.Top-1)+'px '+(c.bW.Left-1)+'px'}},vmlPath:function(j){var k=function(a,w,h,r,b,c,d){var e=a?['m','qy','l','qx','l','qy','l','qx','l']:['qx','l','qy','l','qx','l','qy','l','m'];b*=d;c*=d;w*=d;h*=d;var R=r.slice();for(var i=0;i<4;i++){R[i]*=d;R[i]=Math.min(w/2,h/2,R[i])}var f=[e[0]+Math.floor(0+b)+','+Math.floor(R[0]+c),e[1]+Math.floor(R[0]+b)+','+Math.floor(0+c),e[2]+Math.ceil(w-R[1]+b)+','+Math.floor(0+c),e[3]+Math.ceil(w+b)+','+Math.floor(R[1]+c),e[4]+Math.ceil(w+b)+','+Math.ceil(h-R[2]+c),e[5]+Math.ceil(w-R[2]+b)+','+Math.ceil(h+c),e[6]+Math.floor(R[3]+b)+','+Math.ceil(h+c),e[7]+Math.floor(0+b)+','+Math.ceil(h-R[3]+c),e[8]+Math.floor(0+b)+','+Math.floor(R[0]+c)];if(!a){f.reverse()}var g=f.join('');return g};if(typeof j.bW=='undefined'){this.vmlStrokeWeight(j)}var l=j.bW;var m=j.DD_radii.slice();var n=k(true,j.dim.Width,j.dim.Height,m,0,0,2);m[0]-=Math.max(l.Left,l.Top);m[1]-=Math.max(l.Top,l.Right);m[2]-=Math.max(l.Right,l.Bottom);m[3]-=Math.max(l.Bottom,l.Left);for(var i=0;i<4;i++){m[i]=Math.max(m[i],0)}var o=k(false,j.dim.Width-l.Left-l.Right,j.dim.Height-l.Top-l.Bottom,m,l.Left,l.Top,2);var p=k(true,j.dim.Width-l.Left-l.Right+1,j.dim.Height-l.Top-l.Bottom+1,m,l.Left,l.Top,1);j.vml.color.path=o;j.vml.image.path=p;j.vml.stroke.path=n+o;this.clipImage(j)},nixBorder:function(a){var s=a.currentStyle;var b=['Top','Left','Right','Bottom'];for(var i=0;i<4;i++){a.runtimeStyle['padding'+b[i]]=(parseInt(s['padding'+b[i]],10)||0)+(parseInt(s['border'+b[i]+'Width'],10)||0)+'px'}a.runtimeStyle.border='none'},clipImage:function(e){var f=DD_roundies;if(!e.vmlBg||!f.imgSize[e.vmlBg]){return}var g=e.currentStyle;var h={'X':0,'Y':0};var i=function(a,b){var c=true;switch(b){case'left':case'top':h[a]=0;break;case'center':h[a]=0.5;break;case'right':case'bottom':h[a]=1;break;default:if(b.search('%')!=-1){h[a]=parseInt(b,10)*0.01}else{c=false}}var d=(a=='X');h[a]=Math.ceil(c?((e.dim[d?'Width':'Height']-(e.bW[d?'Left':'Top']+e.bW[d?'Right':'Bottom']))*h[a])-(f.imgSize[e.vmlBg][d?'width':'height']*h[a]):parseInt(b,10));h[a]+=1};for(var b in h){i(b,g['backgroundPosition'+b])}e.vml.image.filler.position=(h.X/(e.dim.Width-e.bW.Left-e.bW.Right+1))+','+(h.Y/(e.dim.Height-e.bW.Top-e.bW.Bottom+1));var j=g.backgroundRepeat;var c={'T':1,'R':e.dim.Width+1,'B':e.dim.Height+1,'L':1};var k={'X':{'b1':'L','b2':'R','d':'Width'},'Y':{'b1':'T','b2':'B','d':'Height'}};if(j!='repeat'){c={'T':(h.Y),'R':(h.X+f.imgSize[e.vmlBg].width),'B':(h.Y+f.imgSize[e.vmlBg].height),'L':(h.X)};if(j.search('repeat-')!=-1){var v=j.split('repeat-')[1].toUpperCase();c[k[v].b1]=1;c[k[v].b2]=e.dim[k[v].d]+1}if(c.B>e.dim.Height){c.B=e.dim.Height+1}}e.vml.image.style.clip='rect('+c.T+'px '+c.R+'px '+c.B+'px '+c.L+'px)'},pseudoClass:function(a){var b=this;setTimeout(function(){b.applyVML(a)},1)},reposition:function(a){this.vmlOffsets(a);this.vmlPath(a)},roundify:function(b){this.style.behavior='none';if(!this.currentStyle){return}else{var c=this.currentStyle}var d={BODY:false,TABLE:false,TR:false,TD:false,SELECT:false,OPTION:false,TEXTAREA:false};if(d[this.nodeName]===false){return}var e=this;var f=DD_roundies;this.DD_radii=b;this.dim={};var g={resize:'reposition',move:'reposition'};if(this.nodeName=='A'){var i={mouseleave:'pseudoClass',mouseenter:'pseudoClass',focus:'pseudoClass',blur:'pseudoClass'};for(var a in i){g[a]=i[a]}}for(var h in g){this.attachEvent('on'+h,function(){f[g[h]](e)})}this.attachEvent('onpropertychange',function(){f.readPropertyChanges(e)});var j=function(a){a.style.zoom=1;if(a.currentStyle.position=='static'){a.style.position='relative'}};j(this.offsetParent);j(this);this.vmlBox=document.createElement('ignore');this.vmlBox.runtimeStyle.cssText='behavior:none; position:absolute; margin:0; padding:0; border:0; background:none;';this.vmlBox.style.zIndex=c.zIndex;this.vml={'color':true,'image':true,'stroke':true};for(var v in this.vml){this.vml[v]=document.createElement(f.ns+':shape');this.vml[v].filler=document.createElement(f.ns+':fill');this.vml[v].appendChild(this.vml[v].filler);this.vml[v].stroked=false;this.vml[v].style.position='absolute';this.vml[v].style.zIndex=c.zIndex;this.vml[v].coordorigin='1,1';this.vmlBox.appendChild(this.vml[v])}this.vml.image.fillcolor='none';this.vml.image.filler.type='tile';this.parentNode.insertBefore(this.vmlBox,this);this.isImg=false;if(this.nodeName=='IMG'){this.isImg=true;this.style.visibility='hidden'}setTimeout(function(){f.applyVML(e)},1)}};try{document.execCommand("BackgroundImageCache",false,true)}catch(err){}DD_roundies.IEversion();DD_roundies.createVmlNameSpace();DD_roundies.createVmlStyleSheet();if(DD_roundies.IE8&&document.attachEvent&&DD_roundies.querySelector){document.attachEvent('onreadystatechange',function(){if(document.readyState=='complete'){var d=DD_roundies.selectorsToProcess;var e=d.length;var f=function(a,b,c){setTimeout(function(){DD_roundies.roundify.call(a,b)},c*100)};for(var i=0;i<e;i++){var g=document.querySelectorAll(d[i].selector);var h=g.length;for(var r=0;r<h;r++){if(g[r].nodeName!='INPUT'){f(g[r],d[i].radii,r)}}}}})}
			;;
			

			/*
			 * Setup page + attach event handlers
			 */
			
			if ($.browser.msie) {
			  DD_roundies.addRule(".corner-dd-all", "5px 5px 5px 5px")
			  DD_roundies.addRule(".corner-dd-top", "5px 5px 0 0");
			  DD_roundies.addRule(".corner-dd-top-left", "5px 0 0 0");
			  DD_roundies.addRule(".corner-dd-bottom", "0 0 5px 5px");
			  DD_roundies.addRule(".corner-dd-middle", "0");
			}
		}
	}
}


// cycle
(function(D){var A="Lite-1.0";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var I=D(this);var J=E.slideExpr?D(E.slideExpr,this):I.children();var G=J.get();if(G.length<2){if(window.console&&window.console.log){window.console.log("terminating; too few slides: "+G.length)}return }var H=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?I.metadata():D.meta?I.data():{});H.before=H.before?[H.before]:[];H.after=H.after?[H.after]:[];H.after.unshift(function(){H.busy=0});var F=this.className;H.width=parseInt((F.match(/w:(\d+)/)||[])[1])||H.width;H.height=parseInt((F.match(/h:(\d+)/)||[])[1])||H.height;H.timeout=parseInt((F.match(/t:(\d+)/)||[])[1])||H.timeout;if(I.css("position")=="static"){I.css("position","relative")}if(H.width){I.width(H.width)}if(H.height&&H.height!="auto"){I.height(H.height)}var K=0;J.css({position:"absolute",top:0,left:0}).hide().each(function(M){D(this).css("z-index",G.length-M)});D(G[K]).css("opacity",1).show();if(D.browser.msie){G[K].style.removeAttribute("filter")}if(H.fit&&H.width){J.width(H.width)}if(H.fit&&H.height&&H.height!="auto"){J.height(H.height)}if(H.pause){I.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}D.fn.cycle.transitions.fade(I,J,H);J.each(function(){var M=D(this);this.cycleH=(H.fit&&H.height)?H.height:M.height();this.cycleW=(H.fit&&H.width)?H.width:M.width()});J.not(":eq("+K+")").css({opacity:0});if(H.cssFirst){D(J[K]).css(H.cssFirst)}if(H.timeout){if(H.speed.constructor==String){H.speed={slow:600,fast:200}[H.speed]||400}if(!H.sync){H.speed=H.speed/2}while((H.timeout-H.speed)<250){H.timeout+=H.speed}}H.speedIn=H.speed;H.speedOut=H.speed;H.slideCount=G.length;H.currSlide=K;H.nextSlide=1;var L=J[K];if(H.before.length){H.before[0].apply(L,[L,L,H,true])}if(H.after.length>1){H.after[1].apply(L,[L,L,H,true])}if(H.click&&!H.next){H.next=H.click}if(H.next){D(H.next).bind("click",function(){return C(G,H,H.rev?-1:1)})}if(H.prev){D(H.prev).bind("click",function(){return C(G,H,H.rev?1:-1)})}if(H.timeout){this.cycleTimeout=setTimeout(function(){B(G,H,0,!H.rev)},H.timeout+(H.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css({opacity:0});var F=function(){G.animate({opacity:1},I.speedIn,I.easeIn,E)};J.animate({opacity:0},I.speedOut,I.easeOut,function(){J.css({display:"none"});if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").css("opacity",0);E.before.push(function(){D(this).show()})}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}})(jQuery);



$(document).ready(function() {
	$(document).pngFix();
	
	$("input[name='search_terms']").toggleVal({
		focusClass: "hinted"
	});
	
	/* remove first and last background elements */
	$("#utilsNav ul li:first-child").css("background", "none");
	$("#primaryNavigation li:last-child").css("background", "none");
	$("#footer ul li:first-child").css("background", "none");
	$("#footer ul li:first-child a").css("padding", "0 5px 0 0");

	$('#banner').cycle(
	{  
		fx: 'fade', 
		timeout: 8000, 
		speed: 2000,
		pause: 1,
		requeueTimeout: 0
	});
	
});
