<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<?php /*<!--[if lte IE 8]>
			<script type="text/javascript" src="<?php echo asset('iframe-resizer/ie8.polyfils.min.js'); ?>"></script>
		<![endif]-->*/ ?>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
		<meta name="description" content="Sume Clientes">
		<meta name="keywords" content="sumeclientes, sume, sume clientes, formulario">
		<link rel="shortcut icon" href="<?php echo asset('SysWeb/SumeClientes/favicon.ico'); ?>" type="image/x-icon">
		<link rel="icon" href="<?php echo asset('SysWeb/SumeClientes/favicon.ico'); ?>" type="image/x-icon">
		<link rel="icon" type="image/png" sizes="16x16" href="<?php echo asset('favicon.ico'); ?>">

		<title> Formulario diseñado en la plataforma Sume Clientes </title>
		<?php /* HTML::style('WebPro/bootstrap/css/bootstrap.min.css') */ ?>
		<?php /* HTML::style('WebPro/css/font-awesome.min.css') */ ?>
		<?php /* HTML::style('SysWeb/SumeClientes/BootstrapMod.css') */ ?>
		<?php echo HTML::style('SysWeb/SumeClientes/bootstrap-all-min.css'); ?>

		<?php echo HTML::style('Intl-Tel-Input/17.0.3/css/intlTelInput.min.css'); ?>

		<?php echo HTML::style('SysWeb/SumeClientes/EditorDeFormularios.min.css?v='.date('H:i:s')); ?>

		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
			<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
			<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->
		<link id="Adamia" href="https://fonts.googleapis.com/css?family=Adamina" rel="stylesheet" type="text/css">
		<link id="DancingScript" href="https://fonts.googleapis.com/css?family=Dancing+Script" rel="stylesheet" type="text/css">
		<link id="DroidSans" href="https://fonts.googleapis.com/css?family=Droid+Sans" rel="stylesheet" type="text/css">
		<link id="JustAnotherHand" href="https://fonts.googleapis.com/css?family=Just+Another+Hand" rel="stylesheet" type="text/css">
		<link id="LobsterTwo" href="https://fonts.googleapis.com/css?family=Lobster+Two" rel="stylesheet" type="text/css">
		<link id="Montserrat" href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
		<link id="NixieOne" href="https://fonts.googleapis.com/css?family=Nixie+One" rel="stylesheet" type="text/css">
		<link id="OpenSans" href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
		<link id="Oswald" href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet" type="text/css">
		<link id="Pacifico" href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet" type="text/css">
		<link id="ShadowsIntoLightTwo" href="https://fonts.googleapis.com/css?family=Shadows+Into+Light+Two" rel="stylesheet" type="text/css">
		<link id="TheGirlNextDoor" href="https://fonts.googleapis.com/css?family=The+Girl+Next+Door" rel="stylesheet" type="text/css">
		<link id="BubblegumSans" href="https://fonts.googleapis.com/css?family=Bubblegum+Sans" rel="stylesheet" type="text/css">
		<link id="LondrinaSolid" href="https://fonts.googleapis.com/css?family=Londrina+Solid" rel="stylesheet" type="text/css">
		<link id="RockSalt" href="https://fonts.googleapis.com/css?family=Rock+Salt" rel="stylesheet" type="text/css">
		<?php echo HTML::style('VideoJS/video-js.min.css'); ?>

		<style> #Campos .iconoN .intl-tel-input {position: relative;display: table-cell;}</style>
	</head>
	<!--<body id="CuerpoFull" onresize="CambiarAlto()">-->
	<body id="CuerpoFull">
		<div class="container-fluid">
			<form id="frmSuscripcion">
				<?php echo trim($Formulario->codigo_html); ?>

				<input type="hidden" value="" id="fuente_suscripcion" name="fuente_suscripcion"></input>
			</form>
		</div>
		<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
		<?php echo HTML::script('WebPro/js/jquery-2.0.2.min.js'); ?>

		<!-- Include all compiled plugins (below), or include individual files as needed -->
		<?php echo HTML::script('WebPro/bootstrap/js/bootstrap.min.js'); ?>

		<?php echo HTML::script('iframe-resizer/iframeResizer.contentWindow.min.js'); ?>

		<?php echo HTML::script('Intl-Tel-Input/17.0.3/js/intlTelInput-jquery.min.js'); ?>

		<?php echo HTML::script('Alphanum/jquery.alphanum.js'); ?>

		<script type="text/javascript">
			if (window!= window.top) { // inside iframe
				document.body.style.backgroundColor = 'transparent';
				// or document.body.style.background = 'none';
			}
			$("#Campos").find('input[name="telefono"], input[name="celular"], input[name="numero_de_telefono_del_trabajo"]').attr({"inputmode": "numeric", "pattern": "[0-9]*"});
			$("#Campos").find('input[name="telefono"], input[name="celular"], input[name="numero_de_telefono_del_trabajo"]').intlTelInput({
				utilsScript: "https://sumeclientes.net/Intl-Tel-Input/17.0.3/js/utils.min.js",
				//onlyCountries: ["us", "mx", "cu", "dm", "do", "pr", "bz", "gt", "sv", "hn", "ni", "cr", "pa", "ve", "ec", "co", "pe", "bo", "cl", "py", "uy", "ar", "es", "gq"]
			});
			$.getJSON("https://sumeclientes.net/EP/GeoIP", function(data){
			var pais = data.isoCode;
				if (pais != "") {
					$("#Campos").find('input[name="telefono"], input[name="celular"], input[name="numero_de_telefono_del_trabajo"]').intlTelInput("setCountry", pais);
				}
			});
			$("#Campos").find('input[name="telefono"], input[name="celular"], input[name="numero_de_telefono_del_trabajo"]').alphanum({
				allow: " +-1234567890",
				disallow: ':;´"qwertyuiopasdfghjklmnbvcxzñ_,.',
				allowSpace: true,
				allowNumeric: true,
				allowUpper: true,
				allowCaseless: false,
				allowOtherCharSets: false,
				forceLower: false
			});
		</script>
		<script type="text/javascript">
			function LimpiarEventos(){
				$("#frmSuscripcion :input").each(function(){ $(this).removeAttr("onclick"); $(this).prop("onclick", null); });
				$("#frmSuscripcion").find("p").each(function(){ $(this).removeAttr("onclick"); $(this).prop("onclick", null); });
			}
			function inIframe () { try { return window.self !== window.top; } catch (e) { return true; } }
			<?php /*function CambiarAlto(){ if( inIframe() ){ var Alto = $("#CuerpoFull").height(); postAlto(Alto); } }
			function postAlto(height){
				var height = height; var json = { "Mensaje":"Alto", "Frm":"<?php echo str_replace('-', '', $Formulario->token); ?>", "height": height };
				var target = parent.postMessage ? parent : (parent.document.postMessage ? parent.document : undefined);
				if(typeof target != "undefined" && document.body.scrollHeight){ target.postMessage(json, "*"); }
			}*/ ?>
			function postDisenho(){
				if($("#Orden").hasClass("Vertical")){
					var json = { "Mensaje":"Disenho", "Disenho": "V" };
				}
				else if($("#Orden").hasClass("Horizontal")){
					var json = { "Mensaje":"Disenho", "Disenho": "H" };
				}
				var target = parent.postMessage ? parent : (parent.document.postMessage ? parent.document : undefined);
				if(typeof target != "undefined" && document.body.scrollHeight){ target.postMessage(json, "*"); }
			}
			$(document).ready(function(){
				$("#fuente_suscripcion").val(document.referrer);
				postDisenho();
				//CambiarAlto();
				LimpiarEventos();
				$("#btnSubmit").click(function(){
					$('[id^="err"]').html("");
					var btnSubmit = $("#btnSubmit").html();
					if($("#frmSuscripcion").find('input[name="telefono"]').length > 0){
						$("#frmSuscripcion").append('<input type="hidden" name="numTel" class="rmtel" value="'+$("#frmSuscripcion").find('input[name="telefono"]').intlTelInput("getNumber")+'">');
						$("#frmSuscripcion").append('<input type="hidden" name="numTel-pais" class="rmtel" value="'+$("#frmSuscripcion").find('input[name="telefono"]').intlTelInput("getSelectedCountryData").iso2+'">');
					}
					if($("#frmSuscripcion").find('input[name="celular"]').length > 0){
						$("#frmSuscripcion").append('<input type="hidden" name="numCel" class="rmtel" value="'+$("#frmSuscripcion").find('input[name="celular"]').intlTelInput("getNumber")+'">');
						$("#frmSuscripcion").append('<input type="hidden" name="numCel-pais" class="rmtel" value="'+$("#frmSuscripcion").find('input[name="celular"]').intlTelInput("getSelectedCountryData").iso2+'">');
					}
					if($("#frmSuscripcion").find('input[name="numero_de_telefono_del_trabajo"]').length > 0){
						$("#frmSuscripcion").append('<input type="hidden" name="numCel" class="rmtel" value="'+$("#frmSuscripcion").find('input[name="numero_de_telefono_del_trabajo"]').intlTelInput("getNumber")+'">');
						$("#frmSuscripcion").append('<input type="hidden" name="numTelT-pais" class="rmtel" value="'+$("#frmSuscripcion").find('input[name="numero_de_telefono_del_trabajo"]').intlTelInput("getSelectedCountryData").iso2+'">');
					}
					//$("#btnSubmit").html('<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i> Procesando..').prop("disabled", true);
					$("#btnSubmit").html('<i class="fa fa-spinner fa-spin" style="font-size: 20px !important;"></i> Procesando...').prop("disabled", true);
					$.post(
						"<?php echo URL::route('SysWebEmailMarketingFormulario', array($Formulario->token)); ?>",
						$("#frmSuscripcion").serialize(),
						function(data){
							$('[id^="err"]').html("");
							$("#frmSuscripcion").find(".rmtel").remove();
							$("#btnSubmit").html(btnSubmit).prop("disabled", false);
							if(data.success){
								if(data.pagina_agradecimiento != ""){
									if( inIframe() ){ window.top.location.href = data.pagina_agradecimiento; }
									else{ window.location.href = data.pagina_agradecimiento; }
								}
								else{
									if( inIframe() ){ window.top.location.reload(); }
									else{ window.location.reload(); }
								}
							}
							else{
								$.each(data.errMensajes, function(key, value){ if(value != ''){ $("#err"+key).html(value); } else{ $("#err"+key).html(""); } });
								//CambiarAlto();
							}
						},
						"json"
					);
				});
			});
		</script>
		<?php echo HTML::script('VideoJS/video.min.js'); ?>

		<?php echo HTML::script('VideoJS/Youtube.min.js'); ?>

	</body>
</html>