﻿	$(document).ready(function(){
		fix_mb_pic(125,150);
		$(".button img").mouseover(function(){
			Swap($(this),"2");
		});
		$(".button img").mouseleave(function(){
			Swap($(this),"1");
		});
	});
	
	function Swap(obj,val){
		src = $(obj).attr("src");
		src_len=src.length;
		src = src.substring(0,src_len - 5) + val + src.substring(src_len - 4);
		$(obj).attr("src",src);
	}
	
	function fix_mb_pic(fixW,fixH){
		var image = new Image();
		image.src = $(".pic>img").attr("src");
		width = image.width;
		height = image.height;
		if(width > fixW && height > fixH){
			fixRatioW = width / fixW;
			fixRatioH = height / fixH;
			fixRatio=fixRatioW > fixRatioH?fixRatioH:fixRatioW;
			width = Math.round(width / fixRatio);
			height = Math.round(height / fixRatio);
			
			$(".pic>img").css("width",width);
			$(".pic>img").css("height",height);
		}
		
		pic_W=parseInt($(".pic").css("width"));
		pic_H=parseInt($(".pic").css("height"));
		pic_SW=parseInt($(".pic").attr("scrollWidth"));
		pic_SH=parseInt($(".pic").attr("scrollHeight"));
		pic_SL=parseInt((pic_SW-pic_W)/2);
		pic_ST=parseInt((pic_SH-pic_H)/2);
		$(".pic").attr("scrollLeft",pic_SL);
		$(".pic").attr("scrollTop",pic_ST);
	}
