//Begin client detection
var na = navigator.appVersion;
var napN = navigator.appName;
var nu = navigator.userAgent;

//browser flags
var isNS6up=false;
var isNS62up=false;
var isIE=false;
var isNN4=false;
var isOpera5up=false;

if ((nu.indexOf("MSIE")!=-1)&&(nu.indexOf("Opera")==-1)){isIE=true;}
var ieMajor=isIE?parseInt(nu.slice(nu.indexOf("MSIE")+4)):0;
var isIE4up=ieMajor>=4;
var isIE5up=ieMajor>=5;
if ((napN =="Netscape")&&(na.indexOf("4")==0)){isNN4=true;}
if (nu.indexOf("Netscape6")!=-1){isNS6up=true;}
var ns6Minor=isNS6up?parseFloat(nu.slice(nu.indexOf("Netscape6/")+10)):0;
if (ns6Minor>=6.2){isNS62up=true;}
if (nu.indexOf("Opera 5")!=-1){isOpera5up=true;}

//OS Flags
var isWin=false;
var isWin98=false;
var isWinNT=false;
var isMac=false;

//OS detector checks
if (nu.indexOf("Win")!=-1){isWin=true;}
if (nu.indexOf("Windows NT")!=-1){isWinNT=true;}
if (nu.indexOf("Windows 98")!=-1){isWin98=true;}
if (nu.indexOf("Mac")!=-1){isMac=true;}
//End client detection

//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

//Details textarea scroll box settings and content
var rows=3;
var cols=20;
//width of input type=text
var inpWidthLg=17;
var inpWidthSm=9; 

if (isNS6up){
	rows=2;  
    inpWidthLg=15; 
    inpWidthSm=7;
    if(!isNS62up){cols=17;}
    else if(isMac) {cols=29;}
    else {cols=34;}
}
if ((isIE4up||isOpera5up)&&(isWin)) {cols=35;}
if (isIE4up && isMac )              {cols=20;}
if ((isIE5up||isOpera5up)&&(isMac)) {cols=28;}
var copy="Subscriber’s Advantage Automatic Renewal Program: We’ll continue to renew your subscription without interruption for as long as you wish unless you tell us to stop. After your initial subscription term, we’ll bill you annually at the guaranteed low rate then in effect. You may cancel at any time and receive a full refund for all unmailed issues.\n\nFORTUNE is published biweekly, except for two issues combined periodically into one and occasional extra or expanded issues. Combined, expanded, and premium issues count as two subscription issues. Rate good in U.S. only. In Canada, $13 issues/$26.34C, subject to GST, HST, and QST.\n\nPlease allow 2-3 weeks for delivery of your first issue.\n\nSubscribers: If the Post Office alerts us that your magazine is undeliverable, we have no further obligation unless we receive a corrected address within two years.";
var details = '<span class="Copyright"><textarea readonly cols="'+cols+'" rows="'+rows+'" wrap class="Copyright" onChange="this.value=copy;">'+copy+'</textarea></span>';

function  TICM_submit(winName,f,h,w){
	if(TICM_check(f)){
       var features = "height=" + h + ",width=" + w + ",scrollbars=yes,location=no"
                   + ",menubar=no,resizable=no,status=yes,directories=no,toolbar=no";
        window.open("",winName,features);
		f.target = winName;
        TICM_SetCookie('popup2OFF','',TICM_popup2ON,'/');
		if(typeof P_isLoaded != "undefined")P_isLoaded = false;
        return true;
	}
    return false;
}

if(document.cookie.indexOf('popup2OFF')!=-1){
	if(typeof P_isLoaded != "undefined")P_isLoaded = 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.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 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"
		
	t = f.zipCode.value;
	good=1;
	if (t==null || t=='' || isblank(t) || t.length<5 || t.length>6 )good=0;
	else{if (state!=''){
			if (t.length==5 && (t.search(/^\d{5}$/) != -1)){ 
				for (d = 0; d<canstates.length;d++){
					if (state==canstates[d])good=0;
				}
			}else good=0;
			if (t.length==6 && t.search(/^[a-zA-Z]\w{5}$/)!=-1){
				good=0;
				for (d = 0; d<canstates.length;d++){
					if (state == 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";

    good=1; t=f.email.value;
    if (t != null && t != '' && !isblank(t)){
        good=(t.search(/^(\w|-)+(\.(\w|-)+)?@((\w|-)+\.){1,}[a-zA-Z]{2,3}$/)==-1)?0:1;
    }
    
	if(!good)msg+="Please enter a valid E-Mail Address.\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

// 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;
}

// begin html for subscription form 

var styles = '<STYLE TYPE="TEXT/CSS">.copy {font-family: Verdana, Arial, sans-serif; font-size: 10px}.form {height: 18px}</STYLE>';

var form_body = '<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><form method="post" name="fo_endofieform" action="https://subs.timeinc.net/FO/fo_endofie2.jhtml" onsubmit="return TICM_submit(\'fo_endofie2\',this,\'410\',\'416\')"><TD COLSPAN="3"><IMG SRC="http://i.timeinc.net/subs2/images/fo/fo_endofie_ofe_01.gif" WIDTH="420" HEIGHT="21"></TD></TR>'+
'<TR><TD BACKGROUND="http://i.timeinc.net/subs2/images/fo/fo_endofie_ofe_06.gif" WIDTH="3"><IMG SRC="http://i.timeinc.net/subs2/images/fo/spacer.gif" WIDTH="3" HEIGHT="1"></TD>'+
'<TD WIDTH="414"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD><IMG SRC="http://i.timeinc.net/subs2/images/fo/fo_endofie_ofe_03.gif" WIDTH="97" HEIGHT="91"></TD><TD VALIGN="TOP"><IMG SRC="http://i.timeinc.net/subs2/images/fo/fo_endofie_ofe_04.gif" WIDTH="317" HEIGHT="16">'+
'<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%"><TR><TD ALIGN="right" CLASS="copy">Name: </TD><TD><INPUT TYPE="text" NAME="name" SIZE="10" MAXLENGTH="30" CLASS="form" tabindex="1"></TD><TD ALIGN="right" CLASS="copy">State/Province: </TD><TD><SELECT NAME="state" CLASS="form" tabindex="4"><OPTION>--<OPTION VALUE=AA>AA<OPTION VALUE=AB>AB<OPTION VALUE=AE>AE<OPTION VALUE=AK>AK<OPTION VALUE=AL>AL<OPTION VALUE=AP>AP<OPTION VALUE=AR>AR<OPTION VALUE=AS>AS<OPTION VALUE=AZ>AZ<OPTION VALUE=BC>BC<OPTION VALUE=CA>CA<OPTION VALUE=CO>CO<OPTION VALUE=CT>CT<OPTION VALUE=DC>DC<OPTION VALUE=DE>DE<OPTION VALUE=FL>FL<OPTION VALUE=GA>GA<OPTION VALUE=HI>HI<OPTION VALUE=IA>IA<OPTION VALUE=ID>ID<OPTION VALUE=IL>IL<OPTION VALUE=IN>IN<OPTION VALUE=KS>KS<OPTION VALUE=KY>KY<OPTION VALUE=LA>LA<OPTION VALUE=MA>MA<OPTION VALUE=MB>MB<OPTION VALUE=MD>MD<OPTION VALUE=ME>ME<OPTION VALUE=MI>MI<OPTION VALUE=MN>MN<OPTION VALUE=MO>MO<OPTION VALUE=MP>MP<OPTION VALUE=MS>MS<OPTION VALUE=MT>MT<OPTION VALUE=NB>NB<OPTION VALUE=NC>NC<OPTION VALUE=ND>ND<OPTION VALUE=NE>NE<OPTION VALUE=NF>NF<OPTION VALUE=NH>NH<OPTION VALUE=NJ>NJ<OPTION VALUE=NM>NM<OPTION VALUE=NV>NV<OPTION VALUE=NS>NS<OPTION VALUE=NT>NT<OPTION VALUE=NY>NY<OPTION VALUE=ON>ON<OPTION VALUE=OH>OH<OPTION VALUE=OK>OK<OPTION VALUE=OR>OR<OPTION VALUE=PA>PA<OPTION VALUE=PE>PE<OPTION VALUE=PR>PR<OPTION VALUE=QC>QC<OPTION VALUE=RI>RI<OPTION VALUE=SC>SC<OPTION VALUE=SD>SD<OPTION VALUE=SK>SK<OPTION VALUE=TN>TN<OPTION VALUE=TX>TX<OPTION VALUE=UT>UT<OPTION VALUE=VA>VA<OPTION VALUE=VI>VI<OPTION VALUE=VT>VT<OPTION VALUE=WA>WA<OPTION VALUE=WI>WI<OPTION VALUE=WV>WV<OPTION VALUE=WY>WY<OPTION VALUE=YT>YT</OPTION></SELECT></TD></TR>'+
'<TR><TD ALIGN="right" CLASS="copy">Address: </TD><TD><INPUT TYPE="text" NAME="address1" SIZE="10" MAXLENGTH="30" CLASS="form" tabindex="2"></TD><TD ALIGN="right" CLASS="copy">Zip/Postal Code: </TD><TD><INPUT TYPE="text" NAME="zipCode" SIZE="10" MAXLENGTH="6" CLASS="form" tabindex="5"></TD></TR>'+
'<TR><TD ALIGN="right" CLASS="copy">City: </TD><TD><INPUT TYPE="text" NAME="city" SIZE="10" MAXLENGTH="20" CLASS="form" tabindex="3"></TD><TD ALIGN="right" CLASS="copy">E-mail: </TD><TD><INPUT TYPE="text" NAME="email" SIZE="10" MAXLENGTH="50" CLASS="form" tabindex="6"></TD></TR></TABLE>'+
'<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="317"><TR ALIGN="CENTER" VALIGN="MIDDLE"><TD CLASS="copy"><FONT COLOR="#990000">Outside U.S. &amp; Canada, <A HREF="http://www.timeinc.net/subs/fortuneasia/fo_int_land.html" target="_blank">click&nbsp;here</A>.</FONT></TD><TD><input type="image" SRC="http://i.timeinc.net/subs2/images/fo/fo_endofie_ofe_10.gif" WIDTH="115" HEIGHT="20" BORDER="0"></TD></TR>'+
'<TR ALIGN="CENTER" VALIGN="MIDDLE"><TD colspan="2"><IMG SRC="http://i.timeinc.net/subs2/images/fo/spacer.gif" WIDTH="1" HEIGHT="5" BORDER="0"></TD></TR></TABLE></TD></TR></TABLE></TD>'+
'<TD BACKGROUND="http://i.timeinc.net/subs2/images/fo/fo_endofie_ofe_06.gif" WIDTH="3"><IMG SRC="http://i.timeinc.net/subs2/images/fo/spacer.gif" WIDTH="3" HEIGHT="1"></TD></TR>'+
'<TR><TD BGCOLOR="#000066" WIDTH="3"><IMG SRC="http://i.timeinc.net/subs2/images/fo/spacer.gif" WIDTH="1" HEIGHT="1"></TD><TD BACKGROUND="http://i.timeinc.net/subs2/images/fo/fo_endofie_ofe_14.gif" HEIGHT="3"><IMG SRC="http://i.timeinc.net/subs2/images/fo/spacer.gif" WIDTH="1" HEIGHT="3"></TD><TD BGCOLOR="#000066" WIDTH="3"><IMG SRC="http://i.timeinc.net/subs2/images/fo/spacer.gif" WIDTH="1" HEIGHT="1"></TD><input type="hidden" name="per_name" value="fo_endofie2"><input type="hidden" name="directory" value="FO"><input type="hidden" name="payment_type" value="BM"><input type="hidden" name="forward" value="fo_endofie"></form></TR></TABLE>';

document.write(styles);
document.write(form_body);