var initialPreset="oslarge";var zoomedPreset="oszoom";var overrideFormat="";var zoomThreshold=1.5;var mobileThreshold=768;var supportsTouch='ontouchstart'in window||navigator.msMaxTouchPoints;var startZoom=-1;var startX=-1;var startY=-1;var startXmargin=-1;var startYmargin=-1;var isZoomed=false;var isMobile=false;var startWidth=800;var actualWidth=startWidth;var startZoomWidth=1600;var actualZoomWidth=startZoomWidth;var rsBulletAction=undefined;var rsBulletMaxItems=4;var rsBulletItemWidth=22;var isHWC=document.getElementById('HWC')!=null;var bgHWCTemplate='&template=HWCBackgroundTemplate';if(supportsTouch==undefined){supportsTouch=false;}
if(window.innerWidth<=mobileThreshold){isMobile=true;}
if(window.location.hash=="#jpg"){overrideFormat="&fmt=jpg";}
else if(window.location.hash=="#png"){overrideFormat="&fmt=png";}
function addS7Image(element,index,array){var divText='<div class="rsContent"><div class="rsMobileZoomContainer" data-S7fullx="'+element.dx+'" data-S7fully="'+element.dy+'"><a class="rsImg" href="//images.mattel.com/scene7/'+element.i.n.replace('Mattel/','')+'?$'+initialPreset+'$'+overrideFormat;if(isHWC){divText=divText+bgHWCTemplate;}
divText=divText+'"></a></div></div>';$('#carouselContainer').append(divText)}
function s7jsonResponse(data){if($('#product-detail-content div.widget_product_image_viewer').width()<startWidth){actualWidth=$('#product-detail-content div.widget_product_image_viewer').width();overrideFormat=overrideFormat+"&wid="+actualWidth+"&hei="+actualWidth;}
if(data.set.item.constructor==Array){if($('#partSceneForCsr').val()==undefined){data.set.item.forEach(addS7Image);}
else{addS7Image(data.set.item[0],0,0);}}
else{addS7Image(data.set.item,0,0);}
$('.rsAfter').each(function(){$('#carouselContainer').append($(this));});var transitionType='move';var numImagesToPreload=0;if(isMobile){transitionType='fade';}
if(isHWC){$(".royalSlider").royalSlider({startSlideId:0,autoScaleSlider:true,autoScaleSliderWidth:800,autoScaleSliderHeight:800,autoHeight:false,loop:true,transitionType:transitionType,sliderTouch:supportsTouch,sliderDrag:supportsTouch,imageScaleMode:'fill',slidesSpacing:0,navigateByClick:false,numImagesToPreload:numImagesToPreload,arrowsNav:true,controlsInside:true,arrowsNavAutoHide:false,arrowsNavHideOnTouch:false,keyboardNavEnabled:true,fadeinLoadedSlide:false,globalCaption:true,globalCaptionInside:true,transitionSpeed:300,addActiveClass:true,controlNavigationSpacing:0,controlNavigation:'thumbnails',});}
else{$(".royalSlider").royalSlider({startSlideId:0,autoScaleSlider:true,autoScaleSliderWidth:800,autoScaleSliderHeight:800,autoHeight:false,loop:true,transitionType:transitionType,sliderTouch:supportsTouch,sliderDrag:supportsTouch,imageScaleMode:'fill',slidesSpacing:0,navigateByClick:false,numImagesToPreload:numImagesToPreload,arrowsNav:true,controlsInside:true,arrowsNavAutoHide:false,arrowsNavHideOnTouch:false,keyboardNavEnabled:true,fadeinLoadedSlide:false,globalCaption:true,globalCaptionInside:true,transitionSpeed:300,addActiveClass:true,controlNavigationSpacing:0,controlNavigation:'bullets',});}
if(data.set.item.constructor!=Array||$('.product-configurator').length>0){$('.rsBullets').hide();}
slider=$(".royalSlider").data('royalSlider');slider.slides[0].holder.on('rsAfterContentSet',function(event){$('.rsNav').wrapInner("<div class='rsNavInner'></div>");if(isHWC){$('.rsNavInnerWrapper').wrapInner("<div class='rsNavInner'></div>");addBulletNavigation();}});slider.ev.on('rsBeforeMove',function(event){$('.rsNoDrag').each(function(){$(this).removeClass('rsNoDrag');});});slider.ev.on('rsAfterContentSet',function(event){adjustProductSlider();$("#productTempImage").css("opacity","0");$("#productTempImage").css("display","none");$(".widget_product_image_viewer.progressive .image_container>div").css("position","relative");});slider.ev.on('rsAfterSlideChange',function(event){adjustProductSlider();if(isHWC){var action=rsBulletAction;rsBulletAction=undefined;var current=$(".rsNavInner .rsNavSelected");var currentIndex=$(".rsNavItem").index(current);var left=$(".rsThumbsContainer").css("left");var leftValue=parseInt(left.split("px")[0]);var minPosition=Math.abs(leftValue/rsBulletItemWidth);var maxPosition=minPosition+rsBulletMaxItems-1;if(currentIndex<minPosition||currentIndex>maxPosition){if(currentIndex==0){leftValue=0;}
else if(currentIndex<minPosition){leftValue+=rsBulletItemWidth;}else{leftValue-=rsBulletItemWidth;}
$(".rsThumbsContainer").css("left",leftValue+"px");}}});if($('.rsGCaption').text()==""){$('.rsGCaption').hide()}
else{$('.rsGCaption').show()}
$('.widget_product_image_viewer').on('mouseenter','#ooyalaplayer',function(){$('.oo_controls_wrap').addClass('rsNoDrag');});$(window).resize(function(){adjustProductSlider();});}
function addBulletNavigation(){var $rsNavInnerWrapper=$("#HWC #carouselContainer .rsNavInnerWrapper");var rsNavItemLength=$rsNavInnerWrapper.find('.rsNavItem').length;if(rsNavItemLength>rsBulletMaxItems){$rsNavInnerWrapper.append('<div class="rsBullet rsBulletLeft"> <div class="rsBulletLeftIcon"></div> </div>');$rsNavInnerWrapper.append('<div class="rsBullet rsBulletRight"> <div class="rsBulletRightIcon"></div> </div>');$rsNavInnerWrapper.children('.rsBullet.rsBulletLeft').click(function(e){if(!rsBulletAction){var prev=$(".rsNavInner .rsNavSelected").prev()[0];if(prev){rsBulletAction="prev";prev.click();}}});$rsNavInnerWrapper.children('.rsBullet.rsBulletRight').click(function(e){if(!rsBulletAction){var next=$(".rsNavInner .rsNavSelected").next()[0];if(next){rsBulletAction="next";next.click();}}});}}
function destroyCloudzoom(){$('.rsSlide img').each(function(){if($(this).data('CloudZoom')!=undefined){$(this).data('CloudZoom').destroy();}});}
function adjustProductSlider(){$('.rsGCaption').text("");img=$('.rsActiveSlide img');var zoomThresholdPixels=$('#carouselContainer').innerWidth()*zoomThreshold;if(parseInt(img.parent().attr('data-s7fullx'))>zoomThresholdPixels||parseInt(img.parent().attr('data-s7fully'))>zoomThresholdPixels){if($(img).attr('src')==undefined){img=$('.rsContent img').eq(0);}
if($(img).attr('data-orig-src')==undefined){$(img).attr('data-orig-src',$(img).attr('src'));}
var zoomOverride="";if(window.devicePixelRatio*actualWidth*2<startZoomWidth){startZoomWidth=window.devicePixelRatio*actualWidth*2;}
zoomOverride="&wid="+startZoomWidth+"&hei="+startZoomWidth;newImgSrc=$(img).attr('data-orig-src').replace("$"+initialPreset+"$"+overrideFormat,"$"+zoomedPreset+"$");newImgSrc=newImgSrc+zoomOverride;if(!supportsTouch){zoomData=$(img).data('CloudZoom');if(zoomData==undefined){options={zoomImage:newImgSrc,autoInside:mobileThreshold,zoomOffsetX:15,tintOpacity:0.25,touchStartDelay:150,animationTime:200,mouseTriggerEvent:"click",zoomPosition:"inside"}
$(img).CloudZoom(options);}
$(img).addClass('zoom-in-cursor');$('.rsGCaption').text("Click to zoom");$('.rsNav').append($('.rsGCaption'));$('.rsGCaption').show();}
else{$('.rsMobileZoomContainer').each(function(){$(this).css('width','');$(this).css('height','');$(this).css('margin-left','');$(this).css('margin-top','');$(this).removeAttr('data-orig-width');});destroyCloudzoom();var theImage=new Image();theImage.src=newImgSrc;var int1=setInterval(function(){if(theImage.complete){clearInterval(int1);$(img).attr('src',newImgSrc);if(theImage.width>=startZoomWidth){$('.rsGCaption').text("Pinch in & out to zoom");$('.rsNav').append($('.rsGCaption'));$('.rsGCaption').show();if((window.outerWidth-$('.rsNavInner').outerWidth())/2>$('.rsGCaption').outerWidth()+20){$('.rsGCaption').css('top',0);}
else{$('.rsGCaption').css('top','-1.1em');}
$(document).on("touchmove",".rsActiveSlide .rsMobileZoomContainer",function(e){if(e.originalEvent.touches.length==1&&$(this).attr('data-orig-width')!=undefined&&parseInt($(this).attr('data-orig-width'))<parseInt($(this).width())){if(startX<0){startX=e.originalEvent.touches[0].pageX;startXmargin=parseInt($(this).css('margin-left'));}
if(startY<0){startY=e.originalEvent.touches[0].pageY;startYmargin=parseInt($(this).css('margin-top'));}
newMarginLeft=startXmargin+e.originalEvent.touches[0].pageX-startX;newMarginTop=startYmargin+e.originalEvent.touches[0].pageY-startY;if(newMarginLeft<$(this).parent().width()-$(this).width()){newMarginLeft=$(this).parent().width()-$(this).width()}
if(newMarginLeft>0){newMarginLeft=0;}
if(newMarginTop<$(this).parent().width()-$(this).width()){newMarginTop=$(this).parent().width()-$(this).width()}
if(newMarginTop>0){newMarginTop=0;}
$(this).css('margin-left',newMarginLeft);$(this).css('margin-top',newMarginTop);e.preventDefault();}
if(e.originalEvent.touches.length==2){e.preventDefault();if($(this).attr('data-orig-width')==undefined){$(this).attr('data-orig-width',$(this).width());}
if(startWidth<0){startWidth=$(this).width();startXmargin=parseInt($(this).css('margin-left'));startYmargin=parseInt($(this).css('margin-top'));}
dataOrigWidth=parseInt($(this).attr('data-orig-width'));if(startZoom<0){startZoom=Math.sqrt(Math.pow(e.originalEvent.touches[0].pageX-e.originalEvent.touches[1].pageX,2)+Math.pow(e.originalEvent.touches[0].pageY-e.originalEvent.touches[1].pageY,2));}
newZoom=startWidth/startZoom*Math.sqrt(Math.pow(e.originalEvent.touches[0].pageX-e.originalEvent.touches[1].pageX,2)+Math.pow(e.originalEvent.touches[0].pageY-e.originalEvent.touches[1].pageY,2));if(theImage.width>newZoom){$(this).css('width',newZoom);$(this).css('height',newZoom);}
newMarginLeft=startXmargin-($(this).width()-startWidth)/(startWidth/($('#carouselContainer').width()/2-startXmargin));newMarginTop=startYmargin-($(this).width()-startWidth)/(startWidth/($('#carouselContainer').width()/2-startYmargin));if(newMarginLeft<$(this).parent().width()-$(this).width()){newMarginLeft=$(this).parent().width()-$(this).width();}
if(newMarginLeft>0){newMarginLeft=0;}
if(newMarginTop<$(this).parent().width()-$(this).width()){newMarginTop=$(this).parent().width()-$(this).width();}
if(newMarginTop>0){newMarginTop=0;}
$(this).css('margin-left',newMarginLeft)
$(this).css('margin-top',newMarginTop)
if(parseInt($(this).width())<=dataOrigWidth){$(this).width(dataOrigWidth);$(this).height(dataOrigWidth);isZoomed=false;$(this).children('.zoomText').fadeIn();$('.rsSlide').removeClass('rsTop');$('.rsImg').removeClass('rsNoDrag');$('.rsImg').parents('.rsSlide').removeClass('rsNoDrag');}
else{isZoomed=true;$('h1').text($(this).parent().children('.zoomText').css('display'));$(this).children('.zoomText').hide();$('.rsActiveSlide').addClass('rsTop');$('.rsImg').addClass('rsNoDrag');$('.rsImg').parents('.rsSlide').addClass('rsNoDrag');}}});$(document).on("touchend",".rsActiveSlide .rsMobileZoomContainer",function(e){startWidth=-1;startZoom=-1;startX=-1;startY=-1;});}}},200)}}}