﻿function getRealColor(){
    var randomColors= new Array();
    
    randomColors[0]="/Data/Resources/LifeScan/Segment_Type1Diabetes/NL/nl/css/theme2-pink.css";
    randomColors[1]="/Data/Resources/LifeScan/Segment_Type1Diabetes/NL/nl/css/theme2-green.css";
    randomColors[2]="/Data/Resources/LifeScan/Segment_Type1Diabetes/NL/nl/css/theme2-brown.css";
    randomColors[3]="/Data/Resources/LifeScan/Segment_Type1Diabetes/NL/nl/css/theme2-silver.css";
    
    return randomColors
    
}

function random(obj){
     var rand = Math.floor(Math.random()*obj.length);
     return obj[rand];
}
function writeCSS(link){
    oScript = document.createElement('link');
    oScript.href = link;
    oScript.type = 'text/css';
    oScript.rel = 'stylesheet';
    oScript.media = 'screen';
	oScript.id = 'color';
   // document.body.appendChild(oScript);
	document.getElementsByTagName("head")[0].appendChild(oScript);
}

function getColor(){    
    writeCSS(random(getRealColor()));    
    }

function init(){
    getColor();
}
if(window.attachEvent){
    window.attachEvent("onload", init);
}else if(document.addEventListener){
    document.addEventListener("DOMContentLoaded", init, null);
}
else{
    window.onload = init;
    init();
} 
