var formElementsCheck = new Array( ); var formElementsCheckLen; var theForm; var submitInput = false; var addressDetails = new Array( ); var inWidth; function formChecker( ) { theForm = document.getElementById( 'roiCalc' ); if ( theForm ) { var theDiv = document.getElementById( 'costPerClickHelp' ); if ( theDiv ) { if ( theDiv.id == 'logoHelp' && ! document.all ) { theDiv.style.top = 2 + 'px'; if ( ! document.all ) { theDiv.style.left = theDiv.offsetLeft - 20 + 'px'; } } var helpMsg = document.createElement( 'div' ); helpMsg.id = 'costPerClickPopup'; helpMsg.className = 'helpMessageJs'; var helpP = document.createElement( 'p' ); helpP.className = 'helpMsgHeader'; var helpTxt = document.createTextNode( "The Seed cost per lead [£]" ); helpP.appendChild( helpTxt ); helpMsg.appendChild( helpP ); var helpMsgBody = document.createElement( 'div' ); helpMsgBody.className = 'helpMsg'; helpMsgBody.innerHTML = ""; helpMsg.appendChild( helpMsgBody ); var top = yOffset( theDiv ); var left = xOffset( theDiv ); left = left - 4 + theDiv.offsetWidth; helpMsg.style.width = 'auto'; helpMsg.style.top = top + 'px'; if ( ! document.all && helpMsg.id == 'logoHelpPopup' ) { // left += 200; } helpMsg.style.left = left + 'px'; setAttribute_IE_HACK( theDiv, 'onmouseover', "document.getElementById( 'costPerClickPopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onmouseout', "document.getElementById( 'costPerClickPopup' ).style.display = 'none';" ); setAttribute_IE_HACK( helpMsg, 'onmouseover', "document.getElementById( 'costPerClickPopup' ).style.display = 'block';" ); setAttribute_IE_HACK( helpMsg, 'onmouseout', "document.getElementById( 'costPerClickPopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onfocus', "document.getElementById( 'costPerClickPopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onblur', "document.getElementById( 'costPerClickPopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onclick', "this.blur( ); return false;" ); document.body.appendChild( helpMsg ); theDiv = false; } var theDiv = document.getElementById( 'conversionRateHelp' ); if ( theDiv ) { if ( theDiv.id == 'logoHelp' && ! document.all ) { theDiv.style.top = 2 + 'px'; if ( ! document.all ) { theDiv.style.left = theDiv.offsetLeft - 20 + 'px'; } } var helpMsg = document.createElement( 'div' ); helpMsg.id = 'conversionRatePopup'; helpMsg.className = 'helpMessageJs'; var helpP = document.createElement( 'p' ); helpP.className = 'helpMsgHeader'; var helpTxt = document.createTextNode( "Your average conversion rate [%]" ); helpP.appendChild( helpTxt ); helpMsg.appendChild( helpP ); var helpMsgBody = document.createElement( 'div' ); helpMsgBody.className = 'helpMsg'; helpMsgBody.innerHTML = ""; helpMsg.appendChild( helpMsgBody ); var top = yOffset( theDiv ); var left = xOffset( theDiv ); left = left - 4 + theDiv.offsetWidth; helpMsg.style.width = 'auto'; helpMsg.style.top = top + 'px'; if ( ! document.all && helpMsg.id == 'logoHelpPopup' ) { // left += 200; } helpMsg.style.left = left + 'px'; setAttribute_IE_HACK( theDiv, 'onmouseover', "document.getElementById( 'conversionRatePopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onmouseout', "document.getElementById( 'conversionRatePopup' ).style.display = 'none';" ); setAttribute_IE_HACK( helpMsg, 'onmouseover', "document.getElementById( 'conversionRatePopup' ).style.display = 'block';" ); setAttribute_IE_HACK( helpMsg, 'onmouseout', "document.getElementById( 'conversionRatePopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onfocus', "document.getElementById( 'conversionRatePopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onblur', "document.getElementById( 'conversionRatePopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onclick', "this.blur( ); return false;" ); document.body.appendChild( helpMsg ); theDiv = false; } var theDiv = document.getElementById( 'customerLifeTimeHelp' ); if ( theDiv ) { if ( theDiv.id == 'logoHelp' && ! document.all ) { theDiv.style.top = 2 + 'px'; if ( ! document.all ) { theDiv.style.left = theDiv.offsetLeft - 20 + 'px'; } } var helpMsg = document.createElement( 'div' ); helpMsg.id = 'customerLifeTimePopup'; helpMsg.className = 'helpMessageJs'; var helpP = document.createElement( 'p' ); helpP.className = 'helpMsgHeader'; var helpTxt = document.createTextNode( "Average lifetime of customer [Years]" ); helpP.appendChild( helpTxt ); helpMsg.appendChild( helpP ); var helpMsgBody = document.createElement( 'div' ); helpMsgBody.className = 'helpMsg'; helpMsgBody.innerHTML = ""; helpMsg.appendChild( helpMsgBody ); var top = yOffset( theDiv ); var left = xOffset( theDiv ); left = left - 4 + theDiv.offsetWidth; helpMsg.style.width = 'auto'; helpMsg.style.top = top + 'px'; if ( ! document.all && helpMsg.id == 'logoHelpPopup' ) { // left += 200; } helpMsg.style.left = left + 'px'; setAttribute_IE_HACK( theDiv, 'onmouseover', "document.getElementById( 'customerLifeTimePopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onmouseout', "document.getElementById( 'customerLifeTimePopup' ).style.display = 'none';" ); setAttribute_IE_HACK( helpMsg, 'onmouseover', "document.getElementById( 'customerLifeTimePopup' ).style.display = 'block';" ); setAttribute_IE_HACK( helpMsg, 'onmouseout', "document.getElementById( 'customerLifeTimePopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onfocus', "document.getElementById( 'customerLifeTimePopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onblur', "document.getElementById( 'customerLifeTimePopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onclick', "this.blur( ); return false;" ); document.body.appendChild( helpMsg ); theDiv = false; } var theDiv = document.getElementById( 'customerOrderNumHelp' ); if ( theDiv ) { if ( theDiv.id == 'logoHelp' && ! document.all ) { theDiv.style.top = 2 + 'px'; if ( ! document.all ) { theDiv.style.left = theDiv.offsetLeft - 20 + 'px'; } } var helpMsg = document.createElement( 'div' ); helpMsg.id = 'customerOrderNumPopup'; helpMsg.className = 'helpMessageJs'; var helpP = document.createElement( 'p' ); helpP.className = 'helpMsgHeader'; var helpTxt = document.createTextNode( "Average number of orders per year" ); helpP.appendChild( helpTxt ); helpMsg.appendChild( helpP ); var helpMsgBody = document.createElement( 'div' ); helpMsgBody.className = 'helpMsg'; helpMsgBody.innerHTML = ""; helpMsg.appendChild( helpMsgBody ); var top = yOffset( theDiv ); var left = xOffset( theDiv ); left = left - 4 + theDiv.offsetWidth; helpMsg.style.width = 'auto'; helpMsg.style.top = top + 'px'; if ( ! document.all && helpMsg.id == 'logoHelpPopup' ) { // left += 200; } helpMsg.style.left = left + 'px'; setAttribute_IE_HACK( theDiv, 'onmouseover', "document.getElementById( 'customerOrderNumPopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onmouseout', "document.getElementById( 'customerOrderNumPopup' ).style.display = 'none';" ); setAttribute_IE_HACK( helpMsg, 'onmouseover', "document.getElementById( 'customerOrderNumPopup' ).style.display = 'block';" ); setAttribute_IE_HACK( helpMsg, 'onmouseout', "document.getElementById( 'customerOrderNumPopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onfocus', "document.getElementById( 'customerOrderNumPopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onblur', "document.getElementById( 'customerOrderNumPopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onclick', "this.blur( ); return false;" ); document.body.appendChild( helpMsg ); theDiv = false; } var theDiv = document.getElementById( 'orderValueHelp' ); if ( theDiv ) { if ( theDiv.id == 'logoHelp' && ! document.all ) { theDiv.style.top = 2 + 'px'; if ( ! document.all ) { theDiv.style.left = theDiv.offsetLeft - 20 + 'px'; } } var helpMsg = document.createElement( 'div' ); helpMsg.id = 'orderValuePopup'; helpMsg.className = 'helpMessageJs'; var helpP = document.createElement( 'p' ); helpP.className = 'helpMsgHeader'; var helpTxt = document.createTextNode( "Average order value [£]" ); helpP.appendChild( helpTxt ); helpMsg.appendChild( helpP ); var helpMsgBody = document.createElement( 'div' ); helpMsgBody.className = 'helpMsg'; helpMsgBody.innerHTML = ""; helpMsg.appendChild( helpMsgBody ); var top = yOffset( theDiv ); var left = xOffset( theDiv ); left = left - 4 + theDiv.offsetWidth; helpMsg.style.width = 'auto'; helpMsg.style.top = top + 'px'; if ( ! document.all && helpMsg.id == 'logoHelpPopup' ) { // left += 200; } helpMsg.style.left = left + 'px'; setAttribute_IE_HACK( theDiv, 'onmouseover', "document.getElementById( 'orderValuePopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onmouseout', "document.getElementById( 'orderValuePopup' ).style.display = 'none';" ); setAttribute_IE_HACK( helpMsg, 'onmouseover', "document.getElementById( 'orderValuePopup' ).style.display = 'block';" ); setAttribute_IE_HACK( helpMsg, 'onmouseout', "document.getElementById( 'orderValuePopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onfocus', "document.getElementById( 'orderValuePopup' ).style.display = 'block';" ); setAttribute_IE_HACK( theDiv, 'onblur', "document.getElementById( 'orderValuePopup' ).style.display = 'none';" ); setAttribute_IE_HACK( theDiv, 'onclick', "this.blur( ); return false;" ); document.body.appendChild( helpMsg ); theDiv = false; } formElementsCheckLen = formElementsCheck.length; setAttribute_IE_HACK( theForm, 'onsubmit', 'return checkFormReturn( )' ); } } function checkFormReturn( ) { var errors = new Array( ); var i; var failed = false; var focused = false; for( i = 0; i < formElementsCheckLen; i++ ) { var toCheck = formElementsCheck[i]; if ( toCheck ) { var opts = false; try { opts = toCheck.split( ',' ); } catch ( e ) {} if ( opts ) { var ele = document.getElementById( opts[0] ); var checkType = opts[1].replace( ' ', '' ); var checkLen = false; if ( checkType.indexOf( '=' ) != -1 ) { var parts = checkType.split( '=' ); checkType = parts[0]; checkLen = parts[1]; } var passed = false; switch( checkType ) { case 'isEmail': passed = validEmail( ele.value ); break; case 'isEmailConf': passed = validEmailConf( ele.value ); break; case 'password': passed = validPassConf( ele ); break; case 'submit': submitInput = ele; passed = true; break; case 'minLength': passed = ele.value.length >= checkLen ? true : false; break; default: passed = ele.value.length; break; } // end switch checkType if ( ! passed ) { if ( ! focused ) { focused = true; var toFocus = ele; } if ( opts[3].length < 4 ) { opts[3] = 'Please provided the information required'; } failed = true; errors[errors.length] = 'Failed : ' + opts[2] + "\n - : " + opts[3]; var parentPs = ele.parentNode.childNodes var appendN = true; if ( parentPs ) { var parentPsLen = parentPs.length; var k; for( k = 0; k < parentPsLen; k++ ) { if ( parentPs[k] && parentPs[k].tagName && parentPs[k].tagName.toLowerCase( ) == 'p' && parentPs[k].className == 'formError' ) { appendN = false; } } } if ( appendN ) { var helpMsg = document.getElementById( opts[0] + 'Popup' ); var p = document.createElement( 'p' ); p.className = 'formError'; p.style.left = ele.offsetLeft + 'px'; /*p.style.width = ( parseFloat( ele.offsetWidth ) - ( 9 ) ) + 'px';*/ p.style.width = '400px'; var txt = document.createTextNode( opts[3].replace( /\'/m, "'" ) ); //, "'" ) ); p.appendChild( txt ); ele.parentNode.appendChild( p ); if ( helpMsg ) { helpMsg.style.top = yOffset( p ) + 'px'; //.offsetHeight + top + 'px'; } } } else { var parentPs = ele.parentNode.childNodes var appendN = true; if ( parentPs ) { var parentPsLen = parentPs.length; var k; for( k = 0; k < parentPsLen; k++ ) { if ( parentPs[k].tagName ) { if ( parentPs[k] && parentPs[k].tagName.toLowerCase( ) == 'p' && parentPs[k].className == 'formError' ) { ele.parentNode.removeChild( parentPs[k] ); } } } } } } } } if ( failed ) { if ( toFocus ) { toFocus.focus( ); } var errorsLen = errors.length; var errorString = ''; for( i = 0; i < errorsLen; i++ ) { errorString += errors[i]; if ( ( i + 1 ) <= errorsLen ) { errorString += "\n"; } } alert( errorString ); return false; } else { if ( submitInput ) { submitInput.disabled = 'disabled'; } return true; } return false; }