﻿$(document).ready(function () {



    try {



        $('.product .social').css('position', 'absolute').css('right', '130px').css('top', '215px').css('z-index', '1000').show('fast');
        $('.productTab').children('li').click(function () {

            $('.productTab').children('li').removeClass('current');
            $(this).addClass('current');

            $('.greenAreaBottomShow').removeClass('greenAreaBottomShow');
            $('.subTab').addClass('greenAreaBottom');
            $('#tab' + $(this).attr('id')).addClass('greenAreaBottomShow');

            
        });


        $('#acilirInfoBtn').click(function () {
            //alert($('#acilirInfo').is(':visible'));
            if ($('#acilirInfo').is(':visible') == true) {
                $('#acilirInfo').slideUp('normal');
                $('#acilirInfoBtn').css('background-image', 'url(/ui/images/altMenu.png)');

            }
            else {
                $('#acilirInfo').slideDown('normal');
                $('#acilirInfoBtn').css('background-image', 'url(/ui/images/altMenu2.png)');
            }
        });


        $('#searchBox').focus(function () {
            if ($(this).val() == $(this).attr('title')) {
                $(this).val('');
            }
        });
        $('#searchBox').blur(function () {
            if ($(this).val() == '') {
                $(this).val($(this).attr('title'));
            }
        });

        $('#txtNewsletter').focus(function () {
            if ($(this).val() == $(this).attr('title')) {
                $(this).val('');
            }
        });
        $('#txtNewsletter').blur(function () {
            if ($(this).val() == '') {
                $(this).val($(this).attr('title'));
            }
        });


        $('.externalControl li a').click(function () {

            $('.externalControl li a').removeClass('active');
            $(this).addClass('active');
        });


        $('#fbLikeBtn').mouseover(function () {
            $(this).animate({ right: 0 }, 'fast');
        });

        $('#fbLikeBtn').mouseout(function () {
            $(this).animate({ right: -92 }, 'fast');
        });

        $('#twLikeBtn').mouseover(function () {
            $(this).animate({ right: 0 }, 'fast');
        });

        $('#twLikeBtn').mouseout(function () {
            $(this).animate({ right: -75 }, 'fast');
        });



        $('#fbLikeInnerBtn').mouseover(function () {
            $(this).animate({ right: -130 }, 'fast');
        });

        $('#fbLikeInnerBtn').mouseout(function () {
            $(this).animate({ right: -222 }, 'fast');
        });

        $('#twLikeInnerBtn').mouseover(function () {
            $(this).animate({ right: -140 }, 'fast');
        });

        $('#twLikeInnerBtn').mouseout(function () {
            $(this).animate({ right: -205 }, 'fast');
        });





        $('#btnNewsletter').click(function () {



            if ($('#txtNewsletter').val() != $('#txtNewsletter').attr('title')) {
                var emailStr = $('#txtNewsletter').val();

                $('#txtNewsletter').val('Ekleniyor...');

                var rege = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
                if (rege.test(emailStr)) {
                    //do something 

                    $.ajax({
                        url: '/ebulten',
                        cache: false,
                        type: 'post',
                        data: {
                            email: emailStr
                        },
                        success: function (data) {
                            if (data == 'true') {
                                $('#txtNewsletter').val('Eklendi.');
                            }
                            else if (data == "exist") {
                                $('#txtNewsletter').val('Daha önceden eklemişsiniz.');
                            }
                            else {
                                $('#txtNewsletter').val('Eklenemedi.');
                            }
                        },
                        error: function (e) {
                            alert(e.responseText);
                            //document.write(e.responseText);
                        }
                    });


                }
                else {
                    $('#txtNewsletter').val('Geçerli e-posta girmelisiniz...');
                    return;
                }


            }


        });



    }
    catch (err)
    { }
});

function searchBox_KeyPress(lang) {

    if (event.which == 13) {
        search(lang);
    }

}



function search(lang) {
    var text = $('#searchBox').val();
    if (text.length > 2 && text != "")
        window.location = '/' + lang + '/s?q=' + text;
    else if (text.length < 3 || text == "")
        alert(alertText.replace("&#231;", "ç"));
}






