$(document).ready(function()
{
    
    /* CUBER */
	
    $("#wuerfel").css({"display":"none"});
    $(".total").hide();
    $('.p_box a').click(function(event) {
        event.preventDefault();
        $(".total").fadeTo("middle", 0);
        $(".p_box").hide();
        $("#pagination").hide();
        $(".inner").css({"border":"none"});
        $(".p_container").hide();
        $('iframe#wuerfel').attr('src', $(this).attr("href"));
        $("#wuerfel").show();
        $(".inner").css({"background":"transparent"});
        $('.total').click(function() { // <-- 100% x 100% div
            $(".total").fadeTo("middle", 0);
            $("#pagination").fadeTo("middle", 1);
            $(".p_container").fadeTo("middle", 1);
            $(".p_box").fadeTo("middle", 1);
            $("#wuerfel").hide();
            $("#wuerfel").css({"display":"none"});
            $("#totalx").hide();
            $("#totalxw").hide();
            $(".inner").css({"background":"#ffffff"});
            $(".inner").css({"border":"1px solid #cecece"});
        });
    });
    
    
    /* EFFECT FOR PORTFOLIO IMAGE HOVER */
    
    $('.p_box a').fadeTo("fast", 1);
    $('.p_box a img').mouseover(function () {
        $(this).fadeTo("fast", 0.8);
        $(this).attr("src", $(this).attr("rel"));
        $(this).attr("rel", $(this).attr("src"));
        $(this).fadeTo("fast", 1)
    });
    $('.p_box a img').mouseout(function () {
        $(this).attr("src", $(this).attr("id"));
    });
    
    
    /* SUBNAV */
    
    $('#subnavigation a').fadeTo("fast", 1);
    
    $('#subnavigation a').mouseover(function () {
        $(this).fadeTo("fast", 1);
        $(this).fadeTo("fast", 1);
    });
    
    $('#subnavigation a').mouseout(function () {
        $(this).fadeTo("fast", 1);
    });
    
    /* MAINPAGE (ENTRYPAGE) */
    
    var over = 1;
    var out = 0;
    var overslide = "fast";
    var outslide = "fast";
    
    $('#printdesignbt').mouseover(function () { $('#printdesign').fadeTo(overslide, over); });
    $('#printdesignbt').mouseout(function () { $('#printdesign').fadeTo(outslide, out); });
    
    $('#agenturleistungenbt').mouseover(function () { $('#agenturleistungen').fadeTo(overslide, over); });
    $('#agenturleistungenbt').mouseout(function () { $('#agenturleistungen').fadeTo(outslide, out); });
    
    $('#kontaktbt').mouseover(function () { $('#kontakt').fadeTo(overslide, over); });
    $('#kontaktbt').mouseout(function () { $('#kontakt').fadeTo(outslide, out); });
    
    $('#referenzenbt').mouseover(function () { $('#referenzenst').fadeTo(overslide, over); });
    $('#referenzenbt').mouseout(function () { $('#referenzenst').fadeTo(outslide, out); });
    
    $('#standortebt').mouseover(function () { $('#standorte').fadeTo(overslide, over); });
    $('#standortebt').mouseout(function () { $('#standorte').fadeTo(outslide, out); });
    
    $('#teambt').mouseover(function () { $('#team').fadeTo(overslide, over); });
    $('#teambt').mouseout(function () { $('#team').fadeTo(outslide, out); });
    
    $('#webdesignbt').mouseover(function () { $('#webdesign').fadeTo(overslide, over); });
    $('#webdesignbt').mouseout(function () { $('#webdesign').fadeTo(outslide, out); });
    
    $('#blogbt').mouseover(function () { $('#blog').fadeTo(overslide, over); });
    $('#blogbt').mouseout(function () { $('#blog').fadeTo(outslide, out); });
	
	
    /* MAINNAV */
	
    $('#navigation a .active').addClass("looser");
	
    $('#navigation a img').mouseover(function () {
		var rel = $(this).attr("rel");
		$(this).fadeTo("fast", 0.8);
		if(rel=="") { rel = $(this).attr("src"); } else { rel = rel + "-hover.jpg"; }
        $(this).attr("src", rel);
        $(this).fadeTo("slow", 1);
    });
	
    $('#navigation a img').mouseout(function () {
		var rel = $(this).attr("rel");
		if(rel=="") { rel = $(this).attr("src"); } else { rel = rel + ".jpg"; }
        $(this).attr("src", rel);
    });
    
    
    /* PAGINATION PORTFOLIO */
    
    var prev = 0;
    var next = 1;
    var aktuell = 0;
    
    $('#prev').hide();
    if(next==maximal) { $('#next').hide(); }
    
    $('#portfolio li').fadeTo("fast", 0);
    $('#0').fadeTo("middle", 1);
    
    $('#next').click(function() {
        $("#prev").attr("rel",$('#' + aktuell).attr("id"))
    $('#' + prev).animate({ opacity: 0, marginLeft: "-20px" }, 400, function(){
            $(this).css("margin-left","0px");
            $(this).hide(); $('#' + aktuell).fadeTo("fast", 1);
            $('#prev').show();
        } );
        
        $('#' + next).fadeTo("slow", 1);
        prev = prev + 1;
        next = next + 1;
        aktuell = aktuell + 1;
        if(next==maximal) { $('#next').hide(); }
    });
    
    $('#prev').click(function() {
        $("#next").attr("rel",$('#' + aktuell).attr("id"))
        aktuell = next - 1;
    $('#' + aktuell).animate({ opacity: 0, marginLeft: "20px" }, 400, function(){
            $(this).css("margin-left","0px");
            $(this).hide();
            $('#' + aktuell).fadeTo("fast", 1);
            if(aktuell==0) { $('#prev').hide(); }
            $('#next').show();
        } );
        $('#' + prev).fadeTo("slow", 1);
        prev = prev - 1;
        next = next - 1;
        aktuell = aktuell - 1;;
    });
    
	
	/* PAGERANK */
	
	$('#dopr').click(function() {
	var prsite = $("input").val();
	$("#dopr").val('warten...');
	$("#dopr").attr('disabled', 'disabled');
	$("input").attr('disabled', 'disabled');
	$.get('../func/pagerank.func.php?url=' + prsite, function(data) {
  	alert(data);
	$("input").attr('disabled', '');
	$("#dopr").attr('disabled', '');
	$("#dopr").val('abfragen');
	 });
	});
	 
	 /* Domaincheck */
	 
	$('#dowhois').click(function() {
	var prsite = $("#whoiswww").val();
	$("#dowhois").val('warten...');
	$("#whoiswww").attr('disabled', 'disabled');
	$("#dowhois").attr('disabled', 'disabled');
	$.get('../func/domain.func.php?url=' + prsite, function(data) {
  	alert(data);
	$("#dowhois").attr('disabled', '');
	$("#whoiswww").attr('disabled', '');
	$("#dowhois").val('abfragen');
	 });
	});

/* Formular */
    $("#form form").submit(function() {
	var name = false;
	var nachnahme = false;
	var email = false;
	
	
  
  	$("#email").require("1").match("email");
               
      if ($("#vorname").val() != "") {
        $(".vorname").text("Korrekt! ").show().addClass('korrekt').removeClass('inkorrekt');
		name = true;
      } else { $(".vorname").text("Name vergessen! ").show().addClass('inkorrekt'); fin = false; }
	  if ($("#nachname").val() != "") {
        $(".nachname").text("Korrekt! ").show().addClass('korrekt').removeClass('inkorrekt');
		nachnahme = true;
      } else { $(".nachname").text("Nachnahme vergessen! ").show().addClass('inkorrekt'); fin = false; }
	  if ($(".error").text()!="1") {
        $(".email").text("Korrekt! ").show().addClass('korrekt').removeClass('inkorrekt');
		email = true;
      } else { $(".email").text("E-Mail vergessen! ").show().addClass('inkorrekt'); $(".error").text(""); fin = false; }
      if (name==true && nachnahme==true && email==true) { 
            $('#form form').ajaxForm(function() { 
                alert("Wir haben Ihre E-Mail erhalten und werden uns bei Ihnen melden!"); 
            }); 
	  } else { return false; }
	
    });

	/* Upload */
	
	$('#doupload').click(function() {
	var lokal = $("#fileup").val();
	var name = $("#ansprechpartner").val();
	var firma = $("#firma").val();
	var mail = $("#email").val();
	$("#doupload").val('bitte warten...');
	$("input").attr('disabled', 'disabled');
	$.get('../func/ftp.func.php?lokal=' + lokal + "&name=" + name + "&firma=" + firma + "&mail=" + mail, function(data) {
  	alert(data);
	$("input").attr('disabled', '');
	$("#doupload").val('neuer Upload');
	 });
	});
	
});
	
	 
