/**
 *      按比例缩放图片
 *      @param int maxW 允许的最大宽度
 *      @param int maxH 允许的最大高度
 *		@author yeahoo2000@163.com
 */
$.fn.fixsize = function(maxW, maxH, speed, callback){
	speed = speed - 0 ? speed : 100;
	this.each(function(){
		fixImg(this, maxW, maxH, speed);
	});
	
	function fixImg (img, maxW, maxH, speed){
		var oImg = new Image();
		oImg.src = img.src;
                //alert(oImg.src + ' ::: ' + oImg.width + ':' + oImg.height);
		var oRatio = oImg.width / oImg.height;
		var ratio = maxW / maxH;
		var w,h;
		if(oImg.width > maxW && oRatio >= ratio){
			w = maxW;
			h = maxW / oRatio;
		}else if (oImg.height > maxH  && oRatio <= ratio){
			w = maxH * oRatio;
			h = maxH;
		}else {
			w = oImg.width;
			h = oImg.height;
		}

		$(img).attr({width:w, height:h}).css({width:w, height:h});
		$(img).animate({opacity:'show'}, speed, callback);
	}
}
$.winopen = function(	src		//窗口内容地址
,width	//宽度
,height	//高度
,s		//是否允许滚动条
){
	//弹出窗口并自动居中显示
	s = (s)?',resizable=1,scrollbars=yes':'';
	aa=window.open(src,'_blank','width='+width+','+'height='+height+s);
	b=screen.width;
	c=screen.height;
	b=(b-width)/2;
	c=(c-height)/2;
	aa.moveTo(b,c);
}
function addBookmark(title, url) {
    if (window.sidebar) { 
        window.sidebar.addPanel(title, url,""); 
    } else if(document.all) {
        window.external.AddFavorite( url, title);
    } else if(window.opera && window.print) {
        return true;
    }
}
