$(document).ready(function() { 
    $(".sec .wrapem").jCarouselLite({
        btnNext: ".morenext",
        btnPrev: ".moreprev",
        circular: false,
        visible: 1,
        speed: 500
    });
    $('.showformagain').click(function() {
        $('.messageform').hide();
        return false;
    })
 
    function checkemail() {
        email = $('#email').attr('value');
        isvalid = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(email);
        if (isvalid) {

            return true;
        }
        else {
            alert('Please enter a valid e-mail address');
            $('.messageform').html('Please enter a valid e-mail address.');
            return false;
        }
    }
    function hideform() { 
        $('.fco').hide('fast');
        $('.messageform').html('asd!<br /><br /><a href="asd" class="asd">asd</a>');
    }
    var options = {
        beforeSubmit: checkemail, 
        success: hideform  
    };

    $('.fco').ajaxForm(options);





    $('.slides a').lightBox();
    $(".sec .list").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        circular: false,
        visible: 8,
        speed: 500,
        vertical: true
    });
    $('.image').hover(function() {
        $(this).removeClass('unhvr');
    }, function() {
        $(this).addClass('unhvr');
    });
    function loadproject() {
        $('.title h2, .title h3').fadeOut(function() { txt1 = $('.sec .here').attr('title'); txt = $('.sec .here b').text(); $('.title h2').text(txt); $('.title h3').text(txt1); });

        $('.slides').fadeOut(function() {
            $('.slides').empty();
            bigpicurl = $('.sec .here').attr('href');
            smallpicurl = $('.sec .here .smallpic').eq(0).text();
            $('.slides').html('<a style="display:none" href="' + bigpicurl + '"><img src="' + smallpicurl + '" alt="" /></a>');
            $('.slides a').lightBox();
            $('.slides a').show();
        });

        $('.slides').fadeIn(500);
        $('.title h2, .title h3').fadeIn(500, function() {
            if ($.browser.msie) {
                $('.title h2').get(0).style.removeAttribute('filter');
                $('.title h3').get(0).style.removeAttribute('filter');
            } 
        });


        $('.prev,.next').removeClass('disabled');
        if ($('.sec .clickableul li:last-child a').hasClass('here')) {
            $('.next').addClass('disabled');

        }
        if ($('.sec .clickableul li:first-child a').hasClass('here')) {
            $('.prev').addClass('disabled');
        }
    }

    $('.sec .clickableul li a').click(function() {
        $('.sec li a').removeClass('here');
        $(this).addClass('here');
        loadproject();
        return false;
    });
    $('.next').click(function() {
        toshow = $('.sec li a.here').parent().next().children('a');
        $('.sec li a').removeClass('here');
        toshow.addClass('here');
        loadproject();
        return false;
    });
    $('.prev').click(function() {
        toshow = $('.sec li a.here').parent().prev().children('a');
        $('.sec li a').removeClass('here');
        toshow.addClass('here');
        loadproject();
        return false;
    }); 
    if ($('.text').length > 0) {
        haha = $('.text').height() + 400;
        if (haha < 883) { haha = 883; }
        else { bubu = haha + 68; bubu1 = haha - 36; $('#out').height(bubu); $('.shad-str').height(bubu1); }
        $('.content').height(haha);
    }
    $(document).pngFix();

 
    if ($('.sec .here').length > 0) {
        loadproject();
    }
    else {
        $('.sec .clickableul li').eq(0).children('a').addClass('here');
        loadproject();
    }


});
 
if ($(window).width() < 1160) {
    document.write('<style type="text/css">@import "css/1024px.css";</style>');
    document.write('<!--[if lt IE 7]><style type="text/css">@import "css/ie6.css";</style><![endif]-->');
}
