$(document).ready(function()	{ 
  /*  menu */
  $("div#menu_top li:last-child").addClass("noborder"); 
  $("div#catalog ul.paging li:last-child").addClass("noborder"); 
  $("div#hp_catalog ul li:last-child").addClass("noborder"); 
  $("div#hp_catalog2 ul li:last-child").addClass("noborder");
        
	/* photogallery */
	$("a[rel^='prettyPhoto']").prettyPhoto({
			theme: 'facebook' 
		});

  /* news*/
   $(".news_info:last-child").addClass("noborder"); 
   $('div.hide').hide();
   $('a.onclick').click(function() {
    $(this).prev().slideToggle('fast');
		if ($(this).html()=="[+]") {
			 $(this).html("[-]");
			 return false;
			 }
		if ($(this).html()=="[-]") $(this).html("[+]");
		return false;
  });
  
/* UI */
/* reg mail */
$("#email").focus(function() {this.value='';	return false;})
$("#name").focus(function() {this.value='';	return false;})
$("#input").focus(function() {this.value='';	return false;})

$("button#cancel_reg_mail").click(function() {window.location.replace("?delete_reg_email=1");})


		
/* basket */
/*
    if ($('#invoceanddelivery').is(':checked')) { $("table#delivery").hide();}
    $('#invoceanddelivery').click(function() {
          $("table#delivery").slideToggle('fast');
      });
  */
/* Google map*/

if ($('div.mapa_ok').length)  initialize_gmap();

/* dropdown*/
$('#dropdown').change(function() {
   window.location = $(this).val();
});

/* kontatky */
  $('div.hide_contact').hide();
 
   if ($('table.contact').length)  initialize();
  
});

  

 function initialize() {
  if ($('div#map_canvas').hasClass("cz")) {var latlng = new google.maps.LatLng(49.8174920, 15.4729620);}
  if ($('div#map_canvas').hasClass("sk")) { var latlng = new google.maps.LatLng(48.618385,19.5);}
    
    var myOptions = {
      zoom: 6,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
    
    
     $('.hide_contact').each(function() {
      var lan = $('.google_lat',this).text();    
      var lng = $('.google_lng',this).text();
      var text =  $('.address',this).html();
      var name =  $('h2',this).text();
     // var image = '/images/firm.png';
      // var shadow = '/images/shadow.png';
      
      var contentString = '<div class="popup" >'+
        '<h1 class="firstHeading">'+name+'</h1>'+
        '<div id="bodyContent">'+
        '<p>'+text+'</p>'+
        '</div>';
      var infowindow = new google.maps.InfoWindow({
        content: contentString

      });
      
       
      var myLatLng =  new google.maps.LatLng(lan,lng);
     
      var marker = new google.maps.Marker({
        position: myLatLng,
        map: map
       // icon: image
       // shadow: shadow
      });
       google.maps.event.addListener(marker, 'click', function() {
         infowindow.open(map,marker);
      })  
       
    });
       
  }





  
 function initialize_gmap() {
    var latlng = new google.maps.LatLng(49.8174920, 15.4729620);
    var myOptions = {
      zoom: 6,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
    
    
    $('.catalog_contact').each(function() {
      var lan = $('.google_lat',this).text();    
      var lng = $('.google_lng',this).text();
      var text =  $('.address',this).html();
      var name =  $('h2.google_name',this).text();
      var image = '/images/home.png';
//      var shadow = '/images/shadow.png';
//        icon: image,
//        shadow: shadow
      
      var contentString = '<div class="popup" >'+
        '<h1 class="firstHeading">'+name+'</h1>'+
        '<div id="bodyContent">'+
        '<p>'+text+'</p>'+
        '</div>';
      var infowindow = new google.maps.InfoWindow({
        content: contentString

      });
      
       
      var myLatLng =  new google.maps.LatLng(lan,lng);
     
      var marker = new google.maps.Marker({
        position: myLatLng,
          icon: image,
        map: map
      });
       google.maps.event.addListener(marker, 'click', function() {
         infowindow.open(map,marker);
      })  
       
    });
       
  }

