var nextInterval=null;var activeRotatingImage=1;var nextRotatingImage=2;var numRotatingImages=0;var rotatingImageNavActive=1;var activeImage=1;var nextActiveImage=1;var lbLoadedForm;(function($){function rotateImage(){numRotatingImages=$('.rotating-image').length;if(numRotatingImages>1){$('#rotating-image-'+nextRotatingImage).css('z-index',4).fadeIn(1000,function(){$('#rotating-image-'+activeRotatingImage).css('display','none').css('z-index',2);$('#rotating-image-'+nextRotatingImage).css('z-index',3);if(activeRotatingImage==numRotatingImages){activeRotatingImage=1}else{activeRotatingImage++}if(nextRotatingImage==numRotatingImages){nextRotatingImage=1}else{nextRotatingImage++}});$('.rotationNav').removeClass('activeRotation');$('#rotationNav-'+nextRotatingImage).addClass('activeRotation');try{nextInterval=setTimeout(rotateImage,7000)}catch(e){}return false}}function setProductWallHeights(){$('ul.products-grid').each(function(i){var a=0;$('ul#products-grid-'+i+' li .productGrid-description').each(function(j){if($(this).height()>a){a=$(this).height()}});$('ul#products-grid-'+i+' li .productGrid-description').css('height',a+'px')})}window.setProductWallHeights=setProductWallHeights;function lightboxPrep(){$('.close-lightbox-overlay').die('click');$('#lb-overlay').removeClass('close-lightbox-overlay');var a=0;var b=0;var c=$(window).height()/2;c=Math.round(c);var d=document.body.scrollTop;if(d==0){if(window.pageYOffset)d=window.pageYOffset;else d=(document.body.parentElement)?document.body.parentElement.scrollTop:0}c=c+d;$('#lb-canvas').css("top",c+'px');$('#lb-loaderIcon').css('top',c+'px');$('#lb-overlay').queue(function(){$("#lb-overlay").css('height',$(document).height()+'px');$('#lb-overlay').css('width','100%');$('#lb-overlay').css('left',0);$('#lb-overlay').css('display','block');$('#lb-loaderIcon').css('display','block');$(this).dequeue()})}window.lightboxPrep=lightboxPrep;function lightBoxPosition(){negativeLeftMargin=$('#lb-canvas-content').outerWidth();negativeLeftMargin=negativeLeftMargin/2;negativeTopMargin=$('#lb-canvas-content').outerHeight();negativeTopMargin=negativeTopMargin+63;negativeTopMargin=negativeTopMargin/2;$('#lb-loaderIcon').css('display','none');$('#lb-canvas').css('margin-left','-'+negativeLeftMargin+'px');$('#lb-canvas').css('margin-top','-'+negativeTopMargin+'px');$('#lb-canvas').css('left','50%');$('#lb-overlay').addClass('close-lightbox-overlay');$('.close-lightbox-overlay').live('click',function(){$('#lb-canvas').css('left','-3000px');$('#lb-canvas #lb-canvas-content').html('');$('#lb-overlay').hide()})}window.lightBoxPosition=lightBoxPosition;function launchZoom(a){lightboxPrep();$('#lb-canvas-content').append('<img src="'+a+'" border="0" id="enlarged-image" />');$('#enlarged-image').load(function(){lightBoxPosition()})}window.launchZoom=launchZoom;function launchLbJsForm(a,b){lightboxPrep();$('#lb-canvas-content').html(a);lightBoxPosition();lbLoadedForm=new VarienForm(b,false)}window.launchLbJsForm=launchLbJsForm;$(document).ready(function(){$('.rotationNav').click(function(){if(nextInterval){clearTimeout(nextInterval)}rotatingImageNavActive=$(this).attr('id');rotatingImageNavActive=rotatingImageNavActive.substring(rotatingImageNavActive.indexOf('-')+1,rotatingImageNavActive.length);$('#rotating-image-'+rotatingImageNavActive).css('z-index',4).fadeIn(1000,function(){$('.rotating-image').not('#rotating-image-'+rotatingImageNavActive).css('display','none').css('z-index',2);$('#rotating-image-'+rotatingImageNavActive).css('z-index',3)});$('.rotationNav').removeClass('activeRotation');$(this).addClass('activeRotation')});$('#mycarousel-next').click(function(){if(nextInterval){clearTimeout(nextInterval)}numRotatingImages=$('.rotating-image').length;activeImage=$('ul li.activeRotation').attr('id');activeImage=activeImage.substring(activeImage.indexOf('-')+1,activeImage.length);if(activeImage==numRotatingImages){activeImage=1}else{activeImage++}$('#rotating-image-'+activeImage).css('z-index',4).fadeIn(1000,function(){$('.rotating-image').not('#rotating-image-'+activeImage).css('display','none').css('z-index',2);$('#rotating-image-'+activeImage).css('z-index',3)});$('.rotationNav').removeClass('activeRotation');$('#rotationNav-'+activeImage).addClass('activeRotation')});$('#mycarousel-prev').click(function(){if(nextInterval){clearTimeout(nextInterval)}numRotatingImages=$('.rotating-image').length;activeImage=$('ul li.activeRotation').attr('id');activeImage=activeImage.substring(activeImage.indexOf('-')+1,activeImage.length);if(activeImage==1){activeImage=numRotatingImages}else{activeImage--}$('#rotating-image-'+activeImage).css('z-index',4).fadeIn(1000,function(){$('.rotating-image').not('#rotating-image-'+activeImage).css('display','none').css('z-index',2);$('#rotating-image-'+activeImage).css('z-index',3)});$('.rotationNav').removeClass('activeRotation');$('#rotationNav-'+activeImage).addClass('activeRotation')});if($('.rotating-image').length){try{if(!nextInterval){nextInterval=setTimeout(rotateImage,7000)}}catch(e){}}$('#toggle-reviewForm').click(function(){$(this).fadeOut(100);$('#prodDtl-reviewForm-hide').show(100)});$('.close-lightbox, .close-lightbox-overlay').live('click',function(){$('#lb-canvas').css('left','-3000px');$('#lb-canvas #lb-canvas-content').html('');$('#lb-overlay').hide();$('#referafriend-overlay').hide();$('#referafriend').hide()});$.fn.clearField=function(){return this.focus(function(){if(this.value==this.defaultValue){this.value=""}}).blur(function(){if(!this.value.length){this.value=this.defaultValue}})};$("").clearField()});$(window).load(function(){if($('ul.products-grid').length){setProductWallHeights()}})})(jQuery);
