var PanelLeft = function()
{
	this.popupFrames = new Array();
	
	this.separatorLayer = null;
	
	this.frameNewsletterRegistrationWidth = 474;
	this.frameNewsletterRegistrationHeight = 372;
}

PanelLeft.prototype.initializeUI = function()
{
	this.body = document.getElementsByTagName("body")[0];
	
	this.createSeparatorLayer();
}
PanelLeft.prototype.onMouseOverUserRequest = function(element, event)
{
	element.style.textDecoration = "underline";
}

PanelLeft.prototype.onMouseOutUserRequest = function(element, event)
{
	element.style.textDecoration = "none";
}

PanelLeft.prototype.onClickNewsletter = function(element, event)
{
	this.displayNewsletterRegistrationPopup();
}

PanelLeft.prototype.displayNewsletterRegistrationPopup = function(element, event)
{
	if (this.frameNewsletterRegistration == null) 
	{
		if (isIE && document.all) 
		{
			this.frameNewsletterRegistration = document.createElement('<iframe onload="panelLeft.onLoadFrameNewsletterRegistration()" name="subtype_definition"></iframe>');
		}
		else 
		{
			this.frameNewsletterRegistration = document.createElement('iframe');
			this.frameNewsletterRegistration.setAttribute("onload", "panelLeft.onLoadFrameNewsletterRegistration()");
			this.frameNewsletterRegistration.name = "subtype_definition";
		}
		
		this.frameNewsletterRegistration.loaded = false;
		
		this.frameNewsletterRegistration.src = "newsletter_registration.php";
		this.frameNewsletterRegistration.style.zIndex = 30000;
		
		this.frameNewsletterRegistration.frameBorder = "0";
	}
	
	var windowSize = getWindowSize();
	var windowWidth = windowSize[0];
	var windowHeight = windowSize[1];

	this.frameNewsletterRegistration.style.position = "absolute";
	this.frameNewsletterRegistration.style.left = 0.5 * (windowWidth - this.frameNewsletterRegistrationWidth) + "px";
	
	if (!document.documentElement.scrollTop) 
		scrollY = document.body.scrollTop;
	else 
		scrollY = document.documentElement.scrollTop;
	
	if (windowHeight < this.frameNewsletterRegistrationHeight) 
	{
		this.frameNewsletterRegistration.setAttribute("width", this.frameNewsletterRegistrationWidth + 17);
		this.frameNewsletterRegistration.setAttribute("height", windowHeight);
		this.frameNewsletterRegistration.style.top = scrollY + "px";
	}
	else 
	{
		this.frameNewsletterRegistration.setAttribute("width", this.frameNewsletterRegistrationWidth);
		this.frameNewsletterRegistration.setAttribute("height", this.frameNewsletterRegistrationHeight);
		this.frameNewsletterRegistration.style.top = scrollY + 0.5 * (windowHeight - this.frameNewsletterRegistrationHeight) + "px";
	}

	// -----------------------------------------------------------------------------------------
	
	if (!this.frameNewsletterRegistration.parentNode)	
		this.body.appendChild(this.frameNewsletterRegistration);
	
	this.frameNewsletterRegistration.style.display = "block";
	
	this.popupFrames.push(this.frameNewsletterRegistration);
	
	this.displaySeparatorLayer();		
}	

PanelLeft.prototype.onCloseFrameNewsletterRegistration = function()
{
	this.hideSeparatorLayer();
	this.updateView();
}

PanelLeft.prototype.onLoadFrameNewsletterRegistration = function()
{
	
}

PanelLeft.prototype.createSeparatorLayer = function()
{
	var windowSize = getWindowSize();

	this.separatorLayer = document.createElement("div");
	this.separatorLayer.style.display = "none";
	this.separatorLayer.style.position = "absolute";
	this.separatorLayer.style.left = "0px";
	this.separatorLayer.style.top = "0px";
	this.separatorLayer.style.width = "100%";
	this.separatorLayer.style.height = windowSize[1] + "px";		
	this.separatorLayer.style.background= "#1F1F3F";
	this.separatorLayer.style.overflow = "visible";
	this.separatorLayer.style.zIndex = 25000;
	var opacity = 30;
	this.separatorLayer.style.filter = "alpha(opacity=" + opacity + ")";
    this.separatorLayer.style.MozOpacity = opacity/100;
    this.separatorLayer.style.opacity = opacity/100;
	this.separatorLayer.onclick = function(event){
		panelLeft.onClickSeparatorLayer(this, event)
	};
	
	this.body.appendChild(this.separatorLayer);
}

PanelLeft.prototype.onClickSeparatorLayer = function(element, event)
{	
	if (!event)
		window.event.cancelBubble = true;
	else
		event.cancelBubble = true;
}

PanelLeft.prototype.displaySeparatorLayer = function()
{	
	var bodySize = getElementSize(this.body);
	this.separatorLayer.style.height= bodySize[1] + "px";	
	this.separatorLayer.style.display = "inline";
}

PanelLeft.prototype.hideSeparatorLayer = function()
{	
	while(this.popupFrames.length > 0)
	{
		this.popupFrames[0].style.display = "none";
		this.popupFrames.pop(this.popupFrames[0]);
	}

	this.separatorLayer.style.display = "none";
}



var panelLeft = new PanelLeft();

addLoadListener(initPanelLeft);

function initPanelLeft()
{
	panelLeft.initializeUI();
}