/**
 * @author Sasha;
 * sashamochalin@ya.ru
 */

//for jCarousel
$(function() {
			$('#mycarousel').jcarousel();
			scroll : 1
		});

//for slide on main
$(function() {

			$("span.more-info").click(function() {
						$("div.info-other").show("slow");
						$(this).hide();
						return false;
					});

			$(".info-other").hide();
			$(".close-info").click(function() {
						$(".more-info").show();
						$(".info-other").hide("slow");
						return false;
					});

		});

// for tabs
$(function() {
			$('dl.search-tabs dt').click(function() {
				$(this).siblings().removeClass('selected').end().next('dd')
						.andSelf().addClass('selected');
			});
		});

//for texts slide (hide)/(show)

$(function() {

			$("span.texts-info").click(function() {
						$(this).next(".info-texts").slideToggle("slow");
						$(this).hide('slow');
						return false;
					});

			$(".info-texts").hide();

			$(".close-texts").click(function() {
						$(".texts-info").show();
						$(this).parents(".info-texts").hide("slow");
						return false;
					});

		});

$(function() {
			$('#i-text h3:first').css('margin-top', '0px');
		});

		
		
// lenta

$(function() {
			$('.i-info table tr td:even').css('color', '#4e4e4e');
		});

		

//profile 

$(function() {

			$(".profile-plans-title").click(function() {
						$(this).toggleClass('opened');
						$(this).next(".profile-plans").slideToggle("slow");
						$(this).toggleClass('closed');
						return false;
					});

			$(".profile-info-title a.info-pseudolink span").click(function() {
						$('.profile-info-title').toggleClass('opened');
						$(".profile-info").slideToggle("slow");
						$('.profile-info-title').toggleClass('closed');
						return false;
					});

			$(".profile-metr").click(function() {
				//$('html, body').animate({scrollTop: $(this).offset().top}, 2000).end();

				$(this).parent().parent().parent().next(".profile-iblock").slideToggle("slow");
				$(this).parent().parent().parent().children().children().find("a.profile-metr").toggleClass('opened');
				$(this).parent().parent().parent().toggleClass('iblock-current')

				return false;

			});
		});

// tablesorter

$(document).ready(function() {
			$('#searchresult').tablesorter({
						widgets : ['zebra']
					});

		});
$(document).ready(function() 
{
	if($('#searchNoBlocksRresult'))
		$('#searchNoBlocksRresult').tablesorter(
				{
					widgets : ['zebra']
				});

});

$(function() {
			$('#searchresult tr td:nth-child(3n)').css('text-align', 'center');
		});

		
		
//for fancybox

$(document).ready(function() {

			$('a.group').fancybox({
						'overlayOpacity' : 0.8,
						'hideOnContentClick' : false
					});

			$('a.phonediv').fancybox({
						'frameWidth' : 500,
						'frameHeight' : 108,
						'overlayOpacity' : 0.8,
						'hideOnContentClick' : false
					});

			$('a.iframe').fancybox({
						'padding' : 0,
						'overlayOpacity' : 0.8,
						'frameWidth' : 450,
						'frameHeight' : 355

					});
		});

function iGadget(){
    return (
        (navigator.platform.indexOf("iPad") != -1) ||
        (navigator.platform.indexOf("iPhone") != -1)
           )
};

$(function(){
    if (iGadget()) {
        $('.search-param input').css('width', '40px');
    }
});

