﻿
var prepinfo = "ctl00_cph_content_AdvertList_";

// ------------------------------------------------------------------------------

function onSelectChange() {
	fillsection($("#" + prepinfo + "categorydrop option:selected").val(), null);
};

//----------------------------------------------------------------------------------------------------------------------

function fillsection(cat_id, sec_id) {

	if (cat_id == "0") {
		$("#" + prepinfo + "section option").remove();
		return;
	}
	

	jQuery.ajax({
		type: "POST",
		url: "/service.h",
		dataType: "json",
		data: "query=getadvsection&value=" + cat_id,
		timeout: 10000,
		success: function(result) {

		$("#" + prepinfo + "categorydrop option[value='" + cat_id + "']").attr("selected", "selected");

			$("#" + prepinfo + "section option").remove();

			jQuery.each(result.result[0], function(i, result) {
				$('<option value="' + result.Id + '">' + result.Name + '</option>').appendTo($("#" + prepinfo + "section"));
			});

			if (sec_id != null) {
				jQuery("#" + prepinfo + "section option[value='" + sec_id + "']").attr("selected", "selected");
			}

		}

	});

};

//----------------------------------------------------------------------------------------------------------------------

function avertquery() {

	var radio;

	 if($("#" + prepinfo + "rb_inout_0").attr("checked")) radio = 0;
	 if($("#" + prepinfo + "rb_inout_1").attr("checked")) radio = 1;
	 if ($("#" + prepinfo + "rb_inout_2").attr("checked")) radio = 2;

	 var _section = $("#" + prepinfo + "section option:selected").val();

	 if (_section == undefined)
	 	_section = '0';

	 location = "/inzerce.aspx/strana-1/druh-" + radio + "/kategorie-" + $("#" + prepinfo + "categorydrop option:selected").val() + "/rubrika-" + _section + "/dni-" + $("#" + prepinfo + "ddDaysAgo option:selected").val();

}

