$(document).ready(function () {

    Cufon.replace('.cal-font', {fontFamily: 'Calibri'});
    Cufon.replace('.iva-font', {fontFamily: 'Ivance'});

    // hovery dla greenline
    $('.leftgreenline-hover-activate').hover(
        function () { $(this).addClass('leftgreenline-hover'); },
        function () { $(this).removeClass('leftgreenline-hover'); }
    );

    // hovery dla box-black-element
    $('.box-black-element').hover(
        function () { $(this).addClass('box-black-element-hover'); },
        function () { $(this).removeClass('box-black-element-hover'); }
    );

    // hovery dla box-black-element
    $('.green-list > li').hover(
        function () { $(this).addClass('green-list-hover'); },
        function () { $(this).removeClass('green-list-hover'); }
    );
    

    // hovery na OkiButtony
    $('.button-white').hover(
        function () { if ($(this).hasClass('active')) return; $(this).find('> span > span > em').css('color', 'white'); Cufon.replace('.button-white', {fontFamily: 'MyriadPro'}); },
        function () { if ($(this).hasClass('active')) return; $(this).find('> span > span > em').css('color', '#a7a9ac'); Cufon.replace('.button-white', {fontFamily: 'MyriadPro'}); }
    );

    // top menu
    Cufon.replace('#topmenu > ul > li > span > a', {fontFamily: 'Ivance'});
    
    $("#topmenu-01, #topmenu-02, #topmenu-03, #topmenu-04").hover(
        function () { if ($(this).hasClass('active')) return; $(this).addClass('active-hover'); },
        function () { if ($(this).hasClass('active')) return; $(this).removeClass('active-hover'); }
    );


    // main page menu
    Cufon.replace('#mainpage-menu > ul > li > span > a', {fontFamily: 'Ivance'});

    $("#mainpage-menu-01, #mainpage-menu-02, #mainpage-menu-03, #mainpage-menu-04").mouseenter(function () {
        if ($(this).hasClass('active-hover')) return;

        var id = parseInt( ($(this).attr('id').toString()).charAt(15) );

        //$("#mainpage-cloud-0"+id).show();
        $(this).addClass('active-hover');
        $(this).find('> span').hide();
    });
	
	$("#mainpage-menu-01, #mainpage-menu-02, #mainpage-menu-03, #mainpage-menu-04").mouseleave(function () {
        
		$(this).removeClass('active-hover');
		$(this).find('> span').show();
    });

    $("#mainpage-cloud-01, #mainpage-cloud-02, #mainpage-cloud-03, #mainpage-cloud-04").mouseleave(function () {
        if ($("#mainpage-menu-0"+id).hasClass('active-hover')) return;
        
        var id = parseInt( ($(this).attr('id').toString()).charAt(16) );
        
        $(this).hide();
        $("#mainpage-menu-0"+id).removeClass('active-hover');
        $("#mainpage-menu-0"+id).find('> span').show();
    });

    // box-title
    Cufon.replace('.box-title-bottom', {fontFamily: 'Ivance'});
    Cufon.replace('.box-black-title', {fontFamily: 'Ivance'});
    Cufon.replace('#video-title', {fontFamily: 'Ivance'});
    Cufon.replace('#gallery-title', {fontFamily: 'Ivance'});
    Cufon.replace('#page-big-title', {fontFamily: 'Ivance'});

    Cufon.replace('.label', {fontFamily: 'Ivance'});
});


function isValidEmailAddress(emailAddress)
{
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}

function scrollTo(){
	$('html, body').animate({
	scrollTop: $('body').offset().top
	}, 1500);
}

