var productRating=null;
function InitializeProductRating(){
$(".product_rating").each(function(){
productRating=new ProductRatingControl();
});
}
function DisablefQtyEnter(){
$("#fQty").keypress(disableEnterKeypress);
}
var top_;
var left;
var height;
var width;
var zoomRatio;
var productPhoto;
var tintLayer;
var productWindow;
var productWindowImage;
var zoomLayer;
var zoomLayerImage;
var xLimit;
var yLimit;
var zoomTop;
var zoomLeft;
var msg;
var productPhotoImage;
function productZoomPlacement(){
top_=productPhotoImage[0].offsetTop;
left=productPhotoImage[0].offsetLeft;
tintLayer.width(productPhotoImage.width()).height(productPhotoImage.height()).css("top",top_+"px").css("left",left+"px");
}
function productZoomInit(){
var _1;
_1=$("#display_product_zoom").val();
if(_1==1){
productPhotoImage=$(".product-photo img");
jQuery("<div />").attr("id","product-photo-zoom").insertBefore(productPhotoImage);
productPhotoImage.wrap("<div id=\"product-photo-wrap\"></div>");
productPhoto=$("#product-photo-wrap");
jQuery("<div />").attr("id","product-photo-window").appendTo(productPhoto);
jQuery("<img />").attr({"id":"product-photo-window-img","src":$("a.product-photo").attr("href"),"width":170}).appendTo($("#product-photo-window"));
jQuery("<div />").attr("id","product-photo-tint").insertAfter($("#product-photo-window"));
jQuery("<img />").attr({"id":"product-photo-zoom-img","src":$("a.product-photo").attr("href")}).appendTo($("#product-photo-zoom"));
jQuery("<div />").attr("id","messagebox").insertAfter(productPhoto);
tintLayer=$("#product-photo-tint");
tintLayer.css("opacity","0.66");
productWindow=$("#product-photo-window");
productWindowImage=$("#product-photo-window-img");
zoomLayer=$("#product-photo-zoom");
zoomLayerImage=$("#product-photo-zoom-img");
msg=$("#messagebox");
productZoomPlacement();
height=productPhotoImage.height();
width=productPhotoImage.width();
zoomRatio=height/zoomLayerImage.height();
var _2=Math.round(zoomLayer.width()*zoomRatio);
if(_2%2!=0){
_2+=1;
}
var _3=Math.round(zoomLayer.height()*zoomRatio);
if(_3%2!=0){
_3+=1;
}
$("#product-photo-window").css("width",_2+"px");
$("#product-photo-window").css("height",_3+"px");
xLimit=productPhotoImage.width()-(productWindow.width()+2);
yLimit=productPhotoImage.height()-(productWindow.height()+2);
if(zoomRatio<0.8){
productPhoto.mousemove(function(e){
displayProductZoom(e);
});
productPhoto.mouseout(function(e){
hideProductZoom(e);
});
$(window).resize(productZoomPlacement);
}
}
}
function displayProductZoom(e){
var x=0;
var y=0;
var _9=0;
var _a=0;
if(e.pageX){
x=e.pageX;
y=e.pageY;
}else{
if(e.clientX){
x=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
y=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
}
}
x-=left;
x-=(width*zoomRatio)/2;
if(x<0){
x=0;
}
if(x>xLimit){
x=xLimit;
}
y-=top_;
y-=(height*zoomRatio)/2;
if(y<0){
y=0;
}
if(y>yLimit){
y=yLimit;
}
productWindow.css("top",(y+top_)+"px");
productWindow.css("left",(x+left)+"px");
productWindowImage.css("top","-"+(y)+"px");
productWindowImage.css("left","-"+(x)+"px");
tintLayer.css("visibility","visible");
productWindow.css("visibility","visible");
x-=(width*zoomRatio)/2;
y-=(height*zoomRatio)/2;
zoomTop=Math.round(0-(y+(zoomLayer.height()*zoomRatio)/2)/zoomRatio);
if(zoomTop>0){
zoomTop=0;
}
zoomLeft=Math.round(0-(x+(zoomLayer.width()*zoomRatio)/2)/zoomRatio);
if(zoomLeft<(0-(zoomLayerImage.width()-zoomLayer.width()))){
zoomLeft=0-(zoomLayerImage.width()-zoomLayer.width());
}
zoomLayerImage.css("top",zoomTop+"px");
zoomLayerImage.css("left",zoomLeft+"px");
zoomLayer.css("visibility","visible");
}
function hideProductZoom(e){
tintLayer.css("visibility","hidden");
productWindow.css("visibility","hidden");
zoomLayer.css("visibility","hidden");
}


