/** * technical-support.detail.js * Pravesvuth Uparanukraw */ $(document).ready(function () { $("#technicalSupportTabs").tabs(); initImageLinks(); }); function initImageLinks() { $("a.content-img").each(function () { var _this = $(this); var img = new Image(); imgSrc = $(this).attr("href"); imgTitle = $(this).attr("title"); img.src = imgSrc; $(img).load(function () { var W=0; var H=0; var oX=0; var oY=0; var imgW = img.width; var imgH = img.height ; if (imgW > 180) $(_this).parent().css("width", "180px"); if (imgH > 180) $(_this).parent().css("height", "180px"); if (imgH > 180 && imgW > imgH) {H=180; W=Math.round(H*imgW/imgH); oX = Math.round(-(W-180)/2);} else if (imgW > 180) {W=180; H=Math.round(W*imgH/imgW); oY = Math.round(-(H-180)/2);} $(img).css({ "margin-left": oX+"px", "margin-top": oY+"px", "width": ((W!=0)?W+"px":imgW+"px"), "height": ((H!=0)?H+"px":imgH+"px") }); $(_this).html(img); if (imgH <= 180 && imgW <= 180) { $(_this).attr("href", "#"); } else { $(_this).fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false }); $(_this).prepend("
"); } }); }); }