﻿var priceEur = '0';
var priceGbp = '0';
var priceUsd = '0';

function ChangePrice(currency) {
    SetPriceFai(currency);

    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 31 * 24 * 60 * 60 * 1000);
    setCookie('pricefai', currency, now);
}

function SetPriceFai(currency) {
    var newValue = priceEur;

    switch (currency) {
        case 'EUR': newValue = priceEur; break;
        case 'GBP': newValue = priceGbp; break;
        case 'USD': newValue = priceUsd; break;
    }
    $('#price_fai').html(newValue);
}

function PriceFaiInit() {
    var currency = getCookie('pricefai');
    if (!currency) currency = 'EUR';

    SetPriceFai(currency);

    $('#price_eur').click(function() {
        ChangePrice('EUR');
    });

    $('#price_gbp').click(function() {
        ChangePrice('GBP');
    });

    $('#price_usd').click(function() {
        ChangePrice('USD');
    });

    $('#popupfai').hover(function() {
        showPopup('popup', this);
    }, function() { hidePopup('popup'); });

    $('#price_eur').hover(function() {
        this.src = '/images/euro18.png';
    }, function() {
        this.src = '/images/euro12.png';
    });

    $('#price_gbp').hover(function() {
        this.src = '/images/pound18.png';
    }, function() {
        this.src = '/images/pound12.png';
    });

    $('#price_usd').hover(function() {
        this.src = '/images/dollar18.png';
    }, function() {
        this.src = '/images/dollar12.png';
    });
}

$(document).ready(function() { PriceFaiInit(); });
