<?php
include("../includes/connect.php");
require_once "../includes/Mobile_Detect.php";

$openFile = fopen("cdata.txt", "r") or die("Unable to open file!");
$campaignData = fread($openFile,filesize("cdata.txt"));
fclose($openFile);

$campaignInfo = explode(PHP_EOL,$campaignData);
$campaignid = $campaignInfo[0];

$datiCampagna = $connection->query("SELECT meta_key,meta_value FROM campaigns_meta WHERE campaign_id = '$campaignid'");

$campaignData = $datiCampagna->fetchAll(PDO::FETCH_KEY_PAIR);

$detect = new Mobile_Detect;

?>


<!DOCTYPE html>
<html lang="<?php echo $campaignData['language']; ?>">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <meta name="description" content="<?php echo $campaignData['campaign_description']; ?>" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">

            <!-- <link rel="shortcut icon" href="assets/1_66bce83c4ac77e50c0afcad5ee7bf433.ico?v=39884" />
        <link rel="apple-touch-icon" href="assets/1_66bce83c4ac77e50c0afcad5ee7bf433.ico?v=39884"> -->
    
    <title><?php echo $campaignData['campaign_title']; ?></title>
    <meta property="og:title" content="<?php echo $campaignData['campaign_title']; ?>" />
    <meta property="og:description" content="<?php echo $campaignData['campaign_description']; ?>" />
<meta property="og:type" content="website" />
<meta property="og:url" content="<?php echo 'https://'. $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); ?>" />
<meta property="og:image" content="<?php echo 'https://'. $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/assets/' . $campaignData['front_desktop']; ?>" />

<link itemprop="thumbnailUrl" href="<?php echo 'https://'. $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/assets/' . $campaignData['front_desktop']; ?>"> 
<span itemprop="thumbnail" itemscope itemtype="//schema.org/ImageObject"> 
  <link itemprop="url" href="<?php echo 'https://'. $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/assets/' . $campaignData['front_desktop']; ?>"> 
</span>

    <link href="../campaignsAssets/css/common.css" rel="stylesheet">
<link href="../campaignsAssets/css/voucherzone_style.css" rel="stylesheet">
<link href="../campaignsAssets/css/layout.css" rel="stylesheet">
<link href="../campaignsAssets/css/white.css" rel="stylesheet">
<link href="../campaignsAssets/css/branding.css" rel="stylesheet">

</head>
<body>

    <style>
       #wabutton a
       {
        text-decoration: none;
       } 

       #b1
       {
            background-color: #009846;
            color: #fff;
            font-size: 1.2em;
            font-weight: bold;
            text-align: center;
            padding:10px;
            margin-top: 10px;
       }
    /* COMMENTS */

.comment-area {
    margin-top: 30px;
    position: relative;
    z-index: 610;
    font-size: 14px !important;
    font-size: 0.95em;
    text-align: left;
    font-family: 'Myriad Pro', sans-serif;
}

.action {
    border-top: 1px solid #e6e6e6;
    background: #fff;
    padding: 5px 10px;
}

.action a {
    display: inline-block;
    padding-left: 20px;
    text-decoration: none;
    color: #6d6d6d;
    margin-right: 15px;
}

.action .like {
    background: url(../campaignsAssets/images/like.png) no-repeat left center;
}

.action .bubble {
    background: url(../campaignsAssets/images/bubble.png) no-repeat left center;
}

.action .share-btn {
    background: url(../campaignsAssets/images/share.png) no-repeat left center;
}

.action .active-like {
    background-image: url(../campaignsAssets/images/like-active.png);
    color: #5890ff;
}

.tot-likes {
    padding: 0 10px;
}

.tot-likes > p {
    line-height: 20px;
    padding: 5px 0;
    color: #3f5199;
    border-bottom: 1px solid #e1e3e4;
}
.like-imgs {
    padding: 10px 0 5px;
    max-height: 47px;
    overflow: hidden;
}

.like-imgs > div {
    display: inline-block;
    margin-right: 5px;
    position: relative;
    margin-bottom: 5px;
}

.like-imgs > div img {
    display: block;
}

.like-imgs > div .reaction-img {
    position: absolute;
    bottom: -5px;
    right: -5px;
    z-index: 10;
}
.you {
    display: none;
}

.you.active {
    display: inline-block;
    line-height: 20px;
    padding-left: 20px;
    background: url(../campaignsAssets/images/btn.png) no-repeat left center;
}

.comment {
    position: relative;
    padding: 10px 10px 10px 70px;
    min-height: 70px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.profile {
    position: absolute;
    top: 10px;
    left: 10px;
}

.name {
    font-weight: 700;
    text-decoration: none;
    color: #3f5199;
}

.com-txt {
    margin-bottom: 10px;
}

.act a {
    color: #3f5199;
    text-decoration: none;
}

.liked {
    background: url(../campaignsAssets/images/like-btn.png) no-repeat left center;
    padding-left: 16px;
    line-height: 16px;
    color: #3f5199;
}

.liked:after {
    content: ' Mi piace ';
}

.time {
    color: #8d9098;
}

.comment .comment {
    padding-left: 50px;
    padding-right: 0;
}

.comment .comment .profile {
    left: 0 !important;
    width: 40px !important;
    height: 40px !important;
}

.fbimg {
    max-width: 190px;
    width: 100%;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    height: auto;
    display: block;
    padding: 3px;
    border: 1px solid #808080;
    border-radius: 2px;
    -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    margin-bottom: 10px;
}

.addComment {
    position: relative;
    padding: 10px 10px 10px 70px;
    height: 70px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.addComment img {
    position: absolute;
    left: 10px;
    top: 8px;
}

.addComment input {
    border-radius: 2px;
    -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    border: 1px solid #e0e0e0;
    line-height: 48px;
    width: 100%;
    display: block;
    outline: 0;
    padding: 0 50px 0 10px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    background: #fff url(../campaignsAssets/images/btnz.png) no-repeat right center;
}

.hider, .likehide, #myCom {
    display: none;
}
.txt2 {
    color: #000;
    line-height: 2.3;
    text-align: left;
}

.timer {
    font-size: 1.5em;
    font-weight: 400;
    color: #d9534f;
}
</style>


<div class="body-wrap lang_it" style="background-image: url(assets/<?php echo $campaignData['bg']; ?>)"> <!-- immagine grande di sfondo --> 
<div class="body-wrap-in">



<div class="content">
    <div class="content-in">
        <div class="panels">
                            

            <?php 
                include("../campaignsAssets/questions.php");
            ?>

            <?php 
                // sharing whatsapp (solo mobile)
            if($detect->isMobile())
            {
               include("../campaignsAssets/whatsapp.php");
            }
            ?>

            <?php 
                // primo step form, anagrafica base
                include("../campaignsAssets/form_step1.php");
            ?>

            <?php
                // secondo step form, indirizzo e cellulare
                include("../campaignsAssets/form_step2.php");
            ?>

            <?php 
                include("../campaignsAssets/questions_after.php")
            ?>


        </div>
    </div>
</div>

</div>
</div>


<?php
	include("../campaignsAssets/footer.php");
?>


<div id="modal-question" class="modal"></div>

<script src="../campaignsAssets/js/common.js"></script> 
<script src="../campaignsAssets/js/Form.js"></script>
<script src="../campaignsAssets/js/scripts.js"></script>


<script>

    $(document).ready(function() {

<?php 
if($detect->isMobile())
{
?>                
        $(".wa").click(function(){
$(this).css("display","none")
$("#caricamento").css("display","block");   
    var i = setTimeout(goToForm,600,this) 
})
<?php 
}
?>        

        var locale = "it_IT";
        var externalId = "<?php echo time(); ?>-<?php echo $campaignid ?>";

        $("#eid").val(externalId);
		var isReturned = 0;
		var endUrl = "thankyou.php";
        var lead = {};
        
        var page = new Landing(locale, externalId);

        page.isDoiRequired = 0;
        page.isCompliant = 1;
        page.useDoiBlockScreen = 0;


        page.initQuestionsApi($("#question-container"), endUrl);
        

        /*if (isReturned) {
                page.startQuestions({leadEmailDomain: lead.emailDomain});
                page.setLead(lead);
                    } else {*/
            page.initFormApi(
                {"cid":{},"eid":{},"gender":{"empty":"Selezionare il sesso e' obbligatorio","invalid":"Questo campo non pu\u00f2 essere lasciato vuoto"},"firstName":{"empty":"Questo campo non pu\u00f2 essere lasciato vuoto","invalid":"Inserisci cortesemente l'informazione corretta"},"lastName":{"empty":"Questo campo non pu\u00f2 essere lasciato vuoto","invalid":"Inserisci cortesemente l'informazione corretta"},"email":{"empty":"Questo campo non pu\u00f2 essere lasciato vuoto","invalid":"L\u2019indirizzo email non \u00e8 corretto"},"postcode":{"empty":"Questo campo non pu\u00f2 essere lasciato vuoto","invalid":"Non \u00e8 stat inserito il Prefisso, 5 numeri sono richiesti per il codice postale"},"phone":{"empty":"Questo campo non pu\u00f2 essere lasciato vuoto","invalid":"Il numero telefonico non \u00e8 valido"},"birthDate":{"empty":"Per favore inserisci la tua data di nascita","invalid":"Per favore inserisci la tua data di nascita"},"street":{"empty":"","invalid":"Per favore seleziona un indirizzo valido"},"address":{"empty":"Questo campo non pu\u00f2 essere lasciato vuoto","invalid":"Per favore seleziona un indirizzo valido"},"city":{"empty":"Questo campo non pu\u00f2 essere lasciato vuoto","invalid":"Invalid value"},"houseNumber":{"empty":"","invalid":""},"houseNumberAddition":{"empty":"","invalid":""},"termsAgree":{"empty":"devi selezionare per andare avanti","invalid":"devi selezionare per andare avanti"},"termsAgree2":{"empty":"devi selezionare per andare avanti","invalid":"devi selezionare per andare avanti"},"termsAgree3":{"empty":"devi selezionare per andare avanti","invalid":"devi selezionare per andare avanti"},"termsAgree4":{"empty":"devi selezionare per andare avanti","invalid":"devi selezionare per andare avanti"},"nationality":{"empty":"Inserisci cortesemente la risposta corretta","invalid":"Inserisci cortesemente la risposta corretta"},"birthDateDay":{"empty":"Per favore inserisci la tua data di nascita","invalid":"Per favore inserisci la tua data di nascita"},"birthDateMonth":{"empty":"Per favore inserisci la tua data di nascita","invalid":"Per favore inserisci la tua data di nascita"},"birthDateYear":{"empty":"Per favore inserisci la tua data di nascita","invalid":"Per favore inserisci la tua data di nascita"}},
                {"1":{"cid":{"required":true,"type":"text","contentType":"text","step":1},"eid":{"required":true,"type":"text","contentType":"text","step":1},"gender":{"required":true,"type":"radio","contentType":"text","step":1},"firstName":{"required":true,"type":"input","contentType":"text","alphanumSettings":{"allow":"\u00e0\u00e1\u00e2\u00e4\u00e3\u00e5\u0105\u010d\u0107\u0119\u00e8\u00e9\u00ea\u00eb\u0117\u012f\u00ec\u00ed\u00ee\u00ef\u0142\u0144\u00f2\u00f3\u00f4\u00f6\u00f5\u00f8\u00f9\u00fa\u00fb\u00fc\u0173\u016b\u00ff\u00fd\u017c\u017a\u00f1\u00e7\u010d\u0161\u017e\u00c0\u00c1\u00c2\u00c4\u00c3\u00c5\u0104\u0106\u010c\u0116\u0118\u00c8\u00c9\u00ca\u00cb\u00cc\u00cd\u00ce\u00cf\u012e\u0141\u0143\u00d2\u00d3\u00d4\u00d6\u00d5\u00d8\u00d9\u00da\u00db\u00dc\u0172\u016a\u0178\u00dd\u017b\u0179\u00d1\u00df\u00c7\u0152\u00c6\u010c\u0160\u017d\u2202\u00f0","allowNumeric":false,"allowOtherCharSets":false},"step":1},"lastName":{"required":true,"type":"input","contentType":"text","alphanumSettings":{"allow":"\u00e0\u00e1\u00e2\u00e4\u00e3\u00e5\u0105\u010d\u0107\u0119\u00e8\u00e9\u00ea\u00eb\u0117\u012f\u00ec\u00ed\u00ee\u00ef\u0142\u0144\u00f2\u00f3\u00f4\u00f6\u00f5\u00f8\u00f9\u00fa\u00fb\u00fc\u0173\u016b\u00ff\u00fd\u017c\u017a\u00f1\u00e7\u010d\u0161\u017e\u00c0\u00c1\u00c2\u00c4\u00c3\u00c5\u0104\u0106\u010c\u0116\u0118\u00c8\u00c9\u00ca\u00cb\u00cc\u00cd\u00ce\u00cf\u012e\u0141\u0143\u00d2\u00d3\u00d4\u00d6\u00d5\u00d8\u00d9\u00da\u00db\u00dc\u0172\u016a\u0178\u00dd\u017b\u0179\u00d1\u00df\u00c7\u0152\u00c6\u010c\u0160\u017d\u2202\u00f0","allowNumeric":false,"allowOtherCharSets":false},"step":1},"email":{"required":true,"type":"input","contentType":"text","alphanumSettings":{"allow":"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&'*+-\/=?^_`{|}~.@","allowNumeric":true,"allowOtherCharSets":false},"step":1},"birthDate":{"type":"select","required":true,"contentType":"text","step":1},"nationality":{"required":true,"type":"input","contentType":"text","step":1},"termsAgree":{"type":"checkbox","textAbove":"terms_agreement_text","required":true,"contentType":"text","step":1},"termsAgree2":{"required":true,"type":"input","contentType":"text","step":1},"termsAgree3":{"required":false,"type":"input","contentType":"text","step":1},"termsAgree4":{"required":false,"type":"input","contentType":"text","step":1},"termsAgree5":{"required":false,"type":"input","contentType":"text","step":1},"termsAgree6":{"required":false,"type":"input","contentType":"text","step":1},"termsAgree7":{"required":false,"type":"input","contentType":"text","step":1},"termsAgree8":{"required":false,"type":"input","contentType":"text","step":1}},"2":{"postcode":{"show":["city"],"set":{"city":[]},"required":true,"type":"input","contentType":"text","maxLength":5,"alphanum":{"allowOtherCharSets":false},"step":2},"city":{"type":"select","display":false,"show":["houseNumber","street"],"required":true,"contentType":"text","step":2},"street":{"autocomplete":true,"type":"input","display":false,"required":true,"contentType":"text","step":2},"houseNumber":{"display":false,"required":true,"type":"input","contentType":"text","mask":{"regex":".{1,25}","clearIncomplete":false},"step":2},"phone":{"required":true,"type":"input","contentType":"text","mask":{"mask":"399 999 9999","clearIncomplete":true},"step":2}}},
                2,
                null,
                ["RenderStatePlugin","StreetAutocompletePlugin","RenderPostcodePlugin","EmailAutocompletePlugin","EmailValidationClassPlugin","InputMaskPlugin","BirthDateFieldExpandPlugin","ValidateAddedControlsPlugin","AlphanumSettingsPlugin","CheckBoxPlugin"]            );

            //page.startForm();
        //}
    });
</script>

<?php 
include("../campaignsAssets/scripts_layout.php");
?>

<style>
    /* stili da sovrascrivere per cambiare colori campagna */

    .btn:hover, .ynBTN_alpha:hover, .button:hover, .btn-continue:hover, .btn-continue-like:hover, .btn:active, .ynBTN_alpha:active, .button:active, .btn-continue:active, .btn-continue-like:active, .btn:focus, .ynBTN_alpha:focus, .button:focus, .btn-continue:focus, .btn-continue-like:focus
    {
    background: <?php echo $campaignData['mainColor']; ?>;
    border-color: <?php echo $campaignData['borderColor']; ?>;
    }

    .btn, .ynBTN_alpha, .button, .btn-continue, .btn-continue-like
    {
    background: <?php echo $campaignData['mainColor']; ?>;
    border-color: <?php echo $campaignData['borderColor']; ?>;
    color: #FFFF;
    }

    .progress-point.active
    {
        background:<?php echo $campaignData['mainColor']; ?>;
    }

    .questionfield, .questions
    {
        border-color:<?php echo $campaignData['borderColor']; ?>;
    }


</style>    

<script type="text/javascript" charset="UTF-8" src="//cdn.cookie-script.com/s/562fa5f760ff38ed5935e7de71af6392.js"></script>


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-60369633-1', 'auto');
  ga('send', 'pageview');

</script>

</body>
</html>
