﻿
function PfxO(sElementId)
{
	if (document.all)
	 return document.all[sElementId];
	else
	 return document.getElementById(sElementId);
}
function PfxGetElementPosInfo(o)
{
	var info = new Object;
	var tmp = o;
	info.height = o.offsetHeight;
	info.width = o.offsetWidth;
	info.left = tmp.offsetLeft;
	info.top = tmp.offsetTop;
	while ((tmp=tmp.offsetParent) != null)
	{
		info.left += tmp.offsetLeft;
		info.top += tmp.offsetTop;
	}
	info.bottom = info.top + info.height;
	info.right = info.left + info.width;
	
	return (info);
}
function trace(string)
{
	alert(string);
}
function NumberPx(number)
{
	return number + "px";
}
function filterPx(string)
{
	return string.substring(0,string.length-2);
}
_construct =function(name,type)
{
	this.Item = PfxO(name);
	this.Item_ent = PfxO(name + "_ent");
	this.Item_pointer = PfxO(name + "_pointer");
	this.Item.type=type;

//	this.onMouseOver();
//	this.onMouseOut();	
}
_visibility = function()
{
	this.Item.style.display="block"
}
_initPosition=function(relelativeItem,leftRel,topRel)
{
	var posItemblocks_obj = PfxGetElementPosInfo( PfxO(relelativeItem));
	this.initTop = NumberPx(posItemblocks_obj.top + topRel);
	//trace(this.initTop);
	this.initLeft = NumberPx(posItemblocks_obj.left+leftRel);
	this.Item.style.left = this.initLeft;
	this.Item.style.top =  this.initTop;
	
	
}
_initHeights=function(v1,v2,v3)
{
	this.mainInitHeight=v1;
	this.textDivInitHeight=v2;
	this.targetHeight=v3;
	this.targetTextHeight=this.targetHeight-(this.mainInitHeight-this.textDivInitHeight);
	this.Item.style.height=NumberPx(this.mainInitHeight);
	this.Item_pointer.style.height=NumberPx(this.mainInitHeight);
	this.Item_ent.style.height=NumberPx(this.textDivInitHeight);
}

_mouseOverAction = function()
{
	this.Item.ent=this.Item_ent
	this.Item.pointer=this.Item_pointer
	this.Item.targetHeight=this.targetHeight
	this.Item.targetTextHeight=this.targetTextHeight
	this.Item.InitHeight=this.mainInitHeight
	this.Item.initTop=this.initTop;
	this.Item.onmouseover=function()
	{
		var Obj=new Object();
		this.style.zIndex=1000;
		if(this.tweenTA)
		{
			this.tweenTA.stop();
		}
	//	trace(this.tweenTA.inittop)
		this.tweenTA = new Tween(Obj,'xyz',Tween.strongEaseIn,Number(filterPx(this.style.height)),this.targetHeight,0.3);
	//	this.tweenTA.inittop=Number(filterPx(this.initTop))
	//	this.tweenTA.initheight=Number(filterPx(this.initTop))
		//trace(this.tweenTA.inittop)
		this.tweenTA.item=this
		li=0;ki=[]
			this.tweenTA.onMotionChanged = function(event)
			{
			 this.item.pointer.style.height=NumberPx(event.target._pos);
			 this.item.ent.style.height=NumberPx(event.target._pos-20);
			 this.item.style.height=NumberPx(event.target._pos)
			 
			
			 
		//	 trace(event.target._pos+this.item.InitHeight);
			 if(this.item.type=="center")
			 {
				// if(li<15)
				// {
				this.item.style.top=NumberPx(Number(filterPx(this.item.initTop))-Math.round(Number(event.target._pos-this.item.InitHeight))/2);
			//	 }else
				// {
				//	 this.item.style.top=NumberPx(Number(filterPx(this.item.initTop))-Number(10+event.target._pos-this.item.InitHeight)/2);
			//	 }
				//ki[li]=event.target._pos
				li++
			 }
			 if(this.item.type=="top")
			 {
				 this.item.style.top=NumberPx(Number(filterPx(this.item.initTop))-Number(event.target._pos-this.item.InitHeight));
			 }
			 
			 
			};
			this.tweenTA.onMotionFinished = function(event)
			{
				if(this.item.type=="center")
				 {
					// trace(this.item.style.top);
					this.item.style.top=NumberPx(Number(filterPx(this.item.initTop))-Number(this.item.targetHeight-this.item.InitHeight)/2);
					//trace(this.item.targetHeight);
				 }
			//	 trace(ki.length);
			}
		this.tweenTA.start();		
	}
		
}

_mouseOutAction = function()
{
	this.Item.ent=this.Item_ent
	this.Item.pointer=this.Item_pointer
	this.Item.itemHeight = this.mainInitHeight;
	this.Item.itemTextHeight = this.textDivInitHeight
	
	this.Item.onmouseout=function()
	{	
		this.tweenTA.stop();
		var Obj=new Object();
		this.tweenTA = new Tween(Obj,'xyz',Tween.strongEaseIn,Number(filterPx(this.style.height)),this.itemHeight,0.3);
		li=0;
		this.tweenTA.item=this
			this.tweenTA.onMotionChanged = function(event)
			{
			this.item.pointer.style.height=NumberPx(event.target._pos);
			 this.item.style.height=NumberPx(event.target._pos)
			  this.item.ent.style.height=NumberPx(event.target._pos-20);
			  
			 if(this.item.type=="center")
			 {
				 if(li<20)
				 {
				this.item.style.top=NumberPx(Number(filterPx(this.item.initTop))-Number(event.target._pos-this.item.InitHeight)/2);
				 }else
				 {
					 	this.item.style.top=NumberPx(Number(filterPx(this.item.initTop))-Number(event.target._pos-this.item.InitHeight)/2);
				 }
				 li++
			 }
			 if(this.item.type=="top")
			 {
				 this.item.style.top=NumberPx(Number(filterPx(this.item.initTop))-Number(event.target._pos-this.item.InitHeight));
			 }
			  
			  
			  
			};
			this.tweenTA.onMotionFinished = function(event)
			{
				if(this.item.type=="center")
				 {
					 this.item.style.top=this.item.initTop;
					 }
				this.item.style.zIndex=1
				 
			}
		this.tweenTA.start();
		
	}
}
billboardItem = _construct;
billboardItem.prototype.setItemPosition = _initPosition;
billboardItem.prototype.visibility = _visibility;
billboardItem.prototype.onMouseOver = _mouseOverAction;
billboardItem.prototype.onMouseOut = _mouseOutAction;
billboardItem.prototype.initHeights = _initHeights;




resize=function()
			{
				var bGreen= new billboardItem("itemGreen","down");
				bGreen.setItemPosition("blocks",558,0);
				bGreen.initHeights(95,75,270);
				bGreen.onMouseOver();bGreen.onMouseOut();
				bGreen.visibility();
				
				
					var bYellow= new billboardItem("itemYellow","center");
					bYellow.setItemPosition("blocks",558,90);
					bYellow.initHeights(90,70,270);
					bYellow.onMouseOver();bYellow.onMouseOut();
					bYellow.visibility();
		
			var bBlue= new billboardItem("itemBlue","top");
			bBlue.setItemPosition("blocks",558,180);
			bBlue.initHeights(90,65,270);
			bBlue.onMouseOver();bBlue.onMouseOut();
			bBlue.visibility();
			//	bYellow.setItemPosition("blocks",558,97);
			//	bBlue.setItemPosition("blocks",558,182);
			}