﻿$(document).ready(function () {
    $("#moment").change(function () {
        if ($(this).val() == 1) {
            $("#moment1ful2").slideUp("slow");
            $("#moment1ful3").slideUp("slow");
            $("#datemorediv").slideUp("slow")
        }
        if ($(this).val() == 2) {
            $("#moment1ful2").slideDown("slow");
            $("#moment1ful3").slideUp("slow");
            $("#datemorediv").slideUp("slow")
        }
        if ($(this).val() == 3) {
            if ($("#who").val() == 2) {
                $("#zdat").show("fast");
                $("#datemorediv").slideDown("slow");
                $("#moment1ful2").slideUp("slow")
            } else {
                $("#moment1ful2").slideUp("slow");
                $("#moment1ful3").slideDown("slow")
            }
        }
    });
    $("#who").change(function () {
        if ($(this).val() == 1) {
            $("#moment1ful2").slideUp("slow");
            $("#moment1ful3").slideUp("slow");
            $("#datemorediv").slideUp("slow");
            $("#zdat").slideUp("slow");
            $("#moredat").slideDown("slow");
            $("#rezfak").text("Ваш резус-фактор");
            $("#fatdat").text("Дата рождения отца");
            $("#fat2").show("slow");
            $("#fat").slideUp("slow");
            $("#momf").text("Уже беременны");
            $("#rodmat").html("У Ваших родителей <small>(из детей)</small>");
            $("#detmat").text("Есть ли у Вас уже дети: ")
        }
        if ($(this).val() == 2) {
            $("#rezfak").text("Резус-фактор будущей мамы");
            $("#fat2").hide("slow");
            $("#fat").slideDown("slow");
            $("#fatdat").text("Дата рождения будущей мамы");
            $("#moredat").slideUp("slow");
            $("#moment1ful3").slideUp("slow");
            $("#momf").text("Готовитесь стать отцом");
            $("#rodmat").html("У родителей матери ребенка <small>(из детей)</small>");
            $("#detmat").text("Есть ли у матери ребенка уже дети: ")
        }
    });
    $("#datemore").click(function () {
        $("#datemorediv").slideToggle("slow")
    });
    $("#f1").click(function () {
        $("#fat").slideUp("slow")
    });
    $("#f2").click(function () {
        $("#fat").slideDown("slow")
    });

    function c() {
        var d, e;
        d = $("body").width();
        e = $("body").height();
        $(".white").width(d);
        $(".white").height(e);
        $(".full-white").width(d);
        $(".full-white").height(e)
    }
    var b = 1;
    $(".next").click(function () {
        if (b == 3) {
            b = 1
        }
        if (b == 2) {
            c();
            $(".timeline span").stop().animate({
                width: "100%"
            }, 3000);
            $(".rez-top").hide();
            $(".analizing").show();
            $(".rez-bott").hide();
            setTimeout("$('.full-white').show();", 3000);
            setTimeout("$('.workout').fadeIn(1000);", 3000);
            setTimeout("$('.rezult-line span').stop().animate({width: '100%'}, 45000);", 3000);
            setTimeout('$(".get-rezult").fadeIn(300);', 47500);
            setTimeout('$(".rez-top").fadeIn(300);', 47500);
            setTimeout('$(".analizing").hide();', 47500);
            setTimeout('$(".rez-bott").fadeIn(300);', 47500);
            $(".rule-box").hide();
            $(".white").hide();
            $(".pay").hide();
            b = 3;
            var i = $("#day_zachat").val() + "." + $("#month_zachat").val() + "." + $("#year_zachat").val();
            $("#sms_part_2").slideDown("slow");
            var g = $("input[name='resusf']:checked").val();
            var f = $("input[name='moment']:checked").val();
            var l = $("input[name='datemore']:checked").val();
            var k = $("input[name='father']:checked").val();
            var j = "percent";
            var h = "mom";
            $.ajax({
                type: "POST",
                url: "ajax/test.php",
                data: ({
                    act: j,
                    resus: g,
                    moment: f,
                    zachatknow: l,
                    zachat: i,
                    fatherknow: k,
                    test: h
                }),
                success: function (d) {
                    $("#percent").text(d);
                    clearInterval(interval);
                    $("#sms_part_1").hide("slow");
                    $("#sms_part_2").show("slow")
                }
            })
        }
        if (b == 1) {
            if ($("#day_b").val() == "") {
                alert("Введите дату рождения")
            } else {
                $(".timeline span").stop().animate({
                    width: "50%"
                }, 1500);
                b = 2;
                $(".rule-box").hide();
                $(".first-step").slideUp(1000);
                $(".second-step").slideDown(1000);
                $(".form-in form p").first().html("Шаг второй")
            }
        }
    });
    var a = 1;
    $("#country").change(function () {
////////////////////////////////////////////////////////////////////////
        $.getJSON("ajax/get.php/country-text/"+$("#country").val(),
                    function(data){
                        $("#country-text").text(""); 
                        $("#country-text").text(data[0].country_text);
        });
////////////////////////////////////////////////////////////////////////

        $("#number").text($("#country").val());
        if ($(this).val() == "номер") {
            $("#pref").text("текст")
        }
        if ($(this).val() == "6666" || $(this).val() == "9395" || $(this).val() == "1315" || $(this).val() == "91810700" || $(this).val() == "483233" || $(this).val() == "9395" || $(this).val() == "1066109833" || $(this).val() == "9089" || $(this).val() == "4500" || $(this).val() == "97605") {
            $("#pref").text("59257")
        }
        if ($(this).val() == "19995577" || $(this).val() == "930400880" || $(this).val() == "9525" || $(this).val() == "22588" || $(this).val() == "5126" || $(this).val() == "2325" || $(this).val() == "3331" || $(this).val() == "1816" || $(this).val() == "636" || $(this).val() == "81404" || $(this).val() == "690619916" || $(this).val() == "66777" || $(this).val() == "54345" || $(this).val() == "6210" || $(this).val() == "1230" || $(this).val() == "95206" || $(this).val() == "5111" || $(this).val() == "99036" || $(this).val() == "57977" || $(this).val() == "35969" || $(this).val() == "4161" || $(this).val() == "88188" || $(this).val() == "92921" || $(this).val() == "4449" || $(this).val() == "3585" || $(this).val() == "1819" || $(this).val() == "1081" || $(this).val() == "3304" || $(this).val() == "1394" || $(this).val() == "64747" || $(this).val() == "141991" || $(this).val() == "25000" || $(this).val() == "9898" || $(this).val() == "4466" || $(this).val() == "2223" || $(this).val() == "2252" || $(this).val() == "2447" || $(this).val() == "92505" || $(this).val() == "68607" || $(this).val() == "1263" || $(this).val() == "4828" || $(this).val() == "6674" || $(this).val() == "55123" || $(this).val() == "7979" || $(this).val() == "17211" || $(this).val() == "81015" || $(this).val() == "67454" || $(this).val() == "14941" || $(this).val() == "9033399" || $(this).val() == "543" || $(this).val() == "72401" || $(this).val() == "7722" || $(this).val() == "13017" || $(this).val() == "42994" || $(this).val() == "14403" || $(this).val() == "483233") {
            $("#pref").text("76633257")
        }
        if ($(this).val() == "15191" || $(this).val() == "7766" || $(this).val() == "32088" || $(this).val() == "35810") {
            $("#pref").text("dam 10238 147")
        }
    });
    $(".statistic").click(function () {
        $(this).css("z-index", "110");
        if (a % 2 != 0) {
            $(this).css("background", 'url("images/statistic-big.png") 0px 0px no-repeat');
            $(".more-stat").slideDown(500)
        } else {
            $(".more-stat").slideUp(200)
        }
        a++
    });
    $(".stat-close").click(function () {
        if (a % 2 == 0) {
            $(".statistic").css("background", 'url("images/statistic.png") 13px 9px no-repeat');
            $(".more-stat").slideUp(200)
        }
        $(this).css("z-index", "90")
    });
    $(".menu li a").click(function () {
        if ($(this).attr("class", "jqModal")) {}
        $(".menu li").removeClass("current");
        $(this).parent().addClass("current")
    });
    $(".rules").click(function () {
        c();
        $(".workout").hide();
        $(".white").show();
        $(".rule-box").fadeIn(800)
    });
    $(".white").click(function () {
        $(this).hide();
        $(".rule-box").hide()
    });
    $(".get-rezult").click(function () {
        $(".timeline span").width(21);
        $(".rezult-line span").width(1);
        $(this).hide();
        $(".full-white").hide();
        $(".workout").hide();
        $(".rule-box").hide();
        $(".white").hide();
        $(".left").hide();
        $(".right").hide();
        $(".pay").fadeIn(500);
        $(".first-step").show();
        $(".second-step").hide();
        $(".form-in form p").first().html("Шаг первый")
    });
    $(".get-rezult").click(function () {
        $(".content").removeClass("main");
        $(".rule-box").hide();
        $(".white").hide();
        $(".left").hide();
        $(".right").hide();
        $(".pay").fadeIn(500)
    });
    $(".all-op").click(function () {
        $(this).hide();
        $(".all-oppinions").fadeIn(500)
    });
    $(".viewallfacts").click(function () {
        $(this).hide();
        $(".all-facts").fadeIn(500)
    });
    $(".home").hover(function () {
        $(".menu").css("background", 'url("images/menu.png") 0 -32px no-repeat')
    }, function () {
        $(".menu").css("background", 'url("images/menu.png") 0 0 no-repeat')
    });
    $(".rules").hover(function () {
        $(".menu").css("background", 'url("images/menu.png") 0 -64px no-repeat')
    }, function () {
        $(".menu").css("background", 'url("images/menu.png") 0 0 no-repeat')
    });
    $(".oppinion").hover(function () {
        $(".menu").css("background", 'url("images/menu.png") 0 -96px no-repeat')
    }, function () {
        $(".menu").css("background", 'url("images/menu.png") 0 0 no-repeat')
    });
    $(".feedback").hover(function () {
        $(".menu").css("background", 'url("images/menu.png") 0 -128px no-repeat')
    }, function () {
        $(".menu").css("background", 'url("images/menu.png") 0 0 no-repeat')
    });
    $(".facts").hover(function () {
        $(".menu").css("background", 'url("images/menu.png") 0 -160px no-repeat')
    }, function () {
        $(".menu").css("background", 'url("images/menu.png") 0 0 no-repeat')
    });
    $(".statistic").hover(function () {
        if (a % 2 == 0) {
            $(this).css("background", 'url("images/statistic-big.png") 0px 0px no-repeat')
        } else {
            $(".statistic").css("background", 'url("images/statistic.png") 13px -78px no-repeat')
        }
    }, function () {
        if (a % 2 == 0) {
            $(this).css("background", 'url("images/statistic-big.png") 0px 0px no-repeat')
        } else {
            $(".statistic").css("background", 'url("images/statistic.png") 13px 9px no-repeat')
        }
    });
    $(".oppinions li:nth-child(2n) .op-tr").css("display", "block");
    $(".oppinions li:nth-child(2n) .op-tl").css("display", "none");
    $(".oppinions li:nth-child(2n) h2").css("text-align", "right");
    $(".all-oppinions li:nth-child(2n) .op-tr").css("display", "block");
    $(".all-oppinions li:nth-child(2n) .op-tl").css("display", "none");
    $(".all-oppinions li:nth-child(2n) h2").css("text-align", "right");
    $(".fact-list li:nth-child(2n) img").css("float", "right");
    $(".fact-list li:nth-child(2n) img").css("margin", "0 0 18px 22px");
    $(".all-facts li:nth-child(2n) img").css("float", "right");
    $(".all-facts li:nth-child(2n) img").css("margin", "0 0 18px 22px");
    $(".menu li:nth-child(1) a").css("text-shadow", "#606d75 0px -1px 2px");
    $(".menu li:nth-child(2) a").css("text-shadow", "#be9cba 0px -1px 2px");
    $(".menu li:nth-child(3) a").css("text-shadow", "#75ba32 0px -1px 2px");
    $(".menu li:nth-child(4) a").css("text-shadow", "#36a7c3 0px -1px 2px");
    $(".menu li:nth-child(5) a").css("text-shadow", "#ed57a5 0px -1px 2px")
});

function sendmess(f, e, h, g) {
    $(".feed").load("index.php?act=send", {
        name: f.value,
        mail: e.value,
        kak: h.value,
        mess: g.value
    });
    alert("Отправка сообщения");
    return false
};

