//////////////////////////////////////////////////////////////////////////////
//shop-scripts.js
//
//Desc: This document contains scripts for use by shop-questions.php
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
//updateFrameSizes
//
//Desc: This performs ajax and replaces the options within the frame sizes
//select statement.
//////////////////////////////////////////////////////////////////////////////
function updateFrameSizes(){
	
	
	//Gather all needed variables for the call - State, Cert, and Gauge
	var state_id = document.getElementById("state").value;
	var certified = checkValue("Certified");	
	var gauge = checkValue("gauge");
	
	//Repackage for easy passing
	var passedVars = "function_name=grabFrameSizes&param1="+state_id+"&param2="+certified+"&param3="+gauge;

	
	//Send
	document.getElementById('message').innerHTML = passedVars;
		
	updateContentArea('frame_p',passedVars,'run.php',"message('callback');");
	
}//end function
//////////////////////////////////////////////////////////////////////////////
//message
//
//
//Desc: updates the message field with ajax info
//////////////////////////////////////////////////////////////////////////////
function message(msg){
	document.getElementById('message').innerHTML += msg;
}
//////////////////////////////////////////////////////////////////////////////
//checkValue
//
//Desc: gets the value of the currently selected button from a radion button
//set.
//////////////////////////////////////////////////////////////////////////////
function checkValue(set_name){
	var curValue = document.buildingForm[set_name];

	for(i=0;i<curValue.length;i++){
		if(curValue[i].checked==true){
			return curValue[i].value;
		}//end if
	}//end for
	return false; //on failure
}//end function
//////////////////////////////////////////////////////////////////////////////
//updateSheetFrames
//
//Desc: Used by the package-stats.php page to update the frames when a different
//sheet is chosen.
//////////////////////////////////////////////////////////////////////////////
function updateSheetFrames(){
	
	//Gather all needed variables for the call - State, Cert, and Gauge
	var sheet_id = checkValue("sheet_id");
	
	//Repackage for easy passing
	var passedVars = "function_name=getFramesForBuilder&param1="+sheet_id;
	
	//Send
	updateContentArea('frame_size_select',passedVars,'Ajax/run.php');
		
}//end function
















