function jq_req_cats()
{
  elm_sel=jQuery("select[name='category'] option:selected").val();	
  elm_catsel=jQuery("input[name='catsel']").val();	
  jQuery.ajax({
		   type: "GET",
		   url: "actions/req_brands.php",
		   cache: false,
		   data: ({category: elm_sel, catsel: elm_catsel}),
		   complete: function (XH, textmes) {
			  if(textmes!="success")
				{
					alert("Eroare de accesare: "+textmes);
				}
			},
		   success: function(html){
				jQuery("#subcategoryelement").html(html);
				jQuery("#subcategory").change(function () {
						jq_req_subcats();
					});
				jq_req_subcats();
			}
		 });
}

function jq_req_subcats()
{
  elm_sel=jQuery("select[name='subcategory'] option:selected").val();	
  elm_catsel=jQuery("input[name='subsubcatsel']").val();	
  jQuery.ajax({
		   type: "GET",
		   url: "actions/req_subcats.php",
		   cache: false,
		   data: ({subcategory: elm_sel, catsel: elm_catsel}),
		   complete: function (XH, textmes) {
			  if(textmes!="success")
				{
					alert("Eroare de accesare: "+textmes);
				}
			},
		   success: function(html){
			 jQuery("#subsubcategoryelement").html(html);
			}
		 });
}

jQuery(document).ready(function () 
{
	
	
	jQuery("#offer_form").submit(function () {
				return validari_oferta();
			});
	
	
	jQuery("#category").change(function () {
				jq_req_cats();
			}).change();
	jQuery("#subcategory").change(function () {
				jq_req_subcats();
			});
	
}
);