Css style changer with javascript - using cookies

hi, I’m having trouble with the style changer on my site, on my PC it works in Chrome, Firefox and IE but not Safari and on another PC it doesn’t work in chrome. here it is


use the links at the very bottom to change the style.

here is the javascript code for setting and getting the cookies for changing the style

function style_choice(style){
	if(style == undefined){
		style = 'main';
	var txt = '<link rel="stylesheet" type="text/css" href="styles/' + style + '.css">';
	return txt;

function setCookie(value){ //called from setCSS function
	var the_date = new Date();
	var final_date = the_date.toGMTString();
	document.cookie = 'style_cookie=' + value + '; expires=' + final_date + '; path=/';

function getCookie(){
	var my_cookie = document.cookie.split(';');
	my_cookie = "x" + my_cookie //add any char to my cookie to make it a string
	return my_cookie.split("=")[1]; //get the value after =

function setCSS(style){ // call when user clicks style link
	setCookie(style); //set the new cookie
	window.location.reload(); //reload the page

var the_cookie = getCookie(); // get cookie info
var default_style = style_choice(the_cookie); // set style with cookie info

The getCookie function is flawed because it relies on there being only one cookie stored on the domain.
It needs to be recoded to look for the named cookie and return its value if any.

Proper Cookie handling functions are to be found at http://snipplr.com/view/45954/

See A Brief History of Javascript