var resizePage = Class.create({
	MAIN_SECTION_MIN_WIDTH: 999,
	MAIN_BANNER_MARGIN_LEFT: 0,
	MAIN_BANNER_MIN_WIDTH: 999,
    initialize: function (a) {

	this.wrapperEl = "mainWrapper";
	this.containerEl = "container";
	this.headerEl = "header";
	this.footerEl = "footer";
	this.wrapperHeight = 0;
	this.headerHeight = $('header').getHeight();
	this.footerHeight = $(this.footerEl).getHeight();

	this._previousWrapperHeight = 0;
	this.mainSectionEl = "mainSection";
	this.mainSectionWidth = $(this.mainSectionEl).getWidth();
	this.mainbanner1 = "mainbanner1";
	this.mainBannerImage1 = "bigbanner1";
	this.imagebig1 = "imagebig1";
	this.imagebigwidth1 = 555;
	this.imagebigheight1 = 850;
	this.mainbanner2 = "mainbanner2";
	this.mainBannerImage2 = "bigbanner2";
	this.imagebig2 = "imagebig2";
	this.imagebigwidth2 = 555;
	this.imagebigheight2 = 850;
	this.mainbanner3 = "mainbanner3";
	this.mainBannerImage3 = "bigbanner3";
	this.imagebig3 = "imagebig3";
	this.imagebigwidth3 = 555;
	this.imagebigheight3 = 850;

        if (initVar == 0) {
            Event.observe(window, "resize", this.initialize.bindAsEventListener(this));
        }	
	this.resize()
    },
    resize: function () {
		var a = $(this.containerEl).getHeight();
		var c = a - this.headerHeight - this.footerHeight;
		if (c !== this.wrapperHeight) {
			$(this.wrapperEl).setStyle({
			height: c +"px"
			});
			this.wrapperHeight = c
		}


		var d = $(this.mainSectionEl).getWidth();
//		alert(d + "-" + this.mainSectionWidth);
//		if (d !== this.mainSectionWidth) {
			if (d < this.MAIN_SECTION_MIN_WIDTH) {
				var e = d - this.MAIN_BANNER_MIN_WIDTH - this.MAIN_BANNER_MARGIN_LEFT - 1;
//				alert('test');
				$(this.imagebig1).setStyle({
					width: "333px"
				});
				$(this.imagebig2).setStyle({
					width: "333px"
				});
				$(this.imagebig3).setStyle({
					width: "333px"
				});
			} else {
//				alert('test2');
				$(this.imagebig1).setStyle({
					width: parseInt(d/3) + "px"
				});
				$(this.imagebig2).setStyle({
					width: parseInt(d/3) + "px"
				});
				$(this.imagebig3).setStyle({
					width:  parseInt(d/3) +"px"
				});
				$(this.mainbanner1).setStyle({
					width: parseInt(d/3) + "px"
				});
				$(this.mainbanner2).setStyle({
					width: parseInt(d/3) + "px"
				});
				$(this.mainbanner3).setStyle({
					width:  parseInt(d/3) +"px"
				});

				var currentheight = $(this.wrapperEl).getHeight();
				var newheight1 = (this.imagebigheight1/this.imagebigwidth1)*parseInt(d/3);
				$(this.imagebig1).setStyle({
					height: parseInt(newheight1) + "px"
				});
				$(this.mainBannerImage1).setStyle({
					height: parseInt(currentheight) + "px"
				});
				var newheight2 = (this.imagebigheight2/this.imagebigwidth2)*parseInt(d/3);
				$(this.imagebig2).setStyle({
					height: parseInt(newheight2) + "px"
				});
				$(this.mainBannerImage2).setStyle({
					height: parseInt(currentheight) + "px"
				});
				var newheight3 = (this.imagebigheight3/this.imagebigwidth3)*parseInt(d/3);
				$(this.imagebig3).setStyle({
					height: parseInt(newheight3) + "px"
				});
				$(this.mainBannerImage3).setStyle({
					height: parseInt(currentheight) + "px"
				});
				
			}
//		}
		if (this._previousWrapperHeight !== this.wrapperHeight) {
			this._previousWrapperHeight = this.wrapperHeight;
			var g = this.wrapperHeight;
			var f = Math.floor(this.wrapperHeight);
/*				$(this.imagebig).setStyle({
					width: this.mainSectionWidth + "px"
				});*/
//				var newheight = (this.imagebigheight/this.imagebigwidth)*this.mainSectionWidth;
//				alert(newheight);
//				$(this.imagebig).setStyle({
//					height: newheight + "px"
//				});
/*ters				var newheight = g+170;
				var currentheight = $(this.containerEl).getHeight();

				$(this.imagebig).setStyle({
					height: newheight + "px"
				});

				var bannerwidth = $(this.imagebig).getWidth();
				var newheight2 = (this.imagebigheight/this.imagebigwidth)*this.mainSectionWidth;
//				alert(bannerwidth + "-" +  this.mainSectionWidth);
				if(bannerwidth>this.mainSectionWidth){
				$(this.imagebig).setStyle({
					height: parseInt(newheight2+20) + "px"
				});
				}teraz*/
/*				else if(bannerwidth<this.mainSectionWidth){
				alert(newheight2);
				$(this.imagebig).setStyle({
					height: parseInt(newheight2+20) + "px"
				});
				}*/
/*teraz				var bannerheight = $(this.imagebig).getHeight();
				var difference = currentheight-bannerheight;
//				alert(bannerheight + "-" + currentheight);
				
				if(bannerheight<currentheight){
				$(this.imagebig).setStyle({
					height: parseInt(g+difference) + "px"
				});
				}

				var bannerwidthn = $(this.imagebig).getWidth();
				var newheight2n = (this.imagebigheight/this.imagebigwidth)*this.mainSectionWidth;
//				alert(bannerwidth + "-" +  this.mainSectionWidth);
				if(bannerwidthn<this.mainSectionWidth){
				$(this.imagebig).setStyle({
					height: parseInt(newheight2n) + "px"
				});
				}
				
				$(this.mainBannerImage).setStyle({
					height: g + "px"
				});teraz*/
		}
   }	
});

var myResize;
var initVar = 0;
var resizeManager = {
    init: function () {
            myResize = new resizePage();
        initVar = 1
    }
};
Event.observe(window, "load", resizeManager.init);

