

function getLeft(element) {
	xPos = element.offsetLeft;
	tempElement = element.offsetParent;
	
	while (tempElement != null) {
		xPos += tempElement.offsetLeft;
		tempElement = tempElement.offsetParent;
	}
	
	return xPos;
} 


function getTop(element) {
	yPos = element.offsetTop;
	tempElement = element.offsetParent;
	
	while (tempElement != null) {
		yPos += tempElement.offsetTop;
		tempElement = tempElement.offsetParent;
	}
	
	return yPos;
} 


function element(objectID) {
	return document.getElementById ? document.getElementById(objectID) : document.all[objectID];
}


function setcookie(name, value, expires, path, domain, secure) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime(today.getTime());

	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if (expires)
	{
		expires = expires * 1000 * 60;
	}
	var expires_date = new Date(today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}


function getcookie(name) 
{
	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) && (name != document.cookie.substring(0, name.length)))
	{
		return null;
	}
	if (start == -1) return null;
	var end = document.cookie.indexOf(";", len);
	if (end == -1) end = document.cookie.length;
	return unescape( document.cookie.substring(len, end));
}



function deletecookie(name, path, domain) 
{
	if (getcookie(name)) 
		document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}



createFCK = function(a, div, textareaId, height, toolbarset)
{
	div.removeChild(a);
	textarea = element('textareaId');

	var oFCKeditor = new FCKeditor(textareaId) ;
	oFCKeditor.BasePath	= '/_includes/FCKeditor/';
	oFCKeditor.Height = height ;
	oFCKeditor.ToolbarSet = toolbarset;
	oFCKeditor.ReplaceTextarea() ;
}



function updateFCK()
{
	for ( i = 0; i < parent.frames.length; ++i )
	if ( parent.frames[i].FCK )
		parent.frames[i].FCK.UpdateLinkedField();
}





showErrorMessage = function(errors)
{
/*
	str = '<strong>Hiba!</strong><br /><br />';
	str += "<div style=\"text-align: left\">";
	for (i=0; i<errors.length; i++)
		str += '- ' + errors[i] + '<br />';

	str += "</div>";
*/

	str = 'Hiba!\n\n';
	for (i=0; i<errors.length; i++)
		str += '- ' + errors[i] + '\n';

	alert(str);
	

//	var d = Dialog.alert(str, {width:300, zIndex: 10000, draggable: true, className: 'alphacube'});
}


showMessage = function(message, redirect)
{

/*
	topDiv = document.createElement('div');
	
	messageDiv = document.createElement('div');
	messageDiv.id = 'message_' + containerId;
	messageDiv.innerHTML = msg;
	
//	closeButton = document.createElement('input');
//	messageDiv.appendChild(closeButton);

	topDiv.appendChild(messageDiv);
	
	$(containerId).scrollTo();
	new Insertion.Top(containerId, topDiv.innerHTML);
	*/
	alert(message);
//	var d = Dialog.alert(message, {width:300, zIndex: 10000, draggable: true, className: 'alphacube'});
	
	if (redirect)
		location.href = redirect;
}




var ImageSlideShow = Class.create();

ImageSlideShow.prototype = {

	initialize: function(id, n, count) {
		this.id = id;
		this.selected = n;
		this.count = count;

//		$$('#imageSlideShow_' + this.id + ' .imageSlideShow_window')[0].style.height = $('imageSlideShow_images_' + this.id).getHeight() + 'px';
		
		this.showImage(this.selected);
	},
	
	
	showImage: function(n)
	{
		try {
			$('imageSlideShow_' + this.id + '_number_' + this.selected).removeClassName('on');
		}
		catch(e) {}

		this.selected = n;
		x = -1 * (n-1) * 300;
		duration = 0.2;
		new Effect.Move ('imageSlideShow_images_' + this.id, {x: x, y:0, mode:'absolute', duration: duration});

		$('imageSlideShow_' + this.id + '_number_' + this.selected).addClassName('on');
	}
}
