function setActiveStyleSheet(name) 
{
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel") && a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == name) a.disabled = false;
    }
  }
}

function changeStyleSheet(name,value)
{
	setProfileCookie(name,value);
	setActiveStyleSheet(value);
}


function setProfileCookie(name,value) 
{
  	var expiration_date = new Date("January 1, 2010");
 	expiration_date = expiration_date.toGMTString();
	setCookie(name, value, expiration_date);
}

function setCookie(name, value, expires)
{
	 document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") + "; path=/" ;
	
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


function setTitle(str)
{
	document.title = "North News - " + str;	
}

function openPicture(url, width, height)
{
	var str = "height=" + (height+30) + ",innerHeight=" + height + ",width=" + (width+30) + ",innerWidth=" + width + ",statusbar=no,scrollbars=yes";
	if (window.screen)
	{
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;
		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;
		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
	}
	try
	{
		window.open(url, name, str);
	}
	catch(e)
	{
		alert("An error has occured: Please call The Roundhouse (REF: WINDOW OPEN EXCEPTION MAIN SITE)");
	}
}