var QQLightbox = Class.create({
	initialize: function(){
		this.stmnGAP1 = 70; 
		this.stmnGAP2 = 325; 
		this.stmnBASE = 90; 
		this.stmnActivateSpeed = 200;
		this.stmnScrollSpeed = 10;
		this.STATICMENU = $("qq_staticMenu");
		this.loadIframe();
	},	
	loadIframe : function(){
		$("qq_if_lb").src = constants.url() + "/jsp/qq_iframe_lightbox.jsp";
	},
	refreshQQ : function(){
		this.STATICMENU.style.top = document.body.scrollTop + this.stmnBASE;
		//this.refreshStaticMenu();
	},
	refreshStaticMenu : function(){
		
		var stmnTimer;
		var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;
		var staticMenuTop = this.STATICMENU.getStyle("top");
		
		stmnStartPoint = parseInt(staticMenuTop, 10);
		stmnEndPoint = this.getScroll() + this.stmnGAP2;
		if (stmnEndPoint < this.stmnGAP1) {
			stmnEndPoint = this.stmnGAP1;
		}
		stmnRefreshTimer = this.stmnActivateSpeed;
		
		if ( stmnStartPoint != stmnEndPoint ) {
			stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
			var tempValue = (( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount);
			var topSize = parseInt(staticMenuTop, 10) + tempValue + 'px';
			this.STATICMENU.setStyle({top: topSize});
			stmnRefreshTimer = this.stmnScrollSpeed;
		}
		stmnTimer = setTimeout ('qqLightbox.refreshStaticMenu();', stmnRefreshTimer);
	},
	gogo : function (){
		this.STATICMENU.style.display='none';
	},
	scroll : function(){
		console.log("hello");
	},
	getScroll: function(){
		if (self.pageYOffset) {
			this.yPos = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){
			this.yPos = document.documentElement.scrollTop; 
		} else if (document.body) {
			this.yPos = document.body.scrollTop;
		}
		return this.yPos;
	},
	clickQQ : function(key){
		var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=' + key;
		var oldscript=document.getElementById('testJs');
		var newscript=document.createElement('script');
		newscript.setAttribute('type','text/javascript'); 
		newscript.setAttribute('id', 'testJs');
		newscript.setAttribute('src',tempSrc);
		if(oldscript == null){
			document.body.appendChild(newscript);
		}else{
			oldscript.parentNode.replaceChild(newscript, oldscript);
		}
		return false;
		
	}
});
var qqLightbox = null;
Event.observe(window,'load',function(){
	qqLightbox = new QQLightbox();
	qqLightbox.refreshQQ();
});
//qqLightbox = new QQLightbox();
//qqLightbox.refreshQQ();

