var $jx=jQuery.noConflict();var featuredcontentglider={csszindex:100,ajaxloadingmsg:'<b>Fetching Content. Please wait...</b>',glide:function(config,showpage,isprev){var selected=parseInt(showpage)
if(selected>=config.$jxcontentdivs.length){alert("No content exists at page "+(selected+1)+"! Loading 1st page instead.")
selected=0}
var $jxtarget=config.$jxcontentdivs.eq(selected)
if(config.$jxtogglerdiv.attr('lastselected')==null||parseInt(config.$jxtogglerdiv.attr('lastselected'))!=selected){var $jxselectedlink=config.$jxtoc.eq(selected)
config.$jxnext.attr('loadpage',(selected<config.$jxcontentdivs.length-1)?selected+1+'pg':0+'pg')
config.$jxprev.attr('loadpage',(selected==0)?config.$jxcontentdivs.length-1+'pg':selected-1+'pg')
var startpoint=(isprev=="previous")?-config.startpoint:config.startpoint
$jxtarget.css(config.leftortop,startpoint).css("zIndex",this.csszindex++)
var endpoint=(config.leftortop=="left")?{left:0}:{top:0}
$jxtarget.animate(endpoint,config.speed)
config.$jxtoc.removeClass('selected')
$jxselectedlink.addClass('selected')
config.$jxtogglerdiv.attr('lastselected',selected+'pg')}},getremotecontent:function(config){config.$jxglider.html(this.ajaxloadingmsg)
$jx.ajax({url:config.remotecontent,error:function(ajaxrequest){config.$jxglider.html('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)},success:function(content){config.$jxglider.html(content)
featuredcontentglider.setuptoggler(config)}})},aligncontents:function(config){config.$jxcontentdivs=$jx("#"+config.gliderid+" ."+config.contentclass)
config.$jxcontentdivs.css(config.leftortop,config.startpoint).css({height:config.$jxglider.height(),visibility:'visible'})},setuptoggler:function(config){this.aligncontents(config)
config.$jxtogglerdiv.hide()
config.$jxtoc.each(function(index){$jx(this).attr('pagenumber',index+'pg')
if(index>(config.$jxcontentdivs.length-1))
$jx(this).css({display:'none'})})
var $jxnextandprev=$jx("#"+config.togglerid+" .next, #"+config.togglerid+" .prev")
$jxnextandprev.click(function(event){featuredcontentglider.glide(config,this.getAttribute('loadpage'),this.getAttribute('buttontype'))
event.preventDefault()})
config.$jxtoc.click(function(event){featuredcontentglider.glide(config,this.getAttribute('pagenumber'))
event.preventDefault()})
config.$jxtogglerdiv.fadeIn(1000,function(){featuredcontentglider.glide(config,config.selected)
if(config.autorotate==true){config.stepcount=0
config.totalsteps=config.$jxcontentdivs.length*config.autorotateconfig[1]
featuredcontentglider.autorotate(config)}})
config.$jxtogglerdiv.click(function(){featuredcontentglider.cancelautorotate(config.togglerid)})},autorotate:function(config){var rotatespeed=config.speed+config.autorotateconfig[0]
window[config.togglerid+"timer"]=setInterval(function(){if(config.totalsteps>0&&config.stepcount>=config.totalsteps){clearInterval(window[config.togglerid+"timer"])}
else{config.$jxnext.click()
config.stepcount++}},rotatespeed)},cancelautorotate:function(togglerid){if(window[togglerid+"timer"])
clearInterval(window[togglerid+"timer"])},getCookie:function(Name){var re=new RegExp(Name+"=[^;]+","i")
if(document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1]
return null},setCookie:function(name,value){document.cookie=name+"="+value},init:function(config){$jx(document).ready(function(){config.$jxglider=$jx("#"+config.gliderid)
config.$jxtogglerdiv=$jx("#"+config.togglerid)
config.$jxtoc=config.$jxtogglerdiv.find('.toc')
config.$jxnext=config.$jxtogglerdiv.find('.next')
config.$jxprev=config.$jxtogglerdiv.find('.prev')
config.$jxprev.attr('buttontype','previous')
var selected=(config.persiststate)?featuredcontentglider.getCookie(config.gliderid):config.selected
config.selected=(isNaN(parseInt(selected)))?config.selected:selected
config.leftortop=(/up/i.test(config.direction))?"top":"left"
config.heightorwidth=(/up/i.test(config.direction))?config.$jxglider.height():config.$jxglider.width()
config.startpoint=(/^(left|up)/i.test(config.direction))?-config.heightorwidth:config.heightorwidth
if(typeof config.remotecontent!="undefined"&&config.remotecontent.length>0)
featuredcontentglider.getremotecontent(config)
else
featuredcontentglider.setuptoggler(config)
$jx(window).bind('unload',function(){config.$jxtogglerdiv.unbind('click')
config.$jxtoc.unbind('click')
config.$jxnext.unbind('click')
config.$jxprev.unbind('click')
if(config.persiststate)
featuredcontentglider.setCookie(config.gliderid,config.$jxtogglerdiv.attr('lastselected'))
config=null})})}}
