<?php
$this->load_template('_header.php');
$this->load_template('_top.php');
?>
<script type="text/javascript" src="<?php echo $C->SITE_URL?>themes/<?php echo $C->THEME ?>/js/js_admin.js"></script>
<div id="generalspace">
        
    <div id="container">
    
    	<div id="column1-admin"><?php $this->load_template('_verticalmenu-admin.php'); ?></div>
        
        <div id="column2-admin">
		
            <div id="dashboard-admin2">
                
                <div class="editarea">
                	
                    <div class="boxdash">
                
	                    <div class="title"><?php echo $this->lang('admin_ads_title');?></div>
                        
                        <div class="spaceinfo">
                    
							<?php $this->load_template('__admin-smenu-ads.php');?>
                            
                            <div id="linkback" class="mrg10T linkblue">&laquo; <a href="<?php echo $C->SITE_URL?>admin/ads"><?php echo $this->lang('admin_txt_linkback')?></a></div>
                            
                            <div class="mrg10T mrg30B">
                            
                            	<div id="prevad" class="editarea">
                                	<div class="subtitle"><?php echo $this->lang('admin_ads_userads_txt_aduser'); ?></div>
                                    <div class="preview-ad mrg10T">
                                    	<a href="<?php echo $D->ad->url_destination?>" target="_blank" class="undecorated">
                                        <?php if (!empty($D->ad->image)) { ?>
                                        <div class="imagead"><img src="<?php echo($C->SITE_URL.$C->FOLDER_ADS.$D->ad->image)?>"></div>
                                        <?php } ?>
                                    	<div id="headlineP" class="headline"><?php echo $D->ad->headline?></div>
                                        <div id="urlvisibleP" class="urlvisible"><?php echo $D->ad->url_visible?></div>
                                        <div id="descriptiveline1P" class="descriptiveline"><?php echo $D->ad->descriptionline1?></div>
                                        <div id="descriptiveline2P" class="descriptiveline"><?php echo $D->ad->descriptionline2?></div>
                                        </a>
                                    </div>
                                </div>
                            
                                <div id="formadd">                                
                                
									<div class="editarea">
                                    
                                    	<div class="subtitle"><?php echo $this->lang('admin_ads_userads_txt_editad'); ?></div>
                    
			                            <div id="form01" class="mrg30B">
            			            		<form id="form1" name="form1" method="post" action="">
                                            <div>
                                                <div class="mrg10T grey1"><?php echo $this->lang('admin_ads_userads_txt_headline')?>:</div>
                                                <div><input onFocus="showNum('numheadline',1)" onBlur="showNum('numheadline',0)" onKeyUp="maxLong(this,25,'numheadline'); updatePreview('#headlineP','#headline');" name="headline" type="text" id="headline" class="boxinput withbox" value="<?php echo $D->ad->headline?>"/><span id="numheadline" class="grey1 hide mrg5L">25</span></div>
                                            </div>
                        
                        					<div class="mrg10T grey1"><?php echo $this->lang('admin_ads_userads_txt_descriptionline')?> 1:</div>
                        					<div><input onFocus="showNum('numdescription1',1)" onBlur="showNum('numdescription1',0)" onKeyUp="maxLong(this,33,'numdescription1'); updatePreview('#descriptiveline1P','#description1');" name="description1" type="text" id="description1" class="boxinput withbox" value="<?php echo $D->ad->descriptionline1?>"/><span id="numdescription1" class="grey1 hide mrg5L">32</span></div>

                        					<div class="mrg10T grey1"><?php echo $this->lang('admin_ads_userads_txt_descriptionline')?> 2:</div>
                        					<div><input onFocus="showNum('numdescription2',1)" onBlur="showNum('numdescription2',0)" onKeyUp="maxLong(this,33,'numdescription2'); updatePreview('#descriptiveline2P','#description2');" name="description2" type="text" id="description2" class="boxinput withbox" value="<?php echo $D->ad->descriptionline2?>"/><span id="numdescription2" class="grey1 hide mrg5L">32</span></div>

                        					<div class="mrg10T grey1"><?php echo $this->lang('admin_ads_userads_txt_displayurl')?>:</div>
                        					<div><input onFocus="showNum('numdisplayurl',1)" onBlur="showNum('numdisplayurl',0)" onKeyUp="maxLong(this,30,'numdisplayurl'); updatePreview('#urlvisibleP','#displayurl');" name="displayurl" type="text" id="displayurl" class="boxinput withbox" value="<?php echo $D->ad->url_visible?>"/><span id="numdisplayurl" class="grey1 hide mrg5L">30</span></div>

                        					<div class="mrg10T grey1"><?php echo $this->lang('admin_ads_userads_txt_destinationurl')?>:</div>
                        					<div><input name="destinationurl" type="text" id="destinationurl" class="boxinput withbox" value="<?php echo $D->ad->url_destination?>"/></div>
											<div id="msgok" class="yellowbox"></div>
                                            <div id="msgerror" class="redbox"></div>
                                            <div class="mrg10T mrg5B">
                                                <span><input type="submit" name="bsave" id="bsave" value="<?php echo $this->lang('admin_ads_userads_txt_bupdatead')?>" class="bblue hand"/></span>
                                            </div>
                      
					                      </form>
                                        </div>
                                
                                    </div>
                                
                                </div>
                            
								<script>
								function showNum(divnum, action) {
									if (action == 0) $('#' + divnum).hide('fast');
									else $('#' + divnum).show('fast');
								}
								
								function updatePreview(divPrev,divNew){
									$(divPrev).html($(divNew).val());
								}
								
								$("#numheadline").html(25 - $("#headline").val().length);
								$("#numdescription1").html(33 - $("#description1").val().length);
								$("#numdescription2").html(33 - $("#description2").val().length);
								$("#numdisplayurl").html(30 - $("#displayurl").val().length);
                                
                                var txt_err_headline='<?php echo $this->lang('admin_ads_userads_error_headline')?>';
                                var txt_err_descrip1='<?php echo $this->lang('admin_ads_userads_error_descriptionline1')?>';
                                var txt_err_descrip2='<?php echo $this->lang('admin_ads_userads_error_descriptionline2')?>';
                                var txt_err_displayu='<?php echo $this->lang('admin_ads_userads_error_displayurl')?>';
                                var txt_err_displayi='<?php echo $this->lang('admin_ads_userads_error_displayurlinvalid')?>';
                                var txt_err_destinau='<?php echo $this->lang('admin_ads_userads_error_destinationurl')?>';
                                var txt_err_destinai='<?php echo $this->lang('admin_ads_userads_error_destinationurlinvalid')?>';
								var codad = '<?php echo $D->ad->code?>';
                                $('#bsave').click(function(){
                                    updateAds('#msgerror', '#msgok', '#bsave');
                                    return false;
                                });
    
                                </script>
                                
                                
                                <div id="formstatus">                                
                                
									<div class="editarea">
                                    
                                    	<div class="subtitle mrg30T"><?php echo $this->lang('admin_ads_userads_txt_statusad'); ?></div>
                    
			                            <div id="form02" class="mrg30B">
            			            		<form id="form2" name="form2" method="post" action="">
                                            <div class="mrg10T grey1"><?php echo $this->lang('admin_ads_userads_txt_status')?>:</div>
											<div><select name="statusad" id="statusad" class="boxinput withbox">
                                                    <option value="0" <?php echo($D->ad->status_admin == 0 ? 'Selected' : ''); ?>><?php echo $this->lang('admin_ads_userads_txt_statusad_authorized')?></option>
                                                    <option value="1" <?php echo($D->ad->status_admin == 1 ? 'Selected' : ''); ?>><?php echo $this->lang('admin_ads_userads_txt_statusad_pausedforrevision')?></option>
                                                </select></div>

											<div id="msgok2" class="yellowbox"></div>
                                            <div id="msgerror2" class="redbox"></div>
                                            <div class="mrg10T mrg5B">
                                                <span><input type="submit" name="bsave2" id="bsave2" value="<?php echo $this->lang('admin_ads_userads_txt_status_bsubmit')?>" class="bblue hand"/></span>
                                            </div>
                      
					                      </form>
                                        </div>
                                
                                    </div>
                                
                                </div>
                               
                               
                               	<script>
                                $('#bsave2').click(function(){
                                    updateStatus('#msgerror2', '#msgok2', '#bsave2');
                                    return false;
                                });
								</script>
								
                            </div>
                                                
                    	</div>
                        
                    </div>
                    
				</div>

            </div>
        
        
        </div>
        
        <div class="sh"></div>
    
    </div>
            
</div> 

<?php
$this->load_template('_foot.php');
$this->load_template('_footer.php');
?>