//Begin client detection
var TICM_na = parseFloat(navigator.appVersion);	
var TICM_napN = navigator.appName.toLowerCase();
var TICM_nu = navigator.userAgent.toLowerCase();

var TICM_isIE=((document.all)&&(TICM_nu.indexOf('opera')==-1))?true:false;
var TICM_isNN4=((document.layers)&&(TICM_na >= 4.03))?true:false;
var TICM_isOpera5up=(TICM_nu.indexOf('opera 5')!=-1)?true:false;
var TICM_isGecko=(TICM_nu.indexOf('gecko')!=-1)?true:false;
var TICM_isDom = document.getElementById?true:false;
var TICM_isNS6 = (TICM_isGecko && TICM_nu.indexOf("/6.") != -1)? true: false;
var TICM_ieMajor=TICM_isIE?parseInt(TICM_nu.slice(TICM_nu.indexOf('msie')+4)):0;
var TICM_isIE4up=TICM_ieMajor >= 4;
var TICM_isIE5up=TICM_ieMajor >= 5;

var TICM_isWin=(TICM_nu.indexOf('win')!=-1)?true:false;
var TICM_isWin98=(TICM_nu.indexOf('windows nt')!=-1)?true:false;
var TICM_isWinNT=(TICM_nu.indexOf('windows 98')!=-1)?true:false;
var TICM_isMac=(TICM_nu.indexOf('mac')!=-1)?true:false;

var TICM_goodClient = (TICM_isNN4 || TICM_isIE5up || TICM_isOpera5up || TICM_isNS6 || TICM_isDom);

//this code is called on submit of form, and turns off popups for 
//24 hours.
function TICM_SetCookie (name,value,expires,path,domain,secure){
        document.cookie = name + escape (value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "; expires=Thu, 01-Jan-1970 00:00:01 GMT") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : ""); 
}
var TICM_day = 86400000; //one day in milliseconds
var TICM_date = new Date();
var TICM_popup2ON = new Date(TICM_date.getTime()+TICM_day);
//End of code for popups

// Form field sizing
var TICM_rows=3;
var TICM_cols=28;
var TICM_inpWidthLg=26; 
var TICM_inpWidthSm=6; 
var TICM_inpWidthXSm=6; 
var TICM_TyWinHeight = 356;
var TICM_TyWinWidth = 448;

if (TICM_isWin){
	if (TICM_isIE4up||TICM_isOpera5up) {TICM_cols=28; TICM_rows=3; TICM_inpWidthLg=16;}
	if (TICM_isGecko){TICM_cols=26; TICM_rows=3; TICM_inpWidthLg=14;}
	if (TICM_isNS6){TICM_cols=26; TICM_rows=3; TICM_inpWidthLg=14;}
}
else if(TICM_isMac){
		if (TICM_isIE5up||TICM_isOpera5up) {TICM_cols=24; TICM_inpWidthLg=14; TICM_inpWidthSm=5;TICM_TyWinHeight = 316;TICM_TyWinWidth = 418;}
		if (TICM_isNN4){TICM_cols=24; TICM_inpWidthLg=14;TICM_TyWinHeight = 316;TICM_TyWinWidth = 418;}
		if (TICM_isGecko){TICM_cols=24; TICM_inpWidthLg=14; TICM_inpWidthSm=5;TICM_TyWinHeight = 316;TICM_TyWinWidth = 438;}
		if (TICM_isNS6){TICM_cols=24; TICM_inpWidthLg=23; TICM_inpWidthSm=5;TICM_TyWinHeight = 316;TICM_TyWinWidth = 438;}		
}
	
function TICM_submit(winName,f,h,w){
	if(TICM_check(f)){
       var features = "height=" + h + ",width=" + w + ",scrollbars=yes,location=no,menubar=no,resizable=yes,status=yes,directories=no,toolbar=no";
		window.name = "pf_opener"
        window.open("",winName,features);
		f.target = winName;	
		return true;	
	}
	return false;
}

// Form Validation Script
function TICM_check(f){
var states = f.state;
var state;
var canstates = ['AB','BC','MB','NB','NF','NS','NT','ON','PE','QC','SK','YT']

	//t:temporary field value, msg:concatenated error message, good: boolean error tracker	
	var t, msg, good;
   	state = states.options[states.selectedIndex].value;  
	msg = "";
	//if ((f.elements["name"].value == null) || (f.elements["name"].value == '') || isblank(f.elements["name"].value)) msg += "Please enter your Name.\n";
	if ((f.elements["name"].value.search(/[A-Za-z]\s[A-Za-z]/) == -1) || (f.elements["name"].value == null) || (f.elements["name"].value == '') || isblank(f.elements["name"].value)) msg += "Please enter your First & last name.\n";
	if ((f.address1.value == null) || (f.address1.value == '') || isblank(f.address1.value)) msg += "Please enter your Address.\n";	
	if ((f.city.value == null) || (f.city.value == '') || isblank(f.city.value)) msg += "Please enter your City.\n";	
	if (state=='')msg+="Please enter your State/Province.\n"
		
    good=1; t=f["email"].value;
	if (t==null || t=='' || CM_isblank(t)) good=0;
	else good=(t.search(/^(\w|-)+(\.(\w|-)+)*@((\w|-)+\.)+[a-zA-Z]{2,3}$/)==-1)?0:1;
	if(!good){msg+='Your E-mail address is blank or incorrect.\n\n';}
   
	t = f.zipCode.value;
	good=1; 
	t=f.zipCode.value;
	if (t==null || t=='' || isblank(t) || t.length<5 || t.length>6 )good=0;
	  else {
	    if (f.state.value!='') {
	      if (t.length==5 && (t.search(/^\d{5}$/) != -1)) {
	        for (d = 0; d<canstates.length;d++){
	          if (f.state.value==canstates[d]) good=0;
	        }
	      }
	      else good=0;
	      if (t.length==6 && t.search(/^([a-zA-Z]\d){3}$/)!=-1){
	        good=0;
	        for (d = 0; d<canstates.length;d++){
	          if (f.state.value == canstates[d]) good=1;
	        }
	      }
	    }
	  }  
	if (!good){msg+="Zip/Postal code is blank or incorrect,\nor it doesn't match the State/Province you selected.\n";}


	if (msg.length) {
		alert ("The form was not submitted because of the following error(s):\n\n" + msg +
			"\n\nPlease correct these error(s) and resubmit your form.\n\nThank you,\nTime Inc. Consumer Services");
		return false;
	}
	return true;
}
// End Form Validation Script
function CM_isblank(s){
	for(var i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
return true;
}

// Utility function to check for blanknocity
function isblank(s){
	for(var i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
return true;
}

var usStates = ["AA", "AE", "AK", "AL", "AP", "AR", "AS", "AZ", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "GU", "HI", "IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN", "MO", "MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH", "OK", "OR", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VA", "VI", "VT", "WA", "WI", "WV", "WY"];
var canProvs = ["AB", "BC", "MB", "NB", "NL", "NS", "NT", "NU", "ON", "PE", "QC", "SK", "YT"];
var statesProvs = usStates.concat(canProvs).sort();
var stateOptionsList = "";
for(var i = 0; i < statesProvs.length; ++i)
{	stateOptionsList += '<option value="'+statesProvs[i]+'">'+statesProvs[i]+'</option>';}


sFormPath = "https://subs.timeinc.net/"; sPgLoc = document.location.href; 
if (sPgLoc.indexOf("timeinc.net") !=-1){
	if (sPgLoc.indexOf("/subs2/dev/") !=-1) sFormPath = "https://dev-subs.timeinc.net/"	
	if (sPgLoc.indexOf("/subs2/stage/") !=-1) sFormPath = "https://stage-subs.timeinc.net/"
}

var form_body = '<div style="width:300px; height:278px; overflow:hidden; background-color:#FFFFFF; border-style:solid; border-width:1px; border-color:#EFEFEF;">'+
'<div style="padding:3px; background-color:#7889A6">'+
'<div style="font-family:Verdana, Arial, Helvetica, sans-serif; color:#FFFFFF; font-size:12px; font-weight:bold;">Get a Free Trial Issue of <span style="color:#000066;">COASTAL LIVING!</span></div>'+
'</div>'+
'<div style="float:left; width:118px; height:256px; background-color:#FFFFFF; background-image:url(https://a248.e.akamai.net/f/1016/606/1d/image.timeinc.net/subs2/images/ct/ct_ofieartrf1016.gif); background-position:-1px 0px; background-repeat:no-repeat;"></div>'+
'<div style="float:right; width:180px; background-color:#EFEFEF;">'+
'<div style="padding:5px;">'+
'<table cellpadding="1" cellspacing="0" border="0" style="width:170px; font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#666666;">'+
'<form method="post" name="ofieform" action="'+sFormPath+'ProcessorServlet.jhtml" onsubmit="return TICM_submit(\'ct_ofieartrf1016\',this,\'575\',\'500\')">' +
'<input type="hidden" name="processorName" value="/net/timeinc/subs/user/controller/handler/curtain/BasicValetCurtainOFIE">' +
'<input type="hidden" name="zone" value="CT"><input type="hidden" name="url" value="">'+
'<input type="hidden" name="per_name" value="ct_ofieartrf1016">'+
'<input type="hidden" name="subs_form_id" value="prod/js/ct/ct_endarticleofie.js">'+
'<input type="hidden" name="forward" value="/CT/ct_ofieartrf1016_upsl.jhtml">'+
'<input type="hidden" name="emailEC" value="CHECK_ON_REQUIRED_ON">'+
'<input type="hidden" name="delayLiveFulfillment" value="true">'+
'<input type="hidden" name="passVariables" value="MSCSIGTP_E">'+
'<tr>' +
'  <td>Full  Name:</td>' +
'  <td><input maxlength="30" name="name" type="text" style="width:100px; height:15px; border-style:solid; border-width:1px; border-color:#666666;"></td></tr>' +
'<tr>' +
'  <td>Address:</td>' +
'  <td><input maxlength="30" name="address1" type="text" style="width:100px; height:15px; border-style:solid; border-width:1px; border-color:#666666;"></td></tr>' +
'<tr>' +
'  <td>City:</td>' +
'  <td><input maxlength="20" name="city" type="text" style="width:100px; height:15px; border-style:solid; border-width:1px; border-color:#666666;"></td></tr>' +
'<tr>' +
'  <td>St./Prov.:</td>' +
'  <td><select name="state" size="1"><option value="">- -</option>'+stateOptionsList+'</select></td></tr>' +
'<tr>' +
'  <td>Zip/Postal:</td>' +
'  <td><input name="zipCode" maxlength="6" type="text" style="width:100px; height:15px; border-style:solid; border-width:1px; border-color:#666666;"></td></tr>' +
'<tr>' +
'  <td>E-mail:</td>' +
'  <td><input maxlength="50" name="email" type="text" style="width:100px; height:15px; border-style:solid; border-width:1px; border-color:#666666;"></td></tr>' +
'<tr>'+
'  <td colspan="2">'+
'  <div style="background-color:#FFFFFF; border-style:solid; border-color:#666666; border-width:1px; height:104px; overflow:auto;">'+
'  <div style="padding:0px;">'+
'Please send my Free Trial Issue of <em>Coastal Living</em>. If I like <em>Coastal Living</em>, I’ll pay just $16 for the trial issue plus 9 more, a total of 10 issues (1 year). If I’m not satisfied, I’ll return the bill marked &quot;cancel&quot; and owe nothing. The trial issue of COASTAL LIVING is mine to keep-FREE!' +
'<br/><br/>' +
'Rate good for new subscribers in the U.S. only. In Canada the rate is 10 issues for $24 CAD, plus GST, HST and QST as applicable. Cover price is $3.99. <em>Coastal Living</em> is published 10 times a year.  Your first issue will arrive in 6 - 8 weeks.'+
'<br/><br/>' +
'Subscribers: If the Post Office alerts us that your magazine is undeliverable, we have no further obligation unless we receive a corrected address within 2 years.'+
'<br/><br/>' + 
'Plus sales tax where applicable.'+
'<br/><br/>' + 
'To learn more about our information practices, read our <a href="http://cgi.timeinc.net/cgi-bin/mail/dnp/privacy_centralized.cgi/coastalliving?dnp_source=I" target="_blank">Privacy Policy</a>.  ' +
'  </div>' +
'  </div>' +
'  </td>' +
'  </tr>' +
'<tr><td>&nbsp;</td>' +
'  <td align="right"><input type="submit" name="submit1" value="Submit" style="background-color:#000066; border-style:solid; border-color:#333333; border-width:1px; color:#FFFFFF;"></td>' +
'</tr></form>' +
'</table>' +
'</div>' +
'</div>' +
'<hr style="padding:0px; margin:0px; visibility:hidden; clear:both;"/>'+
'</div>';

document.write(form_body);
//<!--CLD live=06-16-06-08:39 stage=04-26-06-10:23 stage-last-modified=05-26-06-08:39 -->

