jQuery.fn.MyHomeTCH = function (options) {

    settings = jQuery.extend({}, {
        domain: 'www.myhome.ie'
    }, options);

    var forSalePrices = new Array("100,000", "125,000", "150,000", "200,000", "250,000", "300,000", "350,000", "400,000", "450,000", "500,000", "550,000", "600,000", "650,000", "700,000", "800,000", "900,000", "1,000,000", "1,250,000", "1,500,000", "1,750,000", "2,000,000", "2,250,000", "2,500,000", "2,750,000", "3,000,000", "4,000,000", "5,000,000");
    var toRentPrices = new Array("400", "500", "600", "700", "800", "900", "1,000", "1,100", "1,200", "1,300", "1,400", "1,500", "2,000", "3,000", "4,000", "5,000");

    function appendSelectElements(array) {
        var minElement = '<select id="MinPrice" name="MinPrice"><option value="">Min €</option>';
        var maxElement = '<select id="MaxPrice" name="MaxPrice"><option value="">Max €</option>';
        jQuery.each(array, function () {
            minElement += '<option value="' + this.replace(",", "") + '">' + this + '</option>';
            maxElement += '<option value="' + this.replace(",", "") + '">' + this + '</option>';
        });
        minElement += '</select>';
        maxElement += '</select>';

        jQuery("#priceDropdowns")
					.html("")
					.append(minElement)
					.append(maxElement);
    }

    jQuery(document).ready(function () {

        appendSelectElements(forSalePrices);

        jQuery(".tab").click(function () {
            jQuery(".tab").removeClass("active");
            jQuery(this).addClass("active");

            if (jQuery(this).attr("id") == "forSale") {
                jQuery("#myhomeSearchForm").attr("action", "http://www.myhome.ie/residential/search");
                jQuery("#myhomeSearchForm button").addClass("forSale").removeClass("toRent");
                appendSelectElements(forSalePrices);
            } else {
                jQuery("#myhomeSearchForm").attr("action", "http://www.myhome.ie/lettings/search");
                jQuery("#myhomeSearchForm button").addClass("toRent").removeClass("forSale");
                appendSelectElements(toRentPrices);
            }
        });

    });
};
