var list_height = 0;
var list_height = 0;
var list_height = 0;
var menu1_height = 0;

$(document).ready(function(){
    $(".list3 .body").each(function(n,element){
        if(parseInt($(element).height()) > list_height) {
            list_height = parseInt($(element).height());
        }
    });

    $(".list3 .body").height(list_height);

    $(".menu1 .body").each(function(n,element){
        if(parseInt($(element).height()) > menu1_height) {
            menu1_height = parseInt($(element).height());
        }
    });

    $(".menu1 .body").height(menu1_height);
    
    ww = $(window).width();
    
    if(ww > 1200) {
   	 ww = 1200;
    }
    
	
	$('.fmini').click(function() {
		var elem = $(this).parent().parent().parent().parent().parent();
		var src = $(this).attr('src');
		src = src.replace('_b', '_a');
		var fmacro = $('.body3').children('.fmacro')[$('.review').index(elem)];
		$(fmacro).attr('src', src);
	});
	
    w1 = (parseInt(ww/185));
    w2 = (parseInt((ww-570)/170));
    w3 = (parseInt((ww-570)/90));

	$("#partners .body .body_2").scrollable({size: w1});
    
    $("#content4 .body7 .body_2").scrollable({size: w3});
    $("#content4 .body5 .body_2").scrollable({size: w3});
    
    $("#item3 .body5 .body_2").scrollable({size: w2});

    $("#partners .item img").hover(
		
        function() {
            $(this).attr("src", str_replace(".jpg", "_hover.jpg",$(this).attr("src")));
        }, 
		function() {
            $(this).attr("src", str_replace("_hover.jpg", ".jpg",$(this).attr("src")));
        }
    );

    $("#partners .item img").hover(
        function() {
            $(this).parent().parent().find(".hint").css("display", "block");
        }, function() {
            $(this).parent().parent().find(".hint").css("display", "none");
        }
    );

    $("#partners2 .item img").hover(
        function() {
            $(this).attr("src", str_replace(".jpg", "_hover.jpg",$(this).attr("src")));
        }, 
		function() {
            $(this).attr("src", str_replace("_hover.jpg", ".jpg",$(this).attr("src")));
        }
    );

    $("#partners2 .item").hover(
        function() {
            $(this).find(".hint").css("display", "block");
        }, function() {
            $(this).find(".hint").css("display", "none");
        }
    );

    $("#letters .line ul li a").hover(
        function() {
            $(this).parent().find(".popup2").css("display", "block");
        }, function() {
            $(this).parent().find(".popup2").css("display", "none");
        }
    );

    $("#types .body .line .item ").hover(
        function() {
            $(this).find(".popup2").css("display", "block");
        }, function() {
            $(this).find(".popup2").css("display", "none");
        }
    );

    $(".reg_pop").click(
    	function() {
    		$("#popup1").fadeIn();
    	}
    )
    
    $("#sos").click(
    	function() {
    		$("#popup1").fadeIn();
    	}
    )
    
    $("#kontrol1").click(
    	function() {
    		$("#kontrol").fadeIn();
    	}
    )


	
	
	$(".auth_pop").click(
    	function() {
    		$("#authform").fadeIn();
    	}
    )

    $("#authform .close").click(
    	function() {
    		$("#authform").fadeOut();
    	}
    )
	
    $("#popup1 .close").click(
    	function() {
    		$("#popup1").fadeOut();
    	}
    )
    $("#kontrol .close").click(
    	function() {
    		$("#kontrol").fadeOut();
    	}
    )

	$(".select1 .popup .popup_1 .popup_6 ul li span").click(
    	function() {
    		text = $(this).html();
			$(this).parent().parent().parent().parent()
				.parent().parent().parent().parent().parent().find(".current").html(text);

			$(this).parent().parent().parent().parent()
				.parent().parent().parent().parent().parent().find(".popup").css("visibility", "hidden");
    	}
    )



	$(".select1 .select_3").click(
    	function() {
			if($(this).parent().parent().parent().find(".popup").css("visibility") == "hidden") {
				$(this).parent().parent().parent().find(".popup").css("visibility", "visible");
			} else {
				$(this).parent().parent().parent().find(".popup").css("visibility", "hidden");
			}

    	}
    )

    $('#aphavet .aphavet_1').jScrollPane();
	$(".select1 .popup .popup_6").jScrollPane();
	
	var isMSIE = /*@cc_on!@*/false;

	if(isMSIE == false) {
		$("#opros .result table .item2 .item2_2").corner();
		$(".list4 .body").corner("bottom 3px");
    }
    
    
    $("#comments .title .showCom").click(
    	function() {
    		$(this).parent().parent().parent().find(".body").slideToggle();
    	}
    );
    
    $("#add_comment h2").click(
    	function() {
    		$(this).parent().find(".body").slideToggle();
    	}
    );
    
    partner_height = 50;
    var top;
    $("#partners .body .body_2 .items .item img").each(

		function(intIndex){
			top = (partner_height/2)-($(this).height()/2);
			$(this).css("top", top+"px");
		}
	);

});

function str_replace(search, replace, subject) {
    return subject.split(search).join(replace);
}

