var class_locations = function(){

    var obj = this;

//  ----------------------------------------------------------------------------
    this.getCities = function( nofilter ){

        $.post(
            'data.php',
            {
                action: "getCities",
                shire: $( '#shires' ).val()
            },
            function(data){

                $( '#cities' ).html( data );

				if( !nofilter )
                obj.filter();
            }
        )
    }
//  ----------------------------------------------------------------------------
    this.getShires = function(){
        $.post(
            'data.php',
            {
                action: "getShires"
            },
            function(data){

                $( '#shires' ).html( data );
            }
        )
    }

//  ----------------------------------------------------------------------------
    this.filter = function( page ){

		 $( '#index-content' ).html( '' );
        // $( '#content' ).hide();
        
        $.post(
            'data.php',
            {
                action: "getLocations",
                shire: $( '#shires' ).val(),
                city: $( '#cities' ).val(),
                page: page
            },
            function(data){

                $( '#content' ).html( data );
                // $( '#content' ).show( 'slow' );
            }
        )
    }
}

var locations = new class_locations();
locations.getShires();
locations.getCities( true );

