<?php
	define('WP_USE_THEMES', true);
	require ('../../../../wp-load.php');
	global $post;
	global $wpdb;
	$getPage = $wpdb->prefix . "wpcta_revealr";
	$getID = $_GET['edit'];
	$editBook = $wpdb->get_results("SELECT * FROM $getPage WHERE id = $getID" ,ARRAY_A);

	$tpl = get_post_meta($post->ID,'_template',true);
	
	foreach($editBook as $template){} 		
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title><?php echo $template['name']; ?> -- Shortcode</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css">

	<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
	<script src="jquery.js"></script>
	<script >
	$(document).ready(function() {
	break_apart_ar();
						
				// TAKE APART AR CODE
						
				function break_apart_ar(){
				
				var tags = ['a','iframe','frame','frameset','script'], reg, val = $('#autoresponderCode').val(),
				
				hdn = $('#arcode_hdn_div2'), formurl = $('#arform'), hiddenfields = $('#arhidden');
				
				formurl.val('');
					if(jQuery.trim(val) == '')
					    return false;
					    $('#arcode_hdn_div').html('');
					    $('#arcode_hdn_div2').html('');
					for(var i=0;i<5;i++){
					    reg = new RegExp('<'+tags[i]+'([^<>+]*[^\/])>.*?</'+tags[i]+'>', "gi");
					val = val.replace(reg,'');
									
					reg = new RegExp('<'+tags[i]+'([^<>+]*)>', "gi");
					    val = val.replace(reg,'');
					}
					
					var tmpval;
					try {
					    tmpval = decodeURIComponent(val);
					} catch(err){
					    tmpval = val;
					}
					
					hdn.append(tmpval);
					var num = 0;
					var name_selected = '';
					var email_selected = '';
					
					$(':text',hdn).each(function(){
					    var name = $(this).attr('name'),
					    name_selected = num == '0' ? name : (num != '0' ? name_selected : ''), 
					    email_selected = num == '1' ? name : email_selected;
					    if(num=='0') jQuery('#arname').val(name_selected);
					    if(num=='1') jQuery('#aremail').val(email_selected);
					    num++;
					});
								jQuery(':input[type=hidden]',hdn).each(function(){
									jQuery('#arcode_hdn_div').append(jQuery('<input type="hidden" name="'+jQuery(this).attr('name')+'" />').val(jQuery(this).val()));
								});		
								var hidden_f = jQuery('#arcode_hdn_div').html();
								formurl.val(jQuery('form',hdn).attr('action'));
								hiddenfields.val(hidden_f);
								hdn.html('');
								
				};
				
				$('.ARform').attr('action', $('#arform').val());
				$('.ARhidden').html($('#arhidden').val());
				$('#optinName').attr('name', $('#arname').val());
				$('#optinEmail').attr('name', $('#aremail').val());
			});	
	</script>

	<style>
		<?php if ($template['background'] == "1") { ?>
			
		<?php } ?>
	</style>
</head>
<body class="background<?php echo $template['background']; ?> button<?php echo $template['buttonStyle']; ?>">
	<?php if ($template['rating'] == "on") { ?>
<div style="width: 200px; float: left; margin-top: -26px; z-index-9999; margin-left: 28px; padding-top: 5px;">
		<img src="https://cdn2.iconfinder.com/data/icons/ledicons/star_2.png" style="float: left; margin-right: 5px;">
		<img src="https://cdn2.iconfinder.com/data/icons/ledicons/star_2.png" style="float: left; margin-right: 5px;">
		<img src="https://cdn2.iconfinder.com/data/icons/ledicons/star_2.png" style="float: left; margin-right: 5px;">
		<img src="https://cdn2.iconfinder.com/data/icons/ledicons/star_2.png" style="float: left; margin-right: 5px;">
		<img src="https://cdn2.iconfinder.com/data/icons/ledicons/star_2.png" style="float: left; margin-right: 5px;">
	</div>
	

	<?php } ?>
	<?php if ($template['auto_responder'] != "") { ?>
	<div style="float: right; font-family: 'Oswald', sans-serif;margin-top:-20px; font-size: 13px; margin-right: 35px">
		<a href="#" id="showOptin" style="text-decoration: none; color: #666"><strong><img src="https://cdn2.iconfinder.com/data/icons/ledicons/email.png" style=" float: right;margin-top: 0; margin-left: 10px;"> <span style="padding-top: 5px; font-weight: normal"><?php echo $template['twitter']; ?></span> </strong></a>
	</div>
	<?php } ?>
	<div id="cta_revealBox">
		<div style="height: 290px; display: none" id="cta_optin_inner">
		<div id="cta_optin" style="display: none">
			<h1 style="padding-top: 25px; color: #b4232e;"><?php echo $template['ar_headline']; ?></h1>
			<h3 style="font-weight: normal; color: #666; font-size: 17px; padding: 10px; padding-bottom: 20px; "><?php echo $template['ar_time']; ?></h3>
			<form action="#" method="post" id="form"  class='ARform'>
				<div class='ARhidden'></div>
				<input type="input" placeholder="Enter Your Full Name Here..." name="optinName" id="optinName" style="background: #fff url(https://cdn2.iconfinder.com/data/icons/ledicons/user_silhouette.png) no-repeat; background-position: 430px 7px;width: 80%;padding: 8px; border-radius: 5px; border: 1px solid #999; display: block; margin: 10px 40px">
				
				<input type="input" placeholder="Enter Your Email Address Here..." name="optinEmail" id="optinEmail" style="background: #fff url(https://cdn2.iconfinder.com/data/icons/ledicons/email.png) no-repeat; background-position: 430px 7px;width: 80%; padding: 8px; border-radius: 5px; border: 1px solid #999; display: block; margin: 0 40px">
				<a href="#" id="submit"><?php echo $template['ar_button']; ?></a>
				
			</form>	

			<div id="autoresponder" style="display: none">
			<textarea id="autoresponderCode" name="autoresponderCode"><?php echo $template['auto_responder']; ?></textarea>
			<input type="text"  name="arname" id="arname" value="" />
			<input type="text"   name="aremail" id="aremail" value="" />
			<input type="text"   name="arform" id="arform" value="" />
			<textarea id="arhidden"   name="arhidden"></textarea>
			<div id="arcode_debug"><div id="arcode_hdn_div"></div><div id="arcode_hdn_div2"></div></div>
		</div>
		</div>	
	</div>
		<div id="cta_buttons">	
			<div style="height: 120px">
<h1><?php echo $template['headline']; ?></h1>
			<h2><?php echo $template['subheadline']; ?></h2>
			</div>
			
			<a href="#" id="revealButton">
				<span class="activate"><?php echo $template['revealButton']; ?></span>
				<div id="discount">
					<span class="price"><?php echo $template['price']; ?></span> 
					<span class="discount"><?php echo $template['discount']; ?></span>
				</div>
				
			</a>
			<div id="hiddenBox" style="display: none">
				<?php if ($template['content'] == "") { ?>
					<h3 id="coupon1"><input type="text" id="couponInput" value="<?php echo $template['revealText']; ?>"></h3>
				<?php } else { ?>
					<a href="<?php echo $template['content']; ?>" target="_blank" style="text-decoration: none"><h3 id="coupon1"><?php echo $template['revealText']; ?></h3></a>
				<?php } ?>
			</div>
		</div>	
		<div id="bottom">
			<h3 style="font-weight: normal"><?php echo $template['footerText']; ?></h3>
		</div>
	</div>
	<div id="social">
		<div class="twitter">
			<iframe src="//www.facebook.com/plugins/like.php?href=<?php echo $template['fb']; ?>&amp;send=false&amp;layout=button_count&amp;width=150&amp;show_faces=false&amp;font&amp;colorscheme=light&amp;action=like&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
		</div>
		<div class="twitter">
			<!-- Place this tag where you want the +1 button to render. -->
			<div class="g-plusone" data-size="medium" data-href="<?php echo $template['fb']; ?>"></div>

			<!-- Place this tag after the last +1 button tag. -->
			<script type="text/javascript">
			  (function() {
			    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
			    po.src = 'https://apis.google.com/js/plusone.js';
			    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
			  })();
			</script>
		</div>
		<div class="twitter">
			<a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo $template['fb']; ?>">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
		</div>

		<div class="twitter" >
			<script src="//platform.linkedin.com/in.js" type="text/javascript">
 lang: en_US
</script>
<script type="IN/Share" data-url="<?php echo $template['fb']; ?>" data-counter="right"></script>
		</div>

		<div class="twitter" >
<!-- Place this tag where you want the su badge to render -->
<su:badge layout="2" location="<?php echo $template['fb']; ?>"></su:badge>

<!-- Place this snippet wherever appropriate -->
<script type="text/javascript">
  (function() {
    var li = document.createElement('script'); li.type = 'text/javascript'; li.async = true;
    li.src = ('https:' == document.location.protocol ? 'https:' : 'http:') + '//platform.stumbleupon.com/1/widgets.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(li, s);
  })();
</script>

		</div>
		
	</div>
</body>
</html>