
$(function(){
	
	var FramePosition = {
		
		init : function(){
			
			var me = this;
			this.isIe = false;
			if ($.browser.msie && 7 > parseInt($.browser.version)){
				this.isIe = true;
			}
			this.hNews = $('div.h_news');
			this.frame = $('div.h_news div.footnote div.frame');
			this.frameWrapper = this.frame.find('>div.l');
			this.frame.css({top: 0, height: 'auto'});
			this.getSize();
			
			this.bframeH = false;
			this.margins = this.isIe ? 50 : -30;
			if((this.frameH+this.margins) <= this.hNewsH){
				this.bframeH = true;
			}
			// this.test = this.frameH+this.margins;
			this.alignment();
			
			$(window).resize(function(){
				me.frame.css({top: 0, height: 'auto'});
				me.getSize();
				if((me.frameH + this.margins) <= me.hNewsH){
					me.bframeH = true;
				} else {
					me.bframeH = false;
				}
				me.alignment();
			});
		},
		
		getSize : function(){
			this.hNewsH = this.hNews.height();
			this.frameH = this.frameWrapper.height();
			// alert(this.hNewsH)
			// alert(this.frameH,this.frame)
		},
		
		alignment : function(){
			if(this.bframeH){
				this.frame.height(this.hNewsH);
				// this.hNews.prepend('<div style="position:absolute; white-space:nowrap"><p>'+this.hNewsH+'</p>&nbsp;<p style="background:red;">!!!!!!!!!!'+this.frameH+'</p></div>');
			} else {
				var d = (this.frameH - this.hNewsH)/2;
				this.frame.css({top: -d, height: 'auto'});
				// this.hNews.prepend('<div style="position:absolute; white-space:nowrap"><p>'+this.hNewsH+'</p>&nbsp;<p style="background:red;">'+this.frameH+'</p></div>');
			}
		}
		
	};
	$(window).load(function(){
		FramePosition.init();
	});
	
	
});