function showAnswers() {
	
	$('#next').css('display', 'none');
	$('.wiztext_next').css('display', 'none');
	$("#pccontainer").css("display", "none");
	$("#buttons").css('background-color', '#FFFFFF');
	
	$('#recommendations').css('display','block');
		
	// either r(equired), m(aybe) or n(o)
	chat_choice  = $('#chatform input[@name=chat]:checked').val();
	click_choice = $('#click input[@name=click]:checked').val();
	email_choice = $('#email input[@name=email]:checked').val();
	
	// Note: this code could be cleaned up by propegating the b_ options throughout...
	
	var b_chat =new Boolean(false);
	var b_click =new Boolean(false);
	var b_email =new Boolean(false);
	if (p_chat == 'r') 
		b_chat = true;
	if (p_click == 'r') 
		b_click = true;
	if (p_email == 'r') 
		b_email = true;

		
	// either y or n
	chat_simple = $('#chat_radio input[@name=choice]:checked').val();			
	chat_proactive = $('#radio_proactive input[@name=choice]:checked').val();
	chat_secured = $('#radio_chat_secured input[@name=choice]:checked').val();
	chat_operators = $('#radio_chat_operators input[@name=choice]:checked').val();
	click_multiple = $('#radio_click_multiple input[@name=choice]:checked').val();
	//ccm_browse = $('#radio_co_browse input[@name=choice]:checked').val();
	ccm_control = $('#radio_complete_control input[@name=choice]:checked').val();
	
	
	reportConversion();
	//
	// CCM Options First
	//
	
	if (ccm_control == 'y') {
		// remote control  BoldCCM Enterprise
		$("#answer_enterprise_suite").css("display", "block");
		return;
		
	} 
	
	//
	// CHAT ONLY options
	//
	
	if ( b_chat == true && b_click == false && b_email == false) {
		if ( chat_operators == 'y' ) { 
			// If Operators > 10, show BoldChat Premier  
			$('#answer_premier').css('display', 'block');    		
    	} 
    	// If No to all, show Basic,Pro and Premier
    	else if (chat_operators == 'n' && chat_secured == 'n' && chat_proactive == 'n' ) {
			$('#answer_basic').css('display', 'block');
			$('#answer_pro').css('display', 'block');
			$('#answer_premier').css('display', 'block');
		}
		// If anything but simple option checked, show Pro and Premier
    	else if (chat_operators == 'y' || chat_secured == 'y' || chat_proactive == 'y') {
    		// Show Pro & Premier
			$('#answer_pro').css('display', 'block');
			$('#answer_premier').css('display', 'block');
    	} else if (chat_simple == 'y') {
			$('#answer_basic').css('display', 'block');
		} else {
			$("#answer_smb_suite").css("display", "block");
			$("#answer_enterprise_suite").css("display", "block");
		}
    	return;
		    	
	} else if ( b_click == true && b_chat == false  && b_email == false ) {
		// click-to-call only
		if (click_multiple == 'y') {
			$("#answer_smb_suite").css("display", "block");
			$("#answer_enterprise_suite").css("display", "block");
		} else {
			$('#answer_express').css('display', 'block');
		}
		
		return;
	} else if ( b_click == true && b_chat == true & b_email == false) {
		if (chat_simple == 'y') {
			$('#answer_basic').css('display', 'block');
		} else {
			$("#answer_smb_suite").css("display", "block");
			$("#answer_enterprise_suite").css("display", "block");
		}	
	} else if ( b_email == true ) {
		$("#answer_smb_suite").css("display", "block");
		$("#answer_enterprise_suite").css("display", "block");
		return;
	}
		  			
}

function init_chooser() {

	$('#backtostart').click( function() {
		hide_everything();	
		$("#pccontainer").css("display", "block");
    	$('#thequestions').css('display', 'block');
		$('#next').attr('hint', 'next');
		$('#next').css('display', 'block');
		$('.wiztext_next').css('display', 'block');
	});

	$('#next').click( function() {
	
		var b_chat =new Boolean(false);
		var b_click =new Boolean(false);
		var b_email =new Boolean(false);
	
		hint = $('#next').attr('hint');
		if (hint == "next") {
    		// r n
    		p_chat  = $('#chatform input[@name=chat]:checked').val();
    		p_click = $('#click input[@name=click]:checked').val();
    		p_email = $('#email input[@name=email]:checked').val();
			
    		if (p_chat == 'r') 
    			b_chat = true;
    		if (p_click == 'r') 
    			b_click = true;
    		if (p_email == 'r') 
    			b_email = true;
        				
        	if (p_chat == null || p_click == null || p_email == null) {
                
        		alert('Please select all options.');	
        		return;
        	}
        	if (p_chat == 'n' && p_click == 'n' && p_email == 'n') {
                
        		alert('Please select at least one affirmative option.');	
        		return;
        	}
        				
    		if ((p_chat == 'r') &&  (p_click == 'n' && p_email == 'n')) {
    			// least expensive option 
    			$('#chat_pt1').css('display', 'block');
    			$('#pc_chat').css('display', 'block');
				$('#ccm').css('display', 'none');
    			$('#chat_pt2').css('display', 'none');
    			$('#chat_next').css('display', 'none');
				$('#next').attr('hint', 'least_expensive_next');
			
    		} else if ((p_email == 'r') && (p_chat == 'n')){
				$('#clicktocall').css('display', 'none');        		
    			showAnswers();
    		} else if (p_chat == 'r' || p_chat == 'm') {
				$('#features').css('display', 'block');
				$('#chat_pt1').css('display', 'none');
    			$('#chat_pt2').css('display', 'none');
				$('#ccm').css('display', 'block');
				$('#next').attr('hint', 'chat_plus_option_next');
    			
    		} else if (p_click == 'r' || p_click == 'm') {
    			$('#clicktocall').css('display', 'block');
				$('#ccm').css('display', 'block');
				$('#next').attr('hint', 'clicktocall_next');

    		} 		
        				
    		$('#thequestions').css('display', 'none');
			$('#facebox').css({
				top:	(getPageHeight() / 10)
			});
    		
		} else if (hint == "least_expensive_next") {
    		option  = $('#chat_pt1 input[@name=chat]:checked').val();
    		if (option == 'y'){
    			$('#pc_chat').css('display', 'none');
    			showAnswers();
    		} else {
				$('#chat_pt1').css('display', 'none');
    			$('#least_expensive_next').css('display', 'none');
    			$('#chat_pt2').css('display', 'block');
				$('#ccm').css('display', 'block');
    			$('#chat_next').css('display', 'inline');
    		}
			$('#next').attr('hint', 'chat_next');
		} else if (hint == "chat_next") {
		
		
			chat_proactive = $('#radio_proactive input[@name=choice]:checked').val();
			chat_secured = $('#radio_chat_secured input[@name=choice]:checked').val();
			chat_operators = $('#radio_chat_operators input[@name=choice]:checked').val();
			//ccm_browse = $('#radio_co_browse input[@name=choice]:checked').val();
			ccm_control = $('#radio_complete_control input[@name=choice]:checked').val();
			
			
			if (chat_proactive == null || chat_secured == null ||
				chat_operators == null || ccm_control == null) {
				alert('Please select at least one choice for each question.');
				return;
			}
			
			$('#pc_chat').css('display', 'none');
			$('#ccm').css('display', 'none');
			if (p_click == 'r' || p_click == 'm') {
				$('#clicktocall').css('display', 'block');
			}
			else {
				showAnswers();
			}
			$('#next').attr('hint', 'clicktocall_next');
		} else if (hint == "chat_plus_option_next") {
			
				ccm_control = $('#radio_complete_control input[@name=choice]:checked').val();
				
				if (ccm_control == null) {
					alert('Please select at least one choice for each question.');
					return;
				} else {
					$('#features').css('display', 'none');
					$('#ccm').css('display', 'none');
					showAnswers();
				}
				
		} else if (hint == "clicktocall_next") {
				
					click_multiple = $('#radio_click_multiple input[@name=choice]:checked').val();
					//ccm_browse = $('#radio_co_browse input[@name=choice]:checked').val();
					ccm_control = $('#radio_complete_control input[@name=choice]:checked').val();
					
					if (click_multiple == null || ccm_control == null) {
						alert('Please select at least one choice for each question.');
						return;
					}
					
					$('#clicktocall').css('display', 'none');
					$('#ccm').css('display', 'none');
					
					showAnswers();
				}
    });

	
	hide_everything();
}

function hide_everything() {
    $("#recommendations").css("display", "none");    
    $("#answer_basic").css('display','none')    
    $("#answer_pro").css("display", "none");
	$("#answer_premier").css("display", "none"); 
    $("#answer_express").css("display", "none"); 
    $("#answer_smb_suite").css("display", "none");   
    $("#answer_enterprise_suite").css("display", "none");    
    $("#pc_chat").css("display", "none");
    $("#clicktocall").css("display", "none");
	$("#ccm").css("display", "none");
	$("#features").css("display", "none");
	$("#buttons").css('background-color',"#C6DDEE");

    
    $('#rs1')[0].checked = false;			
	$('#rs2')[0].checked = false;	
	$('#rp1')[0].checked = false;			
	$('#rp2')[0].checked = false;	
	$('#rsc1')[0].checked = false;			
	$('#rsc2')[0].checked = false;			
	$('#rten1')[0].checked = false;			
	$('#rten2')[0].checked = false;			
	$('#rm1')[0].checked = false;			
	$('#rm2')[0].checked = false;			
	$('#rcc1')[0].checked = false;
	$('#rcc2')[0].checked = false;
					
    
}

function getPageHeight() {
    var windowHeight
    if (self.innerHeight) {	// all except Explorer
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowHeight = document.body.clientHeight;
    }	
    return windowHeight
  }
  
    
function reportConversion() {
	var  convImage = new Image(1, 1);
	convImage.src = "http://vms.boldchat.com/aid/2307475884/bc.vci?ccid=1105273021892128900&amp;ca=&amp;cr=&amp;ci=";
}
