function getPlayerNew($playerId, $url) {

    $('#radioPlayer').html('');
    $.post("/getPlayerRadiozendersNew.php", { playerId: $playerId, text: false }, function(data){
        $('#radioPlayer').html(data);
    });

    $url = $url.replace('http://www.radiozenders.fm', '');
    var pageTracker = _gat._getTracker("UA-398344-12");
    pageTracker._trackPageview($url);

    loadPlayerAds($playerId);
}

function getMaliboomboomNew()
{
    $.post("/getPlayerRadiozendersNew.php", {playerId: 61, validAge: true }, function(data){
        $('#radioPlayer').html(data);
    });
}

function validateAgeNew()
{
    var day      = jQuery("#dateDay").val();
    var month    = jQuery("#dateMonth").val();
    var year     = jQuery("#dateYear").val();
    var age      = 18;

    var currdate = new Date();
    var mydate   = new Date();
    mydate.setFullYear(year, month-1, day);

    currdate.setFullYear(currdate.getFullYear() - age);
    if ((currdate - mydate) < 0){
        $('#ageError').html('Je bent niet oud genoeg.');
        return false;
    }
    getMaliboomboomNew();
}

function getInfo($info, $form)
{
    $.post("/getInfo.php", { info: $info, form: $form}, function(data){
	$('#infoPopupContent').html(data);
        $('#infoPopup').css('display', 'block');
    });
}

function sendEmail()
{   $info           = 'contactSubmit';
    $name           = $('#name').val();
    $emailAddress   = $('#emailAddress').val();
    $subject        = $('#subject').val();
    $message        = $('#message').val();
    $.post("/getInfo.php", { info: $info, name: $name, emailAddress: $emailAddress, subject: $subject, message: $message}, function(data){
	$('#infoPopupContent').html(data);
        $('#infoPopup').css('display', 'block');
    });

}

function closePopup()
{
    $('#infoPopup').css('display', 'none');
}

/**
 * Function which loads the player ads when the visitor clicks on a
 * radio station. For certain stations different ads are loaded.
 */
function loadPlayerAds($playerId) {
    return;
    $.getJSON("/getPlayerAd.php", { playerId: $playerId}, function(data){
        if (data.top) {
            $('div.radioTopBanner').html(data.top);
        }

        if (data.left) {
            $('div.bottomLeftBanner').html(data.left);
        }

        if (data.right) {
            $('div.bottomRightBanner').html(data.right);
        }
    });

}

function fadeOutStations() {
    $('td.radioStation').each(function(index) {
        $(this).fadeOut();
//        $(this).delay(50*index).fadeOut();
//        $(this).delay(50*index).fadeTo(250, 0.01);
    });
    return true;
}


function fadeInStations() {
    $('td.radioStation').each(function(index) {
        $(this).fadeIn();
//        $(this).delay(50*index).show("fast");
//        $(this).delay(50*index).fadeTo(250, 1);
    });
    return true;
}

function getStations($province) {
//    fadeOutStations();
//    setTimeout(function() {
        loadStations($province);
        setTimeout(function() {addStationEffects();}, 1000);
//        fadeInStations();
//    }, 3000);
}

function loadStations($province) {
    $.ajaxSetup({
        cache: false
    });
    $.getJSON("/getStationsRadiozenders.php", {province: $province, text: false},
    function(data) {
        for ($i = 1; $i <= 36; $i++) {
            if (data[$i]) {
                $('#radioStation'+$i).html(data[$i]);
            } else {
                $('#radioStation'+$i).html('&nbsp;');
            }
        }
        if (data['center_text']) {
            $('div.radioCenterText').html(data['center_text']);
            $('div.radioCenterTextShadow').html(data['center_text']);
        }
        if (data['banner_top']) {
            $('div.radioTopBanner').html(data['banner_top']);
        }
    });

    var pageTracker = _gat._getTracker("UA-398344-12");
    pageTracker._trackPageview('/'+$province);

}

function addStationEffects() {
    $("td.radioStation img").each(function() {
    $.data(this, 'size', { width: $(this).width(), height: $(this).height() });
}).hover(
    function() {
        $(this).stop().animate({
            height: $.data(this,'size').width=85,
            width: $.data(this,'size').width=85,
            marginLeft: '-5px',
            marginTop: '0px'
            }, {
                duration: 200
            }
        )
    },
    function() {
        $(this).stop().animate({
             height: $.data(this,'size').width=75,
             width: $.data(this,'size').width=75,
             marginLeft: '0px',
             marginTop: '4px'
            }, {
                duration: 200
            }
        );
    });
}

function bookmarksite() {
    title = 'Radiozenders.FM';
    url   = 'http://www.radiozenders.fm/';
    if (window.sidebar) {
        window.sidebar.addPanel(title, url, "");
    } else if (window.opera && window.print) {
        var elem = document.createElement('a');
        elem.setAttribute('href',url);
        elem.setAttribute('title',title);
        elem.setAttribute('rel','sidebar');
        elem.click();
    } else if (document.all) {
        window.external.AddFavorite(url, title);
    }
}
