function CarBodyField(divID, selectID) {
	
	this.click = function(obj, key, event) {

		if($(obj).hasClass("selected")) {
			this.select.attr("selectedIndex", 0);
			$(obj).removeClass("selected");
			
			if(this.makeModelField) {
				this.makeModelField.filterGrbodyMake('');
				this.makeModelField.filterGrbodyModel('');
			}
			
			return;
		}

		this.select.attr("selectedIndex", key);
		this.div.children(".selected").removeClass("selected");
		$(obj).addClass("selected");
		
		if(this.makeModelField) {
			this.makeModelField.filterGrbodyMake(this.select.attr("value"));
			this.makeModelField.filterGrbodyModel(this.select.attr("value"));
		}
	};
	
	var THIS = this;

	this.select = $("#" + this.prepareID(selectID));
	if(!this.select) {
		return;
	}

	this.div = $("#" + this.prepareID(divID));
	if(!this.div) {
		this.div = this.select.parent();
	}

	this.select.hide();
	this.select.children("option").each(function(key, value) {
		if(key == 0) {
			return;
		}

		var id = selectID + "_" + key;
		THIS.div.append("<div align=\"center\" id=\"" + id + "\" style=\"background-image: url(/i/auto/body_" + key + ".png);\" title=\"" + $(value).html() + "\" class=\"cn\"></div>");
		$("#" + THIS.prepareID(id)).click(function(event) {THIS.click(this, key, event);return false;});
		
		if(key == THIS.select.attr("selectedIndex")) {
			$("#" + THIS.prepareID(id)).trigger("click");
		}
	});

	this.makeModelField = null;
    //this.div.children("div").each(function() {this.style.width = this.offsetWidth < 80 ? '80px' : 'auto';});
}

CarBodyField.prototype = new Field();



// options: makeSelectID, makeUrlPrefix, modelSelectID, modelUrlPrefix, popMakeID, popModelsID, ajaxURL, grbodySelectID, makeListID, modelListID
function CarMakeModelFields(options) {
    var THIS = this;

    this.change = function(event) {
        var THIS = this;

        if(!this.modelHidden || !this.modelHidden.is("input")) {
            return true;
        }

        if(this.makeHidden.val()) {

            this.modelSelect.html("");
            this.modelHidden.val(0);

            if(this.popModels) {
                this.popModels.children("a,span").remove();
                this.popModels.append('<span>Загружаю список моделей...</span>');
            }

            $.get(this.ajaxURL, {id: this.makeHidden.val()}, function(data, textStatus, XMLHttpRequest) {
                var pos = data.search(/<hr\/>/);
                THIS.onload(data.substring(0, pos), textStatus, XMLHttpRequest);
                if(THIS.popModels) {
                    THIS.onloadList(data.substring(pos + 5), textStatus, XMLHttpRequest);
                }
            });

        } else {

            this.modelSelect.html("");
            this.modelHidden.val(0);

            if(this.popModels) {
                this.popModels.children("a,span").remove();
            }
        }
    };

    this.onload = function(data, textStatus, XMLHttpRequest) {
        this.modelSelect.html(data);
        this.filterGrbodyMake(this.grbodySelect.attr("value"));
    };

    this.onloadList = function(data, textStatus, XMLHttpRequest) {
        this.popModels.children("a,span").remove();
        this.popModels.contents().filter(function() {
            return this.nodeType == 3;
        }).remove();
        this.popModels.append(data.length > 0 ? data : '');
        this.initModels();
        this.initModelListItems();
        this.filterGrbodyModel(this.grbodySelect.attr("value"));
    };

    this.makeClick = function(link) {

        if($(link).hasClass("active")) {
            $(link).removeClass("active");
            this.makeHidden.val(0);
            this.change();
            return;
        }

        var THIS = this;
        var pos = link.href.indexOf(this.makeUrlPrefix + "=");
        if(pos >= 0) {
            var id = link.href.substring(pos + this.makeUrlPrefix.length + 1);
            if(id.indexOf("&") > 0) {
                id = id.substring(0, id.indexOf("&"));
            }

            if(id != null) {
                this.popMake.children("a.active").removeClass("active");
                $(link).addClass("active");
                this.makeHidden.val(id);
                this.change();
            }
        }
    };

    this.makeListClick = function(link) {

        var THIS = this;
        var pos = link.href.indexOf("#");
        if(pos >= 0) {
            var id = link.href.substring(pos + 1);
            
            if(id != null) {

                var makeName = null;
                this.makeSelect.children("option").each(function(key) {if(this.value == id) makeName = $(this).html();});
                this.makeHidden.val(id);
                this.change();

                var testId = id;
                var found = false;

                this.popMake.children("a").each(function() {
                    var link = $(this);
                    if(link.hasClass("active")) {
                        link.removeClass("active");
                    }

                    var pos = link.attr("href").indexOf(THIS.makeUrlPrefix + "=");
                    if(pos >= 0) {
                        var id = link.attr("href").substring(pos + THIS.makeUrlPrefix.length + 1);
                        if(id.indexOf("&") > 0) {
                            id = id.substring(0, id.indexOf("&"));
                        }

                        if(id == testId) {
                            link.addClass("active");
                            found = true;
                        }
                    }
                });

                if(!found && makeName && id) {

                    var newLink = this.popMake.children("a:last")
                        .detach()
                        .insertBefore(this.popMake.children("a:first"))
                        .addClass("active")
                        .attr("title", "")
                        .html(makeName);

                    var re = new RegExp(THIS.makeUrlPrefix.replace(/[.]/g, '\\.').replace(/\[/g, '\\[').replace(/\]/g, '\\]') + '=[^\\&]*');
                    newLink.attr("href", newLink.attr("href").replace(re, THIS.makeUrlPrefix + '=' + id));
                }
            }
        }

        this.popMake.children("strong").children("a").click();
        $.scrollTo($("#search"), {axis: 'y', duration: 100});
    };

    this.initModels = function() {
        this.popModels.children("a").click(function(event) {THIS.modelClick(this);return false;});
    };

    this.modelClick = function(link) {

        if($(link).hasClass("gray")) {
            return;
        }

        if($(link).hasClass("active")) {
            $(link).removeClass("active");
            this.modelHidden.val(0);
            return;
        }

        var THIS = this;
        var pos = link.href.indexOf(this.modelUrlPrefix + "=");
        if(pos >= 0) {
            var id = link.href.substring(pos + this.modelUrlPrefix.length + 1);
            if(id) {
                this.popModels.children("a.active").removeClass("active");
                $(link).addClass("active");
                this.modelHidden.val(id);
            }
        }
    };

    this.modelListClick = function(link) {

        if($(link).hasClass("gray")) {
            return;
        }

        var THIS = this;
        var pos = link.href.indexOf("#");
        if(pos >= 0) {
            var id = link.href.substring(pos + 1);

            if(id != null) {

                var modelName = $(link).html();
                var modelGrbody = "";
                this.modelSelect.children("option").each(function(key) {if(this.value == id) {modelGrbody = $(this).attr("grbody");}});
                this.modelHidden.val(id);

                var testId = id;
                var found = false;

                this.popModels.children("a").each(function() {
                    var link = $(this);
                    if(link.hasClass("active")) {
                        link.removeClass("active");
                    }

                    var pos = link.attr("href").indexOf(THIS.modelUrlPrefix + "=");
                    if(pos >= 0) {
                        var id = link.attr("href").substring(pos + THIS.modelUrlPrefix.length + 1);
                        if(id.indexOf("&") > 0) {
                            id = id.substring(0, id.indexOf("&"));
                        }

                        if(id == testId) {
                            link.addClass("active");
                            found = true;
                        }
                    }
                });

                if(!found && modelName && id) {

                    var newLink = this.popModels.children("a:last");

                    if(newLink.is("a")) {
                        newLink
                            .detach()
                            .insertAfter(this.popModels.children("strong"))
                            .addClass("active")
                            .removeClass("gray")
                            .attr("title", "")
                            .attr("grbody", modelGrbody)
                            .html(modelName);

                        var re = new RegExp(THIS.modelUrlPrefix.replace(/[.]/g, '\\.').replace(/\[/g, '\\[').replace(/\]/g, '\\]') + '=[^\\&]*');
                        newLink.attr("href", newLink.attr("href").replace(re, THIS.modelUrlPrefix + '=' + id));
                    }
                }
            }
        }

        this.popModels.children("strong").children("a").click();
        $.scrollTo($("#search"), {axis: 'y', duration: 100});
    };

    this.filterGrbodyMake = function(grbody) {
        grbody = grbody + "";
        var rexp = new RegExp(grbody);
        this.modelSelect.children("option").each(function() {
            if(grbody.length > 0 && $(this).attr("grbody") && $(this).attr("grbody").search(rexp) == -1) {
                this.disabled = true;
                this.className += "";
            } else {
                this.disabled = false;
                this.className += "";
            }
        });
    };

    this.filterGrbodyModelCallback = function(link, grbody, rexp) {
        if(grbody.length > 0 && link.attr("grbody") && link.attr("grbody").search(rexp) == -1) {
            if(link.hasClass("active")) {
                link.trigger("click");
            }
            link.addClass("gray");
        } else {
            link.removeClass("gray");
        }
    }

    this.filterGrbodyModel = function(grbody) {
        var THIS = this;

        grbody = grbody + "";
        var rexp = new RegExp(grbody);

        this.popModels.children("a").each(function() {
            THIS.filterGrbodyModelCallback($(this), grbody, rexp);
        });

        this.modelList.find("a").each(function() {
            THIS.filterGrbodyModelCallback($(this), grbody, rexp);
        });
    };

    this.initMakeList = function() {
        var makeNum = this.makeSelect.children("OPTION").size() + 1;
        var columns = 4;
        var perColumn = Math.ceil(makeNum / columns);
        var currentDiv = $('<div class="col1-4"></div>');
        var currentLetter = null;
        var currentUl = $('');
        var index = 0;

        this.makeSelect.children("OPTION").each(function() {

            if(index % perColumn == 0 && index != 0) {
                currentDiv.append(currentUl);
                THIS.makeList.append(currentDiv);

                currentDiv = $('<div class="col1-4"></div>');
                currentUl = $('<ul class="inlinePanel-ul"></ul>');
            }

            if(index != 0) {
                var letter = $(this).html().substr(0, 1).toUpperCase();
                if(currentLetter != letter) {
                    currentDiv.append(currentUl);
                    currentDiv.append('<strong class="inlinePanel-letter grayer">' + letter + '</strong>');
                    currentUl = $('<ul class="inlinePanel-ul"></ul>');
                }

                currentLetter = letter;

            } else {

                currentUl = $('<ul class="inlinePanel-ul"></ul>');
            }

            index = THIS.initMakeListItem(currentUl, $(this), index);
        });

        currentDiv.append(currentUl);
        this.makeList.append(currentDiv);

        this.makeList.find("a").click(function(event) {THIS.makeListClick(this);return false;});

        this.popMake.append('<span class="tg-more"><a href="#" class="flink">ещё<img src="/i/0.gif" width="7" height="4" /></a></span>');

        this.popMake.children("strong,.tg-more").children("a").click(function() {
            if(THIS.makePanel.hasClass("inlinePanel-active")) {
                THIS.makeList.slideUp(200, function() {THIS.makePanel.toggleClass("inlinePanel-active");});
            } else {
                THIS.makePanel.toggleClass("inlinePanel-active");
                THIS.makeList.slideDown(200);
            }
            return false;
        });
    }

    this.initMakeListItem = function(parent, item, index) {
        var value = item.attr("value");
        var name = item.html();

        parent.append('<li class="inlinePanel-ul-li"><a class="flink" href="#' + value + '">' + item.html() + "</a></li>");

        if(!value) {
            parent.append('<li class="inlinePanel-ul-li">&nbsp;</li>');
            ++ index;
        }

        return index + 1;
    };

    this.initModelList = function() {
        this.initModelListItems();

        this.popModels.children("strong").children("a").click(function() {
            if(THIS.modelPanel.hasClass("inlinePanel-active")) {
                THIS.modelList.slideUp(200, function() {THIS.modelPanel.toggleClass("inlinePanel-active");});
            } else {
                THIS.modelPanel.toggleClass("inlinePanel-active");
                THIS.modelList.slideDown(200);
            }
            return false;
        });
    }

    this.initModelListItems = function() {
        var modelNum = this.modelSelect.children("OPTION").size();
        var columns = 4;
        var perColumn = Math.ceil(modelNum / columns);
        var currentDiv = $('<div class="col1-4"><ul></ul></div>');
        var index = 0;

        this.modelList.html('');

        this.modelSelect.children("OPTION").each(function() {

            if(index % perColumn == 0 && index != 0) {
                THIS.modelList.append(currentDiv);

                currentDiv = $('<div class="col1-4"><ul></ul></div>');
            }

            index = THIS.initModelListItem(currentDiv, $(this), index);
        });

        this.modelList.append(currentDiv);

        this.modelList.find("a").click(function(event) {THIS.modelListClick(this);return false;});

        if(modelNum > 1)
            {
            this.popModels.append('<span class="tg-more"><a href="#" class="flink">ещё<img src="/i/0.gif" width="7" height="4" /></a></span>');

            this.popModels.children(".tg-more").children("a").click(function() {
                if(THIS.modelPanel.hasClass("inlinePanel-active")) {
                    THIS.modelList.slideUp(200, function() {THIS.modelPanel.toggleClass("inlinePanel-active");});
                } else {
                    THIS.modelPanel.toggleClass("inlinePanel-active");
                    THIS.modelList.slideDown(200);
                }
                return false;
            });
            }
    }

    this.initModelListItem = function(parent, item, index) {
        var value = item.attr("value");
        var name = item.html();
        var style = "";

        if(name.substr(0, 1) == " " || name.substr(0, 6) == "&nbsp;") {
            name = name.replace(/(\s|&nbsp;)+/g, "");
            style = ' style="margin-left:1.5em"';
        }

        parent.append('<li class="inlinePanel-ul-li"' + style + '><a class="flink" href="#' + value + '" grbody="' + (item.attr("grbody") ? item.attr("grbody") : "") + '">' + name + "</a></li>");

        if(!value) {
            parent.append('<li class="inlinePanel-ul-li">&nbsp;</li>');
            ++ index;
        }

        return index + 1;
    };

    this.ajaxURL = options.ajaxURL ? options.ajaxURL : "/ajax/models";
    this.makeSelect = this.get(options.makeSelectID);
    this.makeUrlPrefix = options.makeUrlPrefix;
    this.modelUrlPrefix = options.modelUrlPrefix;
    this.grbodySelect = this.get(options.grbodySelectID);
    this.popMake = this.get(options.popMakeID);
    this.makeList = this.get(options.makeListID);
    this.modelList = this.get(options.modelListID);
    this.makePanel = this.get(options.makePanelID);
    this.modelPanel = this.get(options.modelPanelID);

    if(options.modelSelectID) {
        this.modelSelect = this.get(options.modelSelectID);
        this.popModels = this.get(options.popModelsID);
        this.filterGrbodyMake(this.grbodySelect.attr("value"));
        this.filterGrbodyModel(this.grbodySelect.attr("value"));
    }

    this.makeHidden = $('<input type="hidden" name="' + this.makeSelect.attr("name") + '" value="' + this.makeSelect.val() + '" />');
    this.makeSelect.replaceWith(this.makeHidden);

    if(this.modelSelect) {
        this.modelHidden = $('<input type="hidden" name="' + this.modelSelect.attr("name") + '" value="' + this.modelSelect.val() + '" />');
        this.modelSelect.replaceWith(this.modelHidden);
    }

    this.makeSelect.change(function(event) {THIS.change(event);});

    if(this.popMake) {
        this.popMake.children("a").click(function(event) {THIS.makeClick(this);return false;});
    }

    if(this.popModels) {
        this.initModels();
    }

    this.initMakeList();

    if(this.modelSelect) {
        this.initModelList();
    }
}

CarMakeModelFields.prototype = new Field();



function CarYearField(yearLID, yearHID, hintID) {
	var THIS = this;
	
	this.click = function(from, till) {
		this.yearH.attr("value", this.year - from);
		if(till > 0) {
			this.yearL.attr("value", this.year - till);
		} else {
			this.yearL.attr("value", "");
		}
	}

	this.year = new Date().getFullYear();

	this.yearL = this.get(yearLID);
	this.yearH = this.get(yearHID);
	this.hint = this.get(hintID);
	if(!this.yearL || !this.yearH || !this.hint) {
		return;
	}

	this.get(hintID).children("A").css("visibility", "visible");

	$("#year_lt3").click(function(event) {THIS.click(0, 3);return false;});
	$("#year_lt7").click(function(event) {THIS.click(0, 7);return false;});
	$("#year_gt7").click(function(event) {THIS.click(7);return false;});
}

CarYearField.prototype = new Field();



function RegionField(options) {
    var THIS = this;

    this.click = function(link) {

        if($(link).hasClass("active")) {
            $(link).removeClass("active");
            this.element.attr("value", "");
            this.propagateSelectionToLinks("");
            return;
        }

        var THIS = this;
        var tokens = link.href.match(this.regex);
        if(tokens && tokens.length > 1) {
            this.div.children("a.active").removeClass("active");
            $(link).addClass("active");

            var region = decodeURI(tokens[1]);
            this.element.attr("value", region);
            this.propagateSelectionToLinks(region);
            
            $("#region_list").attr("checked", false);
        }
    };

    this.listClick = function(link) {

        var THIS = this;

        if($(link).hasClass("gray")) {
            return;
        }

        var pos = link.href.indexOf("#");
        if(pos >= 0) {
            var id = decodeURI(link.href.substring(pos + 1));

            if(id != null) {
                this.element.val(id);
                this.propagateSelectionToLinks(id);
                
                $("#region_list").attr("checked", false);

                var testId = id;
                var found = false;

                this.div.children("a").each(function() {
                    var link = $(this);
                    if(link.hasClass("active")) {
                        link.removeClass("active");
                    }

                    var tokens = link.attr("href").match(THIS.regex);
                    if(tokens && tokens.length > 1 && tokens[1] == testId) {
                        link.addClass("active");
                        found = true;
                    }
                });

                if(!found && id) {

                    var newLink;
                    if(this.div.children("a:last").is("a")) {
                        newLink = this.div.children("a:last").detach();
                    } else {
                        newLink = $("<a href=\"?" + this.urlReplacePrefix + '=' + id + "\"></a>");
                    }
                    
                    if(this.div.children("a:first").is("a")) {
                        newLink.insertBefore(this.div.children("a:first"));
                    } else {
                        newLink.insertBefore(this.div.children("span.tg-more"));
                    }

                    newLink
                        .addClass("active")
                        .attr("title", "")
                        .html(id)
                    ;

                    newLink.attr("href", newLink.attr("href").replace(THIS.regex, THIS.urlReplacePrefix + '=' + id));
                }
            }
        }

        THIS.panelToggle();
    };

    this.panelToggle = function() {
        if(this.panel.hasClass("inlinePanel-active")) {
            this.list.slideUp(200, function() {THIS.panel.toggleClass("inlinePanel-active");});
        } else {
            this.panel.toggleClass("inlinePanel-active");
            this.list.slideDown(200);
        }
    };

    this.propagateSelectionToLinks = function(region) {
        $("#sections A").each(function() {
            if(this.href.match(THIS.regex)) {
                this.href = this.href.replace(THIS.regex, THIS.urlReplacePrefix + "=" + region);
            } else {
                if(this.href.indexOf("?") == -1) {
                    this.href += "?";
                }
                this.href += "&" + THIS.urlReplacePrefix + "=" + region;
            }
        });
    };

    this.initClick = function() {
        this.div.find("a").click(function(event) {THIS.click(this);return false;});
    };

    this.originalElement = this.get(options.elementID);
    this.element = $('<input type="hidden" name="' + this.originalElement.attr("name") + '" value="' + this.originalElement.val() + '" />');
    this.originalElement.replaceWith(this.element);

    this.div = this.get(options.divID);
    this.regex = options.regex;
    this.list = this.get(options.listID);
    this.urlReplacePrefix = options.urlReplacePrefix;
    this.panel = this.get(options.panelID);

    this.initClick();
    this.list.find("a").click(function(event) {THIS.listClick(this);return false;});

    this.div.append('<span class="tg-more"><a href="#" class="flink">ещё<img src="/i/0.gif" width="7" height="4" /></a></span>');

    this.div.children("strong,.tg-more").children("a").click(function() {
        THIS.panelToggle();
        return false;
    });
}

RegionField.prototype = new Field();



function PanelSelectField(options) {
    var THIS = this;

    this.click = function(link) {

        if($(link).hasClass("active")) {
            $(link).removeClass("active");
            this.element.attr("value", "");
            return;
        }

        var THIS = this;
        var tokens = link.href.match(this.regex);
        if(tokens && tokens.length > 1) {
            this.div.children("a.active").removeClass("active");
            $(link).addClass("active");
            this.element.attr("value", decodeURI(tokens[1]));
        }
    };

    this.listClick = function(link) {

        var THIS = this;

        var pos = link.href.indexOf("#");
        if(pos >= 0) {
            var id = link.href.substring(pos + 1);
            var name = $(link).html();

            if(id != null) {
                this.element.val(id);

                var testId = id;
                var found = false;

                this.div.children("a").each(function() {
                    var link = $(this);
                    if(link.hasClass("active")) {
                        link.removeClass("active");
                    }

                    var tokens = link.attr("href").match(THIS.regex);
                    if(tokens && tokens.length > 1 && tokens[1] == testId) {
                        link.addClass("active");
                        found = true;
                    }
                });

                if(!found && id) {

                    var newLink = this.div.children("a:last")
                        .detach()
                        .insertBefore(this.div.children("a:first"))
                        .addClass("active")
                        .attr("title", "")
                        .html(name);

                    newLink.attr("href", newLink.attr("href").replace(THIS.regex, THIS.urlReplacePrefix + '=' + id));
                }
            }
        }

        this.div.children("strong").children("a").click();
    };

    this.initList = function() {
        var num = this.originalElement.children("OPTION").size() + 1;
        var columns = 4;
        var perColumn = Math.ceil(num / columns);
        var currentDiv = $('<div class="col1-4"><ul></ul></div>');
        var index = 0;

        this.originalElement.children("OPTION").each(function() {

            if(index % perColumn == 0 && index != 0) {
                THIS.list.append(currentDiv);

                currentDiv = $('<div class="col1-4"><ul></ul></div>');
            }

            index = THIS.initListItem(currentDiv, $(this), index);
        });

        this.list.append(currentDiv);

        this.list.find("a").click(function(event) {THIS.listClick(this);return false;});
    }

    this.initListItem = function(parent, item, index) {
        var value = item.attr("value");
        var name = item.html();

        parent.append('<li class="inlinePanel-ul-li"><a class="flink" href="#' + value + '">' + item.html() + "</a></li>");

        if(!value) {
            parent.append('<li class="inlinePanel-ul-li">&nbsp;</li>');
            ++ index;
        }

        return index + 1;
    };

    this.originalElement = this.get(options.elementID);
    this.element = $('<input type="hidden" name="' + this.originalElement.attr("name") + '" value="' + this.originalElement.val() + '" />');
    this.originalElement.replaceWith(this.element);

    this.div = this.get(options.divID);
    this.regex = options.regex;
    this.list = this.get(options.listID);
    this.urlReplacePrefix = options.urlReplacePrefix;
    this.panel = this.get(options.panelID);

    this.div.find("a").click(function(event) {THIS.click(this);return false;});

    this.initList();

    this.div.append('<span class="tg-more"><a href="#" class="flink">ещё<img src="/i/0.gif" width="7" height="4" /></a></span>');

    this.div.children("strong,.tg-more").children("a").click(function() {
        if(THIS.panel.hasClass("inlinePanel-active")) {
            THIS.list.slideUp(200, function() {THIS.panel.toggleClass("inlinePanel-active");});
        } else {
            THIS.panel.toggleClass("inlinePanel-active");
            THIS.list.slideDown(200);
        }
        return false;
    });
}

PanelSelectField.prototype = new Field();



function OptionsField(options) {
    var THIS = this;

    this.handler = this.get(options.handlerID);
    this.list = this.get(options.listID);
    this.panel = this.get(options.panelID);

    this.handler.children("strong").children("a").click(function() {
        if(THIS.panel.hasClass("inlinePanel-active")) {
            THIS.list.slideUp(200, function() {THIS.panel.toggleClass("inlinePanel-active");});
        } else {
            THIS.panel.toggleClass("inlinePanel-active");
            THIS.list.slideDown(200);
        }
        return false;
    });
}

OptionsField.prototype = new Field();



function CarPriceField(priceLID, priceHID, hintID) {
	var THIS = this;

	this.click = function(from, till) {
		this.priceL.attr("value", from);
		if(till > 0) {
			this.priceH.attr("value", till);
		} else {
			this.priceH.attr("value", "");
		}
	}

	this.priceL = this.get(priceLID);
	this.priceH = this.get(priceHID);
	this.hint = this.get(hintID);
	if(!this.priceL || !this.priceH || !this.hint) {
		return;
	}

	this.get(hintID).children("A").css("visibility", "visible");

	$("#price_lt5000").click(function(event) {THIS.click('', 5000);return false;});
	$("#price_5000_10000").click(function(event) {THIS.click(5000, 10000);return false;});
	$("#price_10000_15000").click(function(event) {THIS.click(10000, 15000);return false;});
}

CarPriceField.prototype = new Field();

function RegionListField(options) {
    var THIS = this;

    this.regionField = options.regionField;
    this.element = this.get(options.elementID);
    
    this.element.change(function() {
        if(THIS.element.is(":checked")) {
            var a = THIS.regionField.div.find("a.active");
            if(a.is("a")) {
                THIS.regionField.click(a.get(0));
            }
        }
    });
}

RegionListField.prototype = new Field();
