$(document).ready(function(){


	checkHeight();
	
	//checkVert();
	
  $('div.photo').hover(function() {
		$(this).find('div.zoom').show();
  }, function() {
		$(this).find('div.zoom').hide();    
  });
  
  /*
	$('a.zoom').click(function(){
		$(this).siblings('div.zoom').show();
		return false;
	});
	
	$('div.zoom').click(function(){
		$(this).hide();
		return false;
	});
	*/
  
	$('a.lightbox').fancybox({
		type: 'iframe',
		width: 405,
		height: 250,
		onComplete: function(){
			$.fancybox.resize();
		}
	});
	
  /*
	$('#slider').jcarousel({
		auto: 2,
		wrap: 'circular',
		initCallback: carousel_initCallback
	});
  
  */

	////////////////////////////////////////////

    var s  = 'Meklēt';
    var es = 'Search';
    var er = 'Искать';

    $('.search form input[type="text"]').focus(function() {
        if($(this).attr('value') == s) {
            s = $(this).attr('value');
            $(this).attr('value', '');
        }
        
        else if($(this).attr('value') == es) {
            s = $(this).attr('value');
            $(this).attr('value', '');
        }

        else if($(this).attr('value') == er) {
            s = $(this).attr('value');
            $(this).attr('value', '');
        }
    }).blur(function() {
        if($(this).attr('value') == '') { 
            $(this).attr('value', s);
        }
    });
	
});

function checkVert() {
	$('a.zoom img').each(function() {
		$(this).hide();
    if($.browser.msie) {
      img_h = $(this).height();
      img_w = $(this).width();
      if(img_w < img_h) {
        $(this).height(173);
        $(this).width(69);
        $(this).parent().parent().addClass('vert');
      }
      $(this).show();    
    } else {
      $(this).load(function() {
        img_h = $(this).height();
        img_w = $(this).width();
        if(img_w < img_h) {
          new_w = 173*img_w/img_h;
          $(this).height(173);
          $(this).width(new_w);
          $(this).parent().parent().addClass('vert');
        }
        $(this).show();
      });
    }
	});
}

function checkHeight() {
	doc_height = $(document).height();
	wrap_height = $('#container').height();
	cont_height = $('#content').height();
	diff_height = doc_height - wrap_height;
	if(diff_height > 0) {
		//$('#content').height(cont_height+diff_height);
    }
}

function carousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	
	jQuery('#carousel-next').bind('click', function() {
	        carousel.next();
	        return false;
	    });

    jQuery('#carousel-prev').bind('click', function() {
		carousel.prev();
        return false;
    });

	jQuery('#carousel-next').hover(
		function() {
			//alert(carousel.animation);
			var carousel = jQuery('#slider').data('jcarousel');
			//carousel.animation('fast');
			//alert(carousel.interval);
		},
		function() {
			//alert('off');
			var carousel = jQuery('#slider').data('jcarousel');
			//carousel.animation('slow');
			//carousel.interval(2000);
		}
	);


}

