﻿function setSelectedMenu(menuItem) {
    $(document).ready(function() {
        $('.' + menuItem).addClass('Selected');
    });
}

function setText(textBoxItem, focus, text) {
    $(document).ready(function() {
        var textBox = $('#' + textBoxItem);
        if (focus == true) {
            if (textBox.val() == text) {
                textBox.val('');
                textBox.css('font-style', 'inherit').css('color', '#000000');
            }
        }
        else {
            if (textBox.val() == '') {
                textBox.val(text);
                textBox.css('font-style', 'italic').css('color', '#444069');
            }
        }
    });
}

function shareLink(media) {
    var siteUrl = 'http://www.ragarockers.no/';
    var message = 'Sjekk ut Raga Rockers nye websider! ';
    switch (media) {
        case 'facebook':
            window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(siteUrl), 'sharer', 'toolbar=0,status=0,width=626,height=436');
            break;
        case 'twitter':
            window.open('http://twitter.com/home?status=' + encodeURIComponent(message + siteUrl), 'sharer', 'toolbar=0,status=0,width=800,height=600');
            break;
        default:
            alert('Media \'' + media + '\' not available for sharing!');
            break;
    }
}

function popupPlayer() {
    $.cookie('playerIsPopup', 'true');
    window.open('Lydavspiller.aspx', 'Lydavspiller', 'height=100,width=385,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0');
    $('#MediaPlayer').css('display', 'none');
}
function closePlayer() {
    $.cookie('playerIsPopup', null);
    window.opener.$('#MediaPlayer').css('display', 'block');
    var flashvars = {
        siteUrl: "http://www.ragarockers.no/",
        isPopup: "false"
    };
    window.opener.swfobject.embedSWF("SWF/player.swf", "MediaPlayer", "301", "20", "9.0.0", "SWF/expressInstall.swf", flashvars);
    window.close();    
}

function toggleNewCategoryTextBox(senderId) {
    $(document).ready(function() {
        var categoryDropDown = $('#' + senderId);
        var newCategoryTextBox = $('.NewCategoryTextBox');
        //alert(categoryDropDown.val());
        if (categoryDropDown.val() == '') {
            newCategoryTextBox.css('visibility', 'visible');
        }
        else {
            newCategoryTextBox.css('visibility', 'hidden');
        }
    });
}