var colors = new Array('yellow','aqua','lightblue','red','blue','green','orange','purple','darkblue');

function setTheme(color)
{
 setCookie("style", color);
 location.reload();
 return false;
}

function writeTheme()
{
 var testTrans;
 var testRandom;
 var style;
 var re;
 
 style = getCookie('style');
 
 if (style == null)
 {
  style = "blue";
  writeStyle("color-" + style);
  writeStyle("image-" + style);
 }
 else
 {
  testTrans = style.indexOf("trans");
  testRandom = style.indexOf("random");
  
  if (testTrans >= 0 && testRandom >= 0)
  {
   randomTransStyle();
  }
  else
  {
   if (testTrans < 0 && testRandom >= 0)
   {
    randomStyle();
   }
   else
   {
    if (testTrans >= 0 && testRandom < 0)
    {
     style = style.substring(6);
     writeStyle("color-" + style);
     writeStyle("trans-common");
    }
    else
    {
     writeStyle("color-" + style);
     writeStyle("image-" + style);
    }
   }
  }
 }
}


function writeStyle(filename)
{
 document.write('<link rel="stylesheet" type="text/css" \
 href="styles/'+ filename +'.css" />');
}


function randomStyle()
{
 var randomNum;
 randomNum = Math.floor(Math.random() * colors.length);

 writeStyle("color-" +  colors[ randomNum ] );
 writeStyle("image-" + colors[ randomNum ] );
}


function randomTransStyle()
{
 var randomNum;
 randomNum = Math.floor(Math.random() * colors.length);

 writeStyle("trans-common");
 writeStyle("color-" +  colors[ randomNum ] );
}

   /*
        old hack for IE...

   // IE doesn't do png alpha right, so it always gets gray.css
   if(navigator.appName.indexOf("Microsoft") >= 0)
   {
    document.write('<link rel="stylesheet" type="text/css" \
    href="styles/gray.css" />');
    return;
   }*/