// footer include file: Matt

/////////////////////////////// JS FUNCTIONS: RONK /////////////////////////////////
//////////// Email Deals form functions: Ron
//////////// Betsy Bury 02/11/09: Enhanced edits within function
function subscribePg(form)
{
 var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
	if (!emailfilter.test(form.email.value))
	{
		alert("Please enter a valid email address");
		return false;
	}
	else if ((form.zipcode.value != "") && (form.zipcode.value != "ZipCode") && (form.zipcode.value.length < 5))
		{
		alert("Please enter a valid 5 digit US ZipCode \n or a valid Canadian ZipCode \n or leave blank");
		return false;
		}
		else if ((form.zipcode.value != "") && (form.zipcode.value != "ZipCode") && (form.zipcode.value.length == 5) && (isNaN(stringTrim(form.zipcode.value))))
		{
		alert("Please enter a valid 5 digit US ZipCode\n or a valid Canadian ZipCode\n or leave blank");
		return false;
		}

	// Override title defaults if still present		
	if (form.firstname.value == "First Name")
	{
	form.firstname.value = "";
	}
	if (form.zipcode.value == "ZipCode")
	{
	form.zipcode.value = "";
	}
	
	//Get datestamp: Ron
	datetoday = new Date();
	var datestring;
	var month = datetoday.getMonth()+1;
	if (month < 10) { month = '0' + month; }
	var day = datetoday.getDate();
	if (day < 10) { day = '0' + day; }
	var year = datetoday.getFullYear();
	datestring = month + '/' + day + '/' + year;

	//Load variables with form field values
	var emailName = stringTrimL(form.email.value);
	var fName = stringTrimL(form.firstname.value);
	var zCode = stringTrimL(form.zipcode.value);
	location.href = 'http://newsletter.northerntool.com/subscription.jsp?eMail=' + emailName + '&fName=' + fName + '&zip=' + zCode + '';
	return false;
}

function eraseEmailFld() {
	document.EmailSubscribe.email.value="";
	return false;
}
function eraseNameFld() {
	document.EmailSubscribe.firstname.value="";
	return false;
}
function eraseZipFld() {
	document.EmailSubscribe.zipcode.value="";
	return false;
}
/* Strim Trim Right function removes any whitespace (spaces, tabs, and line breaks) using Reg Expression from the
ending of a String and replaces them with nothing */
function stringTrimR(strToTrim) {
	return(strToTrim.replace(/\s+$/g, ''));
}

/* Strim Trim Left function removes any whitespace (spaces, tabs, and line breaks) using Reg Expression from the
beginning of a String and replaces them with nothing */
function stringTrimL(strToTrim) {
	return(strToTrim.replace(/^\s+/g, ''));
}

/* Strim Trim removes any whitespace (spaces, tabs, and line breaks) using Reg Expression from the
beginning and ending of a String and replaces them with nothing */
function stringTrim(strToTrim) {
	return(strToTrim.replace(/^\s+|\s+$/g, ''));
}
//////////// End - Email Deals form functions //////////////////

/////////////////////////// END OF FUNCTIONS /////////////////////////////////

// email deals sign up
document.write('<table align="center" border="0" cellpadding="0" cellspacing="0" width="780" bgcolor="#ebe7de"><tr><td><img src="'+imageServer+'/images/footer/footerbar.gif" width="780" height="1" alt="" border="0"></td></tr><tr><td><form action="http://www.you-click.net/ProfileSubmit?pid=10800&pname=northerntool&i=5" name="EmailSubscribe" method="get" onSubmit="return subscribePg(this)"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><a href="/emaildeals/"><img src="'+imageServer+'/images/footer/emaildealstext.gif" width="343" height="28" alt="Email Deals" border="0"></a></td><td background="/images/footer/emaildealsbkgrd.gif" width="100%"><table cellpadding="2" cellspacing="0" border="0"><tr><td><input type="text" name="email" maxlength="60" value="Email Address" class="inputtypetext" onFocus="eraseEmailFld()" style="width:180px;"></td><td><input type="text" name="firstname" maxlength="25" VALUE="First Name" class="inputtypetext" onFocus="eraseNameFld()" style="width:105px;"></td><td><input type="text" name="zipcode" maxlength="7" VALUE="ZipCode" class="inputtypetext" onFocus="eraseZipFld()" style="width:55px;"></td></tr></table></td><td align="right"><input type="image" src="/images/footer/emaildealssignup.gif" border="0"><input type="hidden" name="func" value="S_survey_submit"><INPUT type="hidden" name="pid" VALUE="10800"><input type="hidden" name="pname" VALUE="northerntool"><input type="hidden" name="u" VALUE="0"><input type="hidden" name="i" VALUE="1"></td></tr></table></form></td></tr>');

// bottom text links
document.write('<tr><td align="center" height="30">');
document.write('<a class="details" href="/">Home</a>&nbsp;|&nbsp;');
document.write('<a class="details" href="/affiliates/">Affiliates</a>&nbsp;|&nbsp;');
document.write('<a class="details" href="/tractors/companyinfo/">Company Info</a>&nbsp;|&nbsp;');
document.write('<a class="details" href="/tractors/custhelp/contactus.htm">Contact Us</a>&nbsp;|&nbsp;');
document.write('<a class="details" href="/custhelp/ordersecurity.htm">Order Security</a>&nbsp;|&nbsp;');
document.write('<a class="details" href="/custhelp/privacypolicy.htm">Privacy Policy</a>&nbsp;|&nbsp;');
document.write('<a class="details" href="/custhelp/terms.htm">Terms + Conditions</a>');
document.write('</td></tr>');

document.write('<tr><td align="center" valign="top"><table cellpadding="8" cellspacing="0" border="0"><tr>');

// years in business
document.write('<td valign="bottom"><a href="/companyinfo/"><img src="'+imageServer+'/images/footer/yearsinbusiness.gif" width="112" height="58" alt="28 Years in Business!" border="0"></a></td>');

// hacker safe
document.write('<td align="center" width="100%"><!-- START SCANALERT CODE --><a target="_blank" href="https://www.scanalert.com/RatingVerify?ref=northerntool.com"><img width="115" height="32" border="0" src="//images.scanalert.com/meter/northerntool.com/12.gif" alt="HACKER SAFE certified sites prevent over 99.9% of hacker crime." oncontextmenu="alert(\'Copying Prohibited by Law - HACKER SAFE is a Trademark of ScanAlert\'); return false;"></a><!-- END SCANALERT CODE --></td>');

// verisign
document.write('<td align="right" valign="bottom"><a href="https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=WWW.NORTHERNTOOL.COM&lang=en" target="_blank"><img src="'+imageServer+'/images/footer/verisign.gif" width="112" height="58" alt="Click to Verify" border="0"></a></td></tr>');

// order info
document.write('<tr><td colspan="3" align="center"><table cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="padding-bottom: 12px;"><img src="'+imageServer+'/images/tractors/footer/buyonlineorcall.gif" width="225" height="14" alt="Buy Online or Call 1-800-521-0438" border="0"></td></tr><tr><td align="center"><img src="'+imageServer+'/images/footer/creditcards.gif" width="351" height="25" alt="Visa, MasterCard, Discover, American Express, SmartPay, Northern Power Card, Northern Net 30 Card, Northern Gift Card" border="0"><img style="margin: 0 0 1px 7px;" src="https://www.paypal.com/en_US/i/logo/PayPal_mark_37x23.gif" width="37" height="23" alt="We Accept PayPal"></td></tr></table></td></tr>');

// copyright info
document.write('<tr><td align="center" colspan="3" class="details">Copyright &#169; 1996 &#150; 2009 Northern Tractor & Power. All Rights Reserved.</td></tr></table></td></tr></table>');