$(document).ready(function(e){ $("table.searchResultTable tr.resultData").hover(function() { $(this).addClass("trhighlight"); }, function() { $(this).removeClass("trhighlight"); }); $("img.mj_hover_effect_01").hover(function() { $link = $(this).attr("ref2"); $(this).attr("src" , $link); }, function() { $link = $(this).attr("ref1"); $(this).attr("src" , $link); }) $('a.edmAd').fancybox({ 'titlePosition' : 'inside' , 'scrolling' : 'no', 'autoScale' : false , 'width' : 600, 'hideOnContentClick' : true }); }); var mj_newslettersubscribe = function(){ var email = $("input[name=news_subscribe_email]").val(); var fm = $("form[name=fm_news_subscribe]").val(); if(verityEmail(email) == false){ alert("错误的电子邮件地址格式"); }else{ $.ajax({ type: "POST", data: "r_email=" + email + "&anti=" + Math.floor(Math.random()*11) , url: 'newsletter_subscribe_proc.php', success: function(data) { alert("订阅成功"); } }); } } var verityEmail = function(iString){ var emailPattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if(iString.match(emailPattern)){ return true; }else{ return false; } } var mj_addToCart = function($Product){ $.ajax({ type: "POST", data: "action=add&product=" + $Product + "&anti=" + Math.floor(Math.random()*11) , url: 'cartAction_proc.php', success: function(data) { alert("已成功加进购物车"); } }); } var mj_RemoveFromCart = function($Product){ $.ajax({ type: "POST", data: "action=del&product=" + $Product + "&anti=" + Math.floor(Math.random()*11) , url: 'cartAction_proc.php', success: function(data) { alert("已从购物车中删除"); window.location.reload(); } }); } var productdeail = function($barcode){ window.open("product_detail.php?product="+$barcode , "ProductDetail" , "width=550,height=350,location=no"); } var mj_url_go = function($url){ window.location = $url; } /* $(document).ready(function() { $('img.edmPreview').each(function() { var maxWidth = 350; // Max width for the image var maxHeight = 350; // Max height for the image var ratio = 0; // Used for aspect ratio var width = $(this).width(); // Current image width var height = $(this).height(); // Current image height var tmpHeight = height; var tmpWidth = width; // Check if the current width is larger than the max if(width > maxWidth){ ratio = maxWidth / width; // get ratio for scaling image $(this).css("width", maxWidth); // Set new width $(this).css("height", height * ratio); // Scale height based on ratio height = height * ratio; // Reset height to match scaled image width = width * ratio; // Reset width to match scaled image tmpWidth = maxWidth; } // Check if current height is larger than max if(height > maxHeight){ ratio = maxHeight / height; // get ratio for scaling image $(this).css("height", maxHeight); // Set new height $(this).css("width", width * ratio); // Scale width based on ratio width = width * ratio; // Reset width to match scaled image } }); }); var resizeEDMPreview = function(obj) { var maxWidth = 350; // Max width for the image var maxHeight = 350; // Max height for the image var ratio = 0; // Used for aspect ratio var width = $(obj).width(); // Current image width var height = $(obj).height(); // Current image height var tmpHeight = height; var tmpWidth = width; // Check if the current width is larger than the max if(width > maxWidth){ ratio = maxWidth / width; // get ratio for scaling image $(obj).css("width", maxWidth); // Set new width $(obj).css("height", height * ratio); // Scale height based on ratio height = height * ratio; // Reset height to match scaled image width = width * ratio; // Reset width to match scaled image tmpWidth = maxWidth; } // Check if current height is larger than max if(height > maxHeight){ ratio = maxHeight / height; // get ratio for scaling image $(obj).css("height", maxHeight); // Set new height $(obj).css("width", width * ratio); // Scale width based on ratio width = width * ratio; // Reset width to match scaled image } } */