<script type="text/javascript">

    jQuery(document).ready(function($){
        
        var index = 1;
        
        //get the string for the new help div
        var getNewHelpDiv = function(newHelpIndex){
            
            var strNewHelp = '<div class="help">';
            
            strNewHelp += 'Videó cím:<br /><input type="text" value="" size="80" maxlength="128" name="title" id="title_' + newHelpIndex + '" /><br />Link:<br /><input type="text" class="swf_link" size="80" maxlength="255" id="swf_link_' + newHelpIndex + '" /><br />Szöveg:<br /><textarea cols="64" rows="10" class="text"></textarea>';
            
            strNewHelp += '<div class="remove">Törlés</div>';
            
            strNewHelp += '</div>';
            
            return strNewHelp;
        };
        
        //insert new video button event
        $('#new_button').css({'cursor': 'pointer'}).click(function(){
            
            //create new help div
            $('#temp_new_divs').append(getNewHelpDiv(index));
            
            //set the click function for the deletion
            $('.remove').css({'cursor': 'pointer'}).click(function(){
                $(this).parent().remove();
            });
            
            index++;
        });
        
        //form submit event
        $('#button').click(function(){
            
            var i = 1;
            var strHtml = '';
            
            $('.help').each(function(){
                strHtml += '<div class="link" onmouseout="tooltip.hide()" onmouseover="tooltip.show(\'Lejátszás!\')"';
                strHtml += ' onclick="self.location.href=\'javascript:show(\'' + i + '\',\'' + $('#swf_link_'+i).val() + '\')\'">';
                strHtml += "<h2 class='divLinkInt'>" + $('#title_'+i).val() + "</h2></div>";
                strHtml += '<div id="' + i + '" class="sketchlike" style="display: none;"/>';
                
                i++;
            });
            
            $('#page_body').append(strHtml);
            //$('#page_form').submit();
        });
    });

</script>
<h1><?=$this->lang->line('pages_h1_edit')?></h1>

<div style="margin: 10px;">
<?=form_open('admin/pageedit_help/'.$record->page_id, array('id' => 'page_form'))?>
<?=form_hidden('page_id', $record->page_id)?>
<?=form_hidden('do', 'update')?>
<p>Kategória:&nbsp;Help<?=form_hidden('page_category', 'Help')?></p>
<p>Cím:&nbsp;&nbsp;<input type="text" name="page_title" size="80" value="<?=$record->page_title?>" /></p>

<div id="page_body_temp">
    <div id="temp_new_divs"></div>
    <div id="new_button">Új videó beillesztése</div>
</div>

<textarea name="page_body" id="page_body" style="display: none;"><?=$record->page_body?></textarea>

<input type="button" id="button" value="Mentés" />

<?if(false):?>
<?=form_submit('ok',$this->lang->line('faq_button_save'))?>
<?endif;?>

<div class="clear"></div>
<?=form_close()?>
</div>