var locationPrices = new Array();
locationPrices['0'] = 0;
locationPrices['1'] = 0;
locationPrices['2'] = 15;
locationPrices['3'] = 10;
locationPrices['4'] = 10;
locationPrices['5'] = 5;

function emailQuoteValidate(){
	alert('emailQuoteValidate');
}

function eraseDefaultOnClick(IncomingElementID,defaultValue){
	if(document.getElementById(IncomingElementID+'').value==defaultValue){
		document.getElementById(IncomingElementID+'').value = '';	
	}
}

function clearQuoteResultAndEmail(){
	
	$("#_QuoteValue").text('');
	$("#_QuoteResult").addClass('hideClass');
	$("#_QuoteResult").removeClass('showClass');
//	$("#_EmailResult").addClass('hideClass');
//	$("#_EmailResult").removeClass('showClass');

}

function showQuoteResultAndEmail(quote_value){
	$("#_QuoteValue").text(quote_value.toFixed(2));
	$("#_QuoteResult").addClass('showClass');
	$("#_QuoteResult").removeClass('hideClass');
//	$("#_EmailResult").addClass('showClass');
//	$("#_EmailResult").removeClass('hideClass');
}

function clearMessage(){
	$("#_Message").text('No Message');
	$("#_Message").addClass('hideClass');
	$("#_Message").removeClass('showClass');
	$("#_Message").removeClass('error_class');
	$("#_Message").removeClass('message_class');	
}

function GenerateQuoteValidate(){
	clearMessage();
	var quote_type = $('#_QuoteType').val();
			
	if(quote_type=='e'){

		//check to make sure there is at least a positive value in linear foot length
		if($('#_LinearFootage').val()==''){
			$("#_Message").text('You must have a valid value in Linear Footage');
			$("#_Message").removeClass('hideClass');
			$("#_Message").addClass('showClass');
			$("#_Message").addClass('error_class');
			return;
		}


		var linear_footage = parseInt($('#_LinearFootage').val());

		if((linear_footage+0)<=0){
			$("#_Message").text('You must have a valid value in Linear Footage');
			$("#_Message").removeClass('hideClass');
			$("#_Message").addClass('showClass');
			$("#_Message").addClass('error_class');
			return;
		}

		//get the other variables
		var location = parseInt($('#_Location').val());
		var stories = parseInt($('#_Stories').val());
		
		var currentTotal = 0.0;
		
		//do the math
		if(stories==1){	currentTotal = linear_footage*0.30;	}

		if(stories==2){	currentTotal = linear_footage*0.5; }
		
		if(location>1){	currentTotal = currentTotal + parseFloat(locationPrices[location]);	}
		
		if(currentTotal<40){ currentTotal=40; }

		//show the results
		showQuoteResultAndEmail(currentTotal);	
	
	}
	
	if(quote_type=='w'){

		//check to make sure there is at least a positive value in linear foot length
		if(($('#_SmallWindows').val()=='')||($('#_MediumWindows').val()=='')||($('#_LargeWindows').val()=='')||($('#_ExtraLargeWindows').val()=='')){
			$("#_Message").text('All windows counters must contain a number');
			$("#_Message").removeClass('hideClass');
			$("#_Message").addClass('showClass');
			$("#_Message").addClass('error_class');
			return;			
		}
		
		var small_windows = parseInt($('#_SmallWindows').val());
		var medium_windows = parseInt($('#_MediumWindows').val());
		var large_windows = parseInt($('#_LargeWindows').val());
		var xlarge_windows = parseInt($('#_ExtraLargeWindows').val());	
		
		if((small_windows+medium_windows+large_windows+xlarge_windows)<=0){
			$("#_Message").text('Your house must have some windows!');
			$("#_Message").removeClass('hideClass');
			$("#_Message").addClass('showClass');
			$("#_Message").addClass('error_class');
			return;
		}
		if((small_windows<0)||(medium_windows<0)||(large_windows<0)||(xlarge_windows)<0){
			$("#_Message").text('No negative windows!');
			$("#_Message").removeClass('hideClass');
			$("#_Message").addClass('showClass');
			$("#_Message").addClass('error_class');
			return;
		}

		//get the other variables
		var location = parseInt($('#_Location').val());
		var stories = parseInt($('#_Stories').val());
		
		var currentTotal = 0.0;
		
		//do the math
		currentTotal = small_windows*1+medium_windows*2.50+large_windows*3.25+xlarge_windows*4;
		
		if(stories==2){	currentTotal = currentTotal*1.25;	}
		if(location>1){	currentTotal = currentTotal + parseFloat(locationPrices[location]);	}
		
		if(currentTotal<45){ currentTotal=45; }

		//show the results
		showQuoteResultAndEmail(currentTotal);
	}
	
}

function SelectQuoteType(quotetypevalue){
		document.getElementById("_QuoteType").value = quotetypevalue;
		clearQuoteResultAndEmail();
		
		if(quotetypevalue=='e'){
			$("#_EstimateDiv").removeClass("hideClass");
			$("#_EstimateDiv").addClass("showClass");
			$("#_EavestroughCleaningButton").removeClass('estimate_button_off');
			$("#_EavestroughCleaningButton").addClass('estimate_button_on');
			$("#_WindowCleaningButton").removeClass('estimate_button_on');
			$("#_WindowCleaningButton").addClass('estimate_button_off');			
			$("#_eavestroughEstimateHiddenDiv").removeClass("hideClass");
			$("#_eavestroughEstimateHiddenDiv").addClass("showClass");
			$("#_windowEstimateHiddenDiv").removeClass("showClass");
			$("#_windowEstimateHiddenDiv").addClass("hideClass");
		}
		
		if(quotetypevalue=='w'){
			$("#_EstimateDiv").removeClass("hideClass");
			$("#_EstimateDiv").addClass("showClass");
			$("#_EavestroughCleaningButton").addClass('estimate_button_off');
			$("#_EavestroughCleaningButton").removeClass('estimate_button_on');
			$("#_WindowCleaningButton").addClass('estimate_button_on');
			$("#_WindowCleaningButton").removeClass('estimate_button_off');	
			$("#_eavestroughEstimateHiddenDiv").removeClass("showClass");
			$("#_eavestroughEstimateHiddenDiv").addClass("hideClass");	
			$("#_windowEstimateHiddenDiv").removeClass("hideClass");
			$("#_windowEstimateHiddenDiv").addClass("showClass");								
		}
}

