$(document).ready(function()	{ 
  /*  menu */
  $("div#menu_top li:last-child").addClass("noborder"); 
  $("div#menu li:last-child").addClass("nopadding"); 
  $("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");

/* tabs */
$("#tabs").tabs(
  {
			event: "mouseover"
		}
);
        
	/* 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;
  });
  
  
  /* cycle */
  
   $('#cycle').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	}); 
	
	/* Forms */
	
	 $("#form1").change(function () {	   location.href = $(this).val();	 });
	 $("#form2").change(function () {	   location.href = $(this).val();	 });
	 $("#form3").change(function () {	   location.href = $(this).val();	 });
	 
	 
	
/* 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");})

/* intro banner */
$("#dialog").dialog({
			bgiframe: true,
			modal: true,
			width: 500,
			height:700,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		});

		
/* 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 ($('table.contact').length)  initialize();
  
});

  

 function initialize() {
    var latlng = new google.maps.LatLng(49.8174920, 15.4729620);
    var myOptions = {
      zoom: 7,
      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 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/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);
      })  
       
    });
       
  }

