<?php echo $header;?>
<div id="dashboard">
	<div class="container">
<div class="row"><br/></div>
<div class="panel">

	<div class="panel-header">
		<?php if ( empty ( $ad ) ) { ?>
			<?php echo $LANG["WBS_ADVERTISER_AD_CREATE_NEW_AD"];?>
		<?php } else { ?>
			<?php echo $LANG["WBS_ADVERTISER_AD_CREATE_UPDATE_AD"];?>
		<?php } ?>
	</div>

<div class="panel-content">
<div class="row"><br/></div>
<div class="col-md-12">




<?php if ( empty ( $ad ) ) { ?>
<div class="col-md-12 input-group margin-bottom-10">
	<label><?php echo $LANG["WBS_ADVERTISER_AD_TYPE"];?></label>

	<select id="adv-ad-type" class="form-control">
		<option value="<?php echo HTTP_SERVER_WEBSITE;?>dashboard/advertiser/ad" selected><?php echo $LANG["WBS_ADVERTISER_AD_TYPE_TEXT"];?></option>
		<option value="<?php echo HTTP_SERVER_WEBSITE;?>dashboard/advertiser/ad/banner"><?php echo $LANG["WBS_ADVERTISER_AD_TYPE_BANNER"];?></option>
	</select>
</div>
<?php } ?>


<div class="row"><br/></div>

</div>

<div id="new-ad-form" class="col-md-6">



<div class="col-md-12 input-group margin-bottom-10">
	<label><?php echo $LANG["WBS_ADVERTISER_AD_SELECT_CAMPAIGN"];?></label>
	<select id="adv-ad-campaign" class="form-control">
		<option value="0"><?php echo $LANG["WBS_ADVERTISER_AD_SELECT_CAMPAIGN_OPTION"];?></option>
			<?php if ( !empty ( $campaigns ) ) { ?>
			<?php foreach($campaigns as $campaign): ?>
				<option value="<?php echo $campaign['adv_campaign_id'];?>" <?php if ( $ad['0']['aau_campaign'] == $campaign['adv_campaign_id'] ) { ?>selected<?php }?>><?php echo $campaign['adv_campaign_title'];?></option>
			<?php endforeach; ?>
			<?php } ?>
	</select>
</div>




<div class="col-md-12 input-group margin-bottom-10">
	<label><?php echo $LANG["WBS_ADVERTISER_AD_TARGET_COUNTRY"];?></label>
	<select id="adv-ad-country" class="form-control disabled-form">
		<option value="0"><?php echo $LANG["WBS_ADVERTISER_AD_TARGET_COUNTRY_OPTION"];?></option>
			<?php if ( !empty ( $countries ) ) { ?>
			<?php foreach($countries as $country): ?>
				<option value="<?php echo $country['country_id'];?>" <?php if ( $ad['0']['aau_target_country'] == $country['country_id'] ) { ?>selected<?php }?>><?php echo $country['country_name'];?></option>
			<?php endforeach; ?>
			<?php } ?>
	</select>
</div>

<div class="col-md-12 input-group margin-bottom-10">
	<label><?php echo $LANG["WBS_ADVERTISER_AD_TITLE"];?> ( <span id="adv-ad-title-chars"></span> )</label>
	<input id="adv-ad-title" type="text" class="form-control disabled-form" placeholder="<?php echo $LANG["WBS_ADVERTISER_AD_PLACEHOLDER_TITLE"];?>" value="<?php echo $ad['0']['aau_title'];?>">
	
	<input id="adv-ad-id" name="adv-ad-id" type="text" value="<?php echo $ad['0']['aau_id'];?>" style="display:none;"/>
</div>

<div class="col-md-12 input-group margin-bottom-10">
	<label><?php echo $LANG["WBS_ADVERTISER_AD_SUMMARY_1"];?> ( <span id="adv-ad-summary-1-chars"></span> )</label>
	<input id="adv-ad-summary-1" type="text" class="form-control disabled-form" placeholder="<?php echo $LANG["WBS_ADVERTISER_AD_PLACEHOLDER_DESCRIPTION_1"];?>" value="<?php echo $ad['0']['aau_summary'];?>">
</div>

<div class="col-md-12 input-group margin-bottom-10">
	<label><?php echo $LANG["WBS_ADVERTISER_AD_SUMMARY_1"];?> ( <span id="adv-ad-summary-2-chars"></span> )</label>
	<input id="adv-ad-summary-2" type="text" class="form-control disabled-form" placeholder="<?php echo $LANG["WBS_ADVERTISER_AD_PLACEHOLDER_DESCRIPTION_2"];?>" value="<?php echo $ad['0']['aau_summary_2'];?>">
</div>

<div class="col-md-12 input-group margin-bottom-10">
	<label><?php echo $LANG["WBS_ADVERTISER_AD_DISPLAYED_URL"];?> ( <span id="adv-ad-display-url-chars"></span> )</label>
	<input id="adv-ad-display-url" type="text" class="form-control disabled-form" placeholder="<?php echo $LANG["WBS_ADVERTISER_AD_PLACEHOLDER_DISPLAY_URL"];?>" value="<?php echo $ad['0']['aau_url'];?>">
</div>

<div class="col-md-12 input-group margin-bottom-10">
	<label><?php echo $LANG["WBS_ADVERTISER_AD_TARGET_URL"];?> ( <span id="adv-ad-target-url-chars"></span> )</label>
	<input id="adv-ad-target-url" type="text" class="form-control disabled-form" placeholder="<?php echo $LANG["WBS_ADVERTISER_AD_PLACEHOLDER_TARGET_URL"];?>" value="<?php echo $ad['0']['aau_target_url'];?>">
</div>

<div class="col-md-12 input-group margin-bottom-10">
	<div id="ad-loader"></div>
</div>

<div class="col-md-12 input-group margin-bottom-10">




<?php if ( $ad['0']['aau_status'] == '3' ) { ?>

	<div class="alert alert-danger" role="alert"><?php echo $LANG["WBS_ADVERTISER_AD_KEYWORD_DISABLED"];?></div>

<?php } else { ?>




<?php if ( !empty ( $ad ) ) { ?>
	<a href="<?php echo HTTP_SERVER_WEBSITE;?>dashboard/advertiser/keywords?id=<?php echo $ad['0']['aau_id'];?>" class="btn blue-btn pull-right"><?php echo $LANG["WBS_ADVERTISER_AD_MANAGE_KEYWORDS"];?></a>
	<div class="pull-right">&nbsp;&nbsp;&nbsp;</div>

	<button id="ad-submit" type="submit" class="btn blue-btn pull-right disabled-form"><?php echo $LANG["WBS_ADVERTISER_AD_UPDATE"];?></button>
<?php } else { ?>
	<button id="ad-submit" type="submit" class="btn blue-btn pull-right disabled-form"><?php echo $LANG["WBS_ADVERTISER_AD_SUBMIT"];?></button>
<?php } ?>


<?php } ?>



</div>


<div class="row"><br/></div>
</div>


<div class="col-md-6">
<legend><?php echo $LANG["WBS_ADVERTISER_AD_PREVIEW"];?></legend>
<script>


jQuery(document).ready(function (e) {
	var title = $("#adv-ad-title-chars");
	$("#adv-ad-title").limiter(35, title);

	var summary_1 = $("#adv-ad-summary-1-chars");
	$("#adv-ad-summary-1").limiter(35, summary_1);

	var summary_2 = $("#adv-ad-summary-2-chars");
	$("#adv-ad-summary-2").limiter(35, summary_2);
	
	var display_url = $("#adv-ad-display-url-chars");
	$("#adv-ad-display-url").limiter(35, display_url);
	
	var target_url = $("#adv-ad-target-url-chars");
	$("#adv-ad-target-url").limiter(250, target_url);

//** Preview **//
$("#adv-ad-title").on('keyup focus', function () {
   var name = $("#adv-ad-title").val();
   if ( name != "" ) {
		$("#title_1").html(name);
		$("#title_2").html(name);
   }
});

$("#adv-ad-summary-1").on('keyup focus', function () {
   var sumary = $("#adv-ad-summary-1").val();
   if ( sumary != "" ) {
		$("#description_1").html(sumary);
		$("#description_2_1").html(sumary);
   }
});

$("#adv-ad-summary-2").on('keyup focus', function () {
   var sumary = $("#adv-ad-summary-1").val();
   var sumary2 = $("#adv-ad-summary-2").val();
   if ( sumary2 != "" ) {
		$("#description_1").html(sumary+' '+sumary2);
		$("#description_2_2").html(sumary2);
   }
});

$("#adv-ad-display-url").on('keyup focus', function () {
   var url = $("#adv-ad-display-url").val();
   if ( url != "" ) {
		$("#url_1").html(url);
		$("#url_2").html(url);
   }
});

<?php if ( empty ( $ad ) ) { ?>
	$(".disabled-form").attr("disabled", "disabled");
<?php } else { ?>
	$(".disabled-form").removeAttr('disabled');
<?php } ?>

});
</script>

<?php if ( empty ( $ad ) ) { ?>
	<div style="width:460px;" class="pull-left adPreviewKeywords">
			<div id="title_1" class="title"><?php echo $LANG["WBS_ADVERTISER_AD_PREVIEW_TITLE"];?></div>
			<div id="url_1" class="url"><?php echo HTTP_DOMAIN;?></div>
			<div id="description_1" class="description"><?php echo $LANG["WBS_ADVERTISER_AD_PREVIEW_FULL_LINE"];?></div>
	</div>
	<div class="row"></div>
	<div class="pull-left adPreviewKeywords2">
			<div id="title_2" class="title"><?php echo $LANG["WBS_ADVERTISER_AD_PREVIEW_TITLE"];?></div>
			<div id="url_2" class="url"><?php echo HTTP_DOMAIN;?></div>
			<div id="description_2_1"class="description"><?php echo $LANG["WBS_ADVERTISER_AD_PREVIEW_LINE_1"];?></div>
			<div id="description_2_2" class="description"><?php echo $LANG["WBS_ADVERTISER_AD_PREVIEW_LINE_2"];?></div>
	</div>
<?php } else { ?>
	<div style="width:460px;" class="pull-left adPreviewKeywords">
			<div id="title_1" class="title"><?php echo $ad['0']['aau_title'];?></div>
			<div id="url_1" class="url"><?php echo $ad['0']['aau_url'];?></div>
			<div id="description_1" class="description"><?php echo $ad['0']['aau_summary'];?> <?php echo $ad['0']['aau_summary_2'];?></div>
	</div>
	<div class="row"></div>
	<div class="pull-left adPreviewKeywords2">
			<div id="title_2" class="title"><?php echo $ad['0']['aau_title'];?></div>
			<div id="url_2" class="url"><?php echo $ad['0']['aau_url'];?></div>
			<div id="description_2_1"class="description"><?php echo $ad['0']['aau_summary'];?></div>
			<div id="description_2_2" class="description"><?php echo $ad['0']['aau_summary_2'];?></div>
	</div>
<?php } ?>


</div>




<div class="row"><br/></div>
</div>

</div>
</div>
</div>
<?php echo $footer;?>