﻿

$(document).ready(function () {

    var $j = jQuery.noConflict();

    $j(".Shabbat_Shabbaton").colorbox({ width: "50%", inline: true, href: "#inline_example1" });


    $j('a.poplight[href^=#]').click(function () {
        var popID = $j(this).attr('rel'); //Get Popup Name
        var popURL = $j(this).attr('href'); //Get Popup href to define size

        //Pull Query & Variables from href URL
        var query = popURL.split('?');
        var dim = query[1].split('&');
        var popWidth = dim[0].split('=')[1]; //Gets the first query string value

        //Fade in the Popup and add close button
        $j('#' + popID).fadeIn().css({ 'width': Number(popWidth) }).prepend('<a href="#" class="close"><img src="images/close-btn.png" class="btn_close" title="Close Window" alt="Close" /></a>');

        //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
        var popMargTop = ($j('#' + popID).height() + 80) / 2;
        var popMargLeft = ($j('#' + popID).width() + 80) / 2;

        //Apply Margin to Popup
        $j('#' + popID).css({
            'margin-top': -popMargTop,
            'margin-left': -popMargLeft
        });

        //Fade in Background
        //$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
        //$('#fade').css({'filter' : 'alpha(opacity=30)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies

        return false;
    });

    //Close Popups and Fade Layer
    $j('a.close, #fade').live('click', function () { //When clicking on the close or fade layer...
        $j('#fade , .popup_block').fadeOut(function () {
            $j('#fade, a.close').remove();  //fade them both out
        });
        return false;
    });


    $j('#login_password-clear').show();
    $j('#login_password_password').hide();
    $j('#login_password-clear').focus(function () {
        $j('#login_password-clear').hide();
        $j('#login_password_password').show();
        $j('#login_password_password').focus();
    });
    $j('#login_password-password').blur(function () {
        if ($j('#login_password_password').val() == '') {
            $j('#login_password-clear').show();
            $j('#login_password_password').hide();
        }
    });

    $j("label").inFieldLabels();


    function randomFromTo(from, to) {
        return Math.floor(Math.random() * (to - from + 1) + from);
    }

    var testing = randomFromTo(1, 17);

    $j("#" + testing + "").css("display", "block");


    $j('#testimonials .slide');
    setInterval(function () {
        $j('#testimonials .slide').filter(':visible').fadeOut(2000, function () {
            if ($j(this).next('li.slide').size()) {
                $j(this).next().fadeIn(1000);
            }
            else {
                $j('#testimonials .slide').eq(0).fadeIn(1000);
            }
        });
    }, 4000);

});



    function SuppressEnterClickOnPopups(e, user) {

        if (window.event) // IE
        {
            getEvent = e.keyCode;
        }
        else if (e.which) // Netscape/Firefox/Opera
        {
            getEvent = e.which;
        }

        if (getEvent == "13") {
            //code to trigger your event

            return false;
        }
        else {
            return true;
        }

    }



    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-11402493-1']);
    _gaq.push(['_trackPageview']);

    (function () {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();


    function recordOutboundLink(link, category, action) {
        try {
            var pageTracker = _gat._getTracker("UA-11402493-1");
            pageTracker._trackEvent(category, action);
            setTimeout('document.location = "' + link.href + '"', 100)
        }
        catch (err) { }
    }


    function googleTranslateElementInit() {
        new google.translate.TranslateElement({
            pageLanguage: 'en',
            autoDisplay: false,
            floatPosition: google.translate.TranslateElement.FloatPosition.TOP_LEFT
        });
    }

