$(document).ready(function(){
  $(".w3-jshow").show();
  $(".w3-jhide").hide();
  $(".w3-jshowclass").click(function() {
    id = "."+$(this).attr("rel");
    $(id).show();
  });
  $('.w3-jtoggle').click(function() {
    id = $(this).attr('rel');
    $(id).toggle();
  });
  $(".w3-jhideclass").click(function() {
    id = "."+$(this).attr("rel");
    $(id).hide();
  });
  $(".w3-close").live("click",function() {
    $(this).parent().hide();
  });
  $(".w3-jselect").change(function(){
    rel = $(this).attr("rel");
    rel = rel.split("-");
    val = $(this).val();
    if(rel[0] == val) {
      $("."+rel[1]).show();
    }
    else {
      $("."+rel[1]).hide();
    } 
  });
  $('.j-show').click(function() {
    id = $(this).attr('href');
    $('.j-showhide').hide();
    $(id).show();
    $('.j-show').parent('li').removeClass('active');
    $(this).parent('li').addClass('active');
    
    
  });
  
  $('.contact').click(function () {
    rel = $(this).attr('rel');    
    loadmaps(rel);
  });
  
  $('.w3-alert .w3-close').click(function() {
    $(this).parent('.w3-alert').hide();
  });
  
  $('button').click(function() {
    return false;
  });
});
function loadmaps(point) {
  point = point.split(';');
  
  GUnload();
  gload(point[0]+';'+point[1],point[2],point[3]);
} 
$(window).load(function() {
  hash = window.location.hash;
  if(hash != '') {
    $('.j-showhide').hide();
    $("a[href='"+hash+"']").parent().addClass("active");
    $(hash+'.j-showhide').show();
    if($("a[href='"+hash+"']").hasClass('contact')) {
      rel = $("a[href='"+hash+"']").attr('rel');
      loadmaps(rel);
    }
  }
  else {
    $('.j-show:first').parent('li').addClass('active');
    id = $('.j-show:first').attr('href');
    $('.j-showhide').hide();
    $(id).show();
    if($("a[href='"+id+"']").hasClass('contact')) {
      rel = $("a[href='"+id+"']").attr('rel');
      loadmaps(rel);
    }
  }  
});
