﻿$(document).ready(function()
{
    SetCurrentTheme();
    $("#ThemeDropDown").change(SetNewTheme);
});

function SetCurrentTheme()
{
    
    var themeval = $.cookie("theme");
    if (themeval == null)
    {
        themeval = "js/themes/south-street/ui.all.css"; //south street is default theme
    }
    if (themeval != null)
    {
        $("#ThemeDropDown").val(themeval);
        $("#ThemeDropDown option:contains(" + themeval + ")").attr("selected", true);
        SetNewTheme();
    }


}

function isIE()
{
    return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

function SetNewTheme()
{
    var selHref = $("#ThemeDropDown").val();
    $.cookie("theme", selHref, { expires: 365 });
    var cssLink = $('<link href="' + selHref + '" type="text/css" rel="Stylesheet" />');
    $("head").append(cssLink);

    if ($("link[href*=ui.all.css]").size() > 3)
    {
        $("link[href*=ui.all.css]:first").remove();
    }	
    
    if (typeof GetTweetItemBackColor != 'undefined')
    {
        $("#ThemeDropDown").oneTime(oneSecond / 2, function()
        {
            GetTweetItemBackColor();
        });
        
        //RefreshTweets();
    }   
    
}