var fnWaySelect="TFWaySelect";var fnFirstName="TFFirstName";var fnLastName="TFLastName";var fnCompanyName="TFCompanyName";var fnEmail="TFEmail";var fnTelephone="TFTelephone";var fnCountry="TFCountry";var fnMessage="TFMessage";var vnWaySelect="WaySelect";var vnFirstName="FirstName";var vnLastName="LastName";var vnCompanyName="CompanyName";var vnEmail="Email";var vnTelephone="Telephone";var vnCountry="Country";var vnMessage="Message";var EMPTY_STRING="";var MINIMUM_STRING_LENGTH=1;var DOWNLOAD_SECTION_PATH="../asp/download_section";var DOWNLOAD_FILE_EXT=".asp";var STRING_TERMINATOR=";";var VALUE_SEPARATOR="=";var EXPIRATION_STRING=";expires=";var ALERT_START="Please enter ";var WAY_SELECT="how you found us"
var FIRST_NAME="First name";var LAST_NAME="Last name";var BUSINESS_TYPE="Business type";var WEB_ADDRESS="Web address";var EMAIL="E-mail";var COMPANY_NAME="Company name";var TELEPHONE_NUMBER="Telephone number";var COUNTRY="Country";function GoToDownloadSection(strSectionNumber)
{document.DownloadForm.action=DOWNLOAD_SECTION_PATH+strSectionNumber+DOWNLOAD_FILE_EXT;document.DownloadForm.submit();}
function DownloadFile(strFileName)
{document.DownloadForm.TFFileName.value=strFileName;document.DownloadForm.submit();}
function checkCookieParent(Cookiename)
{var c=document.cookie;if(c.length==0){window.self.location.href="asp/downloadsForm.asp";}
else{window.self.location.href="asp/downloadfile.asp";}}
function checkCookieChild(Cookiename)
{var c=document.cookie;if(c.length==0){window.self.location.href="asp/downloadsForm.asp";}
else{window.self.location.href="asp/downloadfile.asp";}}
function setDownloadDetailsInCookie()
{strWaySelect=document.DownloadForm.TFWaySelect.value;strFirstName=document.DownloadForm.TFFirstName.value;strLastName=document.DownloadForm.TFLastName.value;strCompanyName=document.DownloadForm.TFCompanyName.value;strEmail=document.DownloadForm.TFEmail.value;strTelephone=document.DownloadForm.TFTelephone.value;strCountry=document.DownloadForm.TFCountry.value;strMessage=document.DownloadForm.TFMessage.value;setCookie(vnWaySelect,strWaySelect);setCookie(vnFirstName,strFirstName);setCookie(vnLastName,strLastName);setCookie(vnCompanyName,strCompanyName);setCookie(vnEmail,strEmail);setCookie(vnTelephone,strTelephone);setCookie(vnCountry,strCountry);setCookie(vnMessage,strMessage);}
function setCookie(CookieName,CookieValue)
{expireDate=new Date
expireDate.setMonth(expireDate.getMonth()+6)
document.cookie=CookieName+VALUE_SEPARATOR+escape(CookieValue)+EXPIRATION_STRING+expireDate.toGMTString();}
function getCookie(CookieName)
{var CurrentCookie=document.cookie;var CookiePrefix=CookieName+VALUE_SEPARATOR;var StartPosition=CurrentCookie.indexOf("; "+CookiePrefix);if(StartPosition==-1)
{StartPosition=CurrentCookie.indexOf(CookiePrefix);if(StartPosition!=0)
{return"";}}
else
{StartPosition+=2;}
var EndPosition=document.cookie.indexOf(STRING_TERMINATOR,StartPosition);if(EndPosition==-1)
{EndPosition=CurrentCookie.length;}
return unescape(CurrentCookie.substring(StartPosition+CookiePrefix.length,EndPosition));}
function GetDownloadDetailsFromCookie()
{if(document.cookie!="")
{strWaySelect=getCookie(vnWaySelect);strFirstName=getCookie(vnFirstName);strLastName=getCookie(vnLastName);strCompanyName=getCookie(vnCompanyName);strEmail=getCookie(vnEmail);strTelephone=getCookie(vnTelephone);strCountry=getCookie(vnCountry);strMessage=getCookie(vnMessage);}
else
{strWaySelect=EMPTY_STRING;strFirstName=EMPTY_STRING;strLastName=EMPTY_STRING;strCompanyName=EMPTY_STRING;strEmail=EMPTY_STRING;strTelephone=EMPTY_STRING;strCountry=EMPTY_STRING;strMessage=EMPTY_STRING;}
document.DownloadForm.TFWaySelect.value=strWaySelect;document.DownloadForm.TFFirstName.value=strFirstName;document.DownloadForm.TFLastName.value=strLastName;document.DownloadForm.TFCompanyName.value=strCompanyName;document.DownloadForm.TFEmail.value=strEmail;document.DownloadForm.TFTelephone.value=strTelephone;document.DownloadForm.TFCountry.value=strCountry;document.DownloadForm.TFMessage.value=strMessage;}
function CheckEntrySize(inputName)
{if(document.DownloadForm[inputName].value.length<MINIMUM_STRING_LENGTH)
{return false;}
else
{return true;}}
function isEmailValid(emailStr)
{var checkTLD=1;var knownDomsPat="";var emailPat=/^(.+)@(.+)$/;var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";var validChars="\[^\\s"+specialChars+"\]";var quotedUser="(\"[^\"]*\")";var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;var atom=validChars+'+';var word="("+atom+"|"+quotedUser+")";var userPat=new RegExp("^"+word+"(\\."+word+")*$");var domainPat=new RegExp("^"+atom+"(\\."+atom+")*$");var matchArray=matchArray=emailStr.match(emailPat);if(matchArray==null)
{alert("E-mail address is invalid.");return false;}
var user=matchArray[1];var domain=matchArray[2];for(i=0;i<user.length;i++)
{if(user.charCodeAt(i)>127)
{alert("E-mail address is invalid.");return false;}}
for(i=0;i<domain.length;i++)
{if(domain.charCodeAt(i)>127)
{alert("E-mail address is invalid.");return false;}}
if(user.match(userPat)==null)
{alert("E-mail address is invalid.");return false;}
var IPArray=domain.match(ipDomainPat);if(IPArray!=null)
{for(var i=1;i<=4;i++)
{if(IPArray[i]>255)
{alert("E-mail address is invalid.");return false;}}
return true;}
var atomPat=new RegExp("^"+atom+"$");var domArr=domain.split(".");var len=domArr.length;for(i=0;i<len;i++)
{if(domArr[i].search(atomPat)==-1)
{alert("E-mail address is invalid.");return false;}}
if(checkTLD&&domArr[domArr.length-1].length!=2&&domArr[domArr.length-1].search(knownDomsPat)==-1)
{alert("E-mail address is invalid.");return false;}
if(len<2)
{alert("E-mail address is invalid.");return false;}
return true;}
function CheckMinimumAndRedirect(RedirectAddress)
{var IsInfoPresent=true;if(!isEmailValid(document.DownloadForm[fnEmail].value))
{IsInfoPresent=false;}
else if(CheckEntrySize(fnEmail)==false)
{IsInfoPresent=false;}
else if(CheckEntrySize(fnWaySelect)==false)
{IsInfoPresent=false;}
else if(CheckEntrySize(fnFirstName)==false)
{IsInfoPresent=false;}
else if(CheckEntrySize(fnLastName)==false)
{IsInfoPresent=false;}
else if(CheckEntrySize(fnCompanyName)==false)
{IsInfoPresent=false;}
if(!IsInfoPresent)
{window.self.location.href=RedirectAddress;}}
function CheckMinimum()
{if(!isEmailValid(document.DownloadForm[fnEmail].value))
{alert('E-mail address is invalid.');document.DownloadForm.TFEmail.focus();}
else if(CheckEntrySize(fnEmail)==false)
{alert(ALERT_START+EMAIL);document.DownloadForm.TFEmail.focus();}
else if(CheckEntrySize(fnWaySelect)==false)
{alert(ALERT_START+WAY_SELECT);document.DownloadForm.TFWaySelect.focus();}
else if(CheckEntrySize(fnFirstName)==false)
{alert(ALERT_START+FIRST_NAME);document.DownloadForm.TFFirstName.focus();}
else if(CheckEntrySize(fnLastName)==false)
{alert(ALERT_START+LAST_NAME);document.DownloadForm.TFLastName.focus();}
else if(CheckEntrySize(fnCompanyName)==false)
{alert(ALERT_START+COMPANY_NAME);document.DownloadForm.TFCompanyName.focus();}
else
{setDownloadDetailsInCookie();document.DownloadForm.submit();}}
function SubmitFormNoCheck()
{document.DownloadForm.submit();}
