// czartContent
function czartContent()
{
	this.domContent = jso_gAV('section',0,'className','content')[0];
	if(this.domContent)
	{
		this.offsetHeight = 0;
		this.bg = false;
		this.bgHeight = 0;
		this.domContainer = jso_gI('container')
		if(this.domContainer)
		{
			this.intervalF();
			var T = this;
			window.setInterval(function(){T.intervalF.call(T)},50);
			jso_aE(window,'resize',function(){T.intervalF.call(T);this.bgHeight = 0})
		}
	}
}
czartContent.prototype.intervalF = function()
{
	if(this.domContent.offsetHeight != this.offsetHeight)
	{
		if(this.offsetHeight == 0)
		{
			this.offsetHeight = this.domContent.offsetHeight;
		}
		else if(this.domContent.offsetHeight > this.offsetHeight)
		{
			this.offsetHeight += Math.ceil((this.domContent.offsetHeight - this.offsetHeight) / 5);
		}
		else
		{
			this.offsetHeight += Math.floor((this.domContent.offsetHeight - this.offsetHeight) / 5);
		}
		var height = this.offsetHeight + 36;
		this.domContainer.style.minHeight = (height < 520 ? 520 : height) + 'px';
	}
	if(this.bg)
	{
		if(this.oPortfolio.domArticle && this.oPortfolio.domArticle.offsetHeight)
		{
			var bgHeight = this.domContainer.offsetHeight - (this.domContent.offsetHeight + 36 - this.oPortfolio.domArticle.offsetHeight );
			if(bgHeight != this.bgHeight)
			{
				this.bgHeight = bgHeight;
				if(jso_ie)
				{
					var iepadding = getStyle(this.oPortfolio.domArticle,'padding').split(' ');
					var top = parseInt(iepadding[0]);
					var bottom = parseInt(iepadding[2]||iepadding[0]);
				}
				else
				{
					var top = parseInt(getStyle(this.oPortfolio.domArticle,'padding-top'));
					var bottom = parseInt(getStyle(this.oPortfolio.domArticle,'padding-bottom'));
				}
				var height = this.oPortfolio.domArticle.offsetHeight - ( top + bottom );
				var padding = bgHeight - height;
				if(padding < 80)padding = 80;
				this.oPortfolio.domArticle.style.padding = Math.ceil(padding/2) + "px 0 "+ Math.floor(padding/2) + "px 0";
			}
		}
	}
}
czartContent.prototype.showBG = function(oPortfolio)
{
	this.oPortfolio = oPortfolio;
	if(this.oPortfolio.domArticle)
	{
		this.oPortfolio.domArticle.style.padding = '';
	}
	this.bgHeight = 0;
	this.bg = true;
	this.intervalF();
}
czartContent.prototype.hideBG = function(oPortfolio)
{
	this.oPortfolio = oPortfolio;
	if(this.oPortfolio.domArticle)
	{
		this.oPortfolio.domArticle.style.padding = '';
	}
	this.bgHeight = 0;
	this.bg = false;
	this.intervalF();
}
// czartHeader
function czartHeader()
{
	this.domContainer = jso_gI('h_header');
	if(this.domContainer)
	{
		this.domImage = jso_gT('img',this.domContainer)[0];
		this.domAnachor = jso_gT('a',this.domContainer)[0];
		if(this.domAnachor)
		{
			this.url = this.domImage.getAttribute('src').match(/^(.*)(\.[^\.\/]+)$/);
			this.mouse = false;
			this.focus = false;
			var T = this;
			jso_aE(this.domAnachor,'focus',function(){T.onF.call(T)});
			jso_aE(this.domAnachor,'mouseover',function(){T.onF.call(T,true)});
			jso_aE(this.domAnachor,'blur',function(){T.offF.call(T)});
			jso_aE(this.domAnachor,'mouseout',function(){T.offF.call(T,true)});
		}
	}
}
czartHeader.prototype.onF = function(mouse)
{
	if(mouse)
	{
		this.mouse = true;
	}
	else
	{
		this.focus = true;
	}
	this.domImage.setAttribute('src',this.url[1]+'_on'+this.url[2]);
}
czartHeader.prototype.offF = function(mouse)
{
	if(mouse)
	{
		this.mouse = false;
	}
	else
	{
		this.focus = false;
	}
	if(!this.mouse && !this.focus)
	{
		this.domImage.setAttribute('src',this.url[0]);
	}
}
// czartBG
function czartBG()
{
	if(window.czart_bg && czart_bg[0])
	{
		this.images = czart_bg;
		this.level = 0;
		this.active = false;
		this.domContainer = jso_gI('container');
		this.domImageBackground = jso_cE('img',{className:'preload',width:1,height:1,alt:''},0,this.domContainer);
		this.domImageShadow = jso_cE('img',{className:'preload',width:1,height:1,alt:''},0,this.domContainer);
		this.czartCookie = readCookie('czartCookie') || 0;
		for(var i=0;i<this.czartCookie;i++)
		{
			this.images.push(this.images.shift());
		}
		this.domImageBackground.src = this.images[0].background;
		if(this.images[0].shadow)
		{
			this.domImageShadow.src = this.images[0].shadow;
		}
		this.domContainer.style.backgroundImage = 'url('+this.images[0].background+')';
		this.domShadowShadow = jso_cE('div',{id:'container_shadow'});
		this.domContainer.insertBefore(this.domShadowShadow,this.domContainer.firstChild);
		if(this.images.length > 1)
		{
			this.domBG = jso_cE('div',{id:'container_new_bg'});
			var T = this;
			this.interval = window.setInterval(function(){T.intervalF.call(T);},50)
		}
	}
}
czartBG.prototype.doNotPlay = false;
czartBG.prototype.intervalF = function()
{
	if(czartBG.prototype.doNotPlay)
	{
		return;
	}
	if(this.level == 0)
	{
		this.domImageBackground.src = this.images[1].background;
		if(this.images[1].shadow)
		{
			this.domImageShadow.src = this.images[1].shadow;
		}
	}
	if(this.level == 150 && !this.domImageBackground.complete)
	{
		return;
	}
	this.level ++;
	if(this.level == 50)
	{
		if(this.images[0].shadow)
		{
			if(!jso_ie)jso_sO(this.domShadowShadow,0);
			this.domShadowShadow.style.backgroundImage = 'url('+this.images[0].shadow+')';
		}
	}
	else if(this.level > 50 && this.level < 70)
	{
		if(this.images[0].shadow)
		{
			if(!jso_ie)jso_sO(this.domShadowShadow,(this.level-50)/20);
		}
	}
	else if(this.level == 70)
	{
		if(this.images[0].shadow)
		{
			jso_cO(this.domShadowShadow);
		}
	}
	else if(this.level == 100)
	{
		jso_cO(this.domShadowShadow);
	}
	else if(this.level == 150)
	{
		this.domBG.style.backgroundImage = 'url('+this.images[1].background+')';
		jso_sO(this.domBG,0);
		this.domContainer.insertBefore(this.domBG,this.domContainer.firstChild);
		if(this.images[0].shadow && jso_ie)
		{
			this.domShadowShadow.style.backgroundImage = '';
		}
	}
	else if(this.level == 170)
	{
		this.images.push(this.images.shift());
		this.domContainer.style.backgroundImage = 'url('+this.images[0].background+')';
		this.domContainer.removeChild(this.domBG);
		this.level = 0;
		jso_sO(this.domShadowShadow,0);
		this.domShadowShadow.style.backgroundImage = '';
		this.czartCookie++;
		if(this.czartCookie == this.images.length)
		{
			this.czartCookie = 0;
		}
		createCookie('czartCookie',this.czartCookie,1);
	}
	else if(this.level > 150)
	{
		if(this.images[0].shadow)
		{
			if(!jso_ie)jso_sO(this.domShadowShadow,(170-this.level)/20);
		}
		jso_sO(this.domBG,(this.level - 150)/20);
	}
}
// czartStartAnimation
function czartStartAnimation()
{
	this.domContent = jso_gAV('section',0,'className','content')[0];
	if(this.domContent)
	{
		var T = this;
		this.level = 0;
		this.onEnd = [];
		jso_sO(this.domContent,0);
		this.interval = window.setInterval(function(){T.intervalF.call(T)},50);
	}
}
czartStartAnimation.prototype.intervalF = function()
{
	this.level++;
	czartBG.prototype.doNotPlay = true;
	if(this.level < 20)
	{
		jso_sO(this.domContent,this.level/20);
	}
	else
	{
		czartBG.prototype.doNotPlay = false;
		jso_cO(this.domContent);
		window.clearInterval(this.interval);
		for(var i=0;i<this.onEnd.length;i++)
		{
			this.onEnd[i]();
		}
	}
}
// czartStart
var oContent = new czartContent();
var oStartAnimation = new czartStartAnimation();
new czartBG();
new czartHeader();
