function wscale(_width,_height,_defaultwidth,_defaultheight){ if((_width > _defaultwidth)&&(_height < _defaultheight)) { _height = _height*_defaultwidth/_width; _width = _defaultwidth; } else if((_height > _defaultheight)&&(_width < _defaultwidth)) { _width = (_width*(_defaultheight/_height)); _height = _defaultheight; } else if((_height > _defaultheight)&&(_width > _defaultwidth)) { if(_defaultwidth/_width < _defaultheight/_height) { _height = _height*_defaultwidth/_width; _width = _defaultwidth; } else { _width = _width*_defaultheight/_height; _height = _defaultheight; } } else { _height = _height; _width = _width; } return _width; }