jQuery.noConflict();
jQuery(document).ready(function($){
    $.ajaxSetup({
        cache: false
    });

    $('#ProductCurrency').change(function(){
        var curId = $(this).val();
        $.get('/currencies/rate/'+curId, function(data){
            data = data.split(';');

            var rate = data[0];
            var code = data[1];

            if(code == 'USD' || code == 'NZD' || code == 'AUD'){
                code = '&#36;';
            }

            if(code == 'EUR'){
                code = '&#8364;';
            }

            if(code == 'GBP'){
                code = '&#163;';
            }

            $('.price').each(function(){
                var newPrice = rate * $(this).attr('title');
                $(this).html(code + ' ' + newPrice.toFixed(2));
            });

            $('.nonPrice').each(function(){
                var newPrice = rate * $(this).attr('title');
                $(this).html(code + ' ' + newPrice.toFixed(2));
            });

            $('.special').each(function(){
                var newPrice = rate * $(this).attr('title');
                $(this).html(code + ' ' + newPrice.toFixed(2));
            });
        });
    });
});

