$(document).ready(doStuff);

function doStuff() {
	$("label a").click(function(event){
		event.preventDefault();
	});
	$(".mo_config_box_title a").click(function(event){
		event.preventDefault();
	});

}

var xmlHttp;

function f_email_summary() { 
	window.open("/monorail/email.php","emailsummary","width=420, height=500, toolbar=no, scrollbars=no, resizable=no, menubar=no, status=no, directories=no, location=no, screenX=200, left=350, screenY=60, top=150"); 
}
function f_request_quote() { 
	window.open("/monorail/quote.php","emailsummary","width=420, height=400, toolbar=no, scrollbars=no, resizable=no, menubar=no, status=no, directories=no, location=no, screenX=200, left=350, screenY=60, top=150"); 
}
function f_print_summary() { 
	window.print();
}

function f_info_popup(what,width,height) {
	window.open("/monorail/info.php?what="+what,"Info","width="+width+", height="+height+", toolbar=no, scrollbars=yes, resizable=no, menubar=no, status=no, directories=no, location=no, screenX=200, left=350, screenY=60, top=150");
	doStuff();
}

/*
function f_info_popup(what) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	
	document.getElementById('info_box').style.display = 'block';
	
	var url= "/monorail/info.php?what="+what;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("info_box"); }
	xmlHttp.send(null);	
}*/




function f_add_item(prod_id,qty) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	var url= "/monorail/cart.php?action=add&prod_id="+prod_id+"&qty="+qty;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("cart"); }
	xmlHttp.send(null);
}

function f_add_connector(connector,qty) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	var url= "/monorail/connectors.php?action=add&connector="+connector+"&qty="+qty;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("connectors"); }
	xmlHttp.send(null);
}

function f_change_head_option(old_prod_id,new_prod_id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}

	var url= "/monorail/change_head.php?prod_id="+new_prod_id;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			document.getElementById("panel_"+old_prod_id).innerHTML=xmlHttp.responseText;
			document.getElementById("panel_"+old_prod_id).setAttribute("id","panel_"+new_prod_id);  
		}
	}
	xmlHttp.send(null);
}

function f_jump(l_connector,t_connector,x_connector,f_connector) {
	var url = "/monorail/index.php?step=2";
	if (l_connector != "")
		url = url + "&l_connector="+l_connector;
	if (t_connector != "")
		url = url + "&t_connector="+t_connector;
	if (x_connector != "")
		url = url + "&x_connector="+x_connector;
	if (f_connector != "")
		url = url + "&f_connector="+f_connector;

	window.location = url;
}

function f_filter_system_type(system_type) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	var url= "/monorail/step_1.php?system_type="+system_type;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("steps_div"); }
	xmlHttp.send(null);
}
function f_filter_transformer_type(transformer_type) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	var url= "/monorail/step_1.php?transformer_type="+transformer_type;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("steps_div"); }
	xmlHttp.send(null);
}
function f_filter_transformer_wattage(transformer_wattage) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	var url= "/monorail/step_1.php?transformer_wattage="+transformer_wattage;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("steps_div"); }
	xmlHttp.send(null);
}
function f_filter_output_voltage(output_voltage) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	var url= "/monorail/step_1.php?output_voltage="+output_voltage;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("steps_div"); }
	xmlHttp.send(null);
}
function f_filter_standoff_length(standoff_length) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	var url= "/monorail/step_1.php?standoff_length="+standoff_length;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("steps_div"); }
	xmlHttp.send(null);
}
function f_filter_kit_length(kit_length) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	var url= "/monorail/step_1.php?kit_length="+kit_length;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("steps_div"); }
	xmlHttp.send(null);
}
function f_filter_finish(finish) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Your browser is not capable of handling this type of request");
	 return;
	}
	var url= "/monorail/step_1.php?finish="+finish;
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=function() { f_state_changed("steps_div"); }
	xmlHttp.send(null);
}








/******************************************************************/
function f_state_changed(what) { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById(what).innerHTML=xmlHttp.responseText;
//		document.getElementById(what).style.display = "block";
	}
}

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;
}
