
// #################################################################### //
//						BOX ADVISOR JAVASCRIPT							//
//					SPECIFIC FOR PRODUCT DETAILS PAGE					//
// #################################################################### //	



//<!-- ################################################## -->
//<!--               Woofer BoxAdvisor(TM) 2009           -->
//<!--                Designed and Written by             -->
//<!--     Eric W. Russell (russeler@rockfordcorp.com)    -->
//<!--                                                    -->
//<!--        This application is NOT freeware NOR        -->
//<!--       is it "open-source".  Any reproduction       -->
//<!--       or usage of this DESIGN and CODE not to      -->
//<!--      be used without explicit written approval.    -->
//<!-- ################################################## -->


	

// #################################################################### //
//						UPDATE UNIT OF MEASURE							//
//				CLICKING "STANDARD" OR "METRIC" RADIO BUTTON			//
//		RE-SUBMITS FORMS TO LOAD VALUES IN "CUBIC FEET" OR "LITERS"		//
// #################################################################### //	

function updateUOM(val) {
	if(val == "standard") {
		document.getElementById('s_units').value = "standard";	
		document.getElementById('v_units').value = "standard";			
		document.getElementById('ib_units').value = "standard";			
	} else if(val == "metric") {
		document.getElementById('s_units').value = "metric";	
		document.getElementById('v_units').value = "metric";			
		document.getElementById('ib_units').value = "metric";	
	}
	//submits individual AJAX content DIV's with new enclosure info.
	getSealedBox(1);
	getVentedBox(1);
	getInfiniteBaffleBox(1);
}



// #################################################################### //
//						SEALED RECOMMENDED (BOX)						//
// 		GETS RECOMMENDED BOX DESIGN WITH OPTION TO CHANGE WOOFER QTY	//
// #################################################################### //
var ajax4 = new sack();

function sWhenLoading2(){
	var e = document.getElementById('sRecBoxDiv');
	e.innerHTML = "<div align='center' style='font-weight:bold; font-size:12px; color:#009900; width:680px; height:346px;'><br clear='all' />" +
				     "<div style='text-align:center; padding-bottom:10px;'><img src='../images/ajax_loading.gif' width='32' height='32' align='center' /></div>" +
				     "<div style='text-align:center;'>Sending Data...</div>" + 
				   "</div>";	
}

function sWhenLoaded2(){
	var e = document.getElementById('sRecBoxDiv');
	e.innerHTML = "<div align='center' style='font-weight:bold; font-size:12px; color:#009900; width:680px; height:346px;'><br clear='all' />" +
				     "<div style='text-align:center; padding-bottom:10px;'><img src='../images/ajax_loading.gif' width='32' height='32' align='center' /></div>" +
				     "<div style='text-align:center;'>Data Sent...</div>" + 
				   "</div>";
}

function sWhenInteractive2(){
	var e = document.getElementById('sRecBoxDiv');
	e.innerHTML = "<div align='center' style='font-weight:bold; font-size:12px; color:#009900; width:680px; height:346px;'><br clear='all' />" +
				     "<div style='text-align:center; padding-bottom:10px;'><img src='../images/ajax_loading.gif' width='32' height='32' align='center' /></div>" +
				     "<div style='text-align:center;'>Getting Data...</div>" + 
				   "</div>";
}

// DEBUG FUNCTION //
function sWhenCompleted2(){
	var e = document.getElementById('sRecBoxDebug');
	if (ajax4.responseStatus){
		var string = "<p>Status Code: " + ajax4.responseStatus[0] + "</p><p>Status Message: " + ajax4.responseStatus[1] + "</p><p>URLString Sent: " + ajax4.URLString + "</p>";
	} else {
		var string = "<p>URLString Sent: " + ajax4.URLString + "</p>";
	}
	e.innerHTML = string;
}	

// SEND AJAX DATA //
function getSealedBox(autoQty){

	var form = document.getElementById('form3');		
	var menuQty = document.getElementById('s_woof_qty_id').selectedIndex;
		
	//get more box options only if Woofer Qty select menu is set to a value - and not defaulted to <Select Woofer Qty>
	if (menuQty != 0)  {
		ajax4.setVar("p_item_id", form.s_item_id.value);
		ajax4.setVar("p_units", form.s_units.value);		
		ajax4.setVar("p_woof_qty_id", form.s_woof_qty_id.value);					
		ajax4.setVar("p_box_type", form.s_box_type.value);		
		ajax4.requestFile = "../rftech/box_advisor_getBoxes.asp";
		ajax4.method = "GET";
		ajax4.element = 'sRecBoxDiv';
		ajax4.onLoading = sWhenLoading2;
		ajax4.onLoaded = sWhenLoaded2; 
		ajax4.onInteractive = sWhenInteractive2;
		ajax4.onCompletion = sWhenCompleted2;	// DEBUG
		ajax4.runAJAX();
	}
}	




// #################################################################### //
//						VENTED RECOMMENDED (BOX)						//
// 		GETS RECOMMENDED BOX DESIGN WITH OPTION TO CHANGE WOOFER QTY	//
// #################################################################### //
var ajax6 = new sack();

function vWhenLoading2(){
	var e = document.getElementById('vRecBoxDiv');
	e.innerHTML = "<div align='center' style='font-weight:bold; font-size:12px; color:#009900; width:680px; height:360px;'><br clear='all' />" +
				     "<div style='text-align:center; padding-bottom:10px;'><img src='../images/ajax_loading.gif' width='32' height='32' align='center' /></div>" +
				     "<div style='text-align:center;'>Sending Data...</div>" + 
				   "</div>";	
}

function vWhenLoaded2(){
	var e = document.getElementById('vRecBoxDiv');
	e.innerHTML = "<div align='center' style='font-weight:bold; font-size:12px; color:#009900; width:680px; height:360px;'><br clear='all' />" +
				     "<div style='text-align:center; padding-bottom:10px;'><img src='../images/ajax_loading.gif' width='32' height='32' align='center' /></div>" +
				     "<div style='text-align:center;'>Data Sent...</div>" + 
				   "</div>";
}

function vWhenInteractive2(){
	var e = document.getElementById('vRecBoxDiv');
	e.innerHTML = "<div align='center' style='font-weight:bold; font-size:12px; color:#009900; width:680px; height:360px;'><br clear='all' />" +
				     "<div style='text-align:center; padding-bottom:10px;'><img src='../images/ajax_loading.gif' width='32' height='32' align='center' /></div>" +
				     "<div style='text-align:center;'>Getting Data...</div>" + 
				   "</div>";
}

// DEBUG FUNCTION //
function vWhenCompleted2(){
	var e = document.getElementById('vRecBoxDebug');
	if (ajax6.responseStatus){
		var string = "<p>Status Code: " + ajax6.responseStatus[0] + "</p><p>Status Message: " + ajax6.responseStatus[1] + "</p><p>URLString Sent: " + ajax6.URLString + "</p>";
	} else {
		var string = "<p>URLString Sent: " + ajax6.URLString + "</p>";
	}
	e.innerHTML = string;
}	

// SEND AJAX DATA //
function getVentedBox(autoQty){

	var form = document.getElementById('form5');		
	var menuQty = document.getElementById('v_woof_qty_id').selectedIndex;
		
	//get more box options only if Woofer Qty select menu is set to a value - and not defaulted to <Select Woofer Qty>
	if (menuQty != 0)  {
		ajax6.setVar("p_item_id", form.v_item_id.value);
		ajax6.setVar("p_units", form.v_units.value);		
		ajax6.setVar("p_woof_qty_id", form.v_woof_qty_id.value);					
		ajax6.setVar("p_box_type", form.v_box_type.value);		
		ajax6.requestFile = "../rftech/box_advisor_getBoxes.asp";
		ajax6.method = "GET";
		ajax6.element = 'vRecBoxDiv';
		ajax6.onLoading = vWhenLoading2;
		ajax6.onLoaded = vWhenLoaded2; 
		ajax6.onInteractive = vWhenInteractive2;
		ajax6.onCompletion = vWhenCompleted2;	// DEBUG
		ajax6.runAJAX();
	}
}



// #################################################################### //
//					INFINITE BAFFLE RECOMMENDED (BOX)					//
// 			GETS RECOMMENDED DESIGN WITH OPTION TO CHANGE WOOFER QTY	//
// #################################################################### //
var ajax7 = new sack();

function ibWhenLoading2(){
	var e = document.getElementById('ibRecBoxDiv');
	e.innerHTML = "<div align='center' style='font-weight:bold; font-size:12px; color:#009900; width:680px; height:360px;'><br clear='all' />" +
				     "<div style='text-align:center; padding-bottom:10px;'><img src='../images/ajax_loading.gif' width='32' height='32' align='center' /></div>" +
				     "<div style='text-align:center;'>Sending Data...</div>" + 
				   "</div>";	
}

function ibWhenLoaded2(){
	var e = document.getElementById('ibRecBoxDiv');
	e.innerHTML = "<div align='center' style='font-weight:bold; font-size:12px; color:#009900; width:680px; height:360px;'><br clear='all' />" +
				     "<div style='text-align:center; padding-bottom:10px;'><img src='../images/ajax_loading.gif' width='32' height='32' align='center' /></div>" +
				     "<div style='text-align:center;'>Data Sent...</div>" + 
				   "</div>";
}

function ibWhenInteractive2(){
	var e = document.getElementById('ibRecBoxDiv');
	e.innerHTML = "<div align='center' style='font-weight:bold; font-size:12px; color:#009900; width:680px; height:360px;'><br clear='all' />" +
				     "<div style='text-align:center; padding-bottom:10px;'><img src='../images/ajax_loading.gif' width='32' height='32' align='center' /></div>" +
				     "<div style='text-align:center;'>Getting Data...</div>" + 
				   "</div>";
}

// DEBUG FUNCTION //
function ibWhenCompleted2(){
	var e = document.getElementById('ibRecBoxDebug');
	if (ajax7.responseStatus){
		var string = "<p>Status Code: " + ajax7.responseStatus[0] + "</p><p>Status Message: " + ajax7.responseStatus[1] + "</p><p>URLString Sent: " + ajax7.URLString + "</p>";
	} else {
		var string = "<p>URLString Sent: " + ajax7.URLString + "</p>";
	}
	e.innerHTML = string;
}	

// SEND AJAX DATA //
function getInfiniteBaffleBox(autoQty){

	var form = document.getElementById('form6');		
	var menuQty = document.getElementById('ib_woof_qty_id').selectedIndex;
		
	//get more box options only if Woofer Qty select menu is set to a value - and not defaulted to <Select Woofer Qty>
	if (menuQty != 0)  {
		ajax7.setVar("p_item_id", form.ib_item_id.value);
		ajax7.setVar("p_units", form.ib_units.value);		
		ajax7.setVar("p_woof_qty_id", form.ib_woof_qty_id.value);					
		ajax7.setVar("p_box_type", form.ib_box_type.value);		
		ajax7.requestFile = "../rftech/box_advisor_getBoxes.asp";
		ajax7.method = "GET";
		ajax7.element = 'ibRecBoxDiv';
		ajax7.onLoading = ibWhenLoading2;
		ajax7.onLoaded = ibWhenLoaded2; 
		ajax7.onInteractive = ibWhenInteractive2;
		ajax7.onCompletion = ibWhenCompleted2;	// DEBUG
		ajax7.runAJAX();
	}
}