$(document).ready(function(){handleViews()});function handleViews(){var g=1;$.each($("ul#productViews").attr("class").split(" "),function(h,j){if(j.indexOf("views_")>-1){g=parseInt(j.replace("views_",""))}});if(g>1){$("#productCont").append('<span id="left" class="arrow">left</span><span id="right" class="arrow">right</span>')}var c=1;var d=g<5?g:5;var b=[$("img#mainProductImage").attr("src")];var e=$("ul#productViews").is(".containsVideo");function f(k,j){if(j===1){if(e&&(k===g)){$("div#mainProductImageCont").hide();$("div#zoomMsgCont").hide();$("div#flash").addClass("play");getFlashMovie("Video").playVideo()}else{if($("div#flash").is(".play")){getFlashMovie("Video").stopVideo();$("div#flash").removeClass("play")}$("div#mainProductImageCont").show();$("div#zoomMsgCont").show()}}split_array=$("#view_"+j).find("img.productView").attr("src").split("_");split_array[split_array.length-1]=k+".jpg";var h=split_array.join("_");$("#view_"+j).find("img.productView").attr("src",h);var l=h.replace("/small/","/xlarge/");if(!b.contains(l)){$("<img>").attr("src",l);b.push(l)}if(j===1){h=h.replace("xlarge","zoom");$("img#zoomProductImg").attr("src",h)}}function a(h){for(i=1;i<d;i++){if(d===4&&i===3){i=4}switch(i){case 1:if((h+1)<=g){next_position=h+1}else{next_position=h+1-g}break;case 2:if((h+2)<=g){next_position=h+2}else{next_position=h+2-g}break;case 3:if((h-2)>0){next_position=h-2}else{next_position=g+(h-2)}break;case 4:if((h-1)>0){next_position=h-1}else{next_position=g+(h-1)}break}if(d===4&&i===4){i=3}f(next_position,i+1)}}f(1,1);a(1);$("ul#productViews li:not(#view_1)").live("click",function(){var j=$(this).find("img").attr("src").split("_");var h=j[j.length-1].replace(".jpg","");f(parseInt(h),1);a(parseInt(h))});$("span.arrow").click(function(){var h=$("img#mainProductImage").attr("src").split("_");h=h[h.length-1].replace(".jpg","");if($(this).is("#left")){if(parseInt(h)-1>0){h=parseInt(h)-1}else{h=g}}else{if(parseInt(h)+1<=g){h=parseInt(h)+1}else{h=1}}f(h,1);a(h)});$("span#left").hover(function(){$("li#view_"+g).addClass("highlight")},function(){$("li.highlight").removeClass("highlight")});$("span#right").hover(function(){$("li#view_2").addClass("highlight")},function(){$("li.highlight").removeClass("highlight")})}function getFlashMovie(b){var a=navigator.appName.indexOf("Microsoft")!=-1;return(a)?window[b]:document[b]}Array.prototype.contains=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return true}}return false};