﻿$(document).ready(function () {

    // Watermarks
    if (Application.LanguageId == 4)
    { $('#txtSearch').Watermark('Search on this site'); }
    else if (Application.LanguageId == 5) {
        $('#txtSearch').Watermark('Rechercher sur le site');
    } else {
        $('#txtSearch').Watermark('Zoek binnen deze site');
    }

    if (Application.LanguageId == 4) {
        $('#txtCity').Watermark('Your Location');
    } else if (Application.LanguageId == 5) {
        $('#txtCity').Watermark('Votre localité');
    } else {
        $('#txtCity').Watermark('Uw Plaats');
    }


    if (Application.LanguageId == 4) {
        $('#txtPostcode').Watermark('Your Postcode');
    } else if (Application.LanguageId == 5) {
        $('#txtPostcode').Watermark('Votre code postal');
    } else {
        $('#txtPostcode').Watermark('Uw Postcode');
    }

    // Functions
    $('#btnSearchTop').click(function () {
        if ($('#txtSearch').val() != null && $('#txtSearch').val().length > 0) {
            document.location = _siteRoot + 'SearchResults.aspx?query=' + $('#txtSearch').val();
        }
    });

    $('#txtSearch').keyup(function (event) {
        if (event.keyCode == 13) {
            document.location = _siteRoot + 'SearchResults.aspx?query=' + $('#txtSearch').val();
        }
    });

    $('#txtPostcode').keyup(function (event) {
        if (event.keyCode == 13) {
            document.location = _siteRoot + 'ShopDirections.aspx?postcode=' + $('#txtPostcode').val();
        }
    });

    $('#txtCity').keyup(function (event) {
        if (event.keyCode == 13) {
            document.location = _siteRoot + 'ShopDirections.aspx?city=' + $('#txtCity').val();
        }
    });

    // Pop-ups
    $dialogShop = $('#divShopDialog').dialog({
        height: 150,
        width: 440,
        modal: true,
        autoOpen: false,
        title: 'Postcode',
        hide: 'scale'
    });

    $('#Route').click(function () {
        $dialogShop.dialog('open');
    });

    $("#txtCity").autocomplete(_siteRoot + "Ajax/GetCities.aspx");

    $("#tdToggle").hide();
    $('#imgToggle').click(function () {
        $('#tdToggle').toggle('slow');
    });

    // Mijn Auto
    $('#lnkSearch').click(function () {
        var plate = $('#txtLicense1').val();
        document.location = 'BandenInformatie.aspx?licencePlate=' + plate;
    });

    // Press release

    $('#lblYear2011').click(function () {
        $('#divPress2011').toggle('slow');
    });

});

function ChangeImage(img) {
    if (img.src.toLowerCase().indexOf("on") > 0)
        img.src = img.src.toLowerCase().replace("on", "");


    else
        img.src = img.src.toLowerCase().replace(".png", "on.png");

}

var Banners = {}

Banners.Intervals = function (value1, value2, value3, value4, value5) {
    if (value1.attr('class') == 'btnTopRed') {
        value1.attr('class', 'btnTopWhite');
        value2.attr('class', 'btnOver');
        value3.attr('class', 'btnNormal');
        value4.attr('class', 'btnNormal');
        value5.attr('class', 'btnBottomWhite');
    }
    else if (value2.attr('class') == 'btnOver') {
        value1.attr('class', 'btnTopWhite');
        value2.attr('class', 'btnNormal');
        value3.attr('class', 'btnOver');
        value4.attr('class', 'btnNormal');
        value5.attr('class', 'btnBottomWhite');

    }
    else if (value3.attr('class') == 'btnOver') {
        value1.attr('class', 'btnTopWhite');
        value2.attr('class', 'btnNormal');
        value3.attr('class', 'btnNormal');
        value4.attr('class', 'btnOver');
        value5.attr('class', 'btnBottomWhite');
    }
    else if (value4.attr('class') == 'btnOver') {
        value1.attr('class', 'btnTopWhite');
        value2.attr('class', 'btnNormal');
        value3.attr('class', 'btnNormal');
        value4.attr('class', 'btnNormal');
        value5.attr('class', 'btnBottomRed');
    } else {
        value1.attr('class', 'btnTopRed');
        value2.attr('class', 'btnNormal');
        value3.attr('class', 'btnNormal');
        value4.attr('class', 'btnNormal');
        value5.attr('class', 'btnBottomWhite');
    }
}

Banners.MoveButtons = function (nav, div, buton1, buton2, buton3, buton4, buton5) {
    $('#' + div).fadeIn(1000, function () {
        $('#' + div).cycle({
            fx: 'fade',
            speed: 'slow',
            timeout: 5000,
            pager: $('#' + nav)
        });
        b1 = $('#' + buton1);
        b2 = $('#' + buton2);
        b3 = $('#' + buton3);
        b4 = $('#' + buton4);
        b5 = $('#' + buton5);
    });
    setInterval('Banners.Intervals(b1,b2,b3,b4,b5)', 5000);
}

function ChangeClass2(link) {
    thelink = $('#' + link);
    thelink.attr("class", "btnOver");
}

function RestoreClass2(link) {
    thelink = $('#' + link);
    thelink.attr("class", "btnNormal");
}

function ChangeClass1(link) {
    thelink = $('#' + link);
    thelink.attr("class", "btnTopRed");
}

function RestoreClass1(link) {
    thelink = $('#' + link);
    thelink.attr("class", "btnTopWhite");
}

function ChangeClass3(link) {
    thelink = $('#' + link);
    thelink.attr("class", "btnBottomRed");
}

function RestoreClass3(link) {
    thelink = $('#' + link);
    thelink.attr("class", "btnBottomWhite");
}

function ShowDetails3(control1, control2, control3, control4) {

    var detail = $('#' + control1);
    var plus = $('#' + control2);
    var firstdiv = $('#' + control3);
    var secondDiv = $('#' + control4);

    if (detail.is(":hidden")) {
        firstdiv.removeClass('LeftPanel');
        secondDiv.css('display', 'block');
        detail.slideDown(100);
        plus.attr('src', _appTheme + 'Images/arrowUp.png')
    }
    else {
        secondDiv.css('display', 'none');
        firstdiv.addClass('LeftPanel');
        detail.slideUp(100);
        plus.attr('src', _appTheme + 'Images/arrowDown.png')

    }
}

function GoToUrl(url) {
    document.location = url;
}

var MijnAuto = {};

MijnAuto.Tip1_1 =  function(languageId, text1, text2, text3) {
    if (text3 != 'N/A')
        if (languageId == 8) {
            if (Number(text3) < 1.6)
                Tip('<span style="font-weight:bold;">Gemonteerde band:</span><br/>' + text1 + '<br><br><span style="font-weight:bold;"">Opgeslagen band:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profieldiepte opgeslagen band:</span><br />' + '<span style="background-color:Red;color:white;">' + text3 + ' mm</span><br /><span style="font-style:italic">profieldiepte onder wettelijk minimum, advies: vervangen</span>', BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
            else {
                if (Number(text3) >= 1.6 && Number(text3) < 4.0)
                    Tip('<span style="font-weight:bold;">Gemonteerde band:</span><br>' + text1 + '<br /><br /><span style="font-weight:bold;">Opgeslagen band:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profieldiepte opgeslagen band:</span><br />' + '<span style="background-color:Orange;color:white;">' + text3 + ' mm</span><br /><span style="font-style:italic"> 1,6-4,0mm is onvoldoende profieldiepte voor winterbanden,<br /> 1,6-2,5mm is onvoldoende profieldiepte voor zomerbanden,<br /> volgens Carmasters heeft het advies: vervangen</span>', BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                else
                    if (Number(text3) >= 4.0)
                        Tip('<span style="font-weight:bold;">Gemonteerde band:</span><br>' + text1 + '<br /><br /><span style="font-weight:bold;">Opgeslagen band:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profieldiepte opgeslagen band:</span><br />' + '<span style="background-color:Green;color:white;">' + text3 + ' mm</span><br /><span style="font-style:italic"> voldoende profieldiepte</span>', BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                    else
                        Tip('<span style="font-weight:bold;">Gemonteerde band:</span><br>' + text1 + '<br /><br /><span style="font-weight:bold;">Opgeslagen band:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profieldiepte opgeslagen band:</span><br />' + text3, BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
            }
        }
        else
            if (languageId == 5) {
                if (Number(text3) < 1.6)
                    Tip('<span style="font-weight:bold;">Pneus monté:</span><br/>' + text1 + '<br><br><span style="font-weight:bold;"">Pneu stocké:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profondeur de sculpture du pneu stocké:</span><br />' + '<span style="background-color:Red;color:white;">' + text3 + ' mm</span><br /><span style="font-style:italic">profondeur sous le minimum légal minimum, conseil: remplacer le pneu</span>', BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                else {
                    if (Number(text3) >= 1.6 && Number(text3) < 4.0)
                        Tip('<span style="font-weight:bold;">Pneus monté:</span><br>' + text1 + '<br /><br /><span style="font-weight:bold;">Pneu stocké:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profondeur de sculpture du pneu stocké:</span><br />' + '<span style="background-color:Orange;color:white;">' + text3 + ' mm</span><br /><span style="font-style:italic"> une profondeur de sculpture de 1,6 à 4 mm est insuffisante pour des pneus hiver,<br /> une profondeur de sculpture de 1,6 à 2,5 mm est insuffisante pour des pneus été,<br /> Carmasters vous conseille: remplacer le pneu</span>', BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                    else
                        if (Number(text3) >= 4.0)
                            Tip('<span style="font-weight:bold;">Pneus monté:</span><br>' + text1 + '<br /><br /><span style="font-weight:bold;">Pneu stocké:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profondeur de sculpture du pneu stocké:</span><br />' + '<span style="background-color:Green;color:white;">' + text3 + ' mm</span><br /><span style="font-style:italic"> assez de profondeur</span>', BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                        else
                            Tip('<span style="font-weight:bold;">Pneus monté:</span><br>' + text1 + '<br /><br /><span style="font-weight:bold;">Pneu stocké:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profondeur de sculpture du pneu stocké:</span><br />' + text3, BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                }
            }
            else {
                if (Number(text3) < 1.6)
                    Tip('<span style="font-weight:bold;">Fitted tyre:</span><br/>' + text1 + '<br><br><span style="font-weight:bold;"">Stored tyre:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profile depth of stored tyre:</span><br />' + '<span style="background-color:Red;color:white;">' + text3 + ' mm</span><br /><span style="font-style:italic">profile tread depth  beneath legal minimum, advice: replace tyre</span>', BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                else {
                    if (Number(text3) >= 1.6 && Number(text3) < 4.0)
                        Tip('<span style="font-weight:bold;">Fitted tyre:</span><br>' + text1 + '<br /><br /><span style="font-weight:bold;">Stored tyre:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profile depth of stored tyre:</span><br />' + '<span style="background-color:Orange;color:white;">' + text3 + ' mm</span><br /><span style="font-style:italic"> 1.6 – 4.0 mm is not enough profile depth for winter tyres,<br /> 1.6 – 2.5 mm is not enough profile depth for summer tyres,<br /> Carmasters advises: replace tyre</span>', BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                    else
                        if (Number(text3) >= 4.0)
                            Tip('<span style="font-weight:bold;">Fitted tyre:</span><br>' + text1 + '<br /><br /><span style="font-weight:bold;">Stored tyre</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profile depth of stored tyre:</span><br />' + '<span style="background-color:Green;color:white;">' + text3 + ' mm</span><br /><span style="font-style:italic"> enough profile depth</span>', BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                        else
                            Tip('<span style="font-weight:bold;">Fitted tyre:</span><br>' + text1 + '<br /><br /><span style="font-weight:bold;">Stored tyre:</span><br>' + text2 + '<br /><br /><span style="font-weight:bold;">Profile depth of stored tyre:</span><br />' + text3, BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
                }
            }
    else
        if (languageId == 8) {
            Tip('<span style="font-weight:bold;">Gemonteerde band:</span><br>' + text1 + '<br><span style="font-weight:bold;">Opgeslagen band:</span><br>' + text2 + '<br /><span style="font-weight:bold;">Profieldiepte opgeslagen band:</span><br />' + text3, BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
        }
        else
            if (languageId == 5) {
                Tip('<span style="font-weight:bold;">Pneus monté:</span><br>' + text1 + '<br><span style="font-weight:bold;">Pneu stocké:</span><br>' + text2 + '<br /><span style="font-weight:bold;">Profondeur de sculpture du pneu stocké:</span><br />' + text3, BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
            }
            else {
                Tip('<span style="font-weight:bold;">Fitted tyre:</span><br>' + text1 + '<br><span style="font-weight:bold;">Stored tyre:</span><br>' + text2 + '<br /><span style="font-weight:bold;">Profile depth of stored tyre:</span><br />' + text3, BORDERWIDTH, 1, PADDING, 10, CLICKCLOSE, true, DELAY, 0);
            }
}

MijnAuto.TipHeight =  function () {
    Tip('<span class="textTyre"><b>Hoogte</b><br>De hoogte wordt weergegeven als percentage van de breedte. Bij de bandenmaat 195/65 R15 bijvoorbeeld, is de hoogte 65% van de breedte. In het hier genoemde voorbeeld is de hoogte 65% van 195 mm, en dus 126,75 mm.</span>', WIDTH, 250, BORDERWIDTH, 1, PADDING, 10, BGCOLOR, '#ffffff', CLICKCLOSE, true, BORDERCOLOR, '#e2e2e2', DELAY, 0);
}
