
	// AJAX
	
	function load_document(id){
		xmlHttp=GetXmlHttpObject();
		var url="ajax.php";
		url=url+"?toDo=load_document"
		url=url+"&id="+id
		url=url+"&sid="+Math.random()
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			 	//alert(xmlHttp.responseText);
				document.getElementById('google_viewer').innerHTML=xmlHttp.responseText;
			 }	
		}
		xmlHttp.send(null);
	}
	
	function filter_step2(){
		xmlHttp=GetXmlHttpObject();
		var url="ajax.php";
		url=url+"?toDo=filter_step2"
		url=url+"&panel_model="+document.getElementById('panel_model').options[document.getElementById('panel_model').selectedIndex].value;
		url=url+"&sid="+Math.random()
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			 	//alert(xmlHttp.responseText);
				var step2 = document.getElementById('step2');
				var step2_menu = document.getElementById('panel_type');
				step2_menu.innerHTML = '<option value="0"> -- Make a Selection -- </option>' + xmlHttp.responseText;
				
				if (xmlHttp.responseText != '') {
					step2.style.color = '#333333';
					step2_menu.disabled = false;
					step2_menu.focus();
				} else {
					step2.style.color = '#BBBBBB';
					step2_menu.disabled = true;
				}
				document.getElementById('step3').style.color = '#BBBBBB';
				document.getElementById('panel_phase').disabled = true;
				document.getElementById('panel_phase').selectedIndex = 0;
				document.getElementById('step4').style.color = '#BBBBBB';
				document.getElementById('panel_breaker').disabled = true;
				document.getElementById('panel_breaker').selectedIndex = 0;
				document.getElementById('step5').style.color = '#BBBBBB';
				document.getElementById('panel_voltage').disabled = true;
				document.getElementById('panel_voltage').selectedIndex = 0;
				document.getElementById('base_panel').style.display = 'none';
			 }	
		}
		xmlHttp.send(null);
	}
	
	function filter_step3(){
		xmlHttp=GetXmlHttpObject();
		var url="ajax.php";
		url=url+"?toDo=filter_step3"
		url=url+"&panel_model="+document.getElementById('panel_model').options[document.getElementById('panel_model').selectedIndex].value;
		url=url+"&panel_type="+document.getElementById('panel_type').options[document.getElementById('panel_type').selectedIndex].value;
		url=url+"&sid="+Math.random()
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			 	//alert(xmlHttp.responseText);
				var step3 = document.getElementById('step3');
				var step3_menu = document.getElementById('panel_phase');
				step3_menu.innerHTML = '<option value="0"> -- Make a Selection -- </option>' + xmlHttp.responseText;
				
				if (xmlHttp.responseText != '') {
					step3.style.color = '#333333';
					step3_menu.disabled = false;
					step3_menu.focus();
				} else {
					step3.style.color = '#BBBBBB';
					step3_menu.disabled = true;
				}
				document.getElementById('step4').style.color = '#BBBBBB';
				document.getElementById('panel_breaker').disabled = true;
				document.getElementById('panel_breaker').selectedIndex = 0;
				document.getElementById('step5').style.color = '#BBBBBB';
				document.getElementById('panel_voltage').disabled = true;
				document.getElementById('panel_voltage').selectedIndex = 0;
				document.getElementById('base_panel').style.display = 'none';
			 }	
		}
		xmlHttp.send(null);
	}
	
	function filter_step4(){
		xmlHttp=GetXmlHttpObject();
		var url="ajax.php";
		url=url+"?toDo=filter_step4"
		url=url+"&panel_model="+document.getElementById('panel_model').options[document.getElementById('panel_model').selectedIndex].value;
		url=url+"&panel_type="+document.getElementById('panel_type').options[document.getElementById('panel_type').selectedIndex].value;
		url=url+"&panel_phase="+document.getElementById('panel_phase').options[document.getElementById('panel_phase').selectedIndex].value;
		url=url+"&sid="+Math.random()
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			 	//alert(xmlHttp.responseText);
				var step4 = document.getElementById('step4');
				var step4_menu = document.getElementById('panel_breaker');
				step4_menu.innerHTML = '<option value="0"> -- Make a Selection -- </option>' + xmlHttp.responseText;
				
				if (xmlHttp.responseText != '') {
					step4.style.color = '#333333';
					step4_menu.disabled = false;
					step4_menu.focus();
				} else {
					step4.style.color = '#BBBBBB';
					step4_menu.disabled = true;
				}
				document.getElementById('step5').style.color = '#BBBBBB';
				document.getElementById('panel_voltage').disabled = true;
				document.getElementById('panel_voltage').selectedIndex = 0;
				document.getElementById('base_panel').style.display = 'none';
			 }	
		}
		xmlHttp.send(null);
	}
	
	function filter_step5(){
		xmlHttp=GetXmlHttpObject();
		var url="ajax.php";
		url=url+"?toDo=filter_step5"
		url=url+"&panel_model="+document.getElementById('panel_model').options[document.getElementById('panel_model').selectedIndex].value;
		url=url+"&panel_type="+document.getElementById('panel_type').options[document.getElementById('panel_type').selectedIndex].value;
		url=url+"&panel_phase="+document.getElementById('panel_phase').options[document.getElementById('panel_phase').selectedIndex].value;
		url=url+"&panel_breaker="+document.getElementById('panel_breaker').options[document.getElementById('panel_breaker').selectedIndex].value;
		url=url+"&sid="+Math.random()
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			 	//alert(xmlHttp.responseText);
				var step5 = document.getElementById('step5');
				var step5_menu = document.getElementById('panel_voltage');
				step5_menu.innerHTML = '<option value="0"> -- Make a Selection -- </option>' + xmlHttp.responseText;
				
				if (xmlHttp.responseText != '') {
					step5.style.color = '#333333';
					step5_menu.disabled = false;
					step5_menu.focus();
				} else {
					step5.style.color = '#BBBBBB';
					step5_menu.disabled = true;
				}
				document.getElementById('base_panel').style.display = 'none';
			 }	
		}
		xmlHttp.send(null);
	}
	
	
	function show_base_panel(){
		xmlHttp=GetXmlHttpObject();
		var url="ajax.php";
		url=url+"?toDo=show_base_panel"
		url=url+"&panel_model="+document.getElementById('panel_model').options[document.getElementById('panel_model').selectedIndex].value;
		url=url+"&panel_type="+document.getElementById('panel_type').options[document.getElementById('panel_type').selectedIndex].value;
		url=url+"&panel_phase="+document.getElementById('panel_phase').options[document.getElementById('panel_phase').selectedIndex].value;
		url=url+"&panel_breaker="+document.getElementById('panel_breaker').options[document.getElementById('panel_breaker').selectedIndex].value;
		url=url+"&panel_voltage="+document.getElementById('panel_voltage').options[document.getElementById('panel_voltage').selectedIndex].value;
		url=url+"&sid="+Math.random()
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			 	//alert(xmlHttp.responseText);
				var base_panel = document.getElementById('base_panel');
				base_panel.innerHTML = xmlHttp.responseText;
				
				if (xmlHttp.responseText != '') {
					base_panel.style.display = 'block';
				} else {
					base_panel.style.display = 'none';
				}
				
			 }	
		}
		xmlHttp.send(null);
	}
	
	function load_base_panel(base_id){
		xmlHttp=GetXmlHttpObject();
		var url="ajax.php";
		url=url+"?toDo=load_base_panel"
		url=url+"&base_id="+base_id;
		url=url+"&sid="+Math.random()
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			 	//alert(xmlHttp.responseText);
				var base_panel = document.getElementById('base_panel');
				base_panel.innerHTML = xmlHttp.responseText;
				
				if (xmlHttp.responseText != '') {
					base_panel.style.display = 'block';
				} else {
					base_panel.style.display = 'none';
				}
				document.getElementById('panel_model').selectedIndex = 0;
				document.getElementById('step2').style.color = '#BBBBBB';
				document.getElementById('panel_type').disabled = true;
				document.getElementById('panel_type').selectedIndex = 0;
				document.getElementById('step3').style.color = '#BBBBBB';
				document.getElementById('panel_phase').disabled = true;
				document.getElementById('panel_phase').selectedIndex = 0;
				document.getElementById('step4').style.color = '#BBBBBB';
				document.getElementById('panel_breaker').disabled = true;
				document.getElementById('panel_breaker').selectedIndex = 0;
				document.getElementById('step5').style.color = '#BBBBBB';
				document.getElementById('panel_voltage').disabled = true;
				document.getElementById('panel_voltage').selectedIndex = 0;
			 }	
		}
		xmlHttp.send(null);
	}
	
	function toggle_option(option_id) {
		if (document.getElementById("option_" + option_id).checked == true) {
			add_option(option_id);
		} else {
			remove_option(option_id);	
		}		
	}
	
	function add_option(option_id){
		var req = new Request({
			method: 'get',
			url: '/ajax.php',
			onComplete: function(response) {
				document.getElementById('summary_info').innerHTML = response;
			}
		}).send('toDo=add_option&option_id=' + option_id);
	}
	
	function remove_option(option_id){
		var req = new Request({
			method: 'get',
			url: '/ajax.php',
			onComplete: function(response) {
				document.getElementById('summary_info').innerHTML = response;
			}
		}).send('toDo=remove_option&option_id=' + option_id);
	}
	
	/*function remove_option(option_id){
		xmlHttp=GetXmlHttpObject();
		var url="/ajax.php";
		url=url+"?toDo=remove_option"
		url=url+"&option_id="+option_id;
		url=url+"&sid="+Math.random()
		xmlHttp.open("GET",url,true)
		xmlHttp.onreadystatechange=function (){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
			 	//alert(xmlHttp.responseText);
				document.getElementById('panel_price').innerHTML = xmlHttp.responseText;
			 }	
		}
		xmlHttp.send(null);
	}*/
	
	
	function GetXmlHttpObject() {
		var xmlHttp=null;
		try {
	 		// Firefox, Opera 8.0+, Safari
	 		xmlHttp=new XMLHttpRequest();
	 	}
		catch (e) {
	 	// Internet Explorer
	 		try {
	  			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  		}
	 		catch (e) {
	  			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  		}
	 	}
		return xmlHttp;
	}