﻿function checkEnter(e) {
    var unicode = e.keyCode ? e.keyCode : e.charCode
    if (unicode == 13) {
        doMainPageSearch();
    }
}
function doMainPageSearch() {
    var oObj = document.getElementById('txtSearchTerm');
    if (oObj) {
        window.location = '/תוצאות-חיפוש/' + oObj.value;
    }
}


jQuery(document).ready(function() {
    $(window).scroll(function() {
        $(".leftBanner").css("top", Number($(window).scrollTop() + 50));
        $(".rightBanner").css("top", Number($(window).scrollTop() + 50));
    });

    scrollNews();

    jQuery(".close_product_of_day").click(function() {
        jQuery("#ProductOfTheDay").fadeOut("slow");
    });

    jQuery(".bannerSeperatorTD").css({ backgroundColor: 'Yellow' });

    var rawUrl = $("#rawUrl").val();
    if (rawUrl != "") {
        $(".homepage_secondMenu a[href*='" + rawUrl + "']").css({ fontWeight: 'bold' });
    }

    jQuery(".largeImageUrl").facebox();
    jQuery(".facebox").facebox();

    jQuery("#cmdSearch").click(function() {
        doMainPageSearch();
    });
    jQuery("li.menuItem").mouseover(function() {
        jQuery(this).addClass("menuItemCurrent");
    });
    jQuery("li.menuItem").mouseout(function() {
        jQuery(this).removeClass("menuItemCurrent");
    });

    $('.Input').bt({
        padding: 20,
        width: 100,
        fill: 'rgba(0, 0, 0, .8)',
        strokeWidth: 3,
        strokeStyle: '#CC0',
        trigger: ['focus', 'blur'],
        positions: ['left'],
        cssStyles: { color: '#FFF', fontWeight: 'bold' }
    });

    swapValues = [];
    $(".Watermark").each(
            function(i) {
                swapValues[i] = $(this).val();
                $(this).focus(function() {
                    if ($(this).val() == swapValues[i]) {
                        $(this).val("")
                    }
                }
                ).blur(function() {
                    if ($.trim($(this).val()) == "") {
                        $(this).val(swapValues[i])
                    }
                }
                )
            }
      )
});

        function generateBanner(width, height, panel, bannerID, flashURL, URL) {
            var SWFObj = new SWFObject(flashURL, bannerID, width, height, "8", "#1D1710");
            SWFObj.addParam("wmode", "transparent");
            SWFObj.addParam("url", URL);
            SWFObj.write(panel);
        }

        //Product Of The Day
        function showPD() {
            AppearPD();
        }

        function AppearPD() {
            var windowWidth = GetWidth();
            jQuery("#ProductOfTheDay").css({left: Number(Number(windowWidth) / 2) + 50});
            jQuery("#ProductOfTheDay").animate({ top: '200px' }, 2000);

        }

        function HideProductOfTheDay() {
            clearInterval(window.showme)
            if (window.hideme) { window.clearInterval(hideme) }
            hideme = window.setInterval("hideit()", 20)
        }

        function hideit() {
            tmp = parseInt(document.getElementById("ProductOfTheDay").style.top, 10)
            if (tmp > TopPosPD) {
                tmp -= 3
                document.getElementById("ProductOfTheDay").style.top = tmp + "px"
            }
            else if (window.hideme) {
                window.clearInterval(hideme)
            }
        }
        //Product Of The Day        
        

function GetWidth()
{
    var x = 0;
    if (self.innerHeight)
    {
            x = self.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
            x = document.documentElement.clientWidth;
    }
    else if (document.body)
    {
            x = document.body.clientWidth;
    }
    return x;
}

function scrollNews() {
    var elementHeight = $(".innerNewsSlider").outerHeight();
    elementHeight = Math.round(Number(elementHeight) + 850);
    var timerInterval = Math.round(Number(elementHeight) * 60);
    var timerBackInterval = timerInterval + 500;

    $(".innerNewsSlider").css({ top: Number(elementHeight) - 850 });
    $(".innerNewsSlider").animate({ top: '-' + elementHeight }, timerInterval);

    setTimeout('scrollNews()', timerBackInterval);
};              

