<script type="text/javascript">

jQuery(document).ready(function($){
    //create the main events and their details from json
    var main_event_object = {
        getAllMainEvents: function(){
            return <?=$main_events_json?>;
        },
        getMainEventByID: function(event_main_id){
            var main_events = this.getAllMainEvents();
            var len = main_events.length;
            
            for(var i = 0; i < len; i++){
                if(main_events[i].event_main_id == event_main_id){
                    return main_events[i];
                }
            }
            
            return false;
        }
    };
    
    //open and close events for the lists
    $('.open-closer').click(function(){
        $(this).parent('li').next('ul').toggle();
    });
    
    //create the edit event dialog
    $('#edit_event_dialog').dialog({
        autoOpen: false,
        modal: true,
        width: 400,
        buttons: {
            'Módosítás': function(){
                $('#modositas_form').submit();
                $('#edit_event_dialog').dialog('close');
            },
            'Mégsem': function(){
                $('#edit_event_dialog').dialog('close');
            }
        }
    });
    
    //confirm the delete links
    $('.del_anchor').click(function(){
        var href = $(this).attr('href');
        var question = $(this).attr('question');
        
        //create the confirm dialog
        $('#confirm_dialog').dialog({
            autoOpen: false,
            modal: true,
            buttons: {
                'Törlés': function(){
                    window.location = href;
                },
                'Mégsem': function(){
                    $('#confirm_dialog').dialog('destroy');
                }
            }
        }).html(question).dialog('open');
        
        return false;
    });
    
    //edit the event details
    $('.edit_anchor').click(function(){
        //populate the dialog
        var con = $('#modositas_form');
        var event = $(this).parents('.event');
        
        $('#event_id', con).val(event.attr('event_id'));
        $('#event_main_id', con).val(event.attr('event_main_id'));
        $('#nev', con).val(event.attr('event_name'));
        $('#datum', con).val(event.attr('event_date'));
        $('#ora_kezdet', con).val(event.attr('event_start_hour'));
        $('#perc_kezdet', con).val(event.attr('event_start_min'));
        $('#ora_veg', con).val(event.attr('event_end_hour'));
        $('#perc_veg', con).val(event.attr('event_end_min'));
        $('#event_limit', con).val(event.attr('event_limit'));
        
        if(event.attr('active') === '1'){
            $('#active', con).attr('checked', 'checked');
        } else {
            $('#active', con).attr('checked', '');
        }
        
        if(event.attr('rss') === '1'){
            $('#rss', con).attr('checked', 'checked');
        } else {
            $('#rss', con).attr('checked', '');
        }
        
        //open the dialog
        $('#edit_event_dialog').dialog('open');
        
        return false;
    });
    
    //create the new event dialog
    $('#new_event_dialog').dialog({
        autoOpen: false,
        modal: true,
        buttons: {
            'Rögzítés': function(){
                $('#rogzites_form').submit();
                $('#new_event_dialog').dialog('close');
            },
            'Mégsem': function(){
                $('#new_event_dialog').dialog('close');
            }
        }
    });
    
    //insert new event
    $('.new_anchor').click(function(){
        //populate the dialog
        var con = $('#rogzites_form');
        var event = $(this).parent('.new-link');
        
        $('#event_main_id_uj', con).val(event.attr('event_main_id'));
        
        //open the dialog
        $('#new_event_dialog').dialog('open');
        
        return false;
    });
    
    var edit_main_event = {
        clickEvent: function(event_main_id){
            this.createDialog();
            this.populateDialog(event_main_id);
            this.openDialog();
        },
        createDialog: function(){
            if(!$('#edit_main_event_dialog').is(':data(dialog)')){
                $('#edit_main_event_dialog').dialog('destroy');
            }
            
            //create the edit main event dialog
            $('#edit_main_event_dialog').dialog({
                autoOpen: false,
                modal: true,
                width: 800,
                buttons: {
                    'Módosítás': function(){
                        $('#modositas_main_form').submit();
                        $('#edit_main_event_dialog').dialog('close');
                    },
                    'Mégsem': function(){
                        $('#edit_main_event_dialog').dialog('destroy');
                    }
                }
            });
        },
        openDialog: function(){
            if(!$('#edit_main_event_dialog').is(':data(dialog)')){
                this.createDialog();
            }
            
            $('#edit_main_event_dialog').dialog('open');
        },
        populateDialog: function(event_main_id){
            //first reset the content
            this.resetDialogContent();
            
            //populate the dialog
            var con = $('#modositas_main_form');
            var main_event = main_event_object.getMainEventByID(event_main_id);
            
            $('#event_main_id', con).val(main_event.event_main_id);
            $('#nev', con).val(main_event.name);
            $('#leiras', con).val(main_event.description);
            
            if(main_event.picture_name != ''){
                $('#kep', con).before('<div class="picture_link_container"><a href="/public/upload/eng/image/events/banner/'+main_event.picture_name+'" target="_blank" class="link" style="color: #003C70;">'+main_event.picture_name+'</a></div>');
            }
            
            if(main_event.thumbnail_name != ''){
                $('#thumb', con).before('<div class="picture_link_container"><a href="/public/upload/eng/image/events/banner/thumbs/'+main_event.thumbnail_name+'" target="_blank" class="link" style="color: #003C70;">'+main_event.thumbnail_name+'</a></div>');
            }
            
            $('#kep_eredeti').val(main_event.picture_name);
            $('#thumb_eredeti').val(main_event.thumbnail_name);
            $('#kiskep_eredeti1').val(main_event.elokep1);
            $('#kiskep_eredeti2').val(main_event.elokep2);
            $('#kiskep_eredeti3').val(main_event.elokep3);
            $('#kiskep_eredeti4').val(main_event.elokep4);
            $('#kozepkep_eredeti').val(main_event.kozepkep);
            
            $('#weboldal', con).val(main_event.homepage).next('span.view_link_container').children('.view_link').attr('href', main_event.homepage);
            $('#archline_oldal', con).val(main_event.archline_page).next('span.view_link_container').children('.view_link').attr('href', '/page/show/'+main_event.archline_page);
            $('#sikeres_reg_oldal', con).val(main_event.reg_success_page).next('span.view_link_container').children('.view_link').attr('href', '/page/show/'+main_event.reg_success_page);
            $('#sikeres_reg_mail', con).val(main_event.reg_success_mail_page).next('span.view_link_container').children('.view_link').attr('href', '/page/show/'+main_event.reg_success_mail_page);
            $('#reg_torles_oldal', con).val(main_event.reg_delete_page).next('span.view_link_container').children('.view_link').attr('href', '/page/show/'+main_event.reg_delete_page);
            $('#rovid_oldal', con).val(main_event.shorttext).next('span.view_link_container').children('.view_link').attr('href', '/page/show/'+main_event.shorttext);
            
            
            $('#view_img1', con).attr('href', '/public/upload/eng/image/events/banner/thumbs/'+main_event.elokep1);
            $('#view_img2', con).attr('href', '/public/upload/eng/image/events/banner/thumbs/'+main_event.elokep2);
            $('#view_img3', con).attr('href', '/public/upload/eng/image/events/banner/thumbs/'+main_event.elokep3);
            $('#view_img4', con).attr('href', '/public/upload/eng/image/events/banner/thumbs/'+main_event.elokep4);
            $('#kozepkepid', con).attr('href', '/'+main_event.kozepkep);
            
            
            $('#event_view_id', con).val(main_event.event_view_id);
            
            $('#datum_kezdet', con).val(main_event.start_date);
            $('#ora_kezdet', con).val(main_event.start_hour);
            $('#perc_kezdet', con).val(main_event.start_min);
            $('#datum_veg', con).val(main_event.end_date);
            $('#ora_veg', con).val(main_event.end_hour);
            $('#perc_veg', con).val(main_event.end_min);
            
            $('#event_main_limit', con).val(main_event.event_main_limit);
            
            if(main_event.active === '1'){
                $('#active', con).attr('checked', 'checked');
            } else {
                $('#active', con).attr('checked', '');
            }
            
            if(main_event.rss === '1'){
                $('#rss', con).attr('checked', 'checked');
            } else {
                $('#rss', con).attr('checked', '');
            }
            
            //set the select link's target
            $('select', con).each(function(){
                $(this).next('.view_link_container').children('a.view_link').attr('href', '/page/show/'+$(this).val());
            }).change(function(){
                $(this).next('.view_link_container').children('a.view_link').attr('href', '/page/show/'+$(this).val());
            });
        },
        resetDialogContent: function(){
            $('.picture_link_container').remove();
        }
    };
    
    //edit the main event details
    $('.edit_main_anchor').click(function(){
        var event_main_id = $(this).parents('.main_event').attr('event_main_id');
        
        //open the dialog
        edit_main_event.clickEvent(event_main_id);
        
        return false;
    });
    
    //create the new main event dialog
    $('#new_main_event_dialog').dialog({
        autoOpen: false,
        modal: true,
        width: 800,
        buttons: {
            'Rögzítés': function(){
                $('#rogzites_main_form').submit();
                $('#new_main_event_dialog').dialog('close');
            },
            'Mégsem': function(){
                $('#new_main_event_dialog').dialog('close');
            }
        }
    });
    
    //create the click event handler for the new main event anchor
    $('.new_main_anchor').click(function(){
        var con = $('#rogzites_main_form');
        
        $('#weboldal_uj', con).bind('keyup blur click', function(){
            $(this).next('.view_link_container').children('a.view_link').attr('href', $(this).val());
        });
        
        //set the select link's target
        $('select', con).each(function(){
            $(this).next('.view_link_container').children('a.view_link').attr('href', '/page/show/'+$(this).val());
        }).change(function(){
            $(this).next('.view_link_container').children('a.view_link').attr('href', '/page/show/'+$(this).val());
        });
        
        $('#new_main_event_dialog').dialog('open');
        
        return false;
    });
    
    $('input[name^="datum"]').datepicker().datepicker('option', {dateFormat: 'yy-mm-dd', showButtonPanel: false , showOn: 'focus', showMonthAfterYear: false, showButtonPanel: true}, $.datepicker.regional['hu']);
    
    //set the numeric fields
    $('.numeric').numeric();
});

</script>
<style type="text/css">

ul.main_events, ul.events, ul.registrations{
    list-style-type: none;
    padding: 0px;
}

ul.main_events, ul.events{
    margin: 0px 0px 0px 20px;
}

ul.registrations{
    margin: 5px 0px 5px 40px;
}

li.main_event{
    font-weight: bold;
}

li.main_event, li.event{
    color: green;
}

ul.events, ul.registrations{
    display: none;
}

li.full span.main_event_name, li.full span.event_date, li.full span.event_name{
    color: red !important;
}

li.inactive span.event_date, li.inactive span.main_event_name, li.inactive span.main_event_dates{
    color: gray !important;
    text-decoration: line-through;
}

li.new-link{
    margin: 5px 0px;
}

li.main_event span.open-closer, span.main_event_name{
    font-size: 14px !important;
}

span.main_event_dates{
    font-weight: normal;
    margin: 0px 0px 0px 10px;
}

span.event_name{
    margin: 0px 10px 0px 0px;
}

span.open-closer{
    margin-right: 10px;
    color: gray;
    cursor: pointer;
}

span.open-closer-space-holder{
    margin-right: 10px;
    color: white;
}

span.delete-link, span.edit-link{
    margin: 0px 0px 0px 20px;
}

span.view_link_container{
    margin: 0px 0px 0px 10px;
}

div#edit_event_dialog table tr td, div#new_event_dialog table tr td, div#edit_main_event_dialog table tr td, div#new_main_event_dialog{
    text-align: left;
}

div.error{
    margin: 10px;
    color: red;
    font-weight: bold;
    text-align: center;
}

div.picture_link_container{
    margin: 0px 0px 10px 0px;
}

a.view_link{
    color: #003C70 !important;
    font-size: 10px !important;
}

tr.neccessary td{
    font-weight: bold;
}

tr.neccessary td input{
    font-weight: normal !important;
    border: 1px solid black;
    background-color: #fdb910;
}

</style>
<?if($error):?>
<div class="error"><?=$error?></div>
<?endif;?>
<?if($main_events):?>
<div id="confirm_dialog" style="display: none;" title="Törlés megerősítés"></div>
<div id="edit_event_dialog" style="display: none;" title="Időpont módosítása">
    <?=form_open('admin/events_new', array('id' => 'modositas_form'))?>
    <?=form_hidden('do', 'modositas')?>
    <input type="hidden" name="event_id" id="event_id" />
    <input type="hidden" name="event_main_id" id="event_main_id" />
    <table cellspacing="0" cellpadding="10" border="0" align="center">
        <tr>
            <td>Név:</td>
            <td><input type="text" name="nev" id="nev" /></td>
        </tr>
        <tr class="neccessary">
            <td>Dátum:</td>
            <td><input type="text" name="datum" id="datum" class="date" /></td>
        </tr>
        <tr class="neccessary">
            <td>Kezdete:</td>
            <td><input class="numeric" type="text" name="ora_kezdet" id="ora_kezdet" maxlength="2" size="2" />:<input class="numeric" type="text" maxlength="2" size="2" name="perc_kezdet" id="perc_kezdet" /></td>
        </tr>
        <tr class="neccessary">
            <td>Vége:</td>
            <td><input class="numeric" type="text" name="ora_veg" id="ora_veg" maxlength="2" size="2" />:<input class="numeric" type="text" maxlength="2" size="2" name="perc_veg" id="perc_veg" /></td>
        </tr>
        <tr>
            <td nowrap="nowrap">Létszám korlát*:</td>
            <td><input class="numeric" type="text" name="event_limit" id="event_limit" maxlength="3" size="3" /></td>
        </tr>
        <tr>
            <td>Aktív:</td>
            <td><input type="checkbox" name="active" id="active" /></td>
        </tr>
        <tr>
            <td colspan="2">*: 0 = nincs létszám korlát</td>
        </tr>
    </table>
    <?=form_close()?>
</div>
<div id="edit_main_event_dialog" style="display: none;" title="Esemény módosítása">
    <?=form_open_multipart('admin/events_new', array('id' => 'modositas_main_form'))?>
    <?=form_hidden('do', 'modositas_main')?>
    <input type="hidden" name="event_main_id" id="event_main_id" />
    <input type="hidden" name="kep_eredeti" id="kep_eredeti" />
    <input type="hidden" name="thumb_eredeti" id="thumb_eredeti" />
    <input type="hidden" name="kiskep_eredeti1" id="kiskep_eredeti1" />
    <input type="hidden" name="kiskep_eredeti2" id="kiskep_eredeti2" />
    <input type="hidden" name="kiskep_eredeti3" id="kiskep_eredeti3" />
    <input type="hidden" name="kiskep_eredeti4" id="kiskep_eredeti4" />
    <input type="hidden" name="kozepkep_eredeti" id="kozepkep_eredeti" />
    <table cellspacing="0" cellpadding="10" border="0" align="center">
        <tr class="neccessary">
            <td>Név:</td>
            <td><input type="text" name="nev" id="nev" size="60" /></td>
        </tr>
        <tr>
            <td valign="top">Leírás:<br /><i>(ez jelenik meg az oldal tetején)</i></td>
            <td><textarea name="leiras" rows="6" cols="40" id="leiras"></textarea></td>
        </tr>
        <tr>
            <td valign="top">Banner:<br /><i>(ez jelenik meg a rövid leírás alatt)</i></td>
            <td><input type="file" name="kep" id="kep" /></td>
        </tr>
        <tr>
            <td valign="top">Kis kép:<br /><i>(200x200 ez jelenik meg a rövid leírás mellett)</i></td>
            <td><input type="file" name="thumb" id="thumb" /></td>
        </tr>
        <tr>
            <td>Hivatalos weboldal:<br /><i>(ide ugrik a bannerre kattintva)</i></td>
            <td>
                <input type="text" name="weboldal" id="weboldal" size="30" />
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr>
            <td>Részletező oldal:<br /><i>(ez jelenik meg a read more linkre kattintva)</i></td>
            <td valign="top">
                <select name="archline_oldal" id="archline_oldal">
                    <?foreach($event_pages as $page):?>
                    <option value="<?=$page->page_id?>"><?=$page->details->page_title?></option>
                    <?endforeach;?>
                </select>
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr>
            <td>Sikeres regisztráció oldal:</td>
            <td>
                <select name="sikeres_reg_oldal" id="sikeres_reg_oldal">
                    <?foreach($event_pages as $page):?>
                    <option value="<?=$page->page_id?>"><?=$page->details->page_title?></option>
                    <?endforeach;?>
                </select>
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr>
            <td>Sikeres regisztráció levél:</td>
            <td>
                <select name="sikeres_reg_mail" id="sikeres_reg_mail">
                    <?foreach($event_pages as $page):?>
                    <option value="<?=$page->page_id?>"><?=$page->details->page_title?></option>
                    <?endforeach;?>
                </select>
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr>
            <td>Regisztráció törlés oldal:</td>
            <td>
                <select name="reg_torles_oldal" id="reg_torles_oldal">
                    <?foreach($event_pages as $page):?>
                    <option value="<?=$page->page_id?>"><?=$page->details->page_title?></option>
                    <?endforeach;?>
                </select>
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr class="neccessary">
            <td>Főesemény kezdete:<br /><i>(ez nem időpont! új időpontot az esemény létrejötte után lehet felvenni)</i></td>
            <td valign="top"><input type="text" name="datum_kezdet" id="datum_kezdet" class="date" size="10" />&nbsp;-&nbsp;<input class="numeric" type="text" name="ora_kezdet" id="ora_kezdet" maxlength="2" size="2" />:<input class="numeric" type="text" maxlength="2" size="2" name="perc_kezdet" id="perc_kezdet" /></td>
        </tr>
        <tr class="neccessary">
            <td>Főesemény vége:</td>
            <td><input type="text" name="datum_veg" id="datum_veg" class="date" size="10" />&nbsp;-&nbsp;<input class="numeric" type="text" name="ora_veg" id="ora_veg" maxlength="2" size="2" />:<input class="numeric" type="text" maxlength="2" size="2" name="perc_veg" id="perc_veg" /></td>
        </tr>
        <tr>
            <td nowrap="nowrap">Létszám korlát*:</td>
            <td><input class="numeric" type="text" name="event_main_limit" id="event_main_limit" maxlength="3" size="3" /></td>
        </tr>
        <tr>
            <td>Alapértelmezett nézet:</td>
            <td>
                <select name="event_view_id" id="event_view_id">
                    <?foreach($event_views as $event_view):?>
                    <option value="<?=$event_view->event_view_id?>"><?=$event_view->name?></option>
                    <?endforeach;?>
                </select>
            </td>
        </tr>
        <tr>
            <td>Aktív:</td>
            <td><input type="checkbox" name="active" id="active" /></td>
        </tr>
        <tr>
            <td>RSS:</td>
            <td><input type="checkbox" name="rss" id="rss" /></td>
        </tr>
        <?
        for($i=1;$i<5;$i++){
            ?><tr>
            
            <td valign="top">
            	Alsó kép <?=$i?>: <i>(ez jelenik meg a rövid leírás alatt)</i>
            	<a href="" target="_blank" class="view_link" id="view_img<?=$i?>">Megtekint</a>
            </td>
            <td><input type="file" name="kiskep<?=$i?>" id="kiskep<?=$i?>" /></td>
            
            </tr><?
        }
        ?>
		<tr>
			<td>
				Kis kép:<br /><i>(558x95 ez jelenik meg a rövid leírás felett)</i>
				<a href="" target="_blank" class="view_link" id="kozepkepid">Megtekint</a>
			</td>
			<td><input type="file" name="kozepkep" /></td>
		</tr>
		<tr>
			<td>Rövid leírás oldal:</td>
			<td>
				<select name="rovid_oldal" id="rovid_oldal">
					<?foreach($event_pages as $page):?>
					<option value="<?=$page->page_id?>"><?=$page->details->page_title?></option>
					<?endforeach;?>
				</select>
				<span class="view_link_container">
					<a href="" target="_blank" class="view_link">megtekint</a>
				</span>
			</td>
		</tr>
		<tr>
			<td colspan="2">*: 0 = nincs létszám korlát</td>
		</tr>
	</table>
	<?=form_close()?>
</div>
<div id="new_main_event_dialog" style="display: none;" title="Új esemény rögzítése">
    <?=form_open_multipart('admin/events_new', array('id' => 'rogzites_main_form'))?>
    <?=form_hidden('do', 'rogzites_main')?>
    <table cellspacing="0" cellpadding="10" border="0" align="center">
        <tr class="neccessary">
            <td>Név:</td>
            <td><input type="text" name="nev" id="nev_uj" size="60" /></td>
        </tr>
        <tr>
            <td valign="top">Leírás:<br /><i>(ez jelenik meg az oldal tetején)</i></td>
            <td><textarea name="leiras" rows="6" cols="40" id="leiras_uj"></textarea></td>
        </tr>
        <tr>
            <td valign="top">Banner:<br /><i>(ez jelenik meg a leírás alatt)</i></td>
            <td><input type="file" name="kep" id="kep_uj" /></td>
        </tr>
        <tr>
            <td valign="top">Kis kép:<br /><i>(200x200 ez jelenik meg a rövid leírás mellett)</i></td>
            <td><input type="file" name="thumb" id="thumb_uj" /></td>
        </tr>
        <tr>
            <td>Hivatalos weboldal:<br /><i>(ide ugrik a bannerre kattintva)</i></td>
            <td>
                <input type="text" name="weboldal" id="weboldal_uj" size="30" />
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr>
            <td>Részletező oldal:<br /><i>(ez jelenik meg a read more linkre kattintva)</i></td>
            <td valign="top">
                <select name="archline_oldal" id="archline_oldal_uj">
                    <?foreach($event_pages as $page):?>
                    <option value="<?=$page->page_id?>"><?=$page->details->page_title?></option>
                    <?endforeach;?>
                </select>
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr>
            <td>Sikeres regisztráció oldal:</td>
            <td>
                <select name="sikeres_reg_oldal" id="sikeres_reg_oldal_uj">
                    <?foreach($event_pages as $page):?>
                    <option value="<?=$page->page_id?>"><?=$page->details->page_title?></option>
                    <?endforeach;?>
                </select>
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr>
            <td>Sikeres regisztráció levél:</td>
            <td>
                <select name="sikeres_reg_mail" id="sikeres_reg_mail_uj">
                    <?foreach($event_pages as $page):?>
                    <option value="<?=$page->page_id?>"><?=$page->details->page_title?></option>
                    <?endforeach;?>
                </select>
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr>
            <td>Regisztráció törlés oldal:</td>
            <td>
                <select name="reg_torles_oldal" id="reg_torles_oldal_uj">
                    <?foreach($event_pages as $page):?>
                    <option value="<?=$page->page_id?>"><?=$page->details->page_title?></option>
                    <?endforeach;?>
                </select>
                <span class="view_link_container"><a href="" target="_blank" class="view_link">megtekint</a></span>
            </td>
        </tr>
        <tr class="neccessary">
            <td>Főesemény kezdete:<br /><i>(ez nem időpont! új időpontot az esemény létrejötte után lehet felvenni)</i></td>
            <td valign="top"><input type="text" name="datum_kezdet" id="datum_kezdet_uj" size="10" />&nbsp;-&nbsp;<input class="numeric" type="text" name="ora_kezdet" id="ora_kezdet_uj" maxlength="2" size="2" />:<input class="numeric" type="text" maxlength="2" size="2" name="perc_kezdet" id="perc_kezdet_uj" /></td>
        </tr>
        <tr class="neccessary">
            <td>Főesemény vége:</td>
            <td><input type="text" name="datum_veg" id="datum_veg_uj" size="10" />&nbsp;-&nbsp;<input class="numeric" type="text" name="ora_veg" id="ora_veg_uj" maxlength="2" size="2" />:<input class="numeric" type="text" maxlength="2" size="2" name="perc_veg" id="perc_veg_uj" /></td>
        </tr>
        <tr>
            <td nowrap="nowrap">Létszám korlát*:</td>
            <td><input class="numeric" type="text" name="event_main_limit" id="event_main_limit_uj" maxlength="3" size="3" value="0" /></td>
        </tr>
        <tr>
            <td>Alapértelmezett nézet:</td>
            <td>
                <select name="event_view_id" id="event_view_id_uj">
                    <?foreach($event_views as $event_view):?>
                    <option value="<?=$event_view->event_view_id?>"><?=$event_view->name?></option>
                    <?endforeach;?>
                </select>
            </td>
        </tr>
        <tr>
            <td>Aktív:</td>
            <td><input type="checkbox" name="active" id="active_uj" checked="checked" /></td>
        </tr>
        <tr>
            <td>RSS:</td>
            <td><input type="checkbox" name="rss" id="rss" /></td>
        </tr>
        <tr>
            <td colspan="2">*: 0 = nincs létszám korlát</td>
        </tr>
    </table>
    <?=form_close()?>
</div>
<div id="new_event_dialog" style="display: none;" title="Új időpont rögzítése">
    <?=form_open('admin/events_new', array('id' => 'rogzites_form'))?>
    <?=form_hidden('do', 'rogzites')?>
    <input type="hidden" name="event_main_id" id="event_main_id_uj" />
    <table cellspacing="0" cellpadding="10" border="0" align="center">
        <tr class="neccessary">
            <td>Név:</td>
            <td><input type="text" name="nev" id="nev_uj" /></td>
        </tr>
        <tr class="neccessary">
            <td>Dátum:</td>
            <td><input type="text" name="datum" id="datum_uj" /></td>
        </tr>
        <tr class="neccessary">
            <td>Kezdete:</td>
            <td><input class="numeric" type="text" name="ora_kezdet" id="ora_kezdet_uj" maxlength="2" size="2" />:<input class="numeric" type="text" maxlength="2" size="2" name="perc_kezdet" id="perc_kezdet_uj" /></td>
        </tr>
        <tr class="neccessary">
            <td>Vége:</td>
            <td><input class="numeric" type="text" name="ora_veg" id="ora_veg_uj" maxlength="2" size="2" />:<input class="numeric" type="text" maxlength="2" size="2" name="perc_veg" id="perc_veg_uj" /></td>
        </tr>
        <tr>
            <td nowrap="nowrap">Létszám korlát:</td>
            <td><input class="numeric" type="text" name="event_limit" id="event_limit_uj" maxlength="3" size="3" /></td>
        </tr>
        <tr>
            <td>Aktív:</td>
            <td><input type="checkbox" name="active" id="active_uj" checked="checked" /></td>
        </tr>
    </table>
    <?=form_close()?>
</div>
<ul class="main_events">
    <li class="new-link"><?=anchor('', 'új esemény rögzítése', 'class="new_main_anchor"')?></li>
    <?foreach($main_events as $main_event):?>
    <li class="main_event<?if(!$main_event->able_to_reg):?><?=' full'?><?endif;?><?if(!$main_event->active):?><?=' inactive'?><?endif;?>" event_main_id="<?=$main_event->event_main_id?>">
        <span class="open-closer">+</span>
        <span class="main_event_name"><?=$main_event->name?></span>
        <span class="main_event_dates"><?=date('Y-m-d', $main_event->event_main_start_ts), ' - ', date('Y-m-d', $main_event->event_main_end_ts)?></span>
        <span class="edit-link"><?=anchor('', 'módosítás', 'class="edit_main_anchor" event_main_id="'.$main_event->event_main_id.'"')?></span>
        <span class="view-link">
            <?if(hun()):?>
            <?=anchor('http://www.archline.hu/interior/workshop/'.$main_event->urlname, ' - megtekintés', 'target="_blank"')?>
            <?else:?>
            <?=anchor('http://www.archlinexp.com/interior/workshop/'.$main_event->urlname, ' - megtekintés', 'target="_blank"')?>
            <?endif;?>
        </span>
        <span class="delete-link"><?=anchor('admin/events_new_main_event_delete/'.$main_event->event_main_id, 'törlés', 'class="del_anchor" question="Biztosan törli az eseményt?"')?></span>
    </li>
        <ul class="events">
            <?if($main_event->events_list):?>
            <li class="new-link" event_main_id="<?=$main_event->event_main_id?>"><?=anchor('', 'új időpont rögzítése', 'class="new_anchor"')?></li>
            <?foreach($main_event->events_list as $event):?>
            <li class="event<?if(!$event->able_to_reg):?><?=' full'?><?endif;?><?if(!$event->active):?><?=' inactive'?><?endif;?>" event_name="<?=$event->name?>" event_id="<?=$event->event_id?>" event_main_id="<?=$event->event_main_id?>" event_date="<?=date('Y-m-d', $event->start_ts)?>" event_start_hour="<?=date('H', $event->start_ts)?>" event_start_min="<?=date('i', $event->start_ts)?>" event_end_hour="<?=date('H', $event->end_ts)?>" event_end_min="<?=date('i', $event->end_ts)?>" event_limit="<?=$event->event_limit?>" active="<?=$event->active?>">
                <?if($event->reg_list):?>
                <span class="open-closer">+</span>
                <?else:?>
                <span class="open-closer-space-holder">+</span>
                <?endif;?>
                <?if($main_event->name != $event->name):?>
                <span class="event_name"><?=$event->name?></span>
                <?endif;?>
                <span class="event_date"><?=date('Y-m-d H:i', $event->start_ts), '&nbsp;-&nbsp;', date('Y-m-d H:i', $event->end_ts)?></span>
                <span class="edit-link"><?=anchor('', 'módosítás', 'class="edit_anchor" event_id="'.$event->event_id.'"')?></span>
                <span class="delete-link"><?=anchor('admin/events_new_event_delete/'.$event->event_id, 'törlés', 'class="del_anchor" question="Biztosan törli az időpontot?"')?></span>
            </li>
            <?if($event->reg_list):?>
            <ul class="registrations">
                <?foreach($event->reg_list as $reg):?>
                <li>
                    <span class="reg_email"><?=$reg->reg_name, '&nbsp;-&nbsp;', $reg->reg_company_name, '&nbsp;-&nbsp;', $reg->reg_zip, '&nbsp;-&nbsp;', $reg->reg_city, '&nbsp;-&nbsp;', $reg->reg_address, '&nbsp;-&nbsp;', $reg->reg_phone, '&nbsp;-&nbsp;', $reg->reg_email?></span>
                    <span class="delete-link"><?=anchor('admin/events_new_reg_delete/'.$reg->reg_id, 'törlés', 'class="del_anchor" question="Biztosan törli a regisztrációt?"')?></span>
                </li>
                <?endforeach;?>
            </ul>
            <?endif;?>
            <?endforeach;?>
            <li class="new-link" event_main_id="<?=$main_event->event_main_id?>"><?=anchor('', 'új időpont rögzítése', 'class="new_anchor"')?></li>
            <?else:?>
            <li class="new-link" event_main_id="<?=$main_event->event_main_id?>"><?=anchor('', 'új időpont rögzítése', 'class="new_anchor"')?></li>
            <?endif;?>
        </ul>
    <?endforeach;?>
    <li class="new-link"><?=anchor('', 'új esemény rögzítése', 'class="new_main_anchor"')?></li>
</ul>
<?else:?>
<p>No events!</p>
<?endif;?>