
$(function(){
    $(".screen_grey").each(function(){
       $(this).css("background-image", "url("+$(this).children("img").attr("src")+")"); 
    });
    
    $(".screen").each(function(){
       $(this).css("background-image", "url("+$(this).children("img").attr("src")+")"); 
    });
    
    $(".belka").mouseover(function(){
       $(this).children(".screen").stop(true, true).fadeIn(500)
    });
    $(".belka").mouseout(function(){
        if($(this).hasClass("belka_active"))
            return false;
        
       $(this).children(".screen").stop(true, true).fadeOut(500)
    });
});

function Email()
{
    if (!chkEmail($('#email').val()))
    {
    $('#komunikat').html("Adres email jest niepoprawny!");
    }
    else
    {
        var imie = $('#imie').val();
        var email = $('#email').val();
        var tresc = $('#tresc').val();
        
        if((imie!='')&&(imie!='Imię i nazwisko:')&&(email!='')&&(email!='Twój adres email:')&&(tresc!='')&&(tresc!='Treść wiadomości:'))
        {
            $.ajax({
              url: "sendmail.php?imie="+imie+"&email="+email+"&tresc="+tresc,
              beforeSend: function(){
                  $('#komunikat').html('Proszę czekać trwa wysyłanie wiadomości');
              },
              success: function(data){
                $('#komunikat').html(data);
              }
            });
        }
        else
        {
            $('#komunikat').html("Proszę wypełnić wszystkie pola!");
        }
    }
}

function hideFormularz()
{
    $("#formularz_bg").hide();
    $("#formularz").hide();  
}


function showFormularz()
{
    $(".skrot_cont").each(function(){
       $(this).stop(true, true).slideUp(); 
       $(this).siblings(".belka").removeClass("belka_active");
       $(".skrot_cont").siblings(".belka").children(".screen").hide();
    });    
    
    var w = viewPort().width
    $("#formularz").css("left", ((w/2)-205)+"px");
    $("#formularz_bg").show();
    $("#formularz").show();
}


function showText(nazwa)
{
    $(".text").hide();
    $("#"+nazwa).slideDown(500);
}


function showProjekt(nr)
{
    $(".belka_active").siblings(".skrot_cont").stop(true, true).slideUp(500);
    $(".belka_active").children(".screen").stop(true, true).fadeOut(500, function(){

    });
    $(".belka_active").removeClass('belka_active');

    

    $("#skrot_cont"+nr).siblings(".belka").addClass("belka_active");
    $("#skrot_cont"+nr).stop(true, true).slideDown(500, function(){
        $("#header_content").stop(true, true).animate({top: ($("#belka"+nr).position().top-13)+'px'}, 500);
    });   

}

function showSzczegoly(nr)
{
    $("#szczegoly_cont"+nr).stop(true, true).slideDown(500);
}

function showAll()
{
    $("#header_content").stop(true, true).animate({top: '0px'}, 500);
    $(".skrot_cont").each(function(){
       $(this).stop(true, true).slideDown(500); 
       $(this).siblings(".belka").addClass("belka_active");
       $(".skrot_cont").siblings(".belka").children(".screen").show();
    });
    
}





function viewPort() 
{
   var h = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight;
   var w = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;

   return {width : w , height : h}
}

function chkEmail(email) {
var regEmail = /^([a-zA-Z0-9._-]{1,})@([a-zA-Z0-9._-]{1,})\.([a-zA-Z]{1,4})$/;
    if (!regEmail.test(email)) 
        return false;
    else return true;
}














