/*
 * portal.js
 *
 * author: joel stevick
 * copyright (c) 2007, cordata, inc
 */

/*
 * Determine if a customer user account already exists
 */
function CustomerUser_Exists(email)
{
	return false;
	/*
	 * Do the work on the server
	 */
	var parameters = new Object;
	parameters['email'] = email;
	var customerUserId = Ajax_Call_Web_Method("CustomerUserExists", parameters);
	
	return customerUserId > 0;
}

/*
 * Send password
 */
function Send_Password(customerid, email)
{
	/*
	 * Validate email
	 */
	if (email == '') {
		alert('Please enter your email address above.');
		return;
	}
	if (email.indexOf('@') <= 0) {
		alert('Please enter a valid email address above.');
		return;
	}
	
	/*
	 * Send the password
	 */
	var parameters = new Object;
	parameters['customerid'] = customerid;
	parameters['email'] = email;
	var customerUserId = Ajax_Call_Web_Method("SendPassword", parameters);
	
	/*
	 * Notify the user
	 */
	if (customerUserId > 0) 	 
		alert('Your password has been sent to:\r\n' + email);
	else
		alert('No user account has been registered for:\r\n' + email);
	
}
/*
 * Display the next question in the list
 */
var NumberOfQuestions = 0;
var CurrentQuestion = 0;
var resetAnswersJS = new Object;
var QuestionID_By_Index = new Object;
var Disable_NextStep_Button_For_This_Question = new Object;

function Display_Next_Question(prevButton, nextButton, nextStepButton)
{
	/*
	 * Hide the current question
	 */
	document.getElementById('questiondiv'+CurrentQuestion).style.display='none';
	
	/*
	 * Reset answerid
	 */
	document.getElementById('answerid').value=0;

	/*
	 * Reset the current question's answers
	 */
	eval(resetAnswersJS[CurrentQuestion].replace(/###apos###/g,"\\'"));
	
	/*
	 * Next question
	 */
	CurrentQuestion++;
	document.getElementById('questiondiv'+CurrentQuestion).style.display='block';
	
	/*
	 * If no next question, then disable this button
	 */
	if (CurrentQuestion == NumberOfQuestions-1) {
		nextButton.disabled=true;
        document.getElementById('nextquestionimage').src='buttons/disabled/btn_3_dis.gif';
	}
	
	/*
	 * Enable the prev button
	 */
	prevButton.disabled=false;
    document.getElementById('prevquestionimage').src='buttons/up/btn_2_up.gif';
	
	/*
	 * Always disable the next step button when switching questions, unless the question to which
	 * we are switching has a preselected answer
	 */
	nextStepButton.disabled=Disable_NextStep_Button_For_This_Question[CurrentQuestion];
	if (nextStepButton.disabled) {
		document.getElementById('nextstepbutton').src='buttons/disabled/btn_4_dis.gif';
		document.getElementById('callout_next').style.display='none';
	} else {
		document.getElementById('nextstepbutton').src='buttons/up/btn_4_up.gif';
		document.getElementById('callout_next').style.display='block';
	}
	
	/*
	 * Remember the selected questionid
	 */
	document.getElementById('selected_questionid').value = QuestionID_By_Index[CurrentQuestion];
	
}

function Display_Prev_Question(prevButton, nextButton, nextStepButton)
{
	/*
	 * Hide the current question
	 */
	document.getElementById('questiondiv'+CurrentQuestion).style.display='none';
	
	/*
	 * Reset answerid
	 */
	document.getElementById('answerid').value=0;
	
	
	/*
	 * Prev question
	 */
	CurrentQuestion--;

	/*
	 * Reset the current question's answers
	 */
	eval(resetAnswersJS[CurrentQuestion].replace(/###apos###/g,"\\'"));

	/*
	 * Display the DIV for this question
	 */
	document.getElementById('questiondiv'+CurrentQuestion).style.display='block';

	/*
	 * If no next question, then disable this button
	 */
	if (CurrentQuestion == 0) {
		prevButton.disabled=true;
        document.getElementById('prevquestionimage').src='buttons/disabled/btn_2_dis.gif';
	}
	/*
	 * Enable the prev button
	 */
	nextButton.disabled=false;
    document.getElementById('nextquestionimage').src='buttons/up/btn_3_up.gif';

	/*
	 * Always disable the next step button when switching questions, unless the question to which
	 * we are switching has a preselected answer
	 */
	nextStepButton.disabled=Disable_NextStep_Button_For_This_Question[CurrentQuestion];
	
	/*
	 * Always disable the next step button when switching questions, unless the question to which
	 * we are switching has a preselected answer
	 */
	nextStepButton.disabled=Disable_NextStep_Button_For_This_Question[CurrentQuestion];
	if (nextStepButton.disabled){
		document.getElementById('nextstepbutton').src='buttons/disabled/btn_4_dis.gif';
		document.getElementById('callout_next').style.display='none';
	} else {
		document.getElementById('nextstepbutton').src='buttons/up/btn_4_up.gif';
		document.getElementById('callout_next').style.display='block';
	}
	/*
	 * Remember the selected questionid
	 */
	document.getElementById('selected_questionid').value = QuestionID_By_Index[CurrentQuestion];
}
