﻿/* Author: 

*/

function isube()
{ window.open("https://esube.teb.com.tr/bireysel/Parola.do", "Essube", "top=0,left=0,width=1020,height=780,status,resize='yes'"); }

$(document).ready(function () {

    /*! Application
    ---------------------------------------------- */

    //$.app.external();                   // External links
    //$.app.nav();                        // Highlights the current in a menu


    /*! Form Validation
    ---------------------------------------------- */

    // Initialize validation on the entire ASP.NET form.
    $("#form1").validate({
        // This prevents validation from running on every
        // form submission by default.
        onsubmit: false
    });

    // Search for controls marked with the causesValidation flag
    // that are contained anywhere within elements marked as
    // validationGroups, and wire their click event up.
    $('.validationGroup .causesValidation').click(Validate);

    // Select any input[type=text] elements within a validation group
    // and attach keydown handlers to all of them.
    $('.validationGroup input[type="text"]').keydown(function (evt) {
        // Only execute validation if the key pressed was enter.
        if (evt.keyCode == 13) {
            // Find and store the next input element that comes after the
            // one in which the enter key was pressed.
            var $nextInput = $(this).nextAll(':input:first');

            // If the next input is a submit button, go into validation.
            // Else, focus the next form element as if enter == tab.
            if ($nextInput.is(':submit')) {
                Validate(evt);
            }
            else {
                evt.preventDefault();
                $nextInput.focus();
            }
        }
    });


    /*! Navigation Highlights
    ---------------------------------------------- */

    // Highlights the current in a menu by comparing the links to the current URL path
    var path = location.pathname.substring(1);
    if (path)
        $('nav a[href$="' + path + '"]').attr('class', 'active');


    /*! Menu Actions
    ---------------------------------------------- */

    $('nav a').click(function () {
        if ($(this).attr('href') == '#') {
            return false;
        }
    });

    if ($.browser.msie && $.browser.version.substr(0, 1) < 8) {
        $('nav[data-role="primary"] > ul > li > a').append('<em></em>');
    }

    $('nav[data-role="primary"] > ul > li').hoverIntent({
        over: makeVisible,
        //timeout: 800,
        out: makeHidden
    });

    $('nav[data-role="primary"] ul ul li').hoverIntent({
        over: makeTall,
        timeout: 800,
        out: makeShort
    });


    $('nav[data-role="primary"] > ul > li > ul').each(function (index) {
        var _this = $(this);
        var $kids = _this.children();
        var len = $kids.length;
        if (len < 2) {
            $kids.addClass('only-child');
            _this.append('<li class="embeded-child"></li>');
        }
    });

    function makeVisible() {
        $('nav[data-role="primary"] ul ul').hide();
        $(this).addClass('activated');
        $(this).find('a:first').next().show();
        //$(this).css('z-index', 50);
    }
    function makeHidden() {
        $(this).removeClass('activated');
        $(this).find('a:first').next().hide();
        //$(this).css('z-index', 20); 
    }

    function makeTall() {
        var el = $(this).find('a:first');
        if (el.next().is('ul')) {
            el.next().slideDown().addClass('activated');
            return false;
        }
    }
    function makeShort() {
        var el = $(this).find('a:first');
        if (el.next().is('ul')) {
            el.next().slideUp().removeClass('activated');
        }
    }


    /*! Placeholder
    ---------------------------------------------- */

    $('input, textarea').placeholder();


    /*! Ellipses
    ---------------------------------------------- */

    $(".ellipses").dotdotdot();


    /*! Toggle
    ---------------------------------------------- */

    $(".toggle").click(function () {
        var el = $(this);
        if (el.hasClass('next')) {
            el.toggleClass("active").parent().next().slideToggle("slow");
        }
        else if (el.hasClass('previous')) {
            el.toggleClass("active").parent().prev().slideToggle("slow");
        }
        return false; //Prevent the browser jump to the link anchor
    }).trigger('click');


    /*! Accordion
    ---------------------------------------------- */

    //Hide (Collapse) the toggle containers on load
    $(".toggle_container").hide();

    //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
    $("h2.trigger").click(function () {
        $(this).toggleClass("active").next().slideToggle("slow");
        return false; //Prevent the browser jump to the link anchor
    }).filter(":first").trigger('click');


    /*! Cufon
    ---------------------------------------------- */

    Cufon.replace('footer li h3, .concierge-category span a', { fontFamily: 'BNPP Sans' });
    Cufon.replace('nav[data-role="complementary"] a, nav[data-role="primary"] a', {
        hover: true,
        fontFamily: 'BNPP Sans'
    });
    Cufon.replace('article h2', { fontFamily: 'BNPP Slab Serif' });
    Cufon.replace('.anythingBase .panel figcaption span', { fontFamily: 'BNPP Slab Serif', textShadow: 'rgba(0,0,0,0.3) 1px 1px' });
    Cufon.replace('.anythingBase .panel figcaption .title', { fontFamily: 'BNPP Sans', fontStyle: 'italic' });


    /*! Slider
    ---------------------------------------------- */

    if ($('#slider').length) {
        $('#slider').anythingSlider({
            expand: true,
            resizeContents: true,
            height: 'auto',
            hashTags: false,
            buildNavigation: false,
            autoPlay: true,
            delay: 8000

        });
    }

});            // document ready


function Validate(evt) {
    // Ascend from the button or input element that triggered the
    // event until we find a container element flagged with
    // .validationGroup and store a reference to that element.
    var $group = $(this).parents('.validationGroup');
    
    var isValid = true;

    // Descending from that .validationGroup element, find any input
    // elements within it, iterate over them, and run validation on
    // each of them.
    $group.find(':input').each(function (i, item) {
        if (!$(item).valid())
            isValid = false;
    });

    // If any fields failed validation, prevent the button's click
    // event from triggering form submission.
    if (!isValid)
        evt.preventDefault();
}


