var prefsLoaded = false;
var currentFontSize = 4;
var minFontSize = 48;
var maxFontSize = 102;
var step = 6;
function revertStyles(fontsize){
	currentFontSize = fontsize;
	changeFontSize(0);
}

function changeFontSize(sizeDifference){
	currentFontSize = currentFontSize + sizeDifference;
	fontSize = minFontSize + parseInt(currentFontSize * step);

	if(fontSize > maxFontSize){
		fontSize = maxFontSize;
	}else if(fontSize < minFontSize){
		fontSize = minFontSize;
	}
	setFontSize(fontSize);
	currentFontSize = parseInt((fontSize - minFontSize)/step);
	createCookie("FontSize", currentFontSize, 365);
};

function setFontSize(fontSize){
	document.body.style.fontSize = fontSize + '%';
};

function changeFontSize1(sizeDifference){
	currentFontSize = currentFontSize + sizeDifference;
	if(currentFontSize > maxFontSize){
		currentFontSize = maxFontSize;
	}else if(currentFontSize < minFontSize){
		currentFontSize = minFontSize;
	}

	document.body.className = "js" + currentFontSize;
	createCookie("FontSize", currentFontSize, 365);
}

function setActiveStyleSheet(title, csstype) {
//alert( title + '\n' + csstype);
  var i, a, main, arr;
  arr = document.getElementsByTagName("link");
  for(i=0; (a = arr[i]); i++) {
  	var ltitle = a.getAttribute("title");
    if(a.getAttribute("rel").indexOf("style") != -1 && ltitle && (!csstype || ltitle.indexOf(csstype)) != -1) {
    //alert(ltitle);
      a.disabled = true;
      if(ltitle == csstype + "_" + title) a.disabled = false;
    }
  }
  if (csstype) 
	  createCookie(csstype, title, 365);
  //createCookie("style", title, 365);
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function setScreenType(screentype){
	document.getElementById('ja-container-shadow').className=screentype;
	createCookie("ScreenType", screentype, 365);
}

