﻿/**
 * stream aptitude singleton - minified - used for deployment/production
 * used to manage form submission of stream aptitude test
 * http://streamrealty.com/aptitude
 *
 * @author Jeremy Burton - SohoPros Inc.
 *
 * Date: 2009-06-19 (Fri, 19 June 2009)
 * Revision: 1.2
 */
 

var stream=window.stream||{};stream.aptitude=(function(){var good;var bad;var allRight;var numRight;function validate(){if($F(tbName)==''){if($F(tbEmail)=='')updateStatus('Your name and email are both required.',bad);else updateStatus('Your name is required.',bad);tbName.focus();return false;}else if($F(tbEmail)==''){updateStatus('Your email is required.',bad);tbEmail.focus();return false;}else{if(!validateEmail()){updateStatus('A valid email address is required.',bad);tbEmail.focus();return false;}}
updateStatus('',good);return true;}
function validateEmail(){var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;return filter.test($F(tbEmail));}
function checkAnswers(){var isOneChecked=false;var isTwoChecked=false;var isThreeChecked=false;var isFourChecked=false;var isFiveChecked=false;var isSixChecked=false;$('apt-complete-wrong').insert(new Element('div',{'class':'apt-q-spacer'})).insert('How many regional offices does Stream Realty have nationwide?');rbQ1.getElementsBySelector('input').each(function(item){if(item.checked){isOneChecked=true;checkAnswer(item,'c. 6');}else{wrongAnswer(item,'c. 6');}});$('apt-complete-wrong').insert(new Element('div',{'class':'apt-q-spacer'})).insert('Stream Realty has earned which of the following awards in 2009?');rbQ2.getElementsBySelector('input').each(function(item){if(item.checked){isTwoChecked=true;checkAnswer(item,'d. All of the above');}else{wrongAnswer(item,'d. All of the above');}});$('apt-complete-wrong').insert(new Element('div',{'class':'apt-q-spacer'})).insert('Chad Hennings, writer of <u>It Takes Commitment</u> former U.S. Air Force pilot and newest member of the Dallas tenant rep team, has won ______ Super Bowl rings with the Dallas Cowboys?');rbQ3.getElementsBySelector('input').each(function(item){if(item.checked){isThreeChecked=true;checkAnswer(item,'b. 3');}else{wrongAnswer(item,'b. 3');}});$('apt-complete-wrong').insert(new Element('div',{'class':'apt-q-spacer'})).insert('Which of the following Stream team members produced a Property Management manual which won first place in the Institute of Real Estate Management\'s (IREM) national competition?');rbQ4.getElementsBySelector('input').each(function(item){if(item.checked){isFourChecked=true;checkAnswer(item,'d. Deborah Lister');}else{wrongAnswer(item,'d. Deborah Lister');}});$('apt-complete-wrong').insert(new Element('div',{'class':'apt-q-spacer'})).insert('When Stream volunteers welcome home arriving soliders at their local airport, what color are their \"Meet the Troops\" t-shirts?');rbQ5.getElementsBySelector('input').each(function(item){if(item.checked){isFiveChecked=true;checkAnswer(item,'c. Red');}else{wrongAnswer(item,'c. Red');}});$('apt-complete-wrong').insert(new Element('div',{'class':'apt-q-spacer'})).insert('The recently completed Stream Ready-to-Fit data center in Westover Hills (San Antonio, TX) can withstand up to how many mile-per-hour winds?');rbQ6.getElementsBySelector('input').each(function(item){if(item.checked){isSixChecked=true;checkAnswer(item,'a. 175');}else{wrongAnswer(item,'a. 175');}});if((!isOneChecked)||(!isTwoChecked)||(!isThreeChecked)||(!isFourChecked)||(!isFiveChecked)||(!isSixChecked)){updateStatus('You must answer all questions.',bad);}else{updateStatus('Submitting answers...',good);wsAptTest.submitAnswers($F(tbName),$F(tbEmail),allRight,submitSuccess,submitFailure);}}
function checkAnswer(item,answer){if(item.value!=answer){allRight=false;$('apt-complete-wrong').insert(new Element('div',{'class':'apt-ans-wrong'}).update(item.value));}
else{numRight++;$('apt-complete-wrong').insert(new Element('div',{'class':'apt-right-answer'}).update(item.value));}}
function wrongAnswer(item,answer){if(item.value==answer){$('apt-complete-wrong').insert(new Element('div',{'class':'apt-right-answer'}).update(item.value));}else{$('apt-complete-wrong').insert(new Element('div').update(item.value));}}
function submitSuccess(result){$('apt-form').hide();if(allRight){$('hdr').update('STREAM APTITUDE TEST');tbNamePass.value=$F(tbName);tbEmailPass.value=$F(tbEmail);$('text-right').hide();$('all-right-form').show();$('apt-complete').setStyle({marginTop:'15px'}).show();}else{$('apt-complete-wrong').insert({'top':new Element('div').update('You answered '+numRight+' out of 6 correctly.')}).setStyle({marginTop:'15px'}).show();$('apt-complete-wrong').insert(new Element('div').update('Thank you for taking the Stream Aptitude Test.').setStyle({color:'green',marginTop:'15px'}));$('apt-complete').show();}}
function submitFailure(error){}
function sendInfoSuccess(result){$('pass-status').update('We have received your information.  You will be contacted by a Stream Realty representative shortly.').setStyle({color:'green'});}
function sendInfoFailure(error){}
function updateStatus(text,fColor){$('apt-status').update(text).setStyle({color:fColor});}
return{init:function(){good='green';bad='red';allRight=true;numRight=0;btnSubmit.setOpacity(0.7);btnSubmitPass.setOpacity(0.7);$j(btnSubmit).hover(function(){btnSubmit.setOpacity(1.0)},function(){btnSubmit.setOpacity(0.7)});$j(btnSubmitPass).hover(function(){btnSubmitPass.setOpacity(1.0)},function(){btnSubmitPass.setOpacity(0.7)});},submitAnswers:function(){btnSubmit.disabled=true;if(validate()){checkAnswers();}
btnSubmit.disabled=false;return false;},submitInfo:function(){btnSubmitPass.disabled=true;var s='';if($F(tbAddress)=='')s+='Your address is required. ';if($F(tbCity)=='')s+='Your city is required. ';if($F(tbState)=='')s+='Your state is required. ';if($F(tbZip)=='')s+='Your zip code is required. ';if(s.length>0){$('pass-status').update(s).setStyle({color:'red'});btnSubmitPass.disabled=false;}else{$('pass-status').update('Sending...').setStyle({color:'green'});wsAptTest.sendEmail($F(tbName),$F(tbEmail),$F(tbAddress),$F(tbCity),$F(tbState),$F(tbZip),$F(ddlSize),sendInfoSuccess,sendInfoFailure);}
return false;}};})();var sa=stream.aptitude;