$(document).ready(function()	{ 

  /*  menu */  
   $("ul#menu_top_ul li:last-child a").addClass("noborder"); 
   $("div#menu_left li:last-child").addClass("noborder"); 
   $("div#menu_bottom li:last-child").addClass("noborder"); 
   
   /* set font */
$("#setfont1").click(function() {

     $(".content_middle").removeClass('fontsize2');
     $(".content_middle").addClass('fontsize1');
     
  	});
$("#setfont2").click(function() {
     $(".content_middle").removeClass('fontsize1');
     $(".content_middle").addClass('fontsize2'); 	
  	});
  	
   // resize reload;
/*$(window).bind('resize',function(){
     window.location.href = window.location.href;
});

  */
  /* cycle */
//  $('#cycle').cycle({		fx: 'fade'	});
//  $('#news-cycle').cycle({		fx: 'fade'	});
  /*  menu */
//  $("div#menu_top li:last-child").addClass("noborder"); 
        
	/* photogallery */
	$("a[rel^='prettyPhoto']").prettyPhoto({
			theme: 'facebook',
      overlay_gallery: false 
		});
  /* diskuze */
  $('a.onclickdown').click(function() {
    $('a.onclickdown').next().slideUp('fast');
    if ($(this).next().is(":hidden")) { $(this).next().slideDown('fast'); }
    return false;
    
  });
  /* 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;
  });
 /* notice   */

 $("#dialog").dialog({
			height: 120,
			modal: true,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		});
	/* print*/         
  	$("a#print_button").click(function() {
      window.print(); 	
  	});
  		$("a#tisknout-stranku").click(function() {
      window.print(); 	
  	});	
/* catalog */
 /*  $('a.click_show').click(function() {
      $(this).next().slideToggle('fast');
    });
   */
/* 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 ($('table.contact').length)  initialize();
*/  
   
/* HP photo cycle 
//Set Default State of each portfolio piece
	$(".paging").show();
	$(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = $(".window").width();
	var imageSum = $(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	$(".image_reel").css({'width' : imageReelWidth});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = $active.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

		$(".paging a").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		$(".image_reel").animate({ 
			left: -image_reelPosition
		}, 500 );
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.paging a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 4000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	//On Hover
	$(".image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
	$(".paging a").click(function() {	
		$active = $(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		return false; //Prevent browser jump to link anchor
	});	 
*/  
});


	  
  
  
/* Google maps*/
 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);
      })  
       
    });
       
  }

