﻿/* ---------- INFO MESSAGE ------------*/

infoMessage='';
function InfoMessage(message) {
	if (message != '') {
		this.doc = document;
		this.message = message;
		this.bordersize = 5;
		/*@cc_on
			/*@if (@_jscript)
				this.ie = (document.all && !window.opera) ? true : false;
			/*@else @*/
				this.ie = false;
			/*@end
		@*/
		this.ie7 = (this.ie && window.XMLHttpRequest);
		this.initialize();
	}
}
InfoMessage.prototype.initialize = function() {
	var objBody = this.doc.getElementsByTagName("body").item(0);	
	if (this.doc.getElementById('infoMain')) {
		objBody.removeChild(this.doc.getElementById("infoMain"));
	}
	var objInfoMessage = this.doc.createElement("div");
		objInfoMessage.setAttribute('id','infoMain');
		objInfoMessage.setAttribute((this.ie ? 'className' : 'class'), "bluebox");
		objInfoMessage.style.display = 'none';
	objBody.appendChild(objInfoMessage);
	objInfoMessage.innerHTML = '<div class="btop"><div class="bt_l" id="infoAboveContainer1"></div><div class="bt_m mes_tb" id="infoAboveContainer2"></div><div class="bt_r" id="infoAboveContainer3"></div></div><div class="bmiddle mes_m" id="infoContainer"><p class="hand_blue">&nbsp;</p><p class="handtext blue" id="infoCaption"></p><div class="clear"></div></div><div class="clear"></div>';
	this.show();
};
InfoMessage.prototype.show = function() {
	if (this.ie && !this.ie7)
		this.toggleSelects('hide');
	if (this.hideFlash)
		this.toggleFlash('hide');
	var pageSize = this.getPageSize();
	var objBody = this.doc.getElementsByTagName("body").item(0);
	var object = this.doc.getElementById('infoMain');
	if (this.isie) {
		object.style.bottom = "0px";
		var top = (this.getPageScroll() + (pageSize[3]-27));
		object.style.right = "0px";
	} else {
		object.style.left = ((pageSize[2]-428)) + "px";
		var top = (this.getPageScroll() + (pageSize[3]-37));
		object.style.top = top + "px";
	}
	//object.style.display = '';
	this.doc.getElementById('infoMain').onclick = function() { myInfoMessage.end(); return false; }
	this.doc.getElementById('infoContainer').onclick = function() { myInfoMessage.end(); return false; }
	var objCaption = this.doc.getElementById('infoCaption');
	objCaption.style.display = '';
	objCaption.innerHTML = this.message;
	var height = objCaption.offsetHeight;
	if (height>20)
		object.style.top = top-height+18 + "px";
	//new Effect.Highlight('infoAboveContainer1', {delay:1.0});
	new Effect.Highlight('infoAboveContainer2', {delay:1.0});
	//new Effect.Highlight('infoAboveContainer3', {delay:1.0});
	new Effect.Highlight('infoContainer', {delay:1.0});
	new Effect.Appear('infoMain');
	setTimeout('myInfoMessage.end();', 7000);
};
InfoMessage.prototype.end = function(caller) {
	new Effect.DropOut('infoMain');
	//this.doc.getElementById('infoMain').style.display = 'none';
	//this.toggleSelects('visible');
	if (this.hideFlash) { this.toggleFlash('visible'); }
};
InfoMessage.prototype.appear = function(id, opacity) {
	var object = this.doc.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + (opacity + 10) + ")";
};
InfoMessage.prototype.fade = function(id, opacity) {
	var object = this.doc.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	if (opacity <= 0) {
		try {
			object.display = 'none';
		} catch(err) { }
	}
};
InfoMessage.prototype.getPageScroll = function() {
	if (self.pageYOffset) {
		return this.isFrame ? parent.pageYOffset : self.pageYOffset;
	} else if (this.doc.documentElement && this.doc.documentElement.scrollTop){
		return this.doc.documentElement.scrollTop;
	} else if (document.body) {
		return this.doc.body.scrollTop;
	}
};
InfoMessage.prototype.getPageSize = function() {	
	var xScroll, yScroll, windowWidth, windowHeight;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = this.doc.scrollWidth;
		yScroll = (this.isFrame ? parent.innerHeight : self.innerHeight) + (this.isFrame ? parent.scrollMaxY : self.scrollMaxY);
	} else if (this.doc.body.scrollHeight > this.doc.body.offsetHeight){
		xScroll = this.doc.body.scrollWidth;
		yScroll = this.doc.body.scrollHeight;
	} else {
		xScroll = this.doc.getElementsByTagName("html").item(0).offsetWidth;
		yScroll = this.doc.getElementsByTagName("html").item(0).offsetHeight;
		xScroll = (xScroll < this.doc.body.offsetWidth) ? this.doc.body.offsetWidth : xScroll;
		yScroll = (yScroll < this.doc.body.offsetHeight) ? this.doc.body.offsetHeight : yScroll;
	}
	if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = this.doc.documentElement.clientWidth;
		if (self.innerHeight)
			windowHeight = self.innerHeight;
		else
			windowHeight = this.doc.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = this.doc.getElementsByTagName("html").item(0).clientWidth;
		windowHeight = this.doc.getElementsByTagName("html").item(0).clientHeight;
		windowWidth = (windowWidth == 0) ? this.doc.body.clientWidth : windowWidth;
		windowHeight = (windowHeight == 0) ? this.doc.body.clientHeight : windowHeight;
	}
	var pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
	var pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;
	return new Array(pageWidth, pageHeight, windowWidth, windowHeight);
};
InfoMessage.prototype.toggleFlash = function(state) {
	var objects = this.doc.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++) {
		objects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
	var embeds = this.doc.getElementsByTagName("embed");
	for (var i = 0; i < embeds.length; i++) {
		embeds[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
};
InfoMessage.prototype.toggleSelects = function(state) {
	var selects = this.doc.getElementsByTagName("select");
	for (var i = 0; i < selects.length; i++ ) {
		selects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
};
function initInfoMessage() { if (infoMessage != '') myInfoMessage = new InfoMessage(infoMessage); }
function showInfoMessage(message) { infoMessage=message; initInfoMessage(); infoMessage=''; }
addOnLoad(function() {setTimeout('initInfoMessage();', 1000);});

/* ---------- ERROR MESSAGE ------------*/

errorMessage='';
errorMessageTitle='';
function ErrorMessage(message,title) {
	if (message != '') {
		this.doc = document;
		this.message = message;
		this.title = title;
		this.bordersize = 5;
		/*@cc_on
			/*@if (@_jscript)
				this.ie = (document.all && !window.opera) ? true : false;
			/*@else @*/
				this.ie = false;
			/*@end
		@*/
		this.ie7 = (this.ie && window.XMLHttpRequest);
		this.initialize();
	}
}
ErrorMessage.prototype.initialize = function() {
	var objBody = this.doc.getElementsByTagName("body").item(0);	
	if (this.doc.getElementById('errOverlay')) {
		objBody.removeChild(this.doc.getElementById("errOverlay"));
		objBody.removeChild(this.doc.getElementById("errMain"));
	}
	var objOverlay = this.doc.createElement("div");
		objOverlay.setAttribute('id','errOverlay');
		objOverlay.style.display = 'none';
	objBody.appendChild(objOverlay);
	var objErrorMessage = this.doc.createElement("div");
		objErrorMessage.setAttribute('id','errMain');
		objErrorMessage.style.display = 'none';
	objBody.appendChild(objErrorMessage);
	var objContainer = this.doc.createElement("div");
		objContainer.setAttribute('id','errContainer');
		objContainer.setAttribute((this.ie ? 'className' : 'class'), "redbox");
	objContainer.innerHTML = '<div class="red_top"><div class="red_tl"></div><div class="red_tm mes_tb"></div><div class="red_tr"></div></div><div class="red_middle mes_m"><div class="redhead"><p class="hand">&nbsp;</p><p class="handtext bold white" id="errTitle"></p><div class="clear"></div></div><div class="redcontent"><p class="white" id="errCaption"></p><a href="javascript:myErrorMessage.end();" class="red_bordered_button ok_button">ok</a><div class="clear"></div></div></div><div class="red_bottom"><div class="red_bl"></div><div class="red_bm mes_tb"></div><div class="red_br"></div></div><div class="clear"></div>';
	objErrorMessage.appendChild(objContainer);
	this.show();
};
ErrorMessage.prototype.show = function() {
	if (this.ie && !this.ie7)
		this.toggleSelects('hide');
	if (this.hideFlash)
		this.toggleFlash('hide');
	var pageSize = this.getPageSize();
	var objOverlay = this.doc.getElementById('errOverlay');
	var objBody = this.doc.getElementsByTagName("body").item(0);
	objOverlay.style.height = pageSize[1] + "px";
	objOverlay.style.display = '';
	this.appear('errOverlay', 50);
	var object = this.doc.getElementById('errMain');
		object.style.top = (this.getPageScroll() + (pageSize[3] / 4)) + "px";
		object.style.display = '';
	/*this.doc.getElementById('errContainer').onclick = function() { myErrorMessage.end(); return false; }
	this.doc.getElementById('errOverlay').onclick = function() { myErrorMessage.end(); return false; }*/
	this.showContent();
	this.enableKeyboardNav();
};
ErrorMessage.prototype.showContent = function() {
	var object = this.doc.getElementById('errCaption');
	object.style.display = '';
	object.innerHTML = this.message;
	var object = this.doc.getElementById('errTitle');
	object.style.display = '';
	object.innerHTML = this.title?this.title:'Figyelem!';
};
ErrorMessage.prototype.enableKeyboardNav = function() { document.onkeydown = this.keyboardAction; };
ErrorMessage.prototype.disableKeyboardNav = function() { document.onkeydown = ''; };
ErrorMessage.prototype.keyboardAction = function(e) {
	var keycode = key = escape = null;
	keycode	= (e == null) ? event.keyCode : e.which;
	key		= String.fromCharCode(keycode).toLowerCase();
	escape  = (e == null) ? 27 : e.DOM_VK_ESCAPE;
	enter   = (e == null) ? 13 : e.DOM_VK_ENTER;
	space   = (e == null) ? 32 : e.DOM_VK_SPACE;
	if ((key == 'x') || (key == 'c') || (keycode == escape) || (keycode == enter) || (keycode == space))
		myErrorMessage.end();
};
ErrorMessage.prototype.end = function(caller) {
	this.disableKeyboardNav();
	this.doc.getElementById('errMain').style.display = 'none';
	this.doc.getElementById('errOverlay').style.display = 'none';
	this.toggleSelects('visible');
	if (this.hideFlash) { this.toggleFlash('visible'); }
};
ErrorMessage.prototype.appear = function(id, opacity) {
	var object = this.doc.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + (opacity + 10) + ")";
};
ErrorMessage.prototype.fade = function(id, opacity) {
	var object = this.doc.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	if (opacity <= 0) {
		try {
			object.display = 'none';
		} catch(err) { }
	}
};
ErrorMessage.prototype.getPageScroll = function() {
	if (self.pageYOffset) {
		return this.isFrame ? parent.pageYOffset : self.pageYOffset;
	} else if (this.doc.documentElement && this.doc.documentElement.scrollTop){
		return this.doc.documentElement.scrollTop;
	} else if (document.body) {
		return this.doc.body.scrollTop;
	}
};
ErrorMessage.prototype.getPageSize = function() {	
	var xScroll, yScroll, windowWidth, windowHeight;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = this.doc.scrollWidth;
		yScroll = (this.isFrame ? parent.innerHeight : self.innerHeight) + (this.isFrame ? parent.scrollMaxY : self.scrollMaxY);
	} else if (this.doc.body.scrollHeight > this.doc.body.offsetHeight){
		xScroll = this.doc.body.scrollWidth;
		yScroll = this.doc.body.scrollHeight;
	} else {
		xScroll = this.doc.getElementsByTagName("html").item(0).offsetWidth;
		yScroll = this.doc.getElementsByTagName("html").item(0).offsetHeight;
		xScroll = (xScroll < this.doc.body.offsetWidth) ? this.doc.body.offsetWidth : xScroll;
		yScroll = (yScroll < this.doc.body.offsetHeight) ? this.doc.body.offsetHeight : yScroll;
	}
	if (self.innerHeight) {
		windowWidth = (this.isFrame) ? parent.innerWidth : self.innerWidth;
		windowHeight = (this.isFrame) ? parent.innerHeight : self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = this.doc.documentElement.clientWidth;
		windowHeight = this.doc.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = this.doc.getElementsByTagName("html").item(0).clientWidth;
		windowHeight = this.doc.getElementsByTagName("html").item(0).clientHeight;
		windowWidth = (windowWidth == 0) ? this.doc.body.clientWidth : windowWidth;
		windowHeight = (windowHeight == 0) ? this.doc.body.clientHeight : windowHeight;
	}
	var pageHeight = (yScroll < windowHeight) ? windowHeight : yScroll;
	var pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;
	return new Array(pageWidth, pageHeight, windowWidth, windowHeight);
};
ErrorMessage.prototype.toggleFlash = function(state) {
	var objects = this.doc.getElementsByTagName("object");
	for (var i = 0; i < objects.length; i++) {
		objects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
	var embeds = this.doc.getElementsByTagName("embed");
	for (var i = 0; i < embeds.length; i++) {
		embeds[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
};
ErrorMessage.prototype.toggleSelects = function(state) {
	var selects = this.doc.getElementsByTagName("select");
	for (var i = 0; i < selects.length; i++ ) {
		selects[i].style.visibility = (state == "hide") ? 'hidden' : 'visible';
	}
};
function initErrorMessage() { if (errorMessage != '') myErrorMessage = new ErrorMessage(errorMessage, errorMessageTitle); }
function showErrorMessage(message, title) { errorMessage=message; errorMessageTitle=title; initErrorMessage(); errorMessage=''; title=''; }
addOnLoad(initErrorMessage);