$(document).ready(function() {
  if ($('.lightbox').length>0)
  $('.lightbox').lightbox();

	//$.preloadAllImages();
	
	$('#checkboxProvocari input[type=checkbox]').prettyCheckboxes();
	$('#myselectbox').selectbox({debug: true});  
	
	$('.testimonialSelectPage').mouseover(function(){
		$(this).prev().show();	
	})
	$('.testimonialSelectPage').mouseout(function(){
		$(this).prev().hide();	
	})
	$('.testimonialSelectPage').click(function(){
		$('.testimonialSelectPage').removeClass('curent');
		$(this).addClass('curent');
		$('.itemTestimonial').filter(':visible').hide();
		$('#'+$(this).attr('rel')).show();
	})
  $('.autoInfo').click(function(){
    $(this).val('');
  })
  
  $('span.plus a').click(function(){
      $('#center *').each(function(index,item){
          var currentFontSizeNum = parseFloat($(item).css('font-size'), 10);
          var newFontSize = currentFontSizeNum*1.2;
          $(item).css('font-size',newFontSize);
      })
  
  })
  $('span.minus a').click(function(){
      $('#center *').each(function(index,item){
          var currentFontSizeNum = parseFloat($(item).css('font-size'), 10);
          var newFontSize = currentFontSizeNum*0.8;
          $(item).css('font-size',newFontSize);
      })
  
  })
  $('span.print a').click(function(){
      window.print();
  
  })
  $('a.sus').click(function(){
      window.scrollTo(0,0);
  
  })
  
  $('.metainfo').closest('li').mouseover(function(){
		$(this).find('.metainfo').show();
  })
  $('.metainfo').closest('li').mouseout(function(){
		$(this).find('.metainfo').hide();
  })
  
  $('._readMore').click(function(){
	  $(this).closest('p').hide();
	  $(this).closest('p').next().show();
  	  $(this).closest('div.bg').css('height','auto');
	  $(this).closest('div.item').css('height','auto');
	 })
  $('._readMoreLeft').click(function(){
	  $(this).closest('p').hide();
	  $(this).closest('p').next().show();
//  	  $(this).closest('div.bg').css('height','auto');
//	  $(this).closest('div.item').css('height','auto');
	 })
  
  $('.openFancyWindow').click(function(){
      var windowHeight=$(window).height();
      var windowWidth=$(window).width();
      cheight=$('.windowFoto').height();
      cwidth=$('.windowFoto').width();
      
      boxTop=parseInt(windowHeight/2)-parseInt(cheight/2);  
      if (boxTop<=5) boxTop=5;
      boxLeft=parseInt(windowWidth/2)-parseInt(cwidth/2);
      if (boxLeft<=5) boxLeft=5;
      $('.windowFoto').css({left:boxLeft,top:boxTop});
     $('#fancy_overlay').fadeIn();
     $('.windowFoto').fadeIn();
  })
  $('#fancy_overlay_close').click(function(){ 
     $('#fancy_overlay').fadeOut();
     $('.windowFoto').fadeOut();
  
  })
  $('#fancy_overlay').click(function(){ 
     $('#fancy_overlay').fadeOut();
     $('.windowFoto').fadeOut();
  })
  
  
  $('._selectTestimonialImage').click(function(){
	$('._testSelectedImage').removeClass('curent');
	i=$('._testSelectedImage').index($($(this).closest('li')));
	  $($(this).closest('li')).addClass('curent');
	  $('._testSelectedNumber').removeClass('curent');
	  $($('._testSelectedNumber')[i]).addClass('curent');
	  $($('._testContent').hide()[i]).show();
	})
  $('._selectTestimonialNumber').click(function(){
	$('._testSelectedNumber').removeClass('curent');
	i=$('._testSelectedNumber').index($($(this).closest('li')));
	  $($(this).closest('li')).addClass('curent');
	  $('._testSelectedImage').removeClass('curent');
	  $($('._testSelectedImage')[i]).addClass('curent');
	  $($('._testContent').hide()[i]).show();
	})
  
  $('._selectTestSidebar').click(function(){
	 	$('._myTestA1').hide();
		$('._myTestA2').hide();
		$('._selectTestSidebar').removeClass('curent');
		i=$('._selectTestSidebar').index($(this));
		$($('._myTestA1')[i]).show();
		$($('._myTestA2')[i]).show();
		$(this).addClass('curent');
		
		
	  
	 })
  
  
});

