$(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' 
		});


 /* grid */
 $("ul.thumb li").hover(function() {
	$(this).find('span').css({visibility: 'visible'});
	$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.css({
			marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
			marginLeft: '-145px',
			top: '50%',
			left: '50%',
			width: '240px', /* Set new width */
			height: '168px', /* Set new height */
			padding: '20px'
		}); /* this value of "200" is the speed of how fast/slow this hover animates */

	} , function() {
	$(this).find('span').css({visibility: 'hidden'});
	$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
	$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.css({
			marginTop: '0', /* Set alignment back to default */
			marginLeft: '0',
			top: '0',
			left: '0',
			width: '140px', /* Set width back to default */
			height: '105px', /* Set height back to default */
			padding: '5px'
		})
});

  /* 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();

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

  

 function initialize() {
    var htmls = []; 
    var to_htmls = []; 
    var from_htmls = []; 
      
    var latlng = new google.maps.LatLng(49.302284, 16.650188);
    var myOptions = {
      zoom: 10,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);

    
    
     $('.info-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/marker.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 mlan = parseFloat($('#lan').text());
    var mlng = parseFloat($('#lng').text());
    var zoom = parseInt($('#zoom').text());
    
    var latlng = new google.maps.LatLng(mlan,mlng);
  
    var myOptions = {
      zoom: zoom,
      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/marker.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);
      })  
       
    });
       
  }



 
 
