﻿var footer, wrapper;
function placeFooter() {
    var diff = ($(window).height() - 72) - wrapper.innerHeight();
    if (diff > 0) { footer.css('margin-top', diff + 'px') }
    else { footer.css('margin-top', '20px') }
}
function mailTo(m, e, t) {
    if (!e) {
        e = 'vestel.com.tr';
    }
    if (!t) {
        t = m + String.fromCharCode(64) + e
    }
    document.write('<a href="mailto:' + m + String.fromCharCode(64) + e + '">' + t + '</a>');
}
function onlyNumber(e) {
    var keyCode = ($.browser.mozilla) ? e.which : event.keyCode;
    if ((keyCode < 48 || keyCode > 57) && keyCode != 8 && keyCode != 0) {
        return false;
    }
}

function onlyEmail(e) {
    var InvalidChars = " !#/*{[()]},;%^><\\?+:='`|şŞĞğÜüÇçİıÖö";

    kCode = InvalidChars.charAt(5);

    var keyCode = ($.browser.mozilla) ? e.which : event.keyCode;

    if (keyCode > 127) {
        return false;
    }
    for (i = 0; i <= InvalidChars.length - 1; i++) {
        if (keyCode == InvalidChars.charCodeAt(i)) {
            return false;
        }
    }
    return true;
}

function onlyLetter(e) {
    var InvalidChars = "!#/*{[()]},;%^><\\?+:='`|&-_";

    var keyCode = ($.browser.mozilla) ? e.which : event.keyCode;

    if (keyCode > 47 && keyCode < 58) {
        return false;
    }
    for (i = 0; i <= InvalidChars.length - 1; i++) {
        if (keyCode == InvalidChars.charCodeAt(i)) {
            return false;
        }
    }
}

var blockLoading = { message: 'Yükleniyor...', overlayCSS: { backgroundColor: '#050228', opacity: '0.8', zIndex: 500 }, css: { border: '0px', backgroundColor: 'transparent', zIndex: 501} };
var blockLoadingPage = { message: '<div class="pleaseWait"></div>',
    overlayCSS: {
        backgroundColor: '#000',
        opacity: '0.4',
        zIndex: 1000
    },
    css: {
        zIndex: 1001,
        padding: 0,
        margin: 0,
        width: '30%',
        top: '40%',
        left: '35%',
        textAlign: 'center',
        color: '#fff',
        border: 'none',
        cursor: 'wait'
    }
};
function setLoading(target, message) {

    var targetObj = $(target);
    var opts;
    if (message != null) {
        opts = $.extend({}, { message: message }, blockLoading);
    } else {
        opts = $.extend({}, blockLoading);
    }
    targetObj.block(opts);

}
function PopItUp(src, w, h, s) {
    if (s) w = w + 17;
    if (w) {
        Popwin = window.open(src, "pop_up", "toolbar=0,width=" + w + ", height=" + h + ", location=0, directories=0, status=1, scrollbars=" + s + ", menubar=0, resizable=0, copyhistory=0");
        Popwin.focus();
    }
    else {
        window.location = src
    }
}
$(document).ready(function () {
    footer = $('#footer');
    wrapper = $('#wrapper');
    $("a").each(function () {
        $(this).attr("hideFocus", "true").css("outline", "none");
    });
    $(window).bind('load resize scroll', placeFooter);
    placeFooter();
    $('.table tbody tr:even').css('background-color', '#f2f4f5');
    $('.breadcrumb li:last a').css('border', '0px');
    $('.breadcrumb li:first').addClass('bHome');
    /* Tabs */
    $(".tabs li:first").addClass("selected");
    $(".tabs-area:first").show();
    $(".tabs li a").click(function () {
        var tabindex = $(this).parent().index();
        $(".tabs li").removeClass("selected");
        $(this).parent().addClass("selected");
        $(".tabs-area").hide().eq(tabindex).show();
        return false;
    });
    $(".ynone:first").addClass('visible-year');
    $('.visible-year .pdf-cont:odd').addClass('pdfodd');
    $('#result_year').bind('change', function () {
        $('.pdf-cont').removeClass('pdfodd');
        var deger = document.getElementById("result_year").value;
        $(".ynone").removeClass('visible-year');
        $("#y" + deger).addClass('visible-year');
        $('.visible-year .pdf-cont:odd').addClass('pdfodd');
        placeFooter();
    });
    /*Input Blur*/
    var bu = "";
    $(".txtInput").each(function () {
        bu = $(this);
        bu.val(bu.attr("title"));
        bu.bind("focus", function () {
            if ($(this).val() == $(this).attr("title")) {
                $(this).val("");
            }
        });
        bu.bind("blur", function () {
            if ($(this).val() == "") {
                $(this).val($(this).attr("title"));
            }
        });
    });
    $(".faqItem .faqTitle a").click(function () {

        // soru indeksi getiriliyor
        var _index = $(".faqItem .faqTitle a").index(this);
        // eger ayni soruya tiklaniyorsa, false donuyoruz
        if ($(".faqItem").eq(_index).hasClass("active")) {
            $(".faqItem").eq(_index).removeClass("active")
            $(".faqItem .faqContent").eq(_index).slideUp(500, function () {
                $(document).trigger('faq-anim-complete');
            });
            return false;
        }
        // tum elementlerde dolasip, class temizleyip slideup yapiliyor
        $(".faqItem").each(function () {
            $(this).removeClass("active");
        })
        $(".faqContent").each(function () {
            $(this).slideUp(500, function () {
                $(document).trigger('faq-anim-complete');
            });
        });

        $(".faqItem").eq(_index).addClass("active");
        $(".faqItem .faqContent").eq(_index).slideToggle(500, function () {
            $(document).trigger('faq-anim-complete');
        });
        // linki disable etmek icin return false

        setTimeout(function () {
            $(".active").scrollTo();
        }, 700)

        return false;
    });

    $(document).bind('faq-anim-complete', placeFooter);

    $("a[href$='.pdf'], a[href$='.ppt'], a[href$='.pptx'], a[href$='.xls'], a[href$='.xlsx'], a[href$='.mp3']").click(function () {
        if ('_gaq' in window) { _gaq.push(['_trackPageview', $(this).attr("href")]); }
    });
    /*for calendar page container height*/
    var calconthght;
    calconthght = $(".calInfoArea").height();
    $(".calArea").css("height", calconthght);
});
