var is_chrome =  navigator.userAgent.toLowerCase().indexOf('chrome')  > -1;

//see if cookies are enabled
if (document.cookie.length>0) {
	var cookiesenabled=(1) }
else {cookiesenabled=(0)
document.cookie="gvgtestcookie=" + escape("Just making sure that cookies are enabled") 
		if(document.cookie.length>0) {
		cookiesenabled=(1) }
		else {cookiesenabled=(0)}
	}

//generic function to look for cookies by name
function gimmeCookie(cookieName) {
var Rx= new RegExp('('+cookieName+'*\\=*[^;]+)')
	results = document.cookie.match(Rx)
	if(results) {
	return(results[1]) }
	}

//call gimmeCookie() to look for (color) style cookie
//if cookie is present, run the (color) style swap function
if(gimmeCookie("gvgstylecookie")) {
cookieMonster=(gimmeCookie("gvgstylecookie")).toString()
cookieCrumbler=cookieMonster.slice(15)
swapStyle(cookieCrumbler)}
else {swapStyle(1)}

//look for (font) style cookie
//if present, run (font) style swap with value assigned
if(gimmeCookie("gvgfontcookie")) {
fontMonster=(gimmeCookie("gvgfontcookie")).toString()
fontSetter=fontMonster.slice(14)
swapFont(fontSetter)}
else {swapFont(7)}

//COLOR style swap
function swapStyle(whichStyle) {
if(whichStyle>0&&whichStyle<=6) {
	for(i=1;i<7;i++) {
		if(i!=whichStyle){
	expiry= new Date()
	expiry.setDate(expiry.getDate()+365)
	document.cookie="gvgstylecookie="+whichStyle+";expires="+expiry.toGMTString()
		document.styleSheets[i].disabled=true
		}else{
		document.styleSheets[i].disabled=false
		}
		}
		}
}

//FONT style swap
function swapFont(whichFont) {
if(whichFont>=7) {	
	s=(document.styleSheets.length)
	for(i=7;i<s;i++) {
		if(i!=whichFont){
	expiry= new Date()
	expiry.setDate(expiry.getDate()+365)
	document.cookie="gvgfontcookie="+whichFont+";expires="+expiry.toGMTString()
		document.styleSheets[i].disabled=true
		}else{
		document.styleSheets[i].disabled=false
		}
		}
		}
	}
