// Common
function $register(ns)
{
	var segs = ns.split(".");
	var namespace = window;
	for(var s = 0; s < segs.length; s++)
	{
		var seg = segs[s];
		if (typeof(namespace[seg]) == "undefined")
			namespace[seg] = new Object();
			
		namespace = namespace[seg];
	}
}

// Namespaces
$register("TWorx.DNN.SkinWidgets");

// Classes

// BEGIN: TWorx.DNN.SkinWidgets.Stylesheet
TWorx.DNN.SkinWidgets.Stylesheet = function()
{
}

TWorx.DNN.SkinWidgets.Stylesheet.prototype = 
{
	inject : $TWorx_DNN_SkinWidgets_Stylesheet_Inject
}

function $TWorx_DNN_SkinWidgets_Stylesheet_Inject(url)
{
   if (document.createStyleSheet)
		document.createStyleSheet(url);
   else
   {
        var head = document.getElementsByTagName("head")[0];
        if (head)
            head.innerHTML += "<link rel=\"stylesheet\" href=\"" + url + "\">";
   }
}

function $TWorx_DNN_SkinWidgets_Stylesheet_GetUrl()
{
	return(this.__url);
}


function $TWorx_DNN_SkinWidgets_Stylesheet_GetCookieName()
{
	return(this.__cookieName);
}

// END: TWorx.DNN.SkinWidgets.StylesheetInjector

// BEGIN: TWorx.DNN.SkinWidgets.Switcher

TWorx.DNN.SkinWidgets.Switcher = function()
{
}

TWorx.DNN.SkinWidgets.Switcher.prototype = 
{
	select : $TWorx_DNN_SkinWidgets_Switcher_Select		
}


function $TWorx_DNN_SkinWidgets_Switcher_Select(url, cookieName, cookieValue)
{
	var stylesheet = new TWorx.DNN.SkinWidgets.Stylesheet();
	stylesheet.inject(url);
   
    if (cookieName != "")
    {
		document.cookie = cookieName + "=" + cookieValue + ";expires=" + new Date("December 31, 2030 23:59:59").toGMTString() + ";path=/";		
    }
}


// END: TWorx.DNN.SkinWidgets.Switcher

var skinWidgetsSwitcher = new TWorx.DNN.SkinWidgets.Switcher();
