function StandardContent() {
    this.defaultBody;
    this.elementReference=$('<div class="standardContent"></div>');
    this.request=null;
    this.createDefaultBody();
    this._width;
    this.loadedHeight=0;
    this.isDefault=true;
    this.isLoaded=false;
}

StandardContent.prototype.createDefaultBody = function () {
	this.isDefault=true;
    var object=this;
    if(!this.defaultBody)
    	this.defaultBody = $('<div class="defaultStandardContent" style="text-align:center; position:relative">'+
				    			// '<img src="graphics/preloader.gif"/>'+
				    			'<div style="position:absolute;left:50%;margin-left:-12px;top:50%;margin-top:-12px"><img src="graphics/preloader.gif"/></div>'+
				    		'</div>');
    this.elementReference.html(this.defaultBody);
    //this.changeContent(this.defaultBody);
    this.elementReference.bind("contentCloseStart",function(event){
        object.prepareToRemove();
    });
    //TODO contentChanged not triggered here
};

StandardContent.prototype.changeContent=function(newContent){
	this.isDefault=false;
    this.elementReference.hide();
    this.elementReference.html(newContent);
    
   // var curHeight=this.elementReference.height();
   // this.elementReference.css('height','auto');
   // var newHeight=this.elementReference.height();
   // this.elementReference.height(newHeight);
    this.elementReference.fadeIn();
    //alert('asd');
    //this.loadedHeight=newHeight;//TODO why is this for?
    this.getBodyReference().trigger({
        type: "contentChanged",
        stack: this
    });
};

StandardContent.prototype.prepareToRemove=function(){
    this.isLoaded=false;
    if(this.request!=null){
        this.request.abort();
    }
};

StandardContent.prototype.getBodyReference = function () {
    return this.elementReference;
};

StandardContent.prototype.load = function (url) {
    this.isLoaded=false;
    var object=this;
    this.request = $.ajax({
        url: url,//TODO check if this works url: url
        success: function (data) {
            object.isLoaded=true;
            object.request=null;
            //object.elementReference.html(data);

            object.changeContent(data);//TODO changeContent called here
        },
        error: function (jqXHR, textStatus, errorThrown) {
            object.request=null;
            //object.elementReference.html("nie można załadować");
            obkect.changeContent('<div style="color:#FE8A00; font-family:Arial, Helvetica, sans-serif; font-size:12px; margin-top:110px; width:400px; margin-left:auto;margin-right:auto">Nie można załadować strony.</div>');
            object.getBodyReference().trigger({
                type: "contentChanged",
                stack: this
            });
        },
        dataType: 'html'
    });
};

StandardContent.prototype.defaultAction=function(){
    this.isLoaded=false;
    if(this.request!=null){
        this.request.abort();
    }
    this.createDefaultBody();
    this.getBodyReference().trigger({
        type: "contentChanged",
        stack: this
    });
};

StandardContent.prototype.height=function(){
	//alert(this.elementReference.height());
    if(this.isDefault==true)
        return 0;
    else{
        //return this.loadedHeight;
    	//alert(this.elementReference.height());
    	var curHeight=this.elementReference.height();
        this.elementReference.css('height','auto');
        var newHeight=this.elementReference.height();
        this.elementReference.height(newHeight);
        return newHeight;
    	//return this.elementReference.height();
    }
};

StandardContent.prototype.refreshBody=function(){
    this.getBodyReference().width(this._width);
};

StandardContent.prototype.width=function(newValue){
    if(newValue)
        this._width=newValue;
    else
        return this._width;
};

StandardContent.prototype.unload=function(){

};
