/***********************************************************************************************************************
DOCUMENT: /core/templates/oldcastle/includes/javascript.js
DEVELOPED BY: Ryan Stemkoski
COMPANY: Zipline Interactive
EMAIL: ryan@gozipline.com
PHONE: 509-321-2849
DATE: 8/28/2009
DESCRIPTION: This document contains general javascript functionality used within the site.  Requires jQuery library
************************************************************************************************************************/

//***********************************************************************************************************************
//ON DOCUMENT READY FUNCTIONS
//***********************************************************************************************************************
$(function() {
	
	//TOGGLE VALUE IN SEARCH FIELD
	$('.search_field').focus(function() {
		var text = $('.search_field').val();
		if(text == "Search") {
			$('.search_field').val("");
		}
	}).blur(function() {
		var text = $('.search_field').val();
		if(text == "") {
			$('.search_field').val("Search");
		}	
	});
	
	//NAV MOUSEOVER
	$('#nav li').mouseover(function() {
		if(!$(this).hasClass("on")) {
			$(this).toggleClass("over");
		}
	}).mouseout(function() {
		if(!$(this).hasClass("on")) {
			$(this).toggleClass("over");
		}
	});
	
	//SELECT MENU IN FOOTER
	$('.footer_menu').change(function() {
		var url = $('.footer_menu').val();
		if(url != "") {
			window.location = url;
		}
	});
});

function calculateVolume() {
	var lf = document.getElementById('cube_lf').value;
	var li = document.getElementById('cube_li').value;
	var wf = document.getElementById('cube_wf').value;
	var wi = document.getElementById('cube_wi').value;
	var hf = document.getElementById('cube_hf').value;
	var hi = document.getElementById('cube_hi').value;

	var lFeet = parseInt(lf)+(li/12);
	var wFeet = parseInt(wf)+(wi/12);
	var hFeet = parseInt(hf)+(hi/12);

	var outputFeet = lFeet*wFeet*hFeet;
	var outputYards = outputFeet/27;
	document.getElementById('cube_feet').innerHTML = outputFeet.toFixed(2);
	document.getElementById('cube_yards').innerHTML = outputYards.toFixed(2);
}

function calculateVolumeCylinder(hf,hi,df,di) {
	var hf = document.getElementById('cyl_hf').value;
	var hi = document.getElementById('cyl_hi').value;
	var df = document.getElementById('cyl_df').value;
	var di = document.getElementById('cyl_di').value;
	
	var hFeet = parseInt(hf)+(hi/12);
	var dFeet = parseInt(df)+(di/12);
	
	var pi = Math.PI;
	var r = dFeet/2;
	var outputFeet = pi*hFeet*(r*r);
	var outputYards = outputFeet/27;
	document.getElementById('cyl_feet').innerHTML = outputFeet.toFixed(2);
	document.getElementById('cyl_yards').innerHTML = outputYards.toFixed(2);
}
