// JavaScript Document	

_WIZ_STEP		= 1;

_WIZ_ENTRANCE	= '/FSBOHelpDesk/';
_WIZ_STEP1		= '/FSBOHelpDesk/Wizard/';
_WIZ_STEP2		= '/FSBOHelpDesk/Wizard/Step2.php';
_WIZ_STEP3		= '/FSBOHelpDesk/Wizard/Step3.php';
_WIZ_STEP4		= '/FSBOHelpDesk/Wizard/Step4.php';
_WIZ_STEP5		= '/FSBOHelpDesk/Wizard/Step5.php';

function exitWizard() {
	window.location.href=_WIZ_ENTRANCE;
}

function gotoStep1() {
	window.location.href=_WIZ_STEP1;
}

function disableGroup() {
	$('WizOpt1').disable();
	$('WizOpt2').disable();
	$('WizOpt3').disable();
	$('WizOpt4').disable();
}

function enableGroup() {
	$('WizOpt1').enable();
	$('WizOpt2').enable();
	$('WizOpt3').enable();
	$('WizOpt4').enable();
}

function whichWizOpt() {

	tmp = '';
	
	if ( $('WizOpt1').checked == true ) { tmp = $('WizOpt1'); }
	if ( $('WizOpt2').checked == true ) { tmp = $('WizOpt2'); }
	if ( $('WizOpt3').checked == true ) { tmp = $('WizOpt3'); }
	if ( $('WizOpt4').checked == true ) { tmp = $('WizOpt4'); }

	return tmp;
}

function changeAction( form_name, action_name ) {
	$(form_name).action = action_name;
}

function fieldError ( field_name ) {
	// set the field outlines to red so we know what's wrong
	field_name.style.border = '2px solid red';
}


function validateForm ( ) {

	errors = 0;
	
	if ( $('FirstName').value == null || $('FirstName').value == "" ) { fieldError($('FirstName')); errors++;}
	if ( $('LastName').value == null || $('LastName').value == "" ) { fieldError($('LastName')); errors++;}
	if ( $('PrimaryPhone').value == null || $('PrimaryPhone').value == "" ) { fieldError($('PrimaryPhone')); errors++;}
	if ( $('Address').value == null || $('Address').value == "" ) { fieldError($('Address')); errors++;}
	if ( $('City').value == null || $('City').value == "" ) { fieldError($('City')); errors++;}
	if ( $('State').value == null || $('State').value == "" ) { fieldError($('State')); errors++;}
	if ( $('PostCode').value == null || $('PostCode').value == "" ) { fieldError($('PostCode')); errors++;}
	if ( $('ShippingAddress').value == null || $('ShippingAddress').value == "" ) { fieldError($('ShippingAddress')); errors++;}
	if ( $('ShippingCity').value == null || $('ShippingCity').value == "" ) { fieldError($('ShippingCity')); errors++;}
	if ( $('ShippingState').value == null || $('ShippingState').value == "" ) { fieldError($('ShippingState')); errors++;}
	if ( $('ShippingPostCode').value == null || $('ShippingPostCode').value == "" ) { fieldError($('ShippingPostCode')); errors++;}
	
	if ( $('WizOpt').value == "MLS Plus" || $('WizOpt').value == "MLS Standard" ) {
		if ( $('AskingPrice').value == null || $('AskingPrice').value == "" ) { fieldError($('AskingPrice')); errors++;}
	}
	
	if ( errors == 0 ) {
		return true;
	} else {
		alert("Your form has errors.  Please correct the highlighted fields and try clicking 'Next' again.");
		return false;
	}
	
}
	
function ChangeSelection(lmnt) {
	
	tmp = '';
	
	disableGroup();
	
	if ( $('MLS Plus').visible() == true ) { tmp = $('MLS Plus'); }
	if ( $('MLS Standard').visible() == true ) { tmp = $('MLS Standard'); }
	if ( $('Tools Only').visible() == true ) { tmp = $('Tools Only'); }
	if ( $('Forms Only').visible() == true ) { tmp = $('Forms Only'); }
	
	Effect.Fade(tmp, { duration: 0.5,
		afterFinish: function() {
		Effect.Appear( lmnt, { duration: 0.5,
			afterFinish: function() {
				enableGroup();
			}} );
		}
	})
}
