﻿function RegionsList() {
  $( "#region-list" ).show();
  $( "#region-lists" ).hide();
  $( "#agents-list" ).hide(); 
  $( "#contact_diy-and-fitting-tips" ).parent().hide();
  $( "#contact_contact-details" ).parent().hide();
}

function AgentTypeList( id ) {
  $( "#region-list" ).hide();
  $( "#agents-list" ).hide();  
  $( "#region-lists" ).show();
  $( ".agentTypeList" ).hide();
  $( "#contact_diy-and-fitting-tips" ).parent().show();
  $( "#contact_contact-details" ).parent().show();
  $( id ).show();
}

function Agent( id ) {
  $( "#region-list" ).hide();
  $( "#region-lists" ).hide();
  $( "#agents-list" ).show();  
  $( ".agent" ).hide();
  $( "#contact_diy-and-fitting-tips" ).parent().hide();
  $( "#contact_contact-details" ).parent().hide();
  $( id ).show();
}

$(document).ready(function() {
  var location = document.location.toString();
  
  if( location.match('#') ) {
    var anchorId = location.split('#')[1];
    var id = "#" + anchorId;
    if( anchorId == 'region-list' ) {
      RegionsList();
    } else if ( anchorId.substr( 0, 5 ) == 'Agent' ) {
      Agent( id );
    } else if( anchorId.indexOf( 'agent-list' ) > 0 ) {
      AgentTypeList( id );
    }
  } else {
    RegionsList();
  }
  
  $( ".showAgentTypeList" ).bind('click',function(e){
    var id = $(this).attr("href");
    AgentTypeList( id );
  });
  
  $( ".showRegionsList" ).bind('click',function(e){
    RegionsList();
  });
  
  $( ".showAgent" ).bind('click',function(e){
    var id = $(this).attr("href");
    Agent( id );
  });
});
