﻿function RegisterNewsletter(_emailid) {
    $(".iletisim_left_box_content .result").html("");
    try {
        var email = $("#" + _emailid).val();
        var errormessage = $("#" + _emailid).attr("ErrorMessage");
        if (!validateEmail(email)) {
            $(".iletisim_left_box_content .result").html(errormessage);
        }
        else {
            $.ajax({
                type: "POST",
                url: "/Content/WebService/ClientSiteWebService.asmx/RegisterNewsletter",
                data: "{Email:'" + email + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    $(".iletisim_left_box_content .result").html(msg.d);
                },
                error: function (msg) {
                    return false;
                }
            });
        }

    } catch (e) {

    }
    return false;
}

$(window).load(function () {
    WindowResize();
    if ($('body > div > iframe').width() != null)
        $('body > div > iframe').parent().css('display', 'none');

    window.onresize = function (event) { WindowResize(); }

    $('.search_box input').keydown(function (e) {
        if (e.keyCode == 13) {
            document.location = "/Page/Search?w=" + $('.search_box input').val();
            return false;
        }
    });

    $('.menu ul.sf-menu').superfish();
});

function WindowResize() {
    var wrapperHeight = $('#header').height() + $('#content').height() + $('#footer').height();
    wrapperHeight += 75;
    if (wrapperHeight < $(window).height()) {
        var contentHeight = $('#content').height() + parseInt($(window).height() - wrapperHeight);
        $('#content').css('min-height', contentHeight + "px");
    }
}

function MainGallery() {
    $('.main_gallery .item').mouseenter(function () {
        if ($('.main_gallery img[index=' + $(this).find('a').attr('index') + ']').css('display') != 'block') {
            $('.main_gallery img').css('display', 'none');
            $('.main_gallery img[index=' + $(this).find('a').attr('index') + ']').fadeIn(400);
        }
    });
}

function Sitemap() {
    if ($('#footer .sitemap').hasClass('visible')) {
        $('#footer .sitemap').slideUp(500);
        $('#footer .sitemap').removeClass('visible');
    }
    else {
        $('#footer .sitemap').addClass('visible');
        $('#footer .sitemap').slideDown(500);
        slideNavigation('#footer .cw');
    }
}

function slideNavigation(navigate) {
    var speed = 1000;
    if ($.browser.opera) {
        $('html').animate({
            scrollTop: $(navigate).offset().top - 50
        }, speed);
    }
    else $('html,body').animate({
        scrollTop: $(navigate).offset().top - 50
    }, speed);
}


function ShowSearch() {
    if ($('.search_box').hasClass('visible')) {
        $('.search_box').css('display', 'none');
        $('.search_box').removeClass('visible');
    }
    else {
        $('.search_box').css('display', 'block');
        $('.search_box').addClass('visible');
    }
}


function MenuSelect(path) {
    $.each($('.menu > ul > li > a'), function (i) {
        if ($(this).attr('href') == path) {
            $(this).parent().addClass('active');
            return false;
        }
    });
}
