<div class="row">
	<div class="col-md-4 ads_col_4">
		<?php echo Wo_LoadPage('ads/includes/header'); ?>
	</div>
	<div class="col-md-8 ads_col_8">
		<form class="form form-horizontal" method="get" id="create-ads">
			<div class="page-margin wow_content wow_creads_minstp step-one-active">
				<div class="line">
					<div class="line_sec"></div>
					<div class="dot one">1</div>
					<div class="dot two">2</div>
					<div class="dot three">3</div>
				</div>
				<div class="steps">
					<div class="step step-one"><?php echo $wo['lang']['media']; ?></div>
					<div class="step step-two"><?php echo $wo['lang']['details']; ?></div>
					<div class="step step-three"><?php echo $wo['lang']['targeting']; ?></div>
				</div>
			</div>
			<div class="page-margin wow_create_ads_stp">
				<!-- Media Step  -->
				<div class="wow_creads_media_step">
					<div class="wo_page_hdng pag_neg_padd hidden">
						<div class="wo_page_hdng_innr">
							<span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M7,15L11.5,9L15,13.5L17.5,10.5L21,15M22,4H14L12,2H6A2,2 0 0,0 4,4V16A2,2 0 0,0 6,18H22A2,2 0 0,0 24,16V6A2,2 0 0,0 22,4M2,6H0V11H0V20A2,2 0 0,0 2,22H20V20H2V6Z"></path></svg></span> <?php echo $wo['lang']['ad_media']; ?>
						</div>
					</div>
					<?php if ($wo['user']['wallet'] == '0.00' || $wo['user']['wallet'] == '0') { ?>
						<div class="alert alert-warning"><?php echo $wo['lang']['balance_is_0'] ?> <a href="<?php echo Wo_SeoLink('index.php?link1=wallet'); ?>"><?php echo $wo['lang']['top_up'] ?></a></div>
					<?php } ?>
					<div class="wow_form_fields">
						<label for="company"><?php echo $wo['lang']['comp_name']; ?></label>
						<input id="company" name="name" type="text" max="50" onkeyup="document.getElementById('copy_camp_comp').innerHTML = escapeHtml(this.value)">
					</div>
					<div class="wow_form_fields">
						<label><?php echo $wo['lang']['image']; ?></label>
						<span class="help-block"><?php echo $wo['lang']['ad_img_help'] ?></span>
						<div class="wow_fcov_image">
							<div id="wow_fcov_img_holder">
								
							</div>
							<div class="upload_ad_image" onclick="document.getElementById('ad-media-file').click(); return false">
								<div class="upload_ad_image_content">
									<svg width="55" height="48" viewBox="0 0 55 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M28.8002 11.8198L28.8925 11.8474L28.8973 11.8418C29.2564 11.8983 29.6089 11.681 29.7145 11.3247C30.6475 8.1896 33.5873 5.99924 36.8624 5.99924C37.2683 5.99924 37.5975 5.67003 37.5975 5.26413C37.5975 4.85821 37.2683 4.52902 36.8624 4.52902C32.8073 4.52902 29.3997 7.22893 28.3056 10.9057C28.1896 11.2949 28.4113 11.7038 28.8002 11.8198Z" class="icon_main_fill icon_main" stroke-width="0.3"></path><path d="M45.0534 33.9345H41.5429C41.2198 33.9345 40.9577 33.6725 40.9577 33.3494C40.9577 33.0263 41.2198 32.7643 41.5429 32.7643H45.0534C49.8926 32.7643 53.83 28.8269 53.83 23.9877C53.83 19.1485 49.8926 15.2112 45.0534 15.2112H44.969C44.7993 15.2112 44.638 15.1376 44.5268 15.0093C44.4157 14.881 44.3655 14.7109 44.3898 14.5429C44.442 14.1784 44.4683 13.8123 44.4683 13.4559C44.4683 9.26192 41.0559 5.84945 36.8619 5.84945C35.2303 5.84945 33.6744 6.35933 32.362 7.32432C32.0736 7.53621 31.6641 7.44218 31.4973 7.12496C27.7807 0.0477366 18.0732 -0.902663 13.0403 5.25391C10.9202 7.84758 10.0872 11.2215 10.7547 14.5099C10.8282 14.8731 10.5503 15.2116 10.1813 15.2116H9.94683C5.10763 15.2116 1.17027 19.149 1.17027 23.9882C1.17027 28.8274 5.10763 32.7647 9.94683 32.7647H13.4574C13.7805 32.7647 14.0425 33.0268 14.0425 33.3498C14.0425 33.6729 13.7805 33.9349 13.4574 33.9349H9.94683C4.46227 33.9349 0 29.4727 0 23.9881C0 18.6574 4.21522 14.2925 9.48751 14.0518C8.99226 10.6402 9.9393 7.19891 12.1343 4.51334C17.5226 -2.07868 27.8491 -1.33981 32.2143 6.01078C33.6069 5.13772 35.2004 4.67971 36.8617 4.67971C41.9429 4.67971 45.9693 9.00449 45.617 14.0572C50.8407 14.3502 55 18.6921 55 23.9877C55 29.4727 50.5377 33.9345 45.0532 33.9345L45.0534 33.9345Z" class="icon_main_fill"></path><path d="M12.6439 33.019C12.6439 41.1676 19.2732 47.7967 27.4217 47.7967C35.5704 47.7967 42.1995 41.1675 42.1995 33.019C42.1995 24.8703 35.5704 18.2412 27.4217 18.2412C19.2731 18.2412 12.6439 24.8704 12.6439 33.019ZM14.1144 33.019C14.1144 25.6816 20.0842 19.7117 27.4217 19.7117C34.7591 19.7117 40.729 25.6815 40.729 33.019C40.729 40.3564 34.7591 46.3263 27.4217 46.3263C20.0843 46.3263 14.1144 40.3565 14.1144 33.019Z" class="icon_main_fill icon_main" stroke-width="0.3"></path><path d="M27.1107 38.9073C27.1107 39.2267 27.3698 39.4857 27.6891 39.4857C28.0084 39.4857 28.2675 39.2271 28.2675 38.9073V27.7698C28.2675 27.4504 28.0085 27.1914 27.6891 27.1914C27.3697 27.1914 27.1107 27.4504 27.1107 27.7698V38.9073Z" class="icon_main_fill icon_main" stroke-width="0.3"></path><path d="M27.6893 28.5892L24.6715 31.607L27.6893 28.5892ZM27.6893 28.5892L30.7072 31.6071C30.82 31.7199 30.9685 31.7765 31.1162 31.7765L27.6893 28.5892ZM23.8534 31.6071C24.0793 31.833 24.4457 31.8332 24.6714 31.6071L31.1162 31.7765C31.2636 31.7765 31.4122 31.7204 31.5252 31.6071C31.7511 31.3811 31.7511 31.0151 31.5251 30.7892L28.0983 27.3623C27.8724 27.1364 27.506 27.1363 27.2803 27.3623C27.2803 27.3623 27.2803 27.3623 27.2803 27.3623C27.2803 27.3623 27.2802 27.3624 27.2802 27.3624L23.8534 30.7892C23.6275 31.0151 23.6275 31.3812 23.8534 31.6071Z" class="icon_main_fill icon_main" stroke-width="0.3"></path></svg> <?php echo $wo['lang']['choose_image'] ?>
								</div>
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<a class="btn btn-main btn-mat cont_to_detail" <?php echo ($wo['user']['wallet'] == '0.00' || $wo['user']['wallet'] == '0') ? 'disabled' : ''; ?>><?php echo $wo['lang']['next'] ?></a>
					</div>
				</div>
							
				<!-- Details Step  -->
				<div class="wow_creads_details_step" style="display: none;">
					<div class="wo_page_hdng pag_neg_padd hidden">
						<div class="wo_page_hdng_innr">
							<span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z"></path></svg></span> <?php echo $wo['lang']['details']; ?>
						</div>
					</div>
					<div class="wow_form_fields">
						<label for="title"><?php echo $wo['lang']['camp_title']; ?></label>
						<input id="title" name="headline" type="text" onkeyup="document.getElementById('copy_camp_title').innerHTML = escapeHtml(this.value)">
					</div>
					<div class="wow_form_fields">
						<label for="description"><?php echo $wo['lang']['camp_desc']; ?></label>
						<textarea id="description" name="description" rows="3" onkeyup="document.getElementById('copy_camp_desc').innerHTML = escapeHtml(this.value)"></textarea>
						<span class="help-block"><?php echo $wo['lang']['ad_desc_help'] ?></span>
					</div>
					<div class="row">
						<div class="col-md-6">
							<div class="wow_form_fields">
								<label for="start_date"><?php echo $wo['lang']['start_date']; ?></label>
								<input id="start_date" name="start" type="text">
								<span class="help-block"><?php echo $wo['lang']['ad_start_date_help'] ?></span>
							</div>
						</div>
						<div class="col-md-6">
							<div class="wow_form_fields">
								<label for="end_date"><?php echo $wo['lang']['end_date']; ?></label>
								<input id="end_date" name="end" type="text">
								<span class="help-block"><?php echo $wo['lang']['ad_end_date_help'] ?></span>
							</div>
						</div>
					</div>
					<div class="wow_form_fields">
						<label for="url"><?php echo $wo['lang']['website_url']; ?></label>
						<input id="url" name="website" type="url">
						<?php if ($wo['config']['pages'] == 1) { ?><span class="help-block"><?php echo $wo['lang']['select_a_page_or_link'] ?></span><?php } ?>
					</div>
					<?php if ($wo['config']['pages'] == 1) { ?>
					<div class="wow_form_fields">
						<label for="select-page"><?php echo $wo['lang']['my_pages']; ?></label>
						<select name="page" id="select-page">			
							<?php if ($wo['my-pages'] && count($wo['my-pages']) > 0): ?>
								<option value="" selected><?php echo $wo['lang']['select']; ?></option>
							<?php foreach ($wo['my-pages'] as $wo['pageItem']): ?>
								<option value="<?php echo $wo['pageItem']['page_name']; ?>"><?php echo $wo['pageItem']['page_name']; ?></option>
							<?php endforeach; ?>
							<?php else:?>
								<option disabled="disabled" selected="selected"><?php echo $wo['lang']['no_pages_found']; ?></option>
							<?php endif;?>
						</select>
					</div>
					<?php } ?>
					<div class="modal-footer">
						<a class="btn btn-mat back_to_media"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"></path></svg> <?php echo $wo['lang']['go_back'];?></a>
						<a class="btn btn-main btn-mat cont_to_submit" <?php echo ($wo['user']['wallet'] == '0.00' || $wo['user']['wallet'] == '0') ? 'disabled' : ''; ?>><?php echo $wo['lang']['next'] ?></a>
					</div>
				</div>
							
				<!-- Final Step  -->
				<div class="wow_creads_submit_step" style="display:none">
					<div class="wo_page_hdng pag_neg_padd hidden">
						<div class="wo_page_hdng_innr">
							<span><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,10.84 21.79,9.69 21.39,8.61L19.79,10.21C19.93,10.8 20,11.4 20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.6,4 13.2,4.07 13.79,4.21L15.4,2.6C14.31,2.21 13.16,2 12,2M19,2L15,6V7.5L12.45,10.05C12.3,10 12.15,10 12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12C14,11.85 14,11.7 13.95,11.55L16.5,9H18L22,5H19V2M12,6A6,6 0 0,0 6,12A6,6 0 0,0 12,18A6,6 0 0,0 18,12H16A4,4 0 0,1 12,16A4,4 0 0,1 8,12A4,4 0 0,1 12,8V6Z"></path></svg></span> <?php echo $wo['lang']['targeting']; ?>
						</div>
					</div>
					<div id="create-ads-alert" class="w100"></div>
					<div class="wow_form_fields">
						<label for="ads-location"><?php echo $wo['lang']['location']; ?></label>
						<input id="ads-location" name="location" type="text" onkeyup="document.getElementById('copy_camp_location').innerHTML = escapeHtml(this.value)">
					</div>
					<?php if ($wo['config']['google_map'] == 1 || $wo['config']['yandex_map'] == 1) { ?>
						<div id="review-ads-location">
							<div id="place" <?php echo($wo['config']['yandex_map'] == 1 ? 'class="yandex_ads_map"' : '') ?>></div>
						</div>
					<?php }?>
					
					<div class="wow_form_fields">
						<label for="ads-audience"><?php echo $wo['lang']['audience']; ?></label>
						<select data-live-search="true" data-actions-box="true" name="audience-list[]" id="ads-audience" class="selectpicker" data-size="7" multiple>
							<?php foreach ($wo['audience'] as $country_ids => $country): ?>
								<?php if ($country_ids == 0): ?>
									<option value="<?php echo $country_ids; ?>" disabled><?php echo $country; ?></option>
								<?php else: ?>
									<option value="<?php echo $country_ids; ?>"><?php echo $country; ?></option>
								<?php endif; ?>
							<?php endforeach;?>
						</select>
					</div>
					<div class="wow_form_fields">
						<label for="gender"><?php echo $wo['lang']['gender']; ?></label>
						<select name="gender" id="gender">
							<option value="all" selected><?php echo $wo['lang']['all']; ?></option>
							<?php foreach ($wo['genders'] as $key => $gender) { ?>
								<option value="<?php echo($key) ?>"><?php echo $gender; ?></option>
							<?php } ?>
						</select>
					</div>
					<div class="wow_form_fields">
						<label for="appears"><?php echo $wo['lang']['appears']; ?></label>
						<select name="appears" id="appears">
							<option value="entire" selected><?php echo $wo['lang']['entire_site']; ?> (<?php echo $wo['lang']['format_image']; ?>)</option>
							<option value="post"><?php echo $wo['lang']['post']; ?> (<?php echo $wo['lang']['format_image']; ?>)</option>
							<option value="sidebar"><?php echo $wo['lang']['sidebar']; ?> (<?php echo $wo['lang']['format_image']; ?>)</option>
							<?php if ($wo['config']['job_system'] == 1) { ?>
							<option value="jobs"><?php echo $wo['lang']['jobs']; ?> (<?php echo $wo['lang']['format_image']; ?>)</option>
							<?php } ?>
							<?php if ($wo['config']['forum'] != 0) { ?>
							<option value="forum"><?php echo $wo['lang']['forum']; ?> (<?php echo $wo['lang']['format_image']; ?>)</option>
							<?php } ?>
							<?php if ($wo['config']['movies'] != 0) { ?>
							<option value="movies"><?php echo $wo['lang']['movies']; ?> (<?php echo $wo['lang']['format_image']; ?>)</option>
							<?php } ?>
							<?php if ($wo['config']['offer_system'] != 0) { ?>
							<option value="offer"><?php echo $wo['lang']['offer']; ?> (<?php echo $wo['lang']['format_image']; ?>)</option>
							<?php } ?>
							<?php if ($wo['config']['funding_system'] != 0) { ?>
							<option value="funding"><?php echo $wo['lang']['funding']; ?> (<?php echo $wo['lang']['format_image']; ?>)</option>
							<?php } ?>
                            <option value="story"><?php echo $wo['lang']['story']; ?> (<?php echo $wo['lang']['format_image']; ?>)</option>

                            <!-- <option value="video"><?php echo $wo['lang']['video_player']; ?> (<?php echo $wo['lang']['format_video']; ?>)</option> -->
						</select>
					</div>
					<div class="wow_form_fields">
						<label for="camp_budget"><?php echo $wo['lang']['camp_budget']; ?></label>
						<input id="camp_budget" name="budget" type="text">
						<span class="help-block"><?php echo $wo['lang']['camp_budget_help'] ?></span>
					</div>
					<div class="wow_form_fields">
						<label for="bidding"><?php echo $wo['lang']['bidding']; ?></label>
						<select name="bidding" id="bidding">
							<option value="clicks" class="entire_site_clicks"><?php echo str_replace('${{PRICE}}',  Wo_GetCurrency($wo['config']['currency']) . $wo['config']['ad_c_price'], $wo['lang']['pay_per_click']); ?></option>
							<option value="views" class="entire_site_views"><?php echo str_replace('${{PRICE}}', Wo_GetCurrency($wo['config']['currency']) . $wo['config']['ad_v_price'], $wo['lang']['pay_per_imprssion']); ?></option>
						</select>
					</div>
					<div class="wow_form_fields" id="estimated" style="display: none;">
						<label><?php echo $wo['lang']['estimated_reach']; ?></label>
						<div class="estimated_ad_limit">
							<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12,5.5A3.5,3.5 0 0,1 15.5,9A3.5,3.5 0 0,1 12,12.5A3.5,3.5 0 0,1 8.5,9A3.5,3.5 0 0,1 12,5.5M5,8C5.56,8 6.08,8.15 6.53,8.42C6.38,9.85 6.8,11.27 7.66,12.38C7.16,13.34 6.16,14 5,14A3,3 0 0,1 2,11A3,3 0 0,1 5,8M19,8A3,3 0 0,1 22,11A3,3 0 0,1 19,14C17.84,14 16.84,13.34 16.34,12.38C17.2,11.27 17.62,9.85 17.47,8.42C17.92,8.15 18.44,8 19,8M5.5,18.25C5.5,16.18 8.41,14.5 12,14.5C15.59,14.5 18.5,16.18 18.5,18.25V20H5.5V18.25M0,20V18.5C0,17.11 1.89,15.94 4.45,15.6C3.86,16.28 3.5,17.22 3.5,18.25V20H0M24,20H20.5V18.25C20.5,17.22 20.14,16.28 19.55,15.6C22.11,15.94 24,17.11 24,18.5V20Z" /></svg> ~<span class="estimated_text"></span> <?php echo $wo['lang']['users']; ?></p>
						</div>
					</div>
					<div class="modal-footer">
						<a class="btn btn-mat back_to_details"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"></path></svg> <?php echo $wo['lang']['go_back'];?></a>
						<button class="btn btn-main btn-mat add_wow_loader" type="submit" <?php echo ($wo['user']['wallet'] == '0.00' || $wo['user']['wallet'] == '0') ? 'disabled' : ''; ?>><?php echo $wo['lang']['publish']; ?></button>
					</div>
				</div>
			</div>
			<input type="file" name="media" class="hidden" id="ad-media-file" accept="image/* video/*">
		</form>
	</div>
</div>

<script>
// Steps
var $firstButton = $(".cont_to_detail"), $secondButton = $(".cont_to_submit");
var $firstbackButton = $(".back_to_media"), $secondbackButton = $(".back_to_details");
var $ad_media_step = $(".wow_creads_media_step"), $ad_detail_step = $(".wow_creads_details_step"), $ad_submit_step = $(".wow_creads_submit_step");

$firstbackButton.on("click", function(e){
	$ad_media_step.slideDown();
	$ad_detail_step.slideUp();
	$('.wow_creads_minstp').removeClass('step-two-active').addClass('step-one-active');
	e.preventDefault();
});
$secondbackButton.on("click", function(e){
	$ad_media_step.slideUp();
	$ad_submit_step.slideUp();
	$ad_detail_step.slideDown();
	$('.wow_creads_minstp').removeClass('step-three-active');
	e.preventDefault();
});

$firstButton.on("click", function(e){
	if (!$('#company').val()) {
		$('#company').addClass('border_class');
	}
	else{
		$('#company').removeClass('border_class');
		$ad_media_step.slideUp();
		$ad_detail_step.slideDown();
		$('.wow_creads_minstp').addClass('step-two-active');
		e.preventDefault();
	}
});
$secondButton.on("click", function(e){
	if (!$('#title').val() || !$('#description').val() || !$('#start_date').val() || !$('#end_date').val() || !$('#url').val()) {
		if (!$('#title').val()) {
			$('#title').addClass('border_class');
		}
		if (!$('#description').val()) {
			$('#description').addClass('border_class');
		}
		if (!$('#start_date').val()) {
			$('#start_date').addClass('border_class');
		}
		if (!$('#end_date').val()) {
			$('#end_date').addClass('border_class');
		}
		if (!$('#url').val()) {
			$('#url').addClass('border_class');
		}
	}
	else{
		$('#title').removeClass('border_class');
		$('#description').removeClass('border_class');
		$('#start_date').removeClass('border_class');
		$('#end_date').removeClass('border_class');
		$('#url').removeClass('border_class');
		$ad_media_step.slideUp();
		$ad_detail_step.slideUp();
		$ad_submit_step.slideDown();
		$('.wow_creads_minstp').addClass('step-three-active');
		e.preventDefault();
	}
});
$(document).ready(function() {
	$('#create-ads').ajaxForm({
		url: Wo_Ajax_Requests_File() + '?f=ads&s=new',
		type:"POST",
		beforeSend: function() {
			$('.wo_settings_page').find('.last-sett-btn .ball-pulse').fadeIn(100);
		},
		success: function(data) {
			scrollToTop();
			if (data['status'] == 200) {
				$("#create-ads-alert").html('<div class="alert alert-success">'+ data['message'] +'</div>');
				window.location = data.url;
			} 

			else if (data['message']) {
				$("#create-ads-alert").html('<div class="alert alert-danger">' + data['message'] + '</div>');
			} 

			$('.wo_settings_page').find('.last-sett-btn .ball-pulse').fadeOut(100);
		}
	});
	$('.selectpicker').selectpicker({
		noneSelectedText: "<?php echo($wo['lang']['nothing_selected']) ?>",
		selectAllText: "<?php echo($wo['lang']['select_all']) ?>",
		deselectAllText: "<?php echo($wo['lang']['deselect_all']) ?>"
	});
});

	jQuery(document).ready(function($) {
		$('.entire_site_clicks').html("<?php echo str_replace('${{PRICE}}',  Wo_GetCurrency($wo['config']['currency']) . $wo['config']['ad_c_price'] * 1.5, $wo['lang']['pay_per_click']); ?>");
		$('.entire_site_views').html("<?php echo str_replace('${{PRICE}}', Wo_GetCurrency($wo['config']['currency']) . $wo['config']['ad_v_price'] * 1.5, $wo['lang']['pay_per_imprssion']); ?>");
		$("#appears").change(function(event) {
			if ($(this).val() == 'entire') {
				$('.entire_site_clicks').html("<?php echo str_replace('${{PRICE}}',  Wo_GetCurrency($wo['config']['currency']) . $wo['config']['ad_c_price'] * 1.5, $wo['lang']['pay_per_click']); ?>");
				$('.entire_site_views').html("<?php echo str_replace('${{PRICE}}', Wo_GetCurrency($wo['config']['currency']) . $wo['config']['ad_v_price'] * 1.5, $wo['lang']['pay_per_imprssion']); ?>");
			}
			else{
				$('.entire_site_clicks').html("<?php echo str_replace('${{PRICE}}',  Wo_GetCurrency($wo['config']['currency']) . $wo['config']['ad_c_price'], $wo['lang']['pay_per_click']); ?>");
				$('.entire_site_views').html("<?php echo str_replace('${{PRICE}}', Wo_GetCurrency($wo['config']['currency']) . $wo['config']['ad_v_price'], $wo['lang']['pay_per_imprssion']); ?>");
			}
		});
		
		$("#start_date").flatpickr({
			dateFormat: "Y-m-d",
			altInput: true,
			altFormat: "F j, Y",
			minDate: "today",
		});
		
		$("#end_date").flatpickr({
			dateFormat: "Y-m-d",
			altInput: true,
			altFormat: "F j, Y",
			minDate: new Date().fp_incr(1),
		});
		
		$('#ad-media-file').on('change', function(event) {
			  $("#wow_fcov_img_holder").html("<img src='" + window.URL.createObjectURL(this.files[0]) + "' alt='Picture'>");
			  $("#fake_post_img_holder").html("<img src='" + window.URL.createObjectURL(this.files[0]) + "' alt='Picture'>");
           });

		$("#ads-audience").change(function(event) {
			var self = $(this);
				get_estimated_users();
		});

		$("#gender").change(function(event) {
			var self = $(this);
			if (self.val() != '') {
				get_estimated_users();
			}
		});

		function get_estimated_users(){
			var audience = null;
			var gender = "ALL";
			if ( $("#ads-audience").val() != '') {
				audience = $("#ads-audience").val().join(',');
			}
			if ( $("#gender").val() != '') {
				gender = $("#gender").val();
			}

			$.ajax({
				url: Wo_Ajax_Requests_File(),
				type: 'GET',
				dataType: 'json',
				data: {f: 'ads',s:'get_estimated_users', estimated_audience:audience, estimated_gender:gender},
			}).done(function(data) {
				if (data.status == 200) {
					$('.estimated_text').text(data.count);
					$("#estimated").show();
				}
			});
		}

	  	

	  	<?php if ($wo['config']['google_map']) { ?>
	    $("#ads-location").keyup(function(event) {
	        if ($(this).val().length >= 3) {
	          Wo_Delay(function(){$("#review-ads-location #place").html('<iframe width="100%" frameborder="0" style="border:0;margin-top: 10px;" src="https://www.google.com/maps/embed/v1/place?key=<?php echo $wo['config']['google_map_api']; ?>&q=' + $("#ads-location").val() + '&language=en"></iframe>')},1000)
	        }
	        else{
	          Wo_Delay(function(){$("#review-ads-location #place").html('<iframe width="100%" frameborder="0" style="border:0;margin-top: 10px;" src="https://www.google.com/maps/embed/v1/place?key=<?php echo $wo['config']['google_map_api']; ?>&q=us&language=en"></iframe>')},1000)
	        }
      	});
	   <?php }else if($wo['config']['yandex_map'] == 1){ ?>
	   	$("#ads-location").keyup(function(event) {
		     	var myMap;
	        ymaps.geocode($("#ads-location").val()).then(function (res) {
	        	$("#review-ads-location #place").html('');
	            myMap = new ymaps.Map('place', {
	                center: res.geoObjects.get(0).geometry.getCoordinates(),
	                zoom : 10
	            });
	            myMap.geoObjects.add(new ymaps.Placemark(res.geoObjects.get(0).geometry.getCoordinates(), {
			            balloonContent: ''
			        }));
	        });
        });
	   <?php } ?>

	    $("#select-page").change(function(event) {
		  	var self     = $(this);
		  	if (self.val() != '') {
		  		var page_url = websiteUrl +'/'+ self.val();
		  		$('#create-ads').find("input[name=website]").val(page_url);
		  	}

		  	else{
		  		$('#create-ads').find("input[name=website]").val('');
		  	}
	  	});

		

	});
</script>
<style type="text/css">
	div .ads_col_8 .border_class{border: 1px solid red !important;}
</style>