function msieversion(){var ua=window.navigator.userAgent;var msie=ua.indexOf("MSIE ");if(msie>0)
{return parseInt(ua.substring(msie+5,ua.indexOf(".",msie)));}
else
{return-1;}}
$(document).ready(function(){if((msieversion()==6)&&(msieversion()!=-1)){$('#img_container').css("background-image","url(../images/carousel-bg.gif)");$('#scroll a img').each(function(i,domEle){var oldsrc=$(this)[0].src;var newsrc=(oldsrc.substring(0,oldsrc.indexOf('.png')))+".gif";$(this)[0].src=newsrc;});}
var WidthOfNonFocusedLI="95";var WidthOfFocusedLI="125";var LIpadding=0;var firstRun=true;allScroll=$('#scroll');allImages=$('#scroll a img');allContent=$('#content div');allAnchors=$('#scroll a');allLI=$('#scroll li');$('#scroll').css('width',(((allLI.length+LIpadding)*WidthOfNonFocusedLI)+(WidthOfFocusedLI-WidthOfNonFocusedLI)));var allLinks=[];for(i=0;i<allAnchors.length;i++){allLinks[i]=allAnchors[i].href;allAnchors[i].href="javascript:void(0)";allAnchors[i].id=i;}
var position=(($('#scroll').outerWidth()-$('#img_container').outerWidth())/2)*-1;var current=0;if(parseInt(allLI.length)%2){current=parseInt((allLI.length)/2);}
else{current=parseInt((allLI.length)/2)-1;position+=WidthOfNonFocusedLI/2;}
displayWidth=parseInt($('#img_container').outerWidth());var maxScroll=(allImages.length)-1;function textPosition(speed){var contentReplacer=allContent[current].innerHTML;$("#ProductMessage").animate({opacity:1},{step:function(){$('#ProductMessage').html(contentReplacer).fadeIn("fast");}});}
$("#scroll a").click(function(e){if(!$("#scroll").is(":animated")){var objId=this.id;clicker(objId,"normal");}});function clicker(objId,animateSpeed){if((objId>=0)&&(objId<=maxScroll)){if(current==objId&&firstRun===false){setTimeout(function(){window.location=allLinks[current];},0);}
else{if($("#ProductMessage").is(":animated")){$('#ProductMessage').stop(true,true);}else{$("#ProductMessage").animate({opacity:0.15},function(){$('#ProductMessage').html('');});if(!firstRun){$(allLI[parseInt(current)]).animate({width:WidthOfNonFocusedLI});}
var item_width=$('#scroll li').outerWidth();position+=(parseInt(WidthOfNonFocusedLI)*-1*(objId-current));current=objId;$("#scroll").animate({"left":position});Animate(objId,animateSpeed);}}}}
function Animate(objId,speed){textPosition(speed);$(allImages[current]).animate({width:WidthOfFocusedLI},speed);$(allLI[parseInt(current)]).animate({width:WidthOfFocusedLI},speed);Scaler(objId,speed);}
function Scaler(objId,speed){try{var sizeDecrementer=80;for(i=parseInt(objId)-1;i>=0;i--){if(sizeDecrementer>1){$(allImages[i]).animate({width:sizeDecrementer},speed);$(allImages[i]).css('float','left');sizeDecrementer-=15;}}
sizeDecrementer=80;for(i=parseInt(objId)+1;i<=allImages.length-1;i++){if(sizeDecrementer>1){$(allImages[i]).animate({width:sizeDecrementer},speed);$(allImages[i]).css('float','right');sizeDecrementer-=15;}}}
catch(Error){}}
$("#btn_right").click(function(){if(!$("#scroll").is(":animated")){clicker(parseInt(current)+1,"normal");}});$("#btn_left").click(function(){if(!$("#scroll").is(":animated")){clicker(parseInt(current)-1,"normal");}});$("img_container").ready(function(){try{var cookVal=getCookie('InboundPathSearchTerm');$('#scroll li').each(function(i){cookVal=(this.id==cookVal)?i:cookVal;});if((cookVal!==null)&&(!cookVal===false)){clicker(parseInt(cookVal),"normal");firstRun=false;}
else{$(allImages[current]).animate({width:WidthOfFocusedLI},100,"swing",function(){clicker(current,"normal");firstRun=false;});}}
catch(err){$(allImages[current]).animate({width:WidthOfFocusedLI},100,"swing",function(){clicker(current,"normal");firstRun=false;});}});function getCookie(name){try{var cookies=document.cookie;if(cookies.indexOf(name)!=-1){var startpos=cookies.indexOf(name)+name.length+1;var endpos=cookies.indexOf(";",startpos);endpos=endpos==-1?cookies.length:endpos;var InboundCookieString=unescape(cookies.substring(startpos,endpos));var ko=InboundCookieString.split('&');for(i=0;i<=ko.length-1;i++){var c=ko[i];while(c.charAt(0)===' '){c=c.substring(1,c.length);}
subKey="CarouselPrdVal=";if(c.indexOf(subKey)===0){return unescape(c.substring(subKey.length,c.length));}}}
else{return false;}}
catch(err)
{}}});
