<script type="text/javascript">

    jQuery(document).ready(function($){
        $('table.compare tr:odd').addClass('paros');
        
        $('.event_chooser input:radio').click(function(){
            $('input:radio').parent('td').removeClass('selected');
            $('input:radio:checked').parent('td').addClass('selected');
        });
        
        //click event for the registrate button
        $('.registrate_button').click(function(){
            var event_main_id = $(this).attr('event_main_id');
            
            $('.registration_container').filter(function(){
                return $(this).attr('event_main_id') == event_main_id;
            }).slideToggle();
            
            return false;
        });
        
        //radio container click event
        $('td.event_radio').click(function(){
            $(this).children(':radio').attr('checked', 'checked');
            $('input:radio').parent('td').removeClass('selected');
            $('input:radio:checked').parent('td').addClass('selected');
        });
        
        //toggle table and list views
        $('div.list_table_toggle_container span').click(function(){
            if($(this).hasClass('table_view')){
                $(this).removeClass('table_view').addClass('list_view');
                $(this).parents('.registration_container').children('.event_chooser').hide();
                $(this).parents('.registration_container').children('.event_chooser_list').show();
            } else if($(this).hasClass('list_view')){
                $(this).removeClass('list_view').addClass('table_view');
                $(this).parents('.registration_container').children('.event_chooser_list').hide();
                $(this).parents('.registration_container').children('.event_chooser').show();
            }
        });
        
        //create buttons
        $('.event_button').button();
    });

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

	h2.ws{
		background: url('/public/img/ui_images/ui-bg_glass_40_111111_1x400.png') repeat-x scroll 50% 50% rgb(17, 17, 17);
		color: white;
		font-size: 18px;
		font-weight: bold;
		padding-left: 10px;
		margin-top: 0px;
		margin-bottom: 0px;
		width: 720px;
	}

    #content-left{
        border: none;
    }

    div.registration_form_container{
        margin: 20px;
        padding: 10px;
        border: 1px solid #c4c4c4;
    }
    
    div.banner_picture{
        text-align: center;
        margin: 40px 0px;
    }
    
    td.date{
        font-size: 14px;
        font-weight: bold;
        text-align: center;
        padding: 5px 10px !important;
    }
    
    th.times{
        color: white;
        background-color: black;
        text-align: center;
        font-size: 12px;
    }
    
    tr.paros{
        background-color: #EDEAE8;
    }
    
    td.selected{
        background: url('/public/img/bg/jqueryui/84bc71_light_green_crossed.png') repeat scroll 50% 50% #84bc71;
    }
    
    div.error{
        color: red;
        text-align: center;
        margin: 0px 0px 20px 0px;
        font-weight: bold;
    }
    
    div.event_chooser td.full{
        background: url('/public/img/bg/jqueryui/b81900_light_red_crossed.png') repeat scroll 50% 50% #b81900;
    }
    
    div.event_chooser_list li.full span.text{
        text-decoration: line-through;
        color: gray;
    }
    
    div.event_chooser_list li.full span.full_text{
        color: red !important;
        font-weight: bold !important;
        text-decoration: none !important;
        margin-left: 10px;
    }
    
    div.event_chooser td.disabled{
        background: url('/public/img/bg/jqueryui/c1bebe_light_gray_crossed.png') repeat scroll 50% 50% #c1bebe;
    }
    
    div.main_event_container{
        float: left;
        margin-bottom: 10px;
        border: 1px solid black;
    }
    
    div.main_event_name{
        font-weight: bold;
        font-size: 18px;
        background: url("/public/img/ui_images/ui-bg_glass_40_111111_1x400.png") repeat-x scroll 50% 50% #111111;
        color: white;
        padding-left: 10px;
    }
    
    p.description{
        font-size: 12px;
        height: 132px;
        overflow: hidden;
        padding: 0px 10px 0px 10px;
    }
    
    div.thumbnail_container{
        width: 200px;
        height: 200px;
        float: left;
        border-right: 1px solid black;
    }
    
    #content div.thumbnail_container img{
        margin: 0px;
        padding: 0px;
    }
    
    div.details_container{
        width: 729px;
        height: 200px;
        float: left;
    }
    
    div.registration_container{
        clear: both;
        float: left;
        width: 100%;
    }
    
    a.date_not_link, a.date_not_link:visited, a.date_not_link:hover{
        text-decoration: none;
        color: black;
    }
    
    div.list_table_toggle_container{
        text-align: right;
    }
    
    div.list_table_toggle_container span{
        cursor: pointer;
        padding: 0px 20px;
        background: url(/public/img/icons/events/events_list_icons.png) no-repeat scroll transparent;
    }
    
    div.list_table_toggle_container span.list_view{
        background-position: -66px -7px;
    }
    
    div.list_table_toggle_container span.table_view{
        background-position: -13px -7px;
    }
    
    #content div.event_chooser_list ul, #content div.event_chooser_list ul li{
        margin: 0px;
        padding: 0px;
        list-style-type: none;
    }
    
    #content a.event_button{
        color: white !important;
    }
    
    div.main_event_with_reg_container{
        float: left;
        clear: both;
        margin-bottom: 20px;
    }

</style>
<?if($error):?>
<div class="error"><?=$error?></div>
<?endif;?>
<?if($main_events):?>
<div class="main_event_with_reg_container">
    <?foreach($main_events as $main_event):?>
    <div class="main_event_container">
        <div class="thumbnail_container">
            <img src="/public/upload/eng/image/events/banner/thumbs/<?=$main_event->thumbnail_name?>" alt="<?=$main_event->name?>" width="200" height="200" />
        </div>
        <div class="details_container">
            <h2 class="ws"><?=$main_event->name?></h2>
            <p class="description"><?=nl2br($main_event->description)?></p>
            <div class="right_links" style="text-align: right; margin: 0px 5px 5px 0px;">
                <a class="event_button" href="/page/show/<?=$main_event->archline_page?>" title="<?=$main_event->name?>"><?=lang('read_more')?></a>
                <?if($main_event->events):?>
                <a class="event_button registrate_button" href="" title="Registrate" event_main_id="<?=$main_event->event_main_id?>"><?=lang('registrate')?></a>
                <?endif;?>
            </div>
        </div>
    </div>
    <?if($main_event->events):?>
    <?=form_open('events', array('id' => 'registration_form'))?>
    <?=form_hidden('do', 'OK')?>
    <?=form_hidden('event_main_id', $main_event->event_main_id)?>
    <div class="registration_container" style="display: none;" event_main_id="<?=$main_event->event_main_id?>">
        <div class="list_table_toggle_container">
            <?if($main_event->event_view_id == 1):?>
            <span class="table_view">&nbsp;</span>
            <?elseif($main_event->event_view_id == 2):?>
            <span class="list_view">&nbsp;</span>
            <?endif;?>
        </div>
        <div class="event_chooser" style="margin: 20px 0px;<?if($main_event->event_view_id == 1):?> display: block;<?else:?> display: none;<?endif;?>">
            <table cellpadding="5" cellspacing="0" border="1" align="center" class="compare">
            <tr class="head">
                <th>&nbsp;</th>
                <?foreach($main_event->times as $time):?>
                <th class="times"><?=$time?></th>
                <?endforeach;?>
            </tr>
            <?foreach($main_event->events as $timestamp => $event_times):?>
            <tr>
                <td class="date"><a class="date_not_link" title="<?=$this->dateclass->getDateString($timestamp)?>"><?=date('Y. m. d.', $timestamp)?></a></td>
                <?foreach($main_event->times as $time):?>
                <?if(isset($event_times[$time])):?>
                <td align="center" class="<?if($event_times[$time]->able_to_reg):?>event_radio<?endif;?>">
                    <?if($event_times[$time]->able_to_reg):?>
                    <input type="radio" name="event_id" value="<?=$event_times[$time]->event_id?>" />
                    <?else:?>
                    <?=lang('full_event_td')?>
                    <?endif;?>
                </td>
                <?else:?>
                <td class="disabled">&nbsp;</td>
                <?endif;?>
                <?endforeach;?>
            </tr>
            <?endforeach;?>
            </table>
        </div>
        <div class="event_chooser_list" style="margin: 20px 0px;<?if($main_event->event_view_id == 2):?> display: block;<?else:?> display: none;<?endif;?>">
            <ul class="events_list">
                <?foreach($main_event->events as $timestamp => $event_times):?>
                <?foreach($main_event->times as $time):?>
                <?if(isset($event_times[$time])):?>
                <li<?if(!$event_times[$time]->able_to_reg):?> class="full"<?endif;?>>
                    <span class="text">
                        <input type="radio" name="event_id" value="<?=$event_times[$time]->event_id?>"<?if(!$event_times[$time]->able_to_reg):?> disabled="disabled"<?endif;?> />
                        <?if($event_times[$time]->name != $main_event->name):?>
                        <?=$event_times[$time]->name, ', '?>
                        <?endif;?>
                        <?=$this->dateclass->getDateString($timestamp), ' - ', $time?>
                    </span>
                    <?if(!$event_times[$time]->able_to_reg):?>
                    <span class="full_text"><?=lang('event_full_text')?></span>
                    <?endif;?>
                </li>
                <?endif;?>
                <?endforeach;?>
                <?endforeach;?>
            </ul>
        </div>
        <div class="registration_form_container">
            <table cellpadding="10" cellspacing="0" align="center">
        		<tr>
        			<td><strong><?=lang('events_form_name')?>:</strong></td>
        			<td><?=form_input('nev',$this->input->post('nev'),'size="40"')?></td>
                    <td><?=lang('events_form_city')?>:</td>
        			<td><?=form_input('varos',$this->input->post('varos'),'size="40"')?></td>
        		</tr>
        		<tr>
        			<td><?=lang('events_form_company')?>:</td>
        			<td colspan="3"><?=form_input('cegnev',$this->input->post('cegnev'))?></td>
        		</tr>
        		<tr>
        			<td><?=lang('events_form_zip')?>:</td>
        			<td><?=form_input('irsz',$this->input->post('irsz'),'size="5"')?></td>
                    <td><?=lang('events_form_address')?>:</td>
        			<td><?=form_input('cim',$this->input->post('cim'),'size="40"')?></td>
        		</tr>
        		<tr>
        			<td><strong><?=lang('events_form_phone')?>:</strong></td>
        			<td><?=form_input('tel',$this->input->post('tel'),'size="40"')?></td>
                    <td nowrap="nowrap"><strong><?=lang('events_form_email')?>:</strong></td>
        			<td><?=form_input('email',$this->input->post('email'),'size="40"')?></td>
        		</tr>
        		<tr>
        			<td><?=lang('events_form_comment')?>:</td>
        			<td colspan="3"><?=form_input('comment',$this->input->post('comment'))?></td>
        		</tr>
        		<tr>
        			<td align="center" colspan="4"><?=form_button(array('type' => 'submit', 'id' => 'mehet', 'name' => 'mehet', 'content' => lang('events_form_sub_reg')))?></td>
        		</tr>
        	</table>
        </div>
    </div>
    <?=form_close()?>
    <?elseif(false):?>
    <div class="error"><?=lang('no_event')?>&nbsp;-&nbsp;<?if(hun()):?><?=anchor('/page/show/27', lang('events_form_contact_us'))?><?else:?><?=anchor('/page/show/102', lang('events_form_contact_us'))?><?endif;?></div>
    <?endif;?>
    <?endforeach;?>
</div>
<?else:?>
<div class="error"><?=lang('no_main_event')?>&nbsp;-&nbsp;<?if(hun()):?><?=anchor('/page/show/27', lang('events_form_contact_us'))?><?else:?><?=anchor('/page/show/102', lang('events_form_contact_us'))?><?endif;?></div>
<?endif;?>