//Accordion Content script: By Dynamic Drive, at http://www.dynamicdrive.com
//Created: Jan 7th, 08'
//Version 1.3: April 3rd, 08':
//**1) Script now no longer conflicts with other JS frameworks
//**2) Adds custom oninit() and onopenclose() event handlers that fire when Accordion Content instance has initialized, plus whenever a header is opened/closed
//**3) Adds support for expanding header(s) using the URL parameter (ie: http://mysite.com/accordion.htm?headerclass=0,1)

//April 9th, 08': Fixed "defaultexpanded" setting not working when page first loads

//Version 1.4: June 4th, 08':
//**1) Added option to activate a header "mouseover" instead of the default "click"
//**2) Bug persistence not working when used with jquery 1.2.6

var ddaccordion={
	
	contentclassname:{}, //object to store corresponding contentclass name based on headerclass

	expandone:function(headerclass, selected){ //PUBLIC function to expand a particular header
		this.toggleone(headerclass, selected, "expand")
	},

	collapseone:function(headerclass, selected){ //PUBLIC function to collapse a particular header
		this.toggleone(headerclass, selected, "collapse")
	},

	expandall:function(headerclass){ //PUBLIC function to expand all headers based on their shared CSS classname
		var $=jQuery
		var $headers=$('.'+headerclass)
		$('.'+this.contentclassname[headerclass]+':hidden').each(function(){
			$headers.eq(parseInt($(this).attr('contentindex'))).trigger("evt_accordion")
		})
	},

	collapseall:function(headerclass){ //PUBLIC function to collapse all headers based on their shared CSS classname
		var $=jQuery
		var $headers=$('.'+headerclass)
		$('.'+this.contentclassname[headerclass]+':visible').each(function(){
			$headers.eq(parseInt($(this).attr('contentindex'))).trigger("evt_accordion")
		})
	},

	toggleone:function(headerclass, selected, optstate){ //PUBLIC function to expand/ collapse a particular header
		var $=jQuery
		var $targetHeader=$('.'+headerclass).eq(selected)
		var $subcontent=$('.'+this.contentclassname[headerclass]).eq(selected)
		if (typeof optstate=="undefined" || optstate=="expand" && $subcontent.is(":hidden") || optstate=="collapse" && $subcontent.is(":visible"))
			$targetHeader.trigger("evt_accordion")
	},

	expandit:function($targetHeader, $targetContent, config, useractivated){
		$targetContent.slideDown(config.animatespeed, function(){config.onopenclose($targetHeader.get(0), parseInt($targetHeader.attr('headerindex')), $targetContent.css('display'), useractivated)})
		this.transformHeader($targetHeader, config, "expand")
	},

	collapseit:function($targetHeader, $targetContent, config, isuseractivated){
		$targetContent.slideUp(config.animatespeed, function(){config.onopenclose($targetHeader.get(0), parseInt($targetHeader.attr('headerindex')), $targetContent.css('display'), isuseractivated)})
		this.transformHeader($targetHeader, config, "collapse")
	},

	transformHeader:function($targetHeader, config, state){
		$targetHeader.addClass((state=="expand")? config.cssclass.expand : config.cssclass.collapse) //alternate btw "expand" and "collapse" CSS classes
		.removeClass((state=="expand")? config.cssclass.collapse : config.cssclass.expand)
		if (config.htmlsetting.location=='src'){ //Change header image (assuming header is an image)?
			$targetHeader=($targetHeader.is("img"))? $targetHeader : $targetHeader.find('img').eq(0) //Set target to either header itself, or first image within header
			$targetHeader.attr('src', (state=="expand")? config.htmlsetting.expand : config.htmlsetting.collapse) //change header image
		}
		else if (config.htmlsetting.location=="prefix") //if change "prefix" HTML, locate dynamically added ".accordprefix" span tag and change it
			$targetHeader.find('.accordprefix').html((state=="expand")? config.htmlsetting.expand : config.htmlsetting.collapse)
		else if (config.htmlsetting.location=="suffix")
			$targetHeader.find('.accordsuffix').html((state=="expand")? config.htmlsetting.expand : config.htmlsetting.collapse)
	},

	urlparamselect:function(headerclass){
		var result=window.location.search.match(new RegExp(headerclass+"=((\\d+)(,(\\d+))*)", "i")) //check for "?headerclass=2,3,4" in URL
		if (result!=null)
			result=RegExp.$1.split(',')
		return result //returns null, [index], or [index1,index2,etc], where index are the desired selected header indices
	},

	getCookie:function(Name){ 
		var re=new RegExp(Name+"=[^;]+", "i") //construct RE to search for target name/value pair
		if (document.cookie.match(re)) //if cookie found
			return document.cookie.match(re)[0].split("=")[1] //return its value
		return null
	},

	setCookie:function(name, value){
		document.cookie = name + "=" + value
	},

	init:function(config){
	document.write('<style type="text/css">\n')
	document.write('.'+config.contentclass+'{display: none}\n') //generate CSS to hide contents
	document.write('<\/style>')
	jQuery(document).ready(function($){
		ddaccordion.urlparamselect(config.headerclass)
		var persistedheaders=ddaccordion.getCookie(config.headerclass)
		ddaccordion.contentclassname[config.headerclass]=config.contentclass //remember contentclass name based on headerclass
		config.cssclass={collapse: config.toggleclass[0], expand: config.toggleclass[1]} //store expand and contract CSS classes as object properties
		config.revealtype=/^(click)|(mouseover)$/i.test(config.revealtype)? config.revealtype.replace(/mouseover/i, "mouseenter") : "click"
		config.htmlsetting={location: config.togglehtml[0], collapse: config.togglehtml[1], expand: config.togglehtml[2]} //store HTML settings as object properties
		config.oninit=(typeof config.oninit=="undefined")? function(){} : config.oninit //attach custom "oninit" event handler
		config.onopenclose=(typeof config.onopenclose=="undefined")? function(){} : config.onopenclose //attach custom "onopenclose" event handler
		var lastexpanded={} //object to hold reference to last expanded header and content (jquery objects)
		var expandedindices=ddaccordion.urlparamselect(config.headerclass) || ((config.persiststate && persistedheaders!=null)? persistedheaders : config.defaultexpanded)
		if (typeof expandedindices=='string') //test for valid cookie ('string'), invalid being null or 1st page load
			expandedindices=expandedindices.replace(/c/ig, '').split(',') //if valid, change to array value
		var $subcontents=$('.'+config["contentclass"])
		if (!(expandedindices instanceof Array)) //check for invalid expandedindices value
			expandedindices=[]
		if (config["collapseprev"] && expandedindices.length>1)
			expandedindices=[expandedindices.pop()] //return last array element as an array (for sake of jQuery.inArray())
		$('.'+config["headerclass"]).each(function(index){ //loop through all headers
			if (/(prefix)|(suffix)/i.test(config.htmlsetting.location) && $(this).html()!=""){ //add a SPAN element to header depending on user setting and if header is a container tag
				$('<span class="accordprefix"></span>').prependTo(this)
				$('<span class="accordsuffix"></span>').appendTo(this)
			}
			$(this).attr('headerindex', index+'h') //store position of this header relative to its peers
			$subcontents.eq(index).attr('contentindex', index+'c') //store position of this content relative to its peers
			var $subcontent=$subcontents.eq(index)
			if (jQuery.inArray(index+'', expandedindices)!=-1){ //check for headers that should be expanded automatically (convert index to string first)
				if (config.animatedefault==false)
					$subcontent.show()
				ddaccordion.expandit($(this), $subcontent, config, false) //Last Boolean value sets 'isuseractivated' parameter
				lastexpanded={$header:$(this), $content:$subcontent}
			}  //end check
			else{
				$subcontent.hide()
				config.onopenclose($(this).get(0), parseInt($(this).attr('headerindex')), $subcontent.css('display'), false) //Last Boolean value sets 'isuseractivated' parameter
				ddaccordion.transformHeader($(this), config, "collapse")
			}
		})
		$('.'+config["headerclass"]).bind("evt_accordion", function(){ //assign custom event handler that expands/ contacts a header
				var $subcontent=$subcontents.eq(parseInt($(this).attr('headerindex'))) //get subcontent that should be expanded/collapsed
				if ($subcontent.css('display')=="none"){
					ddaccordion.expandit($(this), $subcontent, config, true) //Last Boolean value sets 'isuseractivated' parameter
					if (config["collapseprev"] && lastexpanded.$header && $(this).get(0)!=lastexpanded.$header.get(0)){ //collapse previous content?
						ddaccordion.collapseit(lastexpanded.$header, lastexpanded.$content, config, true) //Last Boolean value sets 'isuseractivated' parameter
					}
					lastexpanded={$header:$(this), $content:$subcontent}
				}
				else{
					ddaccordion.collapseit($(this), $subcontent, config, true) //Last Boolean value sets 'isuseractivated' parameter
				}
 		})
		$('.'+config["headerclass"]).bind(config.revealtype, function(){
			if (config.revealtype=="mouseenter"){
				ddaccordion.expandone(config["headerclass"], parseInt($(this).attr("headerindex")))
			}
			else{
				$(this).trigger("evt_accordion")
				return false //cancel default click behavior
			}
		})
		config.oninit($('.'+config["headerclass"]).get(), expandedindices)
		$(window).bind('unload', function(){ //clean up and persist on page unload
			$('.'+config["headerclass"]).unbind()
			var expandedindices=[]
			$('.'+config["contentclass"]+":visible").each(function(index){ //get indices of expanded headers
				expandedindices.push($(this).attr('contentindex'))
			})
			if (config.persiststate==true){ //persist state?
				expandedindices=(expandedindices.length==0)? '-1c' : expandedindices //No contents expanded, indicate that with dummy '-1c' value?
				ddaccordion.setCookie(config.headerclass, expandedindices)
			}
		})
	})
	}
};
/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);;
/*
 * jQuery Nivo Slider v2.5.1
 * http://nivo.dev7studios.com
 *
 * Copyright 2011, Gilbert Pellegrom
 * Free to use and abuse under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * March 2010
 */

(function($){var NivoSlider=function(element,options){var settings=$.extend({},$.fn.nivoSlider.defaults,options);var vars={currentSlide:0,currentImage:'',totalSlides:0,randAnim:'',running:false,paused:false,stop:false};var slider=$(element);slider.data('nivo:vars',vars);slider.css('position','relative');slider.addClass('nivoSlider');var kids=slider.children();kids.each(function(){var child=$(this);var link='';if(!child.is('img')){if(child.is('a')){child.addClass('nivo-imageLink');link=child;}
child=child.find('img:first');}
var childWidth=child.width();if(childWidth==0)childWidth=child.attr('width');var childHeight=child.height();if(childHeight==0)childHeight=child.attr('height');if(childWidth>slider.width()){slider.width(childWidth);}
if(childHeight>slider.height()){slider.height(childHeight);}
if(link!=''){link.css('display','none');}
child.css('display','none');vars.totalSlides++;});if(settings.startSlide>0){if(settings.startSlide>=vars.totalSlides)settings.startSlide=vars.totalSlides-1;vars.currentSlide=settings.startSlide;}
if($(kids[vars.currentSlide]).is('img')){vars.currentImage=$(kids[vars.currentSlide]);}else{vars.currentImage=$(kids[vars.currentSlide]).find('img:first');}
if($(kids[vars.currentSlide]).is('a')){$(kids[vars.currentSlide]).css('display','block');}
slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');slider.append($('<div class="nivo-caption"><p></p></div>').css({display:'none',opacity:settings.captionOpacity}));var processCaption=function(settings){var nivoCaption=$('.nivo-caption',slider);if(vars.currentImage.attr('title')!=''){var title=vars.currentImage.attr('title');if(title.substr(0,1)=='#')title=$(title).html();if(nivoCaption.css('display')=='block'){nivoCaption.find('p').fadeOut(settings.animSpeed,function(){$(this).html(title);$(this).fadeIn(settings.animSpeed);});}else{nivoCaption.find('p').html(title);}
nivoCaption.fadeIn(settings.animSpeed);}else{nivoCaption.fadeOut(settings.animSpeed);}}
processCaption(settings);var timer=0;if(!settings.manualAdvance&&kids.length>1){timer=setInterval(function(){nivoRun(slider,kids,settings,false);},settings.pauseTime);}
if(settings.directionNav){slider.append('<div class="nivo-directionNav"><a class="nivo-prevNav">'+settings.prevText+'</a><a class="nivo-nextNav">'+settings.nextText+'</a></div>');if(settings.directionNavHide){$('.nivo-directionNav',slider).hide();slider.hover(function(){$('.nivo-directionNav',slider).show();},function(){$('.nivo-directionNav',slider).hide();});}
$('a.nivo-prevNav',slider).live('click',function(){if(vars.running)return false;clearInterval(timer);timer='';vars.currentSlide-=2;nivoRun(slider,kids,settings,'prev');});$('a.nivo-nextNav',slider).live('click',function(){if(vars.running)return false;clearInterval(timer);timer='';nivoRun(slider,kids,settings,'next');});}
if(settings.controlNav){var nivoControl=$('<div class="nivo-controlNav"></div>');slider.append(nivoControl);for(var i=0;i<kids.length;i++){if(settings.controlNavThumbs){var child=kids.eq(i);if(!child.is('img')){child=child.find('img:first');}
if(settings.controlNavThumbsFromRel){nivoControl.append('<a class="nivo-control" rel="'+i+'"><img src="'+child.attr('rel')+'" alt="" /></a>');}else{nivoControl.append('<a class="nivo-control" rel="'+i+'"><img src="'+child.attr('src').replace(settings.controlNavThumbsSearch,settings.controlNavThumbsReplace)+'" alt="" /></a>');}}else{nivoControl.append('<a class="nivo-control" rel="'+i+'">'+(i+1)+'</a>');}}
$('.nivo-controlNav a:eq('+vars.currentSlide+')',slider).addClass('active');$('.nivo-controlNav a',slider).live('click',function(){if(vars.running)return false;if($(this).hasClass('active'))return false;clearInterval(timer);timer='';slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');vars.currentSlide=$(this).attr('rel')-1;nivoRun(slider,kids,settings,'control');});}
if(settings.keyboardNav){$(window).keypress(function(event){if(event.keyCode=='37'){if(vars.running)return false;clearInterval(timer);timer='';vars.currentSlide-=2;nivoRun(slider,kids,settings,'prev');}
if(event.keyCode=='39'){if(vars.running)return false;clearInterval(timer);timer='';nivoRun(slider,kids,settings,'next');}});}
if(settings.pauseOnHover){slider.hover(function(){vars.paused=true;clearInterval(timer);timer='';},function(){vars.paused=false;if(timer==''&&!settings.manualAdvance){timer=setInterval(function(){nivoRun(slider,kids,settings,false);},settings.pauseTime);}});}
slider.bind('nivo:animFinished',function(){vars.running=false;$(kids).each(function(){if($(this).is('a')){$(this).css('display','none');}});if($(kids[vars.currentSlide]).is('a')){$(kids[vars.currentSlide]).css('display','block');}
if(timer==''&&!vars.paused&&!settings.manualAdvance){timer=setInterval(function(){nivoRun(slider,kids,settings,false);},settings.pauseTime);}
settings.afterChange.call(this);});var createSlices=function(slider,settings,vars){for(var i=0;i<settings.slices;i++){var sliceWidth=Math.round(slider.width()/settings.slices);if(i==settings.slices-1){slider.append($('<div class="nivo-slice"></div>').css({left:(sliceWidth*i)+'px',width:(slider.width()-(sliceWidth*i))+'px',height:'0px',opacity:'0',background:'url("'+vars.currentImage.attr('src')+'") no-repeat -'+((sliceWidth+(i*sliceWidth))-sliceWidth)+'px 0%'}));}else{slider.append($('<div class="nivo-slice"></div>').css({left:(sliceWidth*i)+'px',width:sliceWidth+'px',height:'0px',opacity:'0',background:'url("'+vars.currentImage.attr('src')+'") no-repeat -'+((sliceWidth+(i*sliceWidth))-sliceWidth)+'px 0%'}));}}}
var createBoxes=function(slider,settings,vars){var boxWidth=Math.round(slider.width()/settings.boxCols);var boxHeight=Math.round(slider.height()/settings.boxRows);for(var rows=0;rows<settings.boxRows;rows++){for(var cols=0;cols<settings.boxCols;cols++){if(cols==settings.boxCols-1){slider.append($('<div class="nivo-box"></div>').css({opacity:0,left:(boxWidth*cols)+'px',top:(boxHeight*rows)+'px',width:(slider.width()-(boxWidth*cols))+'px',height:boxHeight+'px',background:'url("'+vars.currentImage.attr('src')+'") no-repeat -'+((boxWidth+(cols*boxWidth))-boxWidth)+'px -'+((boxHeight+(rows*boxHeight))-boxHeight)+'px'}));}else{slider.append($('<div class="nivo-box"></div>').css({opacity:0,left:(boxWidth*cols)+'px',top:(boxHeight*rows)+'px',width:boxWidth+'px',height:boxHeight+'px',background:'url("'+vars.currentImage.attr('src')+'") no-repeat -'+((boxWidth+(cols*boxWidth))-boxWidth)+'px -'+((boxHeight+(rows*boxHeight))-boxHeight)+'px'}));}}}}
var nivoRun=function(slider,kids,settings,nudge){var vars=slider.data('nivo:vars');if(vars&&(vars.currentSlide==vars.totalSlides-1)){settings.lastSlide.call(this);}
if((!vars||vars.stop)&&!nudge)return false;settings.beforeChange.call(this);if(!nudge){slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');}else{if(nudge=='prev'){slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');}
if(nudge=='next'){slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');}}
vars.currentSlide++;if(vars.currentSlide==vars.totalSlides){vars.currentSlide=0;settings.slideshowEnd.call(this);}
if(vars.currentSlide<0)vars.currentSlide=(vars.totalSlides-1);if($(kids[vars.currentSlide]).is('img')){vars.currentImage=$(kids[vars.currentSlide]);}else{vars.currentImage=$(kids[vars.currentSlide]).find('img:first');}
if(settings.controlNav){$('.nivo-controlNav a',slider).removeClass('active');$('.nivo-controlNav a:eq('+vars.currentSlide+')',slider).addClass('active');}
processCaption(settings);$('.nivo-slice',slider).remove();$('.nivo-box',slider).remove();if(settings.effect=='random'){var anims=new Array('sliceDownRight','sliceDownLeft','sliceUpRight','sliceUpLeft','sliceUpDown','sliceUpDownLeft','fold','fade','boxRandom','boxRain','boxRainReverse','boxRainGrow','boxRainGrowReverse');vars.randAnim=anims[Math.floor(Math.random()*(anims.length+1))];if(vars.randAnim==undefined)vars.randAnim='fade';}
if(settings.effect.indexOf(',')!=-1){var anims=settings.effect.split(',');vars.randAnim=anims[Math.floor(Math.random()*(anims.length))];if(vars.randAnim==undefined)vars.randAnim='fade';}
vars.running=true;if(settings.effect=='sliceDown'||settings.effect=='sliceDownRight'||vars.randAnim=='sliceDownRight'||settings.effect=='sliceDownLeft'||vars.randAnim=='sliceDownLeft'){createSlices(slider,settings,vars);var timeBuff=0;var i=0;var slices=$('.nivo-slice',slider);if(settings.effect=='sliceDownLeft'||vars.randAnim=='sliceDownLeft')slices=$('.nivo-slice',slider)._reverse();slices.each(function(){var slice=$(this);slice.css({'top':'0px'});if(i==settings.slices-1){setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=50;i++;});}
else if(settings.effect=='sliceUp'||settings.effect=='sliceUpRight'||vars.randAnim=='sliceUpRight'||settings.effect=='sliceUpLeft'||vars.randAnim=='sliceUpLeft'){createSlices(slider,settings,vars);var timeBuff=0;var i=0;var slices=$('.nivo-slice',slider);if(settings.effect=='sliceUpLeft'||vars.randAnim=='sliceUpLeft')slices=$('.nivo-slice',slider)._reverse();slices.each(function(){var slice=$(this);slice.css({'bottom':'0px'});if(i==settings.slices-1){setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=50;i++;});}
else if(settings.effect=='sliceUpDown'||settings.effect=='sliceUpDownRight'||vars.randAnim=='sliceUpDown'||settings.effect=='sliceUpDownLeft'||vars.randAnim=='sliceUpDownLeft'){createSlices(slider,settings,vars);var timeBuff=0;var i=0;var v=0;var slices=$('.nivo-slice',slider);if(settings.effect=='sliceUpDownLeft'||vars.randAnim=='sliceUpDownLeft')slices=$('.nivo-slice',slider)._reverse();slices.each(function(){var slice=$(this);if(i==0){slice.css('top','0px');i++;}else{slice.css('bottom','0px');i=0;}
if(v==settings.slices-1){setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=50;v++;});}
else if(settings.effect=='fold'||vars.randAnim=='fold'){createSlices(slider,settings,vars);var timeBuff=0;var i=0;$('.nivo-slice',slider).each(function(){var slice=$(this);var origWidth=slice.width();slice.css({top:'0px',height:'100%',width:'0px'});if(i==settings.slices-1){setTimeout(function(){slice.animate({width:origWidth,opacity:'1.0'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){slice.animate({width:origWidth,opacity:'1.0'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=50;i++;});}
else if(settings.effect=='fade'||vars.randAnim=='fade'){createSlices(slider,settings,vars);var firstSlice=$('.nivo-slice:first',slider);firstSlice.css({'height':'100%','width':slider.width()+'px'});firstSlice.animate({opacity:'1.0'},(settings.animSpeed*2),'',function(){slider.trigger('nivo:animFinished');});}
else if(settings.effect=='slideInRight'||vars.randAnim=='slideInRight'){createSlices(slider,settings,vars);var firstSlice=$('.nivo-slice:first',slider);firstSlice.css({'height':'100%','width':'0px','opacity':'1'});firstSlice.animate({width:slider.width()+'px'},(settings.animSpeed*2),'',function(){slider.trigger('nivo:animFinished');});}
else if(settings.effect=='slideInLeft'||vars.randAnim=='slideInLeft'){createSlices(slider,settings,vars);var firstSlice=$('.nivo-slice:first',slider);firstSlice.css({'height':'100%','width':'0px','opacity':'1','left':'','right':'0px'});firstSlice.animate({width:slider.width()+'px'},(settings.animSpeed*2),'',function(){firstSlice.css({'left':'0px','right':''});slider.trigger('nivo:animFinished');});}
else if(settings.effect=='boxRandom'||vars.randAnim=='boxRandom'){createBoxes(slider,settings,vars);var totalBoxes=settings.boxCols*settings.boxRows;var i=0;var timeBuff=0;var boxes=shuffle($('.nivo-box',slider));boxes.each(function(){var box=$(this);if(i==totalBoxes-1){setTimeout(function(){box.animate({opacity:'1'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){box.animate({opacity:'1'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=20;i++;});}
else if(settings.effect=='boxRain'||vars.randAnim=='boxRain'||settings.effect=='boxRainReverse'||vars.randAnim=='boxRainReverse'||settings.effect=='boxRainGrow'||vars.randAnim=='boxRainGrow'||settings.effect=='boxRainGrowReverse'||vars.randAnim=='boxRainGrowReverse'){createBoxes(slider,settings,vars);var totalBoxes=settings.boxCols*settings.boxRows;var i=0;var timeBuff=0;var rowIndex=0;var colIndex=0;var box2Darr=new Array();box2Darr[rowIndex]=new Array();var boxes=$('.nivo-box',slider);if(settings.effect=='boxRainReverse'||vars.randAnim=='boxRainReverse'||settings.effect=='boxRainGrowReverse'||vars.randAnim=='boxRainGrowReverse'){boxes=$('.nivo-box',slider)._reverse();}
boxes.each(function(){box2Darr[rowIndex][colIndex]=$(this);colIndex++;if(colIndex==settings.boxCols){rowIndex++;colIndex=0;box2Darr[rowIndex]=new Array();}});for(var cols=0;cols<(settings.boxCols*2);cols++){var prevCol=cols;for(var rows=0;rows<settings.boxRows;rows++){if(prevCol>=0&&prevCol<settings.boxCols){(function(row,col,time,i,totalBoxes){var box=$(box2Darr[row][col]);var w=box.width();var h=box.height();if(settings.effect=='boxRainGrow'||vars.randAnim=='boxRainGrow'||settings.effect=='boxRainGrowReverse'||vars.randAnim=='boxRainGrowReverse'){box.width(0).height(0);}
if(i==totalBoxes-1){setTimeout(function(){box.animate({opacity:'1',width:w,height:h},settings.animSpeed/1.3,'',function(){slider.trigger('nivo:animFinished');});},(100+time));}else{setTimeout(function(){box.animate({opacity:'1',width:w,height:h},settings.animSpeed/1.3);},(100+time));}})(rows,prevCol,timeBuff,i,totalBoxes);i++;}
prevCol--;}
timeBuff+=100;}}}
var shuffle=function(arr){for(var j,x,i=arr.length;i;j=parseInt(Math.random()*i),x=arr[--i],arr[i]=arr[j],arr[j]=x);return arr;}
var trace=function(msg){if(this.console&&typeof console.log!="undefined")
console.log(msg);}
this.stop=function(){if(!$(element).data('nivo:vars').stop){$(element).data('nivo:vars').stop=true;trace('Stop Slider');}}
this.start=function(){if($(element).data('nivo:vars').stop){$(element).data('nivo:vars').stop=false;trace('Start Slider');}}
settings.afterLoad.call(this);return this;};$.fn.nivoSlider=function(options){return this.each(function(key,value){var element=$(this);if(element.data('nivoslider'))return element.data('nivoslider');var nivoslider=new NivoSlider(this,options);element.data('nivoslider',nivoslider);});};$.fn.nivoSlider.defaults={effect:'random',slices:15,boxCols:8,boxRows:4,animSpeed:500,pauseTime:3000,startSlide:0,directionNav:true,directionNavHide:true,controlNav:true,controlNavThumbs:false,controlNavThumbsFromRel:false,controlNavThumbsSearch:'.jpg',controlNavThumbsReplace:'_thumb.jpg',keyboardNav:true,pauseOnHover:true,manualAdvance:false,captionOpacity:0.8,prevText:'Prev',nextText:'Next',beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){},lastSlide:function(){},afterLoad:function(){}};$.fn._reverse=[].reverse;})(jQuery);;
jQuery(window).load(function () {

jQuery(".document_info_download a").html("<span>"+jQuery(".document_info_download a").text()+"</span>").addClass("button");

jQuery("#taxonomy-term-95 .field-name-field-dept-director h3").text("Mayor ");

jQuery(".midLeft .block-menu ul.menu li ul.menu li a").each(function(i) { 
  var iclass = jQuery(this).attr('class');
	if(iclass=='active') {
			
			jQuery(this).parent().parent().show().addClass('menu-show');
	}
});


//Calendar focus
//var param = getUrlVars()["q"];
var param = getUrlVars()[0];
if(param == 'month' || param == 'mini' || param.split("com")[1]=='/calendar/month') { showCal(); }


// NIVO SLIDER
jQuery('#pensaSlide').nivoSlider({
	effect: 'random', // Specify sets like: 'fold,fade,sliceDown'
	startSlide: 0, 
	boxCols: 8,
	boxRows: 3,
	slices: 9,
	directionNav: false, // Next & Prev navigation
	controlNav: false, // 1,2,3... navigation
	keyboardNav: false, // Use left & right arrows  
	slideshowEnd: function(){startNews();}
});

//NAVIGATION W/ HOVER INTENT
var config = {    
	sensitivity: 5, // number = sensitivity threshold (must be 1 or higher)    
	interval: 100,  // number = milliseconds for onMouseOver polling interval  
	over: showMenu, // function = onMouseOver callback (REQUIRED)    
	timeout: 300, // number = milliseconds delay before onMouseOut    
	out: hideMenu // function = onMouseOut callback (REQUIRED)    
};

function showMenu() {
	if(!jQuery(this).hasClass('first')) {
		jQuery('div#newsItems ul li').removeClass('active');
		jQuery("#sliderWrap").fadeOut();
		jQuery("#newsDisplay").fadeOut();	
		jQuery('ul:first',this).stop().slideDown(400);
		if(jQuery('#pensaSlide').length != 0) // no element found
			{jQuery('#pensaSlide').data('nivoslider').stop();} //Stop the Slider
	}
}

function hideMenu() {
	if(!jQuery(this).hasClass('first')) {
			jQuery("#sliderWrap").fadeIn();
		jQuery("#newsDisplay").fadeOut();
		jQuery('ul:first',this).stop().slideUp(400);
		if(jQuery('#pensaSlide').length != 0) // no element found
		{jQuery('#pensaSlide').data('nivoslider').start();} //Start the Slider

	}
}
//deprecated custom nav 
//jQuery("ul.nav li").hoverIntent( config )
//add hover intent to drupal main menu
jQuery("div#block-system-main-menu ul.menu li").hoverIntent(config);
//append title attribute (menu item description) in span
jQuery("div#block-system-main-menu ul.menu li ul.menu li a").each(function() {
	jQuery(this).append("<span>"+jQuery(this).attr('title')+"</span>");																																					});

// hide error/warning messages on calendar pages
if(jQuery("div#bradcrm a:nth-child(2)").text()=="Calendar") {
	jQuery("div.midRight div#messages").css("display", "none");
}

jQuery("#newsItems ul li").click(function(){
		//clearInterval(timer);
		//if(jQuery('#pensaSlide').length != 0) // no element found

	jQuery('#pensaSlide').data('nivoslider').stop(); //Stop the Slider
	
	jQuery("#sliderWrap").fadeOut();
		
	jQuery("#newsDisplay").fadeIn();
    //Set Variables
    var imgTitle = jQuery(this).find('a').attr("href"); //Get Main Image URL
    var imgDesc = jQuery(this).find('.block').html();  //Get HTML of the "block" container
    var imgDescHeight = jQuery("#newsDisplay").find('.block').height(); //Find the height of the "block"

    if (jQuery(this).is(".active")) {  //If the list item is active/selected, then...
        return false; // Don't click through - Prevents repetitive animations on active/selected list-item
    } else { //If not active then...
        //Animate the Description
        jQuery("#newsDisplay img").animate({ opacity: 0}, 250 );
			jQuery("#newsDisplay .block").animate({ opacity: 0, marginBottom: -

imgDescHeight }, 250 , function() {
			jQuery("#newsDisplay .block").html(imgDesc).animate({ opacity: 0.85, 

marginBottom: "0" }, 250 );
			jQuery("#newsDisplay img").attr({ src: imgTitle }).animate({ opacity: 1}, 

250 );
		});
		
		
    }
    //Show active list-item
    jQuery("#newsItems ul li").removeClass('active'); //Remove class of 'active' on all list-items
    jQuery(this).addClass('active');  //Add class of 'active' on the selected list
    return false;
})
.hover(function(){ //Hover effects on list-item
    jQuery(this).addClass('hover'); //Add class "hover" on hover
    }, function() {
    jQuery(this).removeClass('hover'); //Remove class "hover" on hover out
});

	


jQuery("a.collapse").click(function(){
    jQuery(".desc .block").slideToggle(); //Toggle the description (slide up and down)
    jQuery("a.collapse").toggleClass("show"); //Toggle the class name of "show" (the hide/show tab)
	return false;
});	

jQuery("a.btnPensa").click(function(){
	jQuery("#newsItems ul li").removeClass('active'); //Remove class of 'active' on all list-items
	jQuery("#newsDisplay").hide();
    jQuery("#sliderWrap").show();
	
	jQuery('#pensaSlide').nivoSlider();
	jQuery('#pensaSlide').data('nivoslider').start(); //Start the Slider
	return false;
 });
 
	jQuery(function() {
		jQuery(window).scroll(function() {
			if(jQuery(this).scrollTop() != 0) {
				jQuery('#backToTop').show();	
			} else {
				jQuery('#backToTop').hide();
			}
		});
	 
		jQuery('#backToTop').click(function() {
			jQuery('body,html').animate({scrollTop:0},800);
		});	
	}); 
	
	//311 controls
		jQuery("#dept_select, .form-radio-311").change(function() {
		var selection = jQuery(this).val();
		if (selection) {
			jQuery(".view iframe").fadeOut('Fast', function() {
				jQuery(".view").html("<img src='http://www.cityofpensacola.com/images/ajax-loader.gif' />");
				jQuery(".view").append("<iframe width='100%' height='1000px' id='iframe_311' scrolling='no'></iframe>");
				jQuery("iframe#iframe_311").attr('src', selection);
				jQuery("iframe#iframe_311").load(function() {
					jQuery(".view img").remove();
					if (selection == "http://webpub.pensacolacitygov.com/GBAMSWEBCITIZEN/?FUI=PENSACOLA311") {
						jQuery("#dept_selection").hide();
					}
				});
			});
		} else if (!selection) {
			jQuery(".view iframe").fadeOut('Fast');
			jQuery("#dept_selection").show();
		}
		});

});


// HOME PAGE TABS		
function services() {
	jQuery("#showServices").show();
	jQuery("#btnServices").addClass("current");
	
	jQuery("#showVisitors").hide();
	jQuery("#btnVisitors").removeClass("current");
	
	jQuery("#showCommunity").hide();
	jQuery("#btnCommunity").removeClass("current");
	
	jQuery("#showCalendar").hide();
	jQuery("#btnCalendar").removeClass("current");
}
function visitors() {
	jQuery("#showServices").hide();
	jQuery("#btnServices").removeClass("current");
	
	jQuery("#showVisitors").show();
	jQuery("#btnVisitors").addClass("current");
	
	jQuery("#showCommunity").hide();
	jQuery("#btnCommunity").removeClass("current");
	
	jQuery("#showCalendar").hide();
	jQuery("#btnCalendar").removeClass("current");
}
function community() {
	jQuery("#showServices").hide();
	jQuery("#btnServices").removeClass("current");
	
	jQuery("#showVisitors").hide();
	jQuery("#btnVisitors").removeClass("current");
	
	jQuery("#showCommunity").show();
	jQuery("#btnCommunity").addClass("current");
	
	jQuery("#showCalendar").hide();
	jQuery("#btnCalendar").removeClass("current");
}
function calendar() {
	jQuery("#showServices").hide();
	jQuery("#btnServices").removeClass("current");
	
	jQuery("#showVisitors").hide();
	jQuery("#btnVisitors").removeClass("current");
	
	jQuery("#showCommunity").hide();
	jQuery("#btnCommunity").removeClass("current");
	
	jQuery("#showCalendar").show();
	jQuery("#btnCalendar").addClass("current");
}


// FOOTER NAVIGATION
function expand() {
	jQuery("#footerNav").slideToggle("slow");
	jQuery('html, body').animate({scrollTop: jQuery(document).height()}, 700);
}

// FOOTER NAVIGATION
function expandVideo() {
	jQuery("#footerNavVideo").slideToggle("slow");
	jQuery('html, body').animate({scrollTop: jQuery(document).height()}, 100);
}



//TRANSFER FROM PENSASLIDE TO NEWS
function startNews(){

	var timer = window.setInterval('slideSwitchTimed()', 6000);
	jQuery('ul.nav li:not(:first)').hover(function(){
		clearInterval(timer);
	});
	
	
	jQuery("#newsItems ul li").click(function(){
		clearInterval(timer);
		//if(jQuery('#pensaSlide').length != 0) // no element found

	jQuery('#pensaSlide').data('nivoslider').stop(); //Stop the Slider
	
	jQuery("#sliderWrap").fadeOut();
		
	jQuery("#newsDisplay").show('fade');
    //Set Variables
    var imgTitle = jQuery(this).find('a').attr("href"); //Get Main Image URL
    var imgDesc = jQuery(this).find('.block').html();  //Get HTML of the "block" container
    var imgDescHeight = jQuery("#newsDisplay").find('.block').height(); //Find the height of the "block"

    if (jQuery(this).is(".active")) {  //If the list item is active/selected, then...
        return false; // Don't click through - Prevents repetitive animations on active/selected list-item
    } else { //If not active then...
        //Animate the Description
        jQuery("#newsDisplay img").animate({ opacity: 0}, 250 );
			jQuery("#newsDisplay .block").animate({ opacity: 0, marginBottom: -

imgDescHeight }, 250 , function() {
			jQuery("#newsDisplay .block").html(imgDesc).animate({ opacity: 0.85, 

marginBottom: "0" }, 250 );
			jQuery("#newsDisplay img").attr({ src: imgTitle }).animate({ opacity: 1}, 250 );
		});
		
		
    }
    //Show active list-item
    jQuery("#newsItems ul li").removeClass('active'); //Remove class of 'active' on all list-items
    jQuery(this).addClass('active');  //Add class of 'active' on the selected list
    return false;
}).hover(function(){ //Hover effects on list-item
    jQuery(this).addClass('hover'); //Add class "hover" on hover
    }, function() {
    jQuery(this).removeClass('hover'); //Remove class "hover" on hover out
});



	
	jQuery('#pensaSlide').data('nivoslider').stop(); //Stop the Slider
	
	jQuery("#sliderWrap").hide();
		
	jQuery("#newsDisplay").fadeIn();
	
	//Set Variables
    var imgTitle = jQuery('#newsItems ul li:first').find('a').attr("href"); //Get Main Image URL
    var imgDesc = jQuery('#newsItems ul li:first').find('.block').html();  //Get HTML of the "block" container
    var imgDescHeight = jQuery("#newsDisplay").find('.block').height(); //Find the height of the 

"block"
	
	jQuery("#newsDisplay img").animate({ opacity: 0}, 250 );
		jQuery("#newsDisplay .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 

250 , function() {
		jQuery("#newsDisplay .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: 

"0" }, 250 );
		jQuery("#newsDisplay img").attr({ src: imgTitle }).animate({ opacity: 1}, 250 );
	});
	
	jQuery("#sliderWrap").delay(200).slideUp(800);
	
	//Show active list-item
    jQuery('#newsItems ul li:first').addClass('active');  //Add class of 'active' on the selected list
	

	

}

function slideSwitchTimed() {
	jQueryactive = jQuery('#newsItems ul li.active').next();
	
	if ( jQueryactive.length == 0 ) jQueryactive = jQuery('#newsItems ul li:first'); //goes back to start when finishes
	
	var jQueryprev = jQuery('#newsItems ul li.active');
	jQueryprev.removeClass('active');
	jQueryactive.addClass('active');

	//Set Variables
	var imgTitle = jQueryactive.find('a').attr("href"); //Get Main Image URL
	var imgDesc = jQueryactive.find('.block').html(); //Get HTML of the "block" container
	var imgDescHeight = jQuery(".main_image").find('.block').height(); //Find the height of the "block"
	
	if (jQuery(this).is(".active")) { //If the list item is active/selected, thenō
		return false; // Don't click through  Prevents repetitive animations on active/selected list-item
	} else { //If not active thenō
	//Animate the Description
		jQuery("#newsDisplay img").animate({ opacity: 0}, 250 );
		jQuery("#newsDisplay .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 

250 , function() {
			jQuery("#newsDisplay .block").html(imgDesc).animate({ opacity: 0.85, 

marginBottom: "0" }, 250 );
			jQuery("#newsDisplay img").attr({ src: imgTitle }).animate({ opacity: 1}, 

250 );
		});
	}
	return false;
}	

function clearText(thefield) {
  if (thefield.defaultValue==thefield.value) { thefield.value = "" }
} 
function replaceText(thefield) {
  if (thefield.value=="") { thefield.value = thefield.defaultValue }
}

function account(tab,cls) 
{
	i=1;
	
	while (document.getElementById("tab_"+i))
	 {
	 document.getElementById("tab_"+i).style.display='none';
	 document.getElementById("z"+i).className='';
	 i++;
	 
	 }
	 document.getElementById(tab).style.display='block';
	 document.getElementById(cls).className='sel';
}



function showHide(HID,IMG) {
	if (document.getElementById(IMG).src.indexOf('expand') != -1) {
		document.getElementById(IMG).src='collapse.gif';
		document.getElementById(HID).className='visibleRow';
	} else {
		document.getElementById(IMG).src='expand.gif';
		document.getElementById(HID).className='hiddenRow';
	}
}




function fp_show(tabopen,cl) 
{
	i=1;
	
	while (document.getElementById("pulic_"+i))
	 {
	 document.getElementById("pulic_"+i).style.display='none';
	 document.getElementById("a"+i).className='';
	 i++;
	 
	 }
	 document.getElementById(tabopen).style.display='block';
	 document.getElementById(cl).className='sel';
}



function showHide(HID,IMG) {
	if (document.getElementById(IMG).src.indexOf('expand') != -1) {
		document.getElementById(IMG).src='collapse.gif';
		document.getElementById(HID).className='visibleRow';
	} else {
		document.getElementById(IMG).src='expand.gif';
		document.getElementById(HID).className='hiddenRow';
	}
}



	ddaccordion.init({
	 headerclass: "expandable", //Shared CSS class name of headers group that are expandable
	 contentclass: "categoryitems", //Shared CSS class name of contents group
	 revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	 collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	 defaultexpanded: [8], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
	 animatedefault: false, //Should contents open by default be animated into view?
	 persiststate: false, //persist state of opened contents within browser session?
	 toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	 togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	 animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
	 oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
	  //do nothing
	 },
	 onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
	  //do nothing
	 }
	});

// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
function showCal() 
{
	fp_show('pulic_4','a4'); //jQuery('#pulic_4 .date-prev a').focus();
	jQuery('.cityLink a').focus();
};

