﻿$(document).ready(function () {
    $(".accordion-content").hide();
    $(".accordion-title").click(function () {
        var content = $(this).next();
        if (content.is(":visible")) {//eger kapalı ise
            $(this).addClass('openMenu').removeClass('closeMenu');
            content.slideUp(200);
            $(this).children().css('color', '#910607');
        }
        else {
            $(this).addClass('closeMenu').removeClass('openMenu');
            content.slideDown(200);
            $(this).children().css('color', '#910607');
        }
        return false;
    });


    //sayfadakı resımler popup ile açmaya yarar.
    $(".popupImage").click(function ()
    {

        var bigImage = $(this).attr('rel');
        var img = new Image();
        $(img).load(function ()
        {
            $('#fileContainer').html(img);
        }).attr('src', bigImage);

        $.pdiPopup({
            content: $("#file-gallery-wrap"),
            close: $("#closefile"),
            dispose: $('#fileContainer')
        });



        return false;
    });

    $(".btnfilegallery").click(function () {


        var galleryId = $(this).attr('id');
        var galleryType = $(this).attr('gtype');
        var src = '';
        if (galleryType == "0") {
            src = 'PageImageGallerySlide.aspx?galleryId=' + galleryId;
        }
        else {
            src = 'PageFileGallerySlide.aspx?galleryId=' + galleryId;
        }
        var htmlIframe = '';
        htmlIframe += '';
        htmlIframe += '<iframe width="615px" height="600" style="border: 0px;" scrolling="no" src="' + src + '"';

        htmlIframe += '></iframe>';
        $('#fileContainer').append(htmlIframe);

        $.pdiPopup({
            content: $("#file-gallery-wrap"),
            close: $("#closefile"),
            dispose: $('#fileContainer')

        });

        return false;
    });

    var selectMenu = $(".select-menu");

    if (selectMenu.parent().attr('id') == "treeView") {
        $(".select-menu .linkbutton a").css({ "background-color": "#85c8d6" });
        $(".select-menu .linkbutton a").css({ "color": "#095b6f" });
        $(".select-menu .linkbutton a").css({ "margin-left": "-12px" });
    }
    else if (selectMenu.parent().attr('class') == "treecontainer") {
        $(".select-menu .linkbutton a").css({ "text-decoration": "underline", "font-size": "12px" });
    }
    else if (selectMenu.parent().attr('class') == "container") {
        $(".select-menu .linkbutton a").css({ "text-decoration": "underline" });
    }


    $('#btnSearch').click(function () {

        textSearchControl();
        return false;
    });


    $('#txtSearch').keyup(function (e) {

        if (e.keyCode == 13) {
            textSearchControl();
        }


    });
});

function textSearchControl() {

    var txtLength = $('#txtSearch').val().length;
    if (txtLength > 3) {
        location.href = 'SiteSearch.aspx?query=' + $('#txtSearch').val();
    }

}
