
function qualify(f) {

posBlackBox();
writeQualContainer();

$('qualSubmit').style.display = 'none';
$('fields').style.display = 'none';
$('selectSpinner').style.display = 'block';
var d = new Date();
var m = 'm=' + d.getTime();	
var bodyUrl = '/sharedApps/ztQualify/default.asp?tn=' + f.areacode[f.areacode.selectedIndex].value + f.npa.value + f.nxx.value;
var ajax = new Ajax.Updater(
					{},
					bodyUrl,
					{method: 'get',
					parameters: m,
					onSuccess:  function(t) { updateQualifier(t.responseText.toLowerCase()); }, // gotta response back, so do something with it
					onFailure: reportError,
					evalScripts: true});			
}





// new stuff

// response text
var QualResponses = {"qualified":{"heading":"Congratulations!","body":"<img src=\"/images/elements/laptopzt.png\" style=\"width: 146px; height: 94px; float: left; margin: 20px 10px 10px 10px;\"><div style=\"float: left; width: 250px;\"><p>ZoomTown is available in your area for as low as $25/mo when you bundle.</p><a href=\"#\" onclick=\"order.i('2'); return false;\"><img src=\"/images/buttons/ordernow_bigwhite.png\" style=\"margin-left: 65px; margin-top: 10px; border: 0; width: 131px; height: 33px;\"></a></div>","color":"green"},"qualified_dayton":{"heading":"Congratulations!","body":"<p>ZoomTown is available in your area.</p>\n<a href=\"/consumer/bundles/dayton/bundle.asp\"><img src=\"/images/buttons/ordernow_bigwhite.png\" style=\"margin-left: 80px; margin-top: 20px; border: 0; width: 131px; height: 33px;\"></a>","color":"green"},"qualified_dayton_business":{"heading":"Congratulations!","body":"<p>ZoomTown may be available in your area. Please call 1-888-CIN-BELL and a customer support representative will assist you.</p>","color":"green"},"qualified_dayton_soho":{"heading":"Congratulations!","body":"<p>ZoomTown may be available in your area. Please call 1-888-CIN-BELL and a customer support representative will assist you.</p>","color":"green"},"qualified_business":{"heading":"Congratulations!","body":"<p>Congratulations! ZoomTown is available in your area.  To begin ordering ZoomTown service, click <a href=\"/business/ordering/?businesssector=smb&bundle=good\"  style=\"color: #FFF;\">here</a>.</p>","color":"green"},"qualified_soho":{"heading":"Congratulations!","body":"<p>Congratulations!  ZoomTown is available in your area.  As low as $49.95/month for 36 months* when you bundle. <a href=\"/business/ordering/?bundle=good\"><img src=\"/images/buttons/ordernow_bigwhite.png\" style=\"margin-left: 80px; margin-top: 10px; border: 0; width: 131px; height: 33px;\"></a><br> * With 36 month service agreement and Business Connections bundle.</p>","color":"green"},"not_qualified":{"heading":"We're Sorry.","body":"<p>ZoomTown is not available in your area.<br>\nWould you like <a href=\"/consumer/internet/fuse_dial_up/\" style=\"color: #ffffff;\">Fuse dial-up with Accelerator</a>?</p>","color":"orange"},"not_qualified_business":{"heading":"We're Sorry.","body":"<p>ZoomTown is not currently available in your area.  However, we have a number of other high-speed Internet options that may be available for your \nbusiness, including dial-up, dedicated T1, IP Trunking and more.  We recommend a free consultation with a local Business Account Manager.<br>\nFind your account manager <a href=\"https://my.cincinnatibell.com/SelfCare/UI/Root/Unauthenticated/www/LocateAccountManager.aspx\"  style=\"color: #FFF;\">here</a>.</p>","color":"orange"},"not_qualified_soho":{"heading":"We're Sorry.","body":"<p>ZoomTown is not currently available in your area.  However, we have a number of other high-speed Internet options that may be available for your business, including dial-up, dedicated T1, IP Trunking and more.  We recommend a free consultation with a local Business Account Manager.<br>\nFind your account manager <a href=\"https://my.cincinnatibell.com/SelfCare/UI/Root/Unauthenticated/www/LocateAccountManager.aspx\"  style=\"color: #FFF;\">here</a>.</p>","color":"orange"},"not_qualified_dayton_soho":{"heading":"We're Sorry.","body":"<p>ZoomTown is not currently available in your area.  However, we have a number of other high-speed Internet options that may be available for your business, including dial-up, dedicated T1, IP Trunking and more.  We recommend a free consultation with a local Business Account Manager.<br>\nFind your account manager <a href=\"https://www.cincinnatibell.com/customer_support/business/locate_account_manager/dayton.asp\"  style=\"color: #FFF;\">here</a>.</p>","color":"orange"},"not_qualified_dayton_business":{"heading":"We're Sorry.","body":"<p>ZoomTown is not currently available in your area.  However, we have a number of other high-speed Internet options that may be available for your business, including dial-up, dedicated T1, IP Trunking and more.  We recommend a free consultation with a local Business Account Manager.<br>\nFind your account manager <a href=\"https://www.cincinnatibell.com/customer_support/business/locate_account_manager/dayton.asp\"  style=\"color: #FFF;\">here</a>.</p>","color":"orange"},"not_a_cbt_number":{"heading":"Invalid Phone Number.","body":"<p>Please enter a valid Cincinnati Bell phone number.</p>","color":"red"},"not_a_cbt_number_business":{"heading":"Invalid Phone Number.","body":"<p>We did not recognize your entry as an existing Cincinnati Bell account, however, we look forward to assisting you!\n\nPlease click <a href=\"/customer_support/contact_us/contact_center/contact_center.asp?action=populate&acc=bus\" style=\"color: #FFF;\">here</a> to contact a Business Specialist online for a response within 24 hours.\nOr give us a <a href=\"/customer_support/contact_us/by_phone/\" style=\"color: #FFF;\">call now </a>.  </p>","color":"red"},"not_a_cbt_number_soho":{"heading":"Invalid Phone Number.","body":"<p>We did not recognize your entry as an existing Cincinnati Bell account, however, we look forward to assisting you!\n\nPlease click <a href=\"http://www.cincinnatibell.com/customer_support/contact_us/contact_center/contact_center.asp?action=populate&acc=bus\" style=\"color: #FFF;\">here</a> to contact a Business Specialist online for a response \nwithin 24 hours. Or give us a <a href=\"http://www.cincinnatibell.com/customer_support/contact_us/by_phone/\" style=\"color: #FFF;\">call now </a>.</p>","color":"red"},"maybe":{"heading":"ZoomTown May Be Available.","body":"<p>You may be able to get ZoomTown. Please call 513-565-2210 and a customer support representative will assist you.</p>","color":"orange"},"maybe_business":{"heading":"ZoomTown May Be Available.","body":"<p>You may be able to get ZoomTown. Please call 513-566-5050 and a customer support representative will assist you.</p>","color":"orange"},"maybe_soho":{"heading":"ZoomTown May Be Available.","body":"<p>You may be able to get ZoomTown. Please call 513-566-5050 and a customer support representative will assist you.</p>","color":"orange"},"generic":{"heading":"We're Sorry.","body":"<p>We are unable to determine a status for that number, please call 513-565-2210</p>","color":"orange"},"generic_business":{"heading":"We're Sorry.","body":"<p>We are unable to determine a status for that number, please call 513-566-5050.</p>","color":"orange"},"generic_soho":{"heading":"We're Sorry.","body":"<p>We are unable to determine a status for that number, please call 513-566-5050.</p>","color":"orange"}};

function posBlackBox() {

if ($('BlackBox') == null) {
	var BlackBox = document.createElement("div");
	BlackBox.setAttribute('id', 'BlackBox');
	BlackBox.style.display = 'none';
	BlackBox.style.width = '100%';
	BlackBox.style.height = '100%';
	BlackBox.style.position = 'fixed';
	BlackBox.style.top = '0';
	BlackBox.style.left = '0';
	BlackBox.style.background = 'black';
	BlackBox.style.zIndex = '100';
	BlackBox.style.opacity = '.6';
	
	if (isIE6) {
	BlackBox.style.position = 'absolute';
	BlackBox.style.filter = ' alpha(opacity=60)';
	}
	
	var inBody = document.getElementsByTagName("body").item(0);
	inBody.insertBefore(BlackBox, inBody.firstChild);
}

$('BlackBox').style.width = document.body.scrollWidth > document.body.offsetWidth ? document.body.scrollWidth : document.body.offsetWidth + 'px';	
$('BlackBox').style.height = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px';	
}
window.onresize = posBlackBox;




function writeQualContainer() {
if ($('QualContainer') == null) {
	var QualContainer = document.createElement("div");
	QualContainer.setAttribute('id', 'QualContainer');
	QualContainer.style.position = 'relative';	
	QualContainer.style.margin = "0 auto 0 auto";
	QualContainer.style.width = '770px';
	QualContainer.style.height = '0';
	QualContainer.style.border = '0';
	QualContainer.style.padding = '0';
	QualContainer.style.lineHeight = '0';
	QualContainer.style.fontSize = '1px';
	QualContainer.style.zIndex = "1001";
	var inBody = document.getElementsByTagName("body").item(0);
	inBody.insertBefore(QualContainer, inBody.firstChild);
}

}


function reportError() {
	//document.getElementById(target).innerHTML = "Error";
	// display error message somehow
}


function showBlackBox() {
new Effect.BlindDown('BlackBox');
//$('BlackBox').style.display = "block";	
if ($('ztMainFlash')) { $('ztMainFlash').style.visibility = "hidden"; }	
}

function hideBlackBox() {
new Effect.BlindUp('BlackBox');
if ($('ztMainFlash')) { $('ztMainFlash').style.visibility = "visible"; }	
}


function showMessage(h,b,c) {
var wHeight = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
var scrollTop = document.body.scrollTop;
if (scrollTop == 0)
{
    if (window.pageYOffset)
        scrollTop = window.pageYOffset;
    else
        scrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
}

if (c == 'green') { c = '008600'; }
else if (c == 'orange') { c = 'ff7800'; }
else { c = 'd40500'; }

	$('QualContainer').innerHTML = '<div id="qualMessage" style="width: 500px; font-size: 9pt; line-height: normal; position: absolute; left: 120px; border: 15px solid white; border-bottom: 22px solid white; background: #'+c+'; top: 100px; padding: 15px; text-align:\
	 left; color: #FFF;"><h2 style="color: #FFF;">' + h + '</h2>' + b + '<a href="#" onclick="hideMessage(); return false;"><img src="/images/buttons/close.gif" class="close" style="bottom: -14px; right: 10px; position: absolute;"></a></div>';
	$('qualMessage').style.top = (parseInt(wHeight) / 2) - parseInt($('qualMessage').offsetHeight) + scrollTop;
}


function hideMessage() {
	hideBlackBox();
	$('QualContainer').innerHTML = '';
	$('qualSubmit').style.display = 'block';
	$('fields').style.display = '';
}


function updateQualifier(r) {
showBlackBox();
var l;
if (locale == 'soho') { l = '_soho'; }
else if (locale == 'business') { l = '_business'; }
else { l = ''; }

switch (r) {
case "not qualified":
	showMessage(QualResponses['not_qualified' + l].heading,QualResponses['not_qualified' + l].body,'red');
	break
case "not a cbt number":
	showMessage(QualResponses['not_a_cbt_number' + l].heading,QualResponses['not_a_cbt_number' + l].body,'red');
	break

case "maybe qualified":
	showMessage(QualResponses['maybe' + l].heading,QualResponses['maybe' + l].body,'orange');
	break
case "qualified":
	showMessage(QualResponses['qualified' + l].heading,QualResponses['qualified' + l].body,'green');
								// added for ROI tracking for successful qualification
									if ($('mediaplexDiv')) { 
										mpt = new Date();
										$('mediaplexDiv').innerHTML = '<img src="http://altfarm.mediaplex.com/ad/bk/4066-41244-2054-4?ZoomTown_Successful_Qual=1&mpuid=' + mpt.getTime() + '-' + mpt.getTimezoneOffset() + '" border="0">';
									}
	break
case "true":
	showMessage(QualResponses['qualified_dayton' + l].heading,QualResponses['qualified_dayton' + l].body,'green');       
	break
case "false":
	showMessage(QualResponses['not_qualified_dayton' + l].heading,QualResponses['not_qualified_dayton' + l].body,'orange');    	
	break	
default:
	showMessage(QualResponses['generic' + l].heading,QualResponses['generic' + l].body,'orange');
	break	
	}

$('selectSpinner').style.display = 'none';
}









// end new stuff






// dave's fine code for the dayton qual

        //function showQualifier()
        //{
        //    $('ResultsDiv').style.display = 'none';                                
        //    $('ztqualifier').style.display = 'block';
        //}
        
        function getStreets()
        {
           //alert($F('city'));           
           
           $('selectSpinner').style.display = 'block';
           
           var city = $F('city')
           
           
           //get all of the streets and populate the select object
           if (city != '')
           {
            var bodyUrl = '/consumer/internet/zoomtown_high_speed/dayton_qualifier/ztq_getstreets.asp';            
            var d = new Date();
            var m = 'city=' + city + '&m=' + d.getTime();
            var ajax = new Ajax.Updater(
			// this page wasn't working... 6/22 -- I added a space between quotes below (after success) and in another place below and then it worked -- YO
                        {success: ' '},
                         bodyUrl,
                        {method: 'get',
                         onComplete: function(request) { populateStreets(request.responseText); },
                         parameters: m,                  
								 onFailure: reportError});
            $('selectSpinner').style.display = 'none';      
            return false;
           }
           
           
                      
        }
        
        
        function populateStreets(r)
        {
            //alert(r);
            //$F('street').innerHTML = r;
            var select = document.getElementById("street");                       
            var options = select.getElementsByTagName('option'), option; 
            var vals = r.split(','), val;
            var k, D = document;
            
            // remove all of the options form the list
            while(select.options.length != 0)
            {
                select.options[0] = null;
            }   
            
            for(k=-1;val=vals[++k];)
            {
                option = D.createElement('option'); 
                option.setAttribute('value',val); 
                option.appendChild(D.createTextNode(val)); 
                select.appendChild(option);             
                //alert(val);
                //document.form.street.options[k] = new Option(val,val);
            }
            

            
        }        
        

        function checkQualifier()
        {


posBlackBox();
writeQualContainer();

		  
            var street = document.qualform.street[document.qualform.street.selectedIndex].value;
            //alert(street);            
            //street =  Form.serialize( street );
            //alert(Form.serialize( street ));
				$('fields').style.display = 'none';
            $('qualSubmit').style.display = 'none';
			$('selectSpinner').style.display = 'block';

            var num = document.qualform.num.value;                     
            var bodyUrl = '/consumer/internet/zoomtown_high_speed/dayton_qualifier/ztq_ajax.asp'; //http://161.155.243.13/consumer/internet/zoomtown_high_speed/dayton_qualifier/
            
            //var beech = Form.serialize(qualform);
           // alert(beech);

                        
            var d = new Date();
            var m = 'num=' + num + '&street=' + street + '&m=' + d.getTime();
            //alert(m);
           //var m = beech + '&m=' + d.getTime();
           // alert(m);
            var ajax = new Ajax.Updater(
                  {success: ' '},
                  bodyUrl,
                  {method: 'get',
                  onComplete: function(request) { updateQualifier(request.responseText.toLowerCase()); },
                  parameters: m,                  
                  onFailure: reportError});                  
                  return false;
        }
    
    
  
		  
		  

// no clue what this does
function changeLife(l,obj) {
l = l + 'Life';
$$('ul.yourlife li').each(function(e) { e.className = ''; if(e.getAttribute('id') == obj) { e.className = 'active'; } });
$$('div.ylc').each(function(e) { e.style.display = 'none'; if (e.getAttribute('id') == l) { e.style.display = 'block'; } });

}
