$(document).ready(function() {
    Cufon.replace('#navi ul li a', {hover: true});
    Cufon.replace('#copyright');
    Cufon.replace('a#open');
    Cufon.replace('a#close');
    Cufon.replace('#footer_kontakt');
    Cufon.replace('.title');
    Cufon.replace('#thumbs ul li a.thumb');
    Cufon.replace('.zeile h1');
    Cufon.replace('.sub_typo3');

    $(".news_anm").colorbox({inline:true, href:"#form", opacity:"0.8", overlayClose:true});
    $(".Typo3leftLink").colorbox({inline:true, href:"#form2", opacity:"0.8", overlayClose:true});
    $(".Typo3RightLink").colorbox({inline:true, href:"#form3", opacity:"0.8", overlayClose:true});
    $("#t3-cta").colorbox({inline:true, href:"#form4", opacity:"0.8", overlayClose:true});
    $("#t3-cta-sec").colorbox({inline:true, href:"#form4", opacity:"0.8", overlayClose:true});
	$("#typo3-cta-tert").colorbox({inline:true, href:"#form4", opacity:"0.8", overlayClose:true});
	
    $('#rueck_check').click( function(){
        if ($('#rueck_check').attr("checked")) {
            $('.zeile.ch_tel').stop(false, true).slideDown('slow', function() {
                    // Animation complete.
            });
        }
        else {
            $('.zeile.ch_tel').stop(false, true).slideUp('slow', function() {
                    // Animation complete.
            });
        }
    });

    $('.sub_news').click( function(){
        submitRequest();
    });

    $('.sub_rueck').click( function(){
        submitRequest2();
    });

    $('.sub_ang').click( function(){
        submitRequest3();
    });
    
    $('.sub_typo3').click( function(){
        submitRequest4();
    });
    
    $('.leistungen_box').hover(
      function () {
          $(this).next('h4').children('a').css({'background-position':'0 -10px', 'color':'#333333'});
      },
      function () {
          //$(this).next('h4').children('a').css();
          $(this).next('h4').children('a').removeAttr('style');
      }
    );

    $('.showbox h4 a').hover(
      function () {
            $(this).parent('h4').prev('.leistungen_box').css({'background-position':'0 -60px'});
      },
      function () {
            $(this).parent('h4').prev('.leistungen_box').removeAttr('style');
      }
    );

    $('.hidden_box').hover(
      function () {
            $(this).next('h4').children('a').css({'background-position':'0 -10px', 'color':'#333333'});
      },
      function () {
            $(this).next('h4').children('a').removeAttr('style');
      }
    );

});


function submitRequest(){
    var error = '';

    if (($('#vorname').val() == 'Vorname'))
    {
        $("#fehler_vorname").fadeIn();
        $('#vorname').css('color', '#880d00');
        error += 'f1';
    }
    else
        $("#fehler_vorname").fadeOut();

    if (($('#name').val() == 'Name'))
    {
        $("#fehler_name").fadeIn();
        $('#name').css('color', '#880d00');
        error += 'f2';
    }
    else
        $("#fehler_name").fadeOut();

    if (($('#email').val() == 'Email'))
    {
        $("#fehler_email").fadeIn();
        $('#email').css('color', '#880d00');
        error += 'f3';
    }
    else
        $("#fehler_email").fadeOut();

    if(error == '')
    {
        $.ajax({
                type: "POST",
                data: {submit:"submit", abs_vorname: $('#vorname').val(), abs_name: $('#name').val(), abs_email: $('#email').val() },
                url: "submit.php",
                /*beforeSend: function(){
                    $(".loading").fadeIn();
                },*/
                success: function(data){
                    if(data == 'emailnv')
                    {
                        $("#fehler_email").fadeIn();
                        $('#email').css('color', '#880d00');
                    }
                    else
                    {
                       //alert("Formular erfolgreich abgesendet");
                       $("#form_news_anm").hide();
                       $("#form_erf").fadeIn();
                    }
                }
        });
    }

    return true;
}

function submitRequest2(){
    var error = '';

    if (($('#vorname2').val() == 'Vorname'))
    {
        $("#fehler_vorname2").fadeIn();
        $('#vorname2').css('color', '#880d00');
        error += 'f1';
    }
    else
        $("#fehler_vorname2").fadeOut();

    if (($('#name2').val() == 'Name'))
    {
        $("#fehler_name2").fadeIn();
        $('#name2').css('color', '#880d00');
        error += 'f2';
    }
    else
        $("#fehler_name2").fadeOut();

    if (($('#telefon').val() == 'Telefon'))
    {
        $("#fehler_tel").fadeIn();
        $('#telefon').css('color', '#880d00');
        error += 'f3';
    }
    else
        $("#fehler_tel").fadeOut();

    if(error == '')
    {
        $.ajax({
                type: "POST",
                data: {submit:"submit", abs_vorname: $('#vorname2').val(), abs_name: $('#name2').val(), abs_telefon: $('#telefon').val() },
                url: "rueckruf.php",
                success: function(data){
                       //alert("Formular erfolgreich abgesendet");
                       $("#form_rueckr").hide();
                       $("#form_erf2").fadeIn();
                }
        });
    }

    return true;
}

function submitRequest3(){
    var error = '';
    var anrede = '';

    if ($("input[name='Anrede'][value='1']").attr("checked","checked")){
        anrede = 'Frau';
    }
    else {
        anrede = 'Herr';
    }

    /* ANREDE */
    if((typeof $("input[name='Anrede']:checked").val() != 'undefined') == false) {
        $("#fehler_01").fadeIn();
        $('#radiobox p.z_text').css('color', '#880d00');
        error += 'f1';
    }
    else {
        $("#fehler_01").fadeOut();
        $('#radiobox p.z_text').css('color', '#979797');
    }

    /* NAME */
    if (($('#name3').val() == 'Name'))
    {
        $("#fehler_02").fadeIn();
        $('#name3').css('color', '#880d00');
        error += 'f2';
    }
    else
        $("#fehler_02").fadeOut();

    /* EMAIL */
    if (($('#email2').val() == 'Email'))
    {
        $("#fehler_04").fadeIn();
        $('#email2').css('color', '#880d00');
        error += 'f4';
    }
    else
        $("#fehler_04").fadeOut();

    /* TEXTFELD */
    if (($('#ang_text').val() == 'Ihre Nachricht'))
    {
        $("#fehler_05").fadeIn();
        $('#ang_text').css('color', '#880d00');
        error += 'f5';
    }
    else
        $("#fehler_05").fadeOut();

    /* TELEFON */
    if (($('#telefon2').val() == 'Telefon') && ($('#rueck_check').attr("checked") == true))
    {
        $("#fehler_03").fadeIn();
        $('#telefon2').css('color', '#880d00');
        error += 'f3';
    }
    else
        $("#fehler_03").fadeOut();

    if(error == '')
    {
        $.ajax({
                type: "POST",
                data: {submit:"submit", abs_anrede:anrede, abs_name:$('#name3').val(), abs_email: $('#email2').val(), abs_text: $('#ang_text').val(), abs_telefon: $('#telefon2').val() },
                url: "kontakt.php",
                success: function(data){
                    if(data == 'emailnok')
                    {
                        $("#fehler_04").fadeIn();
                        $('#email2').css('color', '#880d00');
                    }
                    else
                    {
                       //alert("Formular erfolgreich abgesendet");
                       $("#form_ang").hide();
                       $("#form_erf3").fadeIn();
                    }
                }
        });
    }

    return true;
}


function submitRequest4(){

    var error = '';

    if ($('#t3_text').val() == 'Ihre Nachricht')
    {
        $("#fehler_t3_text").fadeIn();
        $('#t3_text').css('color', '#880d00');
        error += 'f1';
    }
    else
        $("#fehler_t3_text").fadeOut();

    if ( $('#t3_email').val() == 'Email')
    {
        $("#fehler_t3_email").fadeIn();
        $('#t3_email').css('color', '#880d00');
        error += 'f2';
    }
    else
        $("#fehler_t3_email").fadeOut();

    if(error == '')
    {
 
        $.ajax({
                type: "POST",
                data: {submit:"submit", t3_text: $('#t3_text').val(), t3_email: $('#t3_email').val() },
                url: "t3_submit.php",
                /*beforeSend: function(){
                    $(".loading").fadeIn();
                },*/
                success: function(data){
                    if(data == 'emailnv')
                    {
                        $("#fehler_t3_email").fadeIn();
                        $('#t3_email').css('color', '#880d00');
                    }
                    else
                    {
                       //alert("Formular erfolgreich abgesendet");
                       $("#form_typo3").hide();
                       $(".t3_head").hide();
                       $("#form_erf").fadeIn();
                    }
                }
        });
    }

    return true;
}



$('#b-beratung').click(function () {
	$('.bubble').css({'display': 'none'});
	$('.beratung').fadeIn();
});
$('.beratung').click(function () {
	$(this).fadeOut();
});

$('#b-design').click(function () {
	$('.bubble').css({'display': 'none'});
	$('.design').fadeIn();
});
$('.design').click(function () {
	$(this).fadeOut();
});

$('#b-entwicklung').click(function () {
	$('.bubble').css({'display': 'none'});
	$('.entwicklung').fadeIn();
});
$('.entwicklung').click(function () {
	$(this).fadeOut();
});

$('#b-individual').click(function () {
	$('.bubble').css({'display': 'none'});
	$('.individual').fadeIn();
});
$('.individual').click(function () {
	$(this).fadeOut();
});

$('#b-software').click(function () {
	$('.bubble').css({'display': 'none'});
	$('.software').fadeIn();
});
$('.software').click(function () {
	$(this).fadeOut();
});

$('#b-hosting').click(function () {
	$('.bubble').css({'display': 'none'});
	$('.hosting').fadeIn();
});
$('.hosting').click(function () {
	$(this).fadeOut();
});

$('#b-support').click(function () {
	$('.bubble').css({'display': 'none'});
	$('.support').fadeIn();
});
$('.support').click(function () {
	$(this).fadeOut();
});


