$(document).ready(function(){

	var activeBox = null;

	$('blockquote').hide();
	$('.doboz-cim').click(function(){
		var block;
		var item = this;
		i = 0;
		while (i < 4 && !$(item).next('blockquote'))
		{
			i++;
			item = $(item).parent();
		}
		block = $(item).next('blockquote').get(0);
		
		if (activeBox)
		{
			$(activeBox).slideUp();
			activeBox.is_visible = false;
		}
		if (block != activeBox && !block.is_visible)
		{
			$(block).slideDown();
			block.is_visible = true;
			activeBox = block;
		}
	});


	$('.tabla tr:odd').addClass('odd');

});

Acore = new Object();

/***************************************************************************/
/** Page **/

	Acore.Page = new Object();
	Acore.Page.OnLoad = function() {
		Acore.Control.HtmlText.Init();
	}


/***************************************************************************/
/** Control **/

	Acore.Control = new Object();
	Acore.Control.AJAXEval = function(data) {
		eval(data);
		Acore.Page.OnLoad();
	}
	Acore.Control.HandleEvent = function( event_name, control, control_name, use_ajax ) {
		var form = control.parents('form');
		if (form.length == 0)
		{
			$.post(location.href, {
				StateId: ACORE_STATE_ID,
				EventControl: control_name,
				EventAction: event_name,
				UseAJAX: 1
			}, Acore.Control.AJAXEval);
		}
		else
		{
			form.children('#EventControl').val(control_name);
			form.children('#EventAction').val(event_name);
			if (use_ajax)
			{
				form.children('#UseAJAX').val(1);
				form.ajaxForm(); 
				form.ajaxSubmit(Acore.Control.AJAXEval);
			}
			else
			{
				form.children('#UseAJAX').val(0);
				form.submit();
			}
		}
	}
	
	Acore.Control.HtmlText = new Object();
	Acore.Control.HtmlText.Init = function() {
		tinyMCE.init({

			mode : "textareas",
			language : "hu",
			theme : "advanced",
			plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

			theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
			theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,

			content_css : "/html/css/content.css"
			
		});
	}
	
	/*
	Acore.Control.List = new Object();
	Acore.Control.List.Update = function() {
		alert("Order updated");
	}
	Acore.Control.List.Init = function() {
		$('ul.sortable').each(function(i){
			if ($(this).children("li").length > 0)
				$(this).sortable({
					item:"li", 
					handle:"li > span.handler",
					axis:"y",
					update:Acore.Control.List.Update
				});
		});
	}
	*/
	
/***************************************************************************/
/** Functions **/

	function htmlspecialchars(ch) {
		ch = ch.replace(/&/g,"&amp;");
		ch = ch.replace(/\"/g,"&quot;");
		ch = ch.replace(/\'/g,"&#039;");
		ch = ch.replace(/</g,"&lt;");
		ch = ch.replace(/>/g,"&gt;");
		return ch;
	}
