function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function getCookieVal (offset) {
        var endstr = document.cookie.indexOf (";", offset);
                if (endstr == -1)
        endstr = document.cookie.length;
        return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
        var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0) break;
        }

        return null;
}

function SetCookie (name, value) {
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}


	function getActiveStyleSheet() {
		var i, a, url;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("href") && a.getAttribute("title").indexOf("privatelabel") != -1 && !a.disabled) 
			{url=a.getAttribute("href");  }
			else {url=null;}
		}
		return url;
	}
	
	function setActiveStyleSheet(path) {
	  
		var cssNode = document.createElement('link');
		cssNode.type = 'text/css';
		cssNode.rel = 'stylesheet';
		cssNode.href = path;
		cssNode.title = 'privatelabel';
		cssNode.media = 'screen';
	
		document.getElementsByTagName("head")[0].appendChild(cssNode);
	  
	}

	function addLoadEvent(func) { 
	  var oldonload = window.onload; 
	  if (typeof window.onload != 'function') { 
	    window.onload = func; 
	  } else { 
	    window.onload = function() { 
	      if (oldonload) { 
	        oldonload(); 
	      } 
	      func(); 
	    } 
	  } 
	} 
	 

	addLoadEvent(function() { 
	    var cookie = GetCookie("plstyle");
		var labelstylesheet = cookie ? cookie : getActiveStyleSheet();
		setActiveStyleSheet(labelstylesheet);
	});


	var cookie = GetCookie("plstyle");
	var labelstylesheet = cookie ? cookie : getActiveStyleSheet(); 
	setActiveStyleSheet(labelstylesheet);
	SetCookie("plstyle", labelstylesheet);
	

	
	window.onunload = function(e) {
	  var labelstylesheet = getActiveStyleSheet();
	  SetCookie("plstyle", labelstylesheet);
	}


