// JavaScript Document
var myBooledSumsung;
function gotoLink() 
{
    var ismyslideId = document.getElementById("ismyslideId").value;
    if (parseInt(ismyslideId) != 0)
    window.location = "/Products/Details/" + ismyslideId;
}
function callResetBullets(id) {
    if (document.getElementById("NbBulletsMain" + myBooledSumsung) != null) {
        var NbBullets = document.getElementById("NbBulletsMain" + myBooledSumsung).value;
        for (i = 0; i < NbBullets; i++) {
            if (document.getElementById("bulletcontent" + myBooledSumsung + i) != null)
                document.getElementById("bulletcontent" + myBooledSumsung + i).className = "bullet";
        }
        var myIndex = ((parseInt(id) - 1) / 3);
        if (NbBullets == myIndex) {
            myIndex = 0;
        }
        if (myIndex < 0)
            myIndex = 0;
        if (document.getElementById("bulletcontent" + myBooledSumsung + myIndex) != null)
            document.getElementById("bulletcontent" + myBooledSumsung + myIndex).className = "bullet selected";
        document.getElementById("boolselected").value = myIndex;

    }
}
function loadSlideShow() {
    simplePreload("/Content/images/media_prod_desc.png", "/Content/images/media_prod_desc2.png", "/Content/images/slide_preview.png", "/Content/images/close_popup.png,/Content/images/prev_pop_pic.png,/Content/images/no_next.png");    
        $('.slideshow').cycle({
                timeout: 7000,
                fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
            });
    }
    function nextSlide() {
        $('.slideshow').cycle('next');
    }
    function PreviousSlide() {
        $('.slideshow').cycle('prev');
    }
    function Goto(id) {
        $('.slideshow').cycle(id);
    }
    function resetPoints() 
    {
        var nbSliding = document.getElementById("nbSliding").value;
        for (mycount = 0; mycount <= nbSliding; mycount++) 
        {
            document.getElementById("pointCircle" + mycount).className = "bullet";
        }
    }
    function carouselGoto(id) {
        $(".slideBool").jCarouselLite({
            btnGo: id
        });
    }

    function gotoPagePoint(id) 
    {
        jQuery(".slideBool").jcarousel(scroll(jQuery.jcarousel.intval(id)));
    }
    function fadeImgMain(FirstPic, id, imgId) {
        var isopened = document.getElementById("smallimgId" + myBooledSumsung + id).className;
        if (isopened == "" && isFadingImg == false) {
            var imgsmallIn = document.getElementById("imgsmallIn" + myBooledSumsung + imgId).value;
            isFadingImg = true;
            document.getElementById("smallimgId" + myBooledSumsung + imgsmallIn).className = "";

            $("#details_picId" + myBooledSumsung + imgId).fadeOut(1000, function() {
            document.getElementById('leftPicBigId' + myBooledSumsung + imgId).src = Mainroute1 + "Content/images/loader.gif";
                isFadingImg = false;
                var Mainroute1 = document.getElementById("Mainroute").value;
                document.getElementById('leftPicBigId' + myBooledSumsung + imgId).src = Mainroute1 + "Utils/ResizeImage2?imagename=" + FirstPic + "&width=228&height=225";
                setTimeout(function() {
                    $("#details_picId" + myBooledSumsung + imgId).fadeIn("slow");
                }, 200);
                document.getElementById("imgsmallIn" + myBooledSumsung + imgId).value = id;
                document.getElementById("smallimgId" + myBooledSumsung + id).className = "selected";
            });
        }
    }
    var mouseInSamsungBox1 = false;
    var mouseInSamsungBox2 = false;
    var mouseInSamsungBox3 = false;
    var BoxInActionslide = 0;
    var isClosingBox = false;
    var isOpeningBox = false;
    var HasNextBoxInActionslide = 0;

    function openTheBoxNow(id) {
        if (parseInt(id) != parseInt(BoxInActionslide)) {
            var myindexBox = document.getElementById("boxhiddenValeur" + id).value;
            isOpeningBox = true;
            var otherId1;
            var otherId2;

            if (myindexBox == "1") {
                otherId1 = parseInt(id) + 1;
                otherId2 = parseInt(id) + 2;
                leftsamsung1 = "200";
                leftsamsung2 = "105";

                widthsamsung1 = "160";
                widthsamsung2 = "160";
                isSamsungBoxing1 = true;
            }
            if (myindexBox == "2") {
                otherId1 = parseInt(id) - 1;
                otherId2 = parseInt(id) + 1;

                leftsamsung1 = "10";
                leftsamsung2 = "105";

                widthsamsung1 = "145";
                widthsamsung2 = "145";
                isSamsungBoxing2 = true;
            }
            if (myindexBox == "3") {
                otherId1 = parseInt(id) - 2;
                otherId2 = parseInt(id) - 1;
                leftsamsung1 = "10";
                leftsamsung2 = "-89";

                widthsamsung1 = "145";
                widthsamsung2 = "145";
                isSamsungBoxing3 = true;
            }

            eval("mouseInSamsungBox" + myindexBox + "= true");
            eval("mouseInSamsungBox" + otherId1 + "= false");
            eval("mouseInSamsungBox" + otherId2 + "= false");
            HasNextBoxInActionslide = id;


            if ((parseInt(BoxInActionslide) == 0) && (document.getElementById("boxSamsungId" + myBooledSumsung + id) != null)) {
                document.getElementById("boxSamsungId" + myBooledSumsung + id).style.display = "block";
                $(".samsung_product_pic2").hide();
                BoxInActionslide = id;

                var widthsamsung1;
                var widthsamsung2;
                var leftsamsung1;
                var leftsamsung2;
                $("#boxSamsungId" + myBooledSumsung + otherId1).css("z-index", "1");
                $("#boxSamsungId" + myBooledSumsung + otherId2).css("z-index", "1");
                $(".divMainScroll").css("z-index", "1");
                $("#boxSamsungId" + myBooledSumsung + id).css("z-index", "10000");
                if (myindexBox == "2") {
                    $("#boxSamsungId" + myBooledSumsung + id).stop().animate(
                  {
                      height: "295",
                      width: "479",
                      left: "187"
                  },
            {
                duration: 500,
                step: function() {
                    if (eval("mouseInSamsungBox" + myindexBox) == false) {
                        $("#boxSamsungId" + myBooledSumsung + id).stop();
                        $("#divMainScroll" + myBooledSumsung + numBoxSscroll).stop();
                        $("#divMainScroll" + myBooledSumsung + numBoxSscrol2).stop();
                        CloseTheBoxNow(id, 500, 0);
                    }
                },
                complete: function() {
                $("#subboxSamsung" + myBooledSumsung + id).fadeIn();
                    isOpeningBox = false;
                    if (parseInt(BoxInActionslide) == parseInt(id)) {
                        HasNextBoxInActionslide = 0;
                    }
                }
            });
                }
                else {

                    $("#boxSamsungId" + myBooledSumsung + id).stop().animate(
                  {
                      height: "295",
                      width: "479"
                  },
            {
                duration: 500,
                step: function() {
                    if (eval("mouseInSamsungBox" + myindexBox) == false) {
                        $("#boxSamsungId" + myBooledSumsung + id).stop();
                        $("#divMainScroll" + myBooledSumsung + numBoxSscroll).stop();
                        $("#divMainScroll" + myBooledSumsung + numBoxSscrol2).stop();
                        CloseTheBoxNow(id, 500, 0);
                    }
                },
                complete: function() {
                $("#subboxSamsung" + myBooledSumsung + id).fadeIn();
                isOpeningBox = false;
                    if (parseInt(BoxInActionslide) == parseInt(id)) {
                        HasNextBoxInActionslide = 0;
                    }
                }
            });
                }
                var boolselected = document.getElementById("boolselected").value;
                var numBoxSscroll = parseInt(otherId1);
                var numBoxSscrol2 = parseInt(otherId2);
                scrollSmallBoxes("#divMainScroll" + myBooledSumsung + numBoxSscroll, 160, leftsamsung1, 0);
                scrollSmallBoxes("#divMainScroll" + myBooledSumsung + numBoxSscrol2, 160, leftsamsung2, 0);
            }
            else {
                if (parseInt(BoxInActionslide) != parseInt(id))
                    CloseTheBoxNow(BoxInActionslide, 100, id);
            }
        }
    }

    function CloseTheBoxNow(id, speedClose, hasToOpen) {
        if (isClosingBox == false) {
            isClosingBox == true;
            if (speedClose == null || speedClose == 0)
                speedClose = 500;
            var myindexBox = document.getElementById("boxhiddenValeur" + id).value;
            var BoxToClose1 = captureIndexBox(myindexBox, 1, id);
            var BoxToClose2 = captureIndexBox(myindexBox, 2, id);

            eval("mouseInSamsungBox" + myindexBox + "= false");
            $("#subboxSamsung" + myBooledSumsung + id).fadeOut(100);

            if (myindexBox != "2") {
                $("#boxSamsungId" + myBooledSumsung + id).stop().animate({
                    height: "132",
                    width: "278"
                }, speedClose, function() {
                    document.getElementById("boxSamsungId" + myBooledSumsung + id).style.display = "none";
                    document.getElementById("subboxSamsung" + myBooledSumsung + id).style.display = "none";
                    $(".samsung_product_pic2").show();
                    isClosingBox == false;
                    BoxInActionslide = 0;
                    if (parseInt(hasToOpen) != 0)  //this step if i am mousing out on another box
                    {
                        openTheBoxNow(hasToOpen);
                    }
                    else {
                        if (mouseInSamsungBox1 == true || mouseInSamsungBox2 == true || mouseInSamsungBox3 == true) {
                            openTheBoxNow(HasNextBoxInActionslide);
                        }
                    }

                });
            }
            else {
                $("#boxSamsungId" + myBooledSumsung + id).stop().animate(
                        {
                            height: "132", width: "278", left: "284"
                        }, speedClose, function() {
                            document.getElementById("boxSamsungId" + myBooledSumsung + id).style.display = "none";
                            document.getElementById("subboxSamsung" + myBooledSumsung + id).style.display = "none";
                            $(".samsung_product_pic2").show();
                            isClosingBox == false;
                            BoxInActionslide = 0;
                            if (parseInt(hasToOpen) != 0)  //this step if i am mousing out on another box
                            {
                                openTheBoxNow(hasToOpen);
                            }
                            else {
                                if (mouseInSamsungBox1 == true || mouseInSamsungBox2 == true || mouseInSamsungBox3 == true) {
                                    openTheBoxNow(HasNextBoxInActionslide);
                                }
                            }
                        });
            }
            scrollSmallBoxes("#divMainScroll" + myBooledSumsung + parseInt(BoxToClose1), 248, 10, speedClose);
            scrollSmallBoxes("#divMainScroll" + myBooledSumsung + parseInt(BoxToClose2), 248, 10, speedClose);
        }
    }

    ///this function is used to take the index of the box  1 - 2 - 3
    function captureIndexBox(myindexBox, BoxIndex, id) {
        var otherId1, otherId2;
        if (myindexBox == "1") {
            otherId1 = parseInt(id) + 1;
            otherId2 = parseInt(id) + 2;
        }
        if (myindexBox == "2") {
            otherId1 = parseInt(id) + 1;
            otherId2 = parseInt(id) - 1;
        }
        if (myindexBox == "3") {
            otherId1 = parseInt(id) - 1;
            otherId2 = parseInt(id) - 2;
        }
        if (BoxIndex == "1") {
            return otherId1;
        }
        else {
            return otherId2;
        }
    }
    /////////////////////////////////////////////////////////////
    function scrollSmallBoxes(id, mywidth, myleft, speedClose) {
        if (speedClose == null || speedClose == 0)
            speedClose = 500;
        var contrustProperties = "";
        if (parseInt(mywidth) != 0) {
            contrustProperties = "width: \"" + mywidth + "\"";
        }
        if (parseInt(myleft) != 0) {
            if (contrustProperties != "") {
                contrustProperties = contrustProperties + ",left: \"" + myleft + "\"";
            }
            else {
                contrustProperties = contrustProperties + "left: \"" + myleft + "\"";
            }
        }



        $("" + id).stop().animate(
        {
            width: "" + mywidth,
            left: "" + myleft
        }, speedClose, function() {
        });
    }
//    $(document).ready(
//    function() {
//        $('#emailLetter').keyup(function(event) {
//        if (event.keyCode == 13) {
//            goNewsletter();
//            }
//        });
//    }

//    );
