﻿$(document).ready(function() {

    // Navigation //

    $('#navigation ul li a').hover(function() {
        $(this).parent('li').css('background-position', 'bottom left');
    }, function() {
        $(this).parent('li').css('background-position', 'top left');
    });

    // Feature List //

    $('div.featurelist a').click(function() {
        var clicked = $(this).attr('title');
        $('#feature img').hide();
        $('#feature span').hide();
        $('#feature img#img-' + clicked).show();
        $('#feature span#txt-' + clicked).show();
    });

    // Local Rep Continent > Country Select //

    $('select#localrep-region').change(function() {
        var region = $(this).val();
        $('.localrep-country').hide();
        $('#localrep-' + region).show();
        $('div.address span').hide();
        $('form, .hide').hide();
        $.cookie('continent', region);
    });

    // Local Rep Country > Address Select //

    $('select.localrep-country').change(function() {
        var country = $(this).val();
        var countryformatted = $(this).find('option[@value=' + country + ']').text();
        $('div.address span').hide();
        $('form, .hide').hide();
        $('div.address .' + country).show();
        $.cookie('country_set', 'true');
        $.cookie('country', country);
        var recipient = $(this).find('option[@value=' + country + ']').attr('name');
        $('input#field-country').val(countryformatted);
        $('#emailaddress').attr('href', 'mailto:info@elgalabwater.com?subject=PURELAB flex enquiry - ' + countryformatted).text('info@elgalabwater.com');
    });

    // Turn List Names into Values //
    //$('select.localrep-country option').each(function(){
    //	var countryval = $(this).text();
    //	$(this).val(countryval);
    //});

    // Product Rollovers //

    $('map#mapclosed area').mouseover(function() {
        var over = $(this).attr('id');
        $('#feature img').hide();
        $('#feature span').hide();
        $('#feature img#img-' + over).show();
        $('#feature span#txt-' + over).show();
    });

    $('map#mapopen area').mouseover(function() {
        var over = $(this).attr('id');
        $('#feature img').hide();
        $('#feature span').hide();
        $('#feature img#img-' + over).show();
        $('#feature span#txt-' + over).show();
    });

    $('map#maphandset area').mouseover(function() {
        var over = $(this).attr('id');
        $('#feature img').hide();
        $('#feature span').hide();
        $('#feature img#img-' + over).show();
        $('#feature span#txt-' + over).show();
    });


    // Closed Product //

    $('map#mapclosed area#dispensetube').mouseover(function() {
        $('#closed img').attr('src', 'img/flex_closed_tube_highlighted.jpg');
    });
    $('map#mapclosed area#dispensetube').mouseout(function() {
        $('#closed img').attr('src', 'img/flex_closed_handset_unhighlighted.jpg');
    });

    $('map#mapclosed area#handset').mouseover(function() {
        $('#closed img').attr('src', 'img/flex_closed_handset_highlighted.jpg');
    });
    $('map#mapclosed area#handset').mouseout(function() {
        $('#closed img').attr('src', 'img/flex_closed_handset_unhighlighted.jpg');
    });

    $('map#mapclosed area#usbport').mouseover(function() {
        $('#closed img').attr('src', 'img/flex_closed_usb_highlighted.jpg');
    });
    $('map#mapclosed area#usbport').mouseout(function() {
        $('#closed img').attr('src', 'img/flex_closed_handset_unhighlighted.jpg');
    });

    $('map#mapclosed area#adjustablearm').mouseover(function() {
        $('#closed img').attr('src', 'img/flex_closed_arm_highlighted.jpg');
    });
    $('map#mapclosed area#adjustablearm').mouseout(function() {
        $('#closed img').attr('src', 'img/flex_closed_handset_unhighlighted.jpg');
    });

    $('map#mapclosed area#doorsclosed').mouseover(function() {
        $('#closed img').attr('src', 'img/flex_closed_doors_highlighted.jpg');
    });
    $('map#mapclosed area#doorsclosed').mouseout(function() {
        $('#closed img').attr('src', 'img/flex_closed_handset_unhighlighted.jpg');
    });


    // Open Product //

    $('map#mapopen area#dispensetube').mouseover(function() {
        $('#open img').attr('src', 'img/flex_open_tube_highlighted.jpg');
    });
    $('map#mapopen area#dispensetube').mouseout(function() {
        $('#open img').attr('src', 'img/flex_open_handset_unhighlighted.jpg');
    });

    $('map#mapopen area#handset').mouseover(function() {
        $('#open img').attr('src', 'img/flex_open_handset_highlighted.jpg');
    });
    $('map#mapopen area#handset').mouseout(function() {
        $('#open img').attr('src', 'img/flex_open_handset_unhighlighted.jpg');
    });

    $('map#mapopen area#adjustablearm').mouseover(function() {
        $('#open img').attr('src', 'img/flex_open_arm_highlighted.jpg');
    });
    $('map#mapopen area#adjustablearm').mouseout(function() {
        $('#open img').attr('src', 'img/flex_open_handset_unhighlighted.jpg');
    });

    $('map#mapopen area#uvlamp').mouseover(function() {
        $('#open img').attr('src', 'img/flex_open_uvlamp_highlighted.jpg');
    });
    $('map#mapopen area#uvlamp').mouseout(function() {
        $('#open img').attr('src', 'img/flex_open_handset_unhighlighted.jpg');
    });

    $('map#mapopen area#purificationpack').mouseover(function() {
        $('#open img').attr('src', 'img/flex_open_purificationpack_highlighted.jpg');
    });
    $('map#mapopen area#purificationpack').mouseout(function() {
        $('#open img').attr('src', 'img/flex_open_handset_unhighlighted.jpg');
    });

    $('map#mapopen area#doorsopen').mouseover(function() {
        $('#open img').attr('src', 'img/flex_open_doors_highlighted.jpg');
    });
    $('map#mapopen area#doorsopen').mouseout(function() {
        $('#open img').attr('src', 'img/flex_open_handset_unhighlighted.jpg');
    });

    // Handset Rollovers //

    $('map#maphandset area#dispensebutton').mouseover(function() {
        $('#clickhandset img').attr('src', 'img/flex_handset_dispensebutton_highlighted.jpg');
    });
    $('map#maphandset area#dispensebutton').mouseout(function() {
        $('#clickhandset img').attr('src', 'img/flex_handset_unhighlighted.jpg');
    });

    $('map#maphandset area#qualitydisplay').mouseover(function() {
        $('#clickhandset img').attr('src', 'img/flex_handset_qualitydisplay_highlighted.jpg');
    });
    $('map#maphandset area#qualitydisplay').mouseout(function() {
        $('#clickhandset img').attr('src', 'img/flex_handset_unhighlighted.jpg');
    });

    $('map#maphandset area#autovolumedisplay').mouseover(function() {
        $('#clickhandset img').attr('src', 'img/flex_handset_autovolumedisplay_highlighted.jpg');
    });
    $('map#maphandset area#autovolumedisplay').mouseout(function() {
        $('#clickhandset img').attr('src', 'img/flex_handset_unhighlighted.jpg');
    });

    $('map#maphandset area#dispensetip').mouseover(function() {
        $('#clickhandset img').attr('src', 'img/flex_handset_dispensetip_highlighted.jpg');
    });
    $('map#maphandset area#dispensetip').mouseout(function() {
        $('#clickhandset img').attr('src', 'img/flex_handset_unhighlighted.jpg');
    });

    // Switch between images //

    $('map#mapclosed area#handset, map#mapopen area#handset').click(function() {
        $('div#closed').hide();
        $('div#open').hide();
        $('div#clickhandset').show();
    });

    $('map#mapclosed area#doorsclosed').click(function() {
        $('div#closed').hide();
        $('div#open').show();
    });

    $('map#mapopen area#doorsopen').click(function() {
        $('div#open').hide();
        $('div#closed').show();
    });

    // List to Image switch //

    $('a#link-handset').click(function() {
        $('div#closed').hide();
        $('div#open').hide();
        $('#clickhandset img').attr('src', 'img/flex_handset_unhighlighted.jpg');
        $('div#clickhandset').show();
    });

    $('a#link-dispensebutton').click(function() {
        $('div#closed').hide();
        $('div#open').hide();
        $('#clickhandset img').attr('src', 'img/flex_handset_dispensebutton_highlighted.jpg');
        $('div#clickhandset').show();
    });

    $('a#link-qualitydisplay').click(function() {
        $('div#closed').hide();
        $('div#open').hide();
        $('#clickhandset img').attr('src', 'img/flex_handset_qualitydisplay_highlighted.jpg');
        $('div#clickhandset').show();
    });

    $('a#link-autovolumedisplay').click(function() {
        $('div#closed').hide();
        $('div#open').hide();
        $('#clickhandset img').attr('src', 'img/flex_handset_autovolumedisplay_highlighted.jpg');
        $('div#clickhandset').show();
    });

    $('a#link-dispensetip').click(function() {
        $('div#closed').hide();
        $('div#open').hide();
        $('#clickhandset img').attr('src', 'img/flex_handset_dispensetip_highlighted.jpg');
        $('div#clickhandset').show();
    });

    $('a#link-adjustablearm').click(function() {
        $('div#open').hide();
        $('div#clickhandset').hide();
        $('#closed img').attr('src', 'img/flex_closed_arm_highlighted.jpg');
        $('div#closed').show();
    });

    $('a#link-usbport').click(function() {
        $('div#open').hide();
        $('div#clickhandset').hide();
        $('#closed img').attr('src', 'img/flex_closed_usb_highlighted.jpg');
        $('div#closed').show();
    });

    $('a#link-purificationpack').click(function() {
        $('div#closed').hide();
        $('div#clickhandset').hide();
        $('#open img').attr('src', 'img/flex_open_purificationpack_highlighted.jpg');
        $('div#open').show();
    });

    $('a#link-uvlamp').click(function() {
        $('div#closed').hide();
        $('div#clickhandset').hide();
        $('#open img').attr('src', 'img/flex_open_uvlamp_highlighted.jpg');
        $('div#open').show();
    });

    $('a#link-dispensetube').click(function() {
        $('div#open').hide();
        $('div#clickhandset').hide();
        $('#closed img').attr('src', 'img/flex_closed_tube_highlighted.jpg');
        $('div#closed').show();
    });

    // Return/Back Links //

    $('a.back').click(function() {
        $('div#open').hide();
        $('div#clickhandset').hide();
        $('div#closed').show();
        $('#feature img').hide();
        $('#feature span').hide();
        $('#feature img#img-qualitydisplay').show();
        $('#feature span#txt-default').show();
    });

});
