

document.write('<div id="downloadconvert">');
document.write('<form name="downloadsendEmail" action="#" method="post" id="downloadsendEmail">');
document.write('<p><label for="downloademail">Email Address: <span>* Required</span></label><input type="text" class="default-value name-box"  name="email" id="downloademail"  value="Enter your email address"  /></p>');
document.write('<p><label for="downloadname">Your Name: <span>* Required</span></label><input type="text" class="default-value name-box"  name="name" id="downloadname"  value="Enter your name" /></p>');
document.write('<p><label for="downloadphone">Phone Number: <span>* Required</span></label><input type="text" class="default-value name-box"  name="phone" id="downloadphone"  value="Enter your phone number" /></p>');
document.write('<input type="hidden" id="submitted" name="submitted" class="hidden"  value="true" />');
document.write('<input type="hidden" id="return"  name="return" class="hidden" value="http://www.americanunit.com/edge/thanks.php" />');
document.write('<input type="hidden" id="referrer" class="hidden"  name="referrer"/>');
document.write('<input type="hidden" class="hidden" id="source" name="source" value="' + source + '" />');
document.write('<input type="hidden" class="hidden"  id="medium" name="medium" value="' + medium + '" />');
document.write('<input type="hidden" class="hidden"  id="term" name="term" value="' + term + '" />');
document.write('<input type="hidden" class="hidden"  id="content" name="content" value="' + content + '" />');
document.write('<input type="hidden" class="hidden"  id="campaign" name="campaign" value="' + campaign + '" />');
document.write('<input type="hidden" class="hidden"  id="csegment" name="csegment" value="' + csegment + '" />');
document.write('<p><input class="submit ' + sw_actionType +'" type="submit" /></p><br class="clear" />');
document.write('</form>');
document.write('<p class="privacy">Your <a href="/privacy-policy.php">Privacy</a> is important to us. We will never resell or abuse your email address.</p>');
document.write('</div>');


$(document).ready(function() {

    
    myemail = $.cookie('email');
	  myname = $.cookie('name');
	  myphone = $.cookie('phone');
	  
	  if(myemail)
	  {
      $("#downloademail").attr('value', myemail);
      $("#downloademail").removeClass('default-value');
     }
     
	  if(myname)
	  {
      $("#downloadname").attr('value', myname);
      $("#downloadname").removeClass('default-value');
     }
     
    if(myphone)
	  {
      $("#downloadphone").attr('value', myphone);
      $("#downloadphone").removeClass('default-value');
     }
     
     action="";
     fileName = "";
     fileTitle="";
     if (typeof sw_actionType!="undefined")
      action = sw_actionType;
      if(typeof sw_filename!="undefined")
      fileName = sw_filename;
      
    if(typeof sw_filetitle!="undefined")
      fileTitle = sw_filetitle;
	/* default values */
   	var active_color = '#000000'; // Colour of user provided text
    var inactive_color = '#828282'; // Colour of default text
    
	$("input.default-value").css("color", inactive_color);
	  
	  var default_values = new Array();
	  
	  $("input.default-value").focus(function() {
	    if (!default_values[this.id]) {
	      default_values[this.id] = this.value;
	    }
	    if (this.value == default_values[this.id]) {
	      this.value = '';
	      this.style.color = active_color;
	    }
	    $(this).blur(function() {
	      if (this.value == '') {
	        this.style.color = inactive_color;
	        this.value = default_values[this.id];
	      }
	    });
	  });
	  
	
	  
	  
	  
		jQuery(function($){
		   $("#downloadphone").mask("(999) 999-9999");
		});

		$("#downloadsendEmail").submit(function(){					   				   

			$(".error").hide();
			

			var hasError = false;

			var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

			var telusEmail = /@telus\.com/i;

			var hotmailEmail = /@hotmail\.com/i;

			var liveEmail = /@live\.com/i;

			var gmailEmail = /@gmail\.com/i;

			var yahooEmail = /@yahoo\.com/i;

			var yahooCAEmail = /@yahoo\.ca/i;

			var sympaticoEmail = /@sympatico\.ca/i;

			var rogersEmail = /@rogers\.com/;

	

			var emailVal = $("#downloademail").val();

			if(emailVal == '') {

				$("#downloademail").after('<p class="error">You forgot to enter your email address.</p>');

				hasError = true;

			} else if(!emailReg.test(emailVal)) {	

				$("#downloademail").after('<p class="error">Enter a valid email address to send to.</p>');

				hasError = true;

			} else if(emailVal.match(telusEmail)) {	

				$("#downloademail").after('<p class="error">Please use your Business / Office email address.</p>');

				hasError = true;

			} else if(emailVal.match(hotmailEmail)) {	

				$("#downloademail").after('<p class="error">Please use your Business / Office email address.</p>');

				hasError = true;

			} else if(emailVal.match(liveEmail)) {	

				$("#downloademail").after('<p class="error">Please use your Business / Office email address.</p>');

				hasError = true;

			} else if(emailVal.match(gmailEmail)) {	

				$("#downloademail").after('<p class="error">Please use your Business / Office email address.</p>');

				hasError = true;

			} else if(emailVal.match(yahooEmail)) {	

				$("#downloademail").after('<p class="error">Please use your Business / Office email address.</p>');

				hasError = true;

			} else if(emailVal.match(yahooCAEmail)) {	

				$("#downloademail").after('<p class="error">Please use your Business / Office email address.</p>');

				hasError = true;

			} else if(emailVal.match(sympaticoEmail)) {	

				$("#downloademail").after('<p class="error">Please use your Business / Office email address.</p>');

				hasError = true;

			} else if(emailVal.match(rogersEmail)) {	

				$("#downloademail").after('<p class="error">Please use your Business / Office email address.</p>');

				hasError = true;

			}




 


			var nameVal = $("#downloadname").val();

			if(nameVal == '') {

				$("#downloadname").after('<p class="error">You forgot to enter your full name.</p>');

				hasError = true;

			}

			

			var phoneVal = $("#downloadphone").val();

			if(phoneVal.length < 10 ) {

				$("#downloadphone").after('<p class="error">You forgot to enter a valid phone number.</p>');

				hasError = true;

			}

			

			

			if(hasError == false) {

  
				$(this).hide();

				$("#downloadsendEmail li.buttons").append('<img src="images/loading.gif" alt="Loading" id="loading" />');

				

				$.post("http://www.americanunit.com/edge/sendemail.php",

					{ 

						email: emailVal,

						name: nameVal,

						phone: phoneVal,

						referrer: $("#referrer").val(),
						source: $("#source").val(),
						medium: $("#medium").val(),
						term: $("#term").val(),
						content: $("#content").val(),
						campaign: $("#campaign").val(),
						csegment: $("#csegment").val(),
						fileName: fileName,
						fileTitle: fileTitle,
						action: action,
						datatype: "script",
 
						success: function(data){

							$("#downloadconvert").slideUp("normal", function() {				   
						
								// call virtual page for ajax Google Analytics conversion tracking
								pageTracker._trackPageview('/edge/virtual-conversion');


								// Google Code for Conversion (eDGE) Conversion Page
									var google_conversion_id = 1027858468;
									var google_conversion_language = "en";
									var google_conversion_format = "3";
									var google_conversion_color = "ffffff";
									var google_conversion_label = "FEt0CIiSzQEQpMCP6gM";
									var google_conversion_value = 0;
									if (1) {
									  google_conversion_value = 1;
									}

									gaconversioncode = '<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"></script>';

									$("#downloadconvert").before(gaconversioncode);					

				

				// write cookie
                $.cookie("name", nameVal, { path: '/', expires: 365 });
                $.cookie("email", emailVal, { path: '/', expires: 365 });
                $.cookie("phone", phoneVal, { path: '/', expires: 365 });
                //$.cookie("phone", phoneVal, { expires: 365 });


				
                damessage = '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1027858468/?value=1&amp;label=FEt0CIiSzQEQpMCP6gM&amp;guid=ON&amp;script=0"/><div id="success"><h2>Success</h2><p>An email containing a link to download this file has been sent to your email address. It may take up to <strong>15 minutes</strong> to arrive.</p></div>';
                
                if (action !='download')
                {
                  damessage = '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1027858468/?value=1&amp;label=FEt0CIiSzQEQpMCP6gM&amp;guid=ON&amp;script=0"/><div id="success"><h2>Success</h2><p>A representative will be in touch with you within 24 hours.</p></div>';
                }
				
									$("#downloadconvert").before(damessage);											

				

							});

						}

					 });
					 
					 return false;

			
			}
			else {

			
        
        return false;
        }

		});						   
  
	  
	  
	  
});


