function DD_Set(selector1,selector2,action)
{
	var script = "get_contact_data.php";
	var data = {
		"action" : action,
		"id" : $("option:selected",selector1).val()
	};
	$.getJSON(script,data,function(response){
		DD_Format(selector2);
		DD_Populate(selector2,response);
	},"json");
}
function DD_Format(selector)
{
	$("option",selector).not("[value=0]").remove();
}
function DD_Populate(selector,data)
{
	var clone = new Object();
	$(data).each(function(){
		clone = $("option:last",selector).clone();
		$(clone).val(this.id);
		$(clone).text(this.value);
		clone.insertAfter($("option:last",selector));
	});
	$("option:first",selector).attr("selected","selected");
}
function DD_Modify()
{
	if($(this).hasClass("dropdown1"))
	{
		DD_Set(".dropdown1",".dropdown2","categories_products");
		DD_Format(".dropdown3");
	}
	if($(this).hasClass(".dropdown2"))
	{
		DD_Set(".dropdown2",".dropdown3","products");
	}
}
function validate()
{
	if($("#form").valid()){
		$("#form").submit();
	}
	return false;
}
$(document).ready(function(){
	$("#submit").click(validate);
	$(".dropdown").change(DD_Modify);
});

