// JavaScript Document
Cufon.replace('.title');

$(function () {

    var days = 1;
    var month = 3;
    var year = 2012;
    var hours = 9;
    var minutes = 00;

    $("#fliptimer").fliptimer({
        year: year,
        month: month,
        days: days,
        hours: hours,
        minutes: minutes
    });
    if ($.browser.msie && $.browser.version == 7) {
        $("#tabs>div:first").show();
    }
    var index = 0,
        temp = '';
    $("#tab-controls ul li a").click(function (event) {
        if ($(this).parent("li").index("#tab-controls ul li") == index) return;

        index = $(this).parent("li").index("#tab-controls ul li");

        $("#tabs>div").fadeOut('fast');
        $("#tabs>div:eq(" + index + ")").fadeIn('fast');

        $("#tab-controls ul li").not($(this).parent("li")).removeClass("active-tab").addClass("default-tab");
        $(this).parent("li").addClass("active-tab");

        event.preventDefault();

    });

    $("input[type=text],textarea").bind({

        focusin: function () {

            temp = $(this).val();
            $(this).val('');

        },
        focusout: function () {

            if ($(this).val() == '') {
                $(this).val(temp);
            }
        }

    });


    $("#contact_submit").click(function (event) {
        flag = false;


        $("#contact_form").find("input[type=text],textarea").each(function () {
            if ($(this).val() == "Name" || $(this).val() == "Email" || $(this).val() == "Message") {
                $(this).css("border", "1px solid  #cccccc");
                flag = true;
            } else {
                $(this).css("border", "1px solid #dddddd");

            }
        });
        if (flag == true) {
            event.preventDefault();
            return;
        }


        $("#contact_submit").attr("value", "Sending");
        $.post("contact.php", {
            email: $("#email").val(),
            name: $("#name").val(),
            message: $("#msg").val(),
            choice: "contact"
        }, function (data) {

            if (data == "success") $("#contact_submit").attr("value", "Sent !");
            else $("#contact_submit").attr("value", "Not Sent !");
        });


        event.preventDefault();

    });


    $("#in_submit").click(function (event) {

        if ($("#inform_email").val() == "Εισάγετε το email σας και μείνετε συντονισμένοι!") {

            $("#inform_email").css("border", "1px solid  #cccccc");
            event.preventDefault();
            return;
        }

    });


    $("#social li a").hover(function () {

        $(this).stop(true, true).animate({
            bottom: 3
        }, 200);


    }, function () {

        $(this).stop(true, true).animate({
            bottom: 0
        }, 200);

    });

});
