﻿$(document).ready(function() {


    var h;
    var w;
    function ResizeAllContent() {

        h = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.documentElement.clientHeight); w = (typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);

        $("#wrapper1").css("width", w);
        $("#wrapper1").css("height", h);

        $("#bgimg1").show();
        $("#deniz_tech_footer").css("width", w);
        $(".logo").css("margin-left", w / 75);
        $("#newsopportunitycontainer").css("top", 200);
        if (w < 1030) {
            $(".logo").css("margin-left", w / 255);
        }

        $("#MailContainer").css("width", w).css("height", h);
        $("#MailClose").css("left", w - 145).css("top", 97);


        $("#WeatherContainer").css("width", w).css("height", h);
        $("#WeatherFrame").css("width", w - 200).css("height", h - 200);
        $("#WeatherClose").css("left", w - 188).css("top", 100);
    } ResizeAllContent();
    $(window).resize(function() { ResizeAllContent(); });

    $("#nextmap").click(function() {

        if ($("#kroki").attr("src") == "images/maps2.png") {
            $("#kroki").css("width", 2464);
            $("#kroki").attr("src", "images/maps.jpg");
            $("#kroki").css("top", -550);
            $("#kroki").css("left", -1000);
        }
        else {
            $("#kroki").attr("src", "images/maps2.png");
            $("#kroki").css("width", 3931);
            $("#kroki").css("top", -800);
            $("#kroki").css("left", -1800);
        }
    });
    $("#prevmap").click(function() {

        if ($("#kroki").attr("src") == "images/maps2.png") {
            $("#kroki").css("width", 2464);
            $("#kroki").attr("src", "images/maps.jpg");
            $("#kroki").css("top", -550);
            $("#kroki").css("left", -1000);


        }
        else {
            $("#kroki").attr("src", "images/maps2.png");
            $("#kroki").css("width", 3931);
            $("#kroki").css("top", -800);
            $("#kroki").css("left", -1800);

        }

    });


    var bgc = 1;
    var bgcz = 2;
    function ChangeRandBg() {
        var str = Math.floor(Math.random() * 21);


        if (str > 9) {

            $("#bgimg" + bgcz).attr("src", "images/bgimg/0" + str + ".jpg").fadeIn(1000);
            $("#bgimg" + bgc).fadeOut(1000);

        }
        else {

            $("#bgimg" + bgcz).attr("src", "images/bgimg/00" + str + ".jpg").fadeIn(1000);
            $("#bgimg" + bgc).fadeOut(1000);
        }

        if (bgc == 1) {
            bgcz = 1;
            bgc = 2;
        }
        else {
            bgcz = 2;
            bgc = 1;
        }
    } ChangeRandBg();



    var inte = setInterval(ChangeRandBg, 7000);




    $(".logo").each(function() {
        $(this).click(function() {
            var gw = $('#BrandContainer').width();
            var gh = $('#BrandContainer').height();
            gw = gw - (gw / 10);
            gh = gh - (gh / 5);
            $("#BrandContainer").show();
            $("#BrandLB").animate({ width: gw }, 1000).animate({ height: gh }, 1000); $("#FrameClose").show(); $("#BrandFrame").attr("src", $(this).attr("f"));
        });
    });

    $(".logo").each(function() {
        $(this).hover(function() {
            var ofs = $(this).offset();
            var bg = $(this).attr("b");
            $("#preview").css("top", ofs.top - 140).css("left", ofs.left);
            $("#preview").css('background-image', 'url(' + bg + ')');
            $("#preview").show();
        }, function() {
            $("#preview").hide();

        });
    });

    $("#MailClose").click(function() { $("#MailClose").hide(); $("#MailLB").animate({ width: 10 }, 1000).animate({ height: 10 }, { duration: 1000, complete: function() { $("#MailContainer").hide(); } }); $("#mailprocces").hide(); });
    $("#FrameClose").click(function() { $("#FrameClose").hide(); $("#BrandLB").animate({ width: 10 }, 1000).animate({ height: 10 }, { duration: 1000, complete: function() { $("#BrandContainer").hide(); } }); $("#BrandFrame").attr("src", ""); });
    $("#mcCloseAbt").click(function() { $("#mcCloseAbt").hide(); $("#maincontent").animate({ width: 10 }, 1000).animate({ height: 10 }, { duration: 1000, complete: function() { $("#maincontent").hide(); } }); $("#maincontent").attr("src", ""); });
    $("#mcCloseCnt").click(function() { $("#mcCloseCnt").hide(); $("#maincontent").animate({ width: 10 }, 1000).animate({ height: 10 }, { duration: 1000, complete: function() { $("#maincontent").hide(); } }); $("#maincontent").attr("src", ""); });
    $("#mcCloseUfl").click(function() { $("#mcCloseUfl").hide(); $("#maincontent").animate({ width: 10 }, 1000).animate({ height: 10 }, { duration: 1000, complete: function() { $("#maincontent").hide(); } }); $("#maincontent").attr("src", ""); });


    $("#WhtrLink").click(function() {
        var gw = $('#BrandContainer').width();
        var gh = $('#BrandContainer').height();

        gw = gw - (gw / 10);
        gh = gh - (gh / 5);
        $("#BrandContainer").show();
        $("#BrandLB").animate({ width: gw }, 1000).animate({ height: gh }, 1000); $("#FrameClose").show(); $("#BrandFrame").attr("src", "http://www.dmi.gov.tr/deniz/metu3-ayrintili.aspx");

    });

    $("#maillogo").click(function() {
        $("#MailContainer").show();
        $("#MailLB").animate({ width: w - 200 }, 1000).animate({ height: h - 200 }, 1000); $("#MailClose").show(); $("#MailFrame").show();

    });

    $("#usf_boatshow").click(function() {
        $("#BrandContainer").show();
        $("#BrandLB").animate({ width: w - 200 }, 1000).animate({ height: h - 200 }, 1000); $("#FrameClose").show(); $("#BrandFrame").attr("src", "http://www.boatshows.com/calendar.aspx");

    });



    $(".deniz_tech_javaimages:first").show();
    setInterval(DenizTech, 1000)

    function DenizTech() {
        if ($(".deniz_tech_javaimages:visible:first").next().parent().attr("id") == "dnztchjscn") {
            $(".deniz_tech_javaimages:visible:first").next().delay(1000).fadeIn(1000);
            $(".deniz_tech_javaimages:visible:first").fadeOut(1000);
        }
        else {
            $(".deniz_tech_javaimages:visible:first").fadeOut(1000);
            $(".deniz_tech_javaimages:first").delay(1000).fadeIn(1000);
        }
    };

    $(".useful_info_menu_content").each(function() {


        $(this).hover(function() {
            $(this).children("h1").css("color", "#FFFFFF");
        }, function() { $(this).children("h1").css("color", "#333333"); });
    });


    function nic() {
        if ($(".News:visible:first").next(".News").parent().attr("id") == "newsdisplayer") {
            $(".News:visible:first").next(".News").delay(200).fadeIn(200);
            $(".News:visible:first").fadeOut(200);
        }
        else {
            $(".News:visible:first").fadeOut(200);
            $(".News:first").delay(200).fadeIn(200);
        }
    }

    function oic() {
        if ($(".oportunity:visible:first").next(".oportunity").parent().attr("id") == "oportunitydisplayer") {
            $(".oportunity:visible:first").next(".oportunity").delay(200).fadeIn(200);
            $(".oportunity:visible:first").fadeOut(200);
        }
        else {
            $(".oportunity:visible:first").fadeOut(200);
            $(".oportunity:first").delay(200).fadeIn(200);
        }
    }
    if (window.location == "http://www.denizyatcilik.com/HomePage.aspx") {
        setInterval(oic, 4000); setInterval(nic, 4000);
    }

    if (window.location == "http://www.denizyatcilik.com/Anasayfa.aspx") {
        setInterval(oic, 4000); setInterval(nic, 4000);
    }
    $("#displayerarwL").click(function() {
        if ($(".News:visible:first").prev().parent().attr("id") == "newsdisplayer") {
            $(".News:visible:first").prev().delay(200).fadeIn(200);
            $(".News:visible:first").fadeOut(200);
        }
        else {
            $(".News:visible:first").fadeOut(200);
            $(".News:first").delay(200).fadeIn(200);
        }
    });
    $("#displayerarwR").click(function() {
        nic();
    });

    $("#displayerarwL1").click(function() {
        if ($(".oportunity:visible:first").prev().parent().attr("id") == "oportunitydisplayer") {
            $(".oportunity:visible:first").prev().delay(200).fadeIn(200);
            $(".oportunity:visible:first").fadeOut(200);
        }
        else {
            $(".oportunity:visible:first").fadeOut(200);
            $(".oportunity:first").delay(200).fadeIn(200);
        }
    });
    $("#displayerarwR1").click(function() {
        oic();
    });

    //$(".cubuk").each(function(){ $(this).slider( {animate: true,change: handleSliderChange,slide: handleSliderSlide,orientation: 'vertical',value: 100}  ) });
    //  
    //function handleSliderChange(e, ui)
    //{
    //  var maxScroll = $(".slidearea").attr("scrollHeight") - 
    //                  $(".slidearea").height();
    //  $(".slidearea").animate({scrollTop: ui.value * 
    //     (maxScroll / 100) }, 1000);
    //}

    //  
    //function handleSliderSlide(e, ui)
    //{
    //  var maxScroll = $(".slidearea").attr("scrollHeigh") - 
    //                  $(".slidearea").height();
    //  $(".slidearea").attr({scrollTop: ui.value * (maxScroll / 100) });
    //}
    $(".News:hidden:first").show();

    $(".oportunity:hidden:first").show();

    $('#logo').click(function() {
        window.location.replace('HomePage.aspx');
    });

    $('#logo-tr').click(function() {
        window.location.replace('Anasayfa.aspx');
    });

    $('#HomeLink').click(function() {
        window.location.replace('HomePage.aspx');
    });

    $('#OppLink').click(function() {
        window.location.replace('Opportunity.aspx');
    });

    $('#SchLink').click(function() {
        window.location.replace('SecondHand.aspx');
    });

    $('#AccsLink').click(function() {
        window.location.replace('Accessories.aspx');
    });

    $('#NewsLink').click(function() {
        window.location.replace('News.aspx');
    });

    $('#AbtusLink').click(function() {
        window.location.replace('AboutUs.aspx');
    });

    $('#CntcLink').click(function() {
        window.location.replace('Contact.aspx');
    });

    $('#AnnsmLink').click(function() {
        window.location.replace('Announcement.aspx');
    });
    $('#UsflInfLink').click(function() {
        window.location.replace('UsefulInformations.aspx');
    });
    $('#HomeLinktr').click(function() {
        window.location.replace('Anasayfa.aspx');
    });

    $('#OppLinktr').click(function() {
        window.location.replace('Firsat.aspx');
    });

    $('#SchLinktr').click(function() {
        window.location.replace('Ikinciel.aspx');
    });
    $('#AccsLinktr').click(function() {
        window.location.replace('Aksesuar.aspx');
    });

    $('#NewsLinktr').click(function() {
        window.location.replace('Haber.aspx');
    });

    $('#AbtusLinktr').click(function() {
        window.location.replace('Hakkimizda.aspx');
    });

    $('#CntcLinktr').click(function() {
        window.location.replace('Iletisim.aspx');
    });

    $('#AnnsmLinktr').click(function() {
        window.location.replace('Duyuru.aspx');
    });
    $('#UsflInfLinktr').click(function() {
        window.location.replace('Restoran.aspx');
    });

    $('#usf_Restaurant').click(function() {
        window.location.replace('UsefulInformations.aspx');
    });

    $('#usf_Marinas').click(function() {
        window.location.replace('Marina.aspx');
    });

    $('#usf_GasStation').click(function() {
        window.location.replace('GasStation.aspx');
    });

    $('#usf_Service').click(function() {
        window.location.replace('Journal.aspx');
    });
    $('#usf_Practical_info').click(function() {
        window.location.replace('PracticalInformationAboutBoats.aspx');
    });

    $('#usf_buying').click(function() {
        window.location.replace('StepsOfBuyingBoats.aspx');
    });

    $('#usf_Restauranttr').click(function() {
        window.location.replace('Restoran.aspx');
    });

    $('#usf_Marinastr').click(function() {
        window.location.replace('Marinalar.aspx');
    });

    $('#usf_GasStationtr').click(function() {
        window.location.replace('Benzinistasyonlari.aspx');
    });

    $('#usf_Servicetr').click(function() {
        window.location.replace('SeyirDefteri.aspx');
    });
    $('#usf_Practical_infotr').click(function() {
        window.location.replace('TekneİleİlgiliPratikBilgiler.aspx');
    });

    $('#usf_buyingtr').click(function() {
        window.location.replace('Adimadimteknealmak.aspx');
    });


    $('#dnzmenu').click(function() {
        window.location.replace('DenizTech.aspx');
    });

    $('#dnzmenutr').click(function() {
        window.location.replace('DenizTech-TR.aspx');
    });


    $('#tohome').click(function() {
        window.location.replace('HomePage.aspx');
    });

    $('#GstbkLink').click(function() {
        window.location.replace('GuestBook.aspx');
    });

    $('#GstbkLinktr').click(function() {
        window.location.replace('ZiyaretciDefteri.aspx');
    });


    $('#tr').click(function() {
        window.location.replace('Anasayfa.aspx');
    });

    $('#en').click(function() {
        window.location.replace('HomePage.aspx');
    });


    $('#openclose').click(function() {
        if ($("#newsopportunity").css("display") != "none") {
            $("#newsopportunity").animate({ width: 'hide' });
            $("#openclose").css('background-image', 'url(images/open2.png)');
        }
        else {
            $("#newsopportunity").animate({ width: 'show' });
            $("#openclose").css('background-image', 'url(images/close2.png)');

        }
    });

    $('#openclose-tr').click(function() {
        if ($("#newsopportunity").css("display") != "none") {
            $("#newsopportunity").animate({ width: 'hide' });
            $("#openclose-tr").css('background-image', 'url(images/open.png)');
        }
        else {
            $("#newsopportunity").animate({ width: 'show' });
            $("#openclose-tr").css('background-image', 'url(images/close.png)');

        }
    });


    $('#shropenclose').click(function() {
        if ($("#shrfacebook").css("display") != "none") {
            $("#shrfacebook").animate({ width: 'hide' });
            $("#shropenclose").css('background-image', 'url(images/facebook_open.png)');
            $("#share1").animate({ width: '18px' });
        }
        else {
            $("#shrfacebook").animate({ width: 'show' });
            $("#shropenclose").css('background-image', 'url(images/facebook_close.png)');
            $("#share1").animate({ width: '186px' });
        }
    });

    $('#shropenclose-tr').click(function() {
        if ($("#shrfacebook-tr").css("display") != "none") {
            $("#shrfacebook-tr").animate({ width: 'hide' });
            $("#shropenclose-tr").css('background-image', 'url(images/facebook_open.png)');
            $("#share1-tr").animate({ width: '18px' });
        }
        else {
            $("#shrfacebook-tr").animate({ width: 'show' });
            $("#shropenclose-tr").css('background-image', 'url(images/facebook_close.png)');
            $("#share1-tr").animate({ width: '186px' });
        }
    });


    $(".showComment").each(function() {

        $(this).click(function() {
            $("#comment" + $(this).attr("id")).slideToggle();
        });


    });




    var id = "#toBeScrolled";

    $("#aboutUsPic div:first").fadeIn(1000);

    var fn2 = function() {
        if ($("#aboutUsPic div:visible:first").next().parent().attr("id") == "aboutUsPic") {
            $("#aboutUsPic div:visible:first").next().delay(1000).fadeIn(1000);
            $("#aboutUsPic div:visible:first").fadeOut(1000);
        }
        else {
            $("#aboutUsPic div:visible:first").fadeOut(1000);
            $("#aboutUsPic div:first").delay(1000).fadeIn(1000);
        }
    };

    var inte = setInterval(fn2, 2000);




    $(".rpt:first").fadeIn("slow");

    $("#arwright").click(function() {

        if ($(".rpt:visible:first").parent().attr("id") == "harita1") {
            $(".rpt:visible:first").next().fadeIn(5000);
            $(".rpt:visible:first").fadeOut(5000);
        }

    });
});


