var Resizer =  new function()
{
    this.init = function(){Resizer.recordAsideWidth(); };
    this.addListeners = function(){ $(window).bind("resize", Resizer.resizeWindow);};
    
    this.resizeWindow = function()
    {
        if (($('#content').width() >= 880)) {
		
            $('.scale').each(function(){ Resizer.resizeContent($(this));});
        }
    };

    this.recordAsideWidth = function()
    {
        $('aside').each(function()
        {
            $(this).attr("width", $(this).css("width"));   
        });
		
		Resizer.resizeWindow();
		Resizer.addListeners();
    };
    
    
    this.resizeContent = function($this)
    {	
        $scale = Math.round(($('#content').width() / 1160) * 100) / 100;
		
		
		if(!$this.attr('nwidth')) { 
			$this.attr('nwidth',$this.width());
			$this.attr('nheight',$this.height());
		}

		if ($this.parent().parent().find('aside').width()) {

			$s = $this.parent().parent().find('aside').attr("width").replace("px","");
			if ( $s != '100%'){		   
			   $this.parent().parent().find('aside').css({
					width: ($scale * $s) + "px"
				});   
			}
        }
		//alert($($this).attr('nwidth'));
        $this.css({		
            width: ($scale * $($this).attr('nwidth')) + 'px',
            height: ($scale * $($this).attr('nheight')) + 'px'
        });
		
		
    };
};

$(window).load(function() {
	Resizer.init();
});
