$.widget( "ui.dep_size", {

    options: {
    	foreignSelector: ''
    },
    
    foreign: null,
    
    _create: function()
    {
    	this.options.foreignSelector = this.element.find('input[name=foreign-selector]:first').val();

    	this.foreign = $(this.options.foreignSelector); 
    	
    	var $this = this;
    	
    	this.doSync();
    	$(window).resize(function(){ $this.doSync(); });
    },
    
    doSync: function()
    {
    	var fHeight = this.foreign.height();
    	var cHeight = this.element.height();
    	
    	if (fHeight>cHeight) {
    		this.element.height(fHeight+30);
    	}
    	else {
    		this.foreign.height(cHeight-30);
    	}
    }
    
} );


$(document).ready(function(){
    $('.ui-dep-size').dep_size();
});

