﻿$(document).ready(function() {
    pushContent();
});

function addEmail() {
    var e = document.getElementById("txtEmail").value;
    var optin = document.getElementById("rdoOptin").checked;
    var c = location.href;
    var url = encodeURI("http://pdc-vampire.d.dotboxideas.com/handler/ecapture.ashx?&jsonp=addEmailHandler&e=" + e + "&optin=" + optin + "&c=" + c);

    addScript(url);
//    $.getJSON(url, function(data) {
//        if (data != null) {
//             
//        }
//    });

    document.getElementById("vampire-inputs").style.display = "none";
    document.getElementById("vampire-thanks").style.display = "block";

}

function addEmailHandler(result, methodName) {
    //alert('addemailhandler called');
}

function pushContent() {
    var html = "";

    html += "<div style=\"width: 500px; height: 150px; background-image: url(http://pdc-vampire.d.dotboxideas.com/images/bg.jpg);\"> ";
    html += "<div style=\"margin-left: 115px; padding-top: 95px\"> ";
    html += "<div id=\"vampire-inputs\" style=\"display: block\">";
    html += "   <input onblur=\"if (this.value == '') {this.value = 'Enter your email address';}\" ";
    html += "      onfocus=\"if (this.value == 'Enter your email address') {this.value = '';}\" value=\"Enter your email address\" ";
    html += "      style=\"width: 204px; border: 0; padding: 3px 0 0 3px; height: 20px; font-family: Georgia,'Times New Roman',Times,serif; ";
    html += "      vertical-align: middle; margin-bottom: 6px;\" id=\"txtEmail\" /> ";
    html += "  <input id=\"btnSubmit\" type=\"image\" onclick=\"addEmail(); return false;\" href=\"#\" style=\"border: 0px; ";
    html += "      vertical-align: middle; margin-bottom: 6px;\" src=\"http://pdc-vampire.d.dotboxideas.com/images/btnSubmit.jpg\" /><br /> ";
    html += "  <input id=\"rdoOptin\" type=\"checkbox\" checked=\"checked\" /><span style=\"color: White; ";
    html += "      font-size: 11px; font-family: Arial, Helvetica, sans-serif;\">Opt-in to receive emails ";
    html += "      from Parfums de Coeur</span> <span><a href=\"http://pdc-vampire.d.dotboxideas.com/terms.html\" style=\"color: #282828; font-size: 10px; ";
    html += "          font-family: Arial, Helvetica, Sans-Serif; margin-left: 35px;\">Terms &amp; Conditions</a></span> ";
    html += "</div>";
    html += "<div id=\"vampire-thanks\" style=\"padding-left: 100px; color: White; font-size: 21px; font-family: Arial, Helvetica, sans-serif; display: none;\">Thank You</div>";
    html += "</div> ";
    html += " </div> ";


    $('#vampire-content').html(html);
}

function addScript(scriptUrl) {
    var script = document.createElement('script');

    script.setAttribute('type', 'text/javascript');
    script.setAttribute('src', scriptUrl);

    var head = document.getElementsByTagName('head')[0];
    head.appendChild(script);
}
