currentTheme = "";
function checkBrowserWidth() {
	var theWidth = getBrowserWidth();
	
	if (theWidth > 764) {
		if(currentTheme != "largeLayout") {			
			parent.document.getElementById("initContainer").className = 'initContainerLarge';
			parent.document.getElementById("settingUtilities").className = 'utilitiesBoxScale';
			parent.document.getElementById("textUtilities").className = 'utilitiesBoxScale';
			currentTheme = "largeLayout";			
		}
	} else {
		if(currentTheme != "smallLayout") {
			parent.document.getElementById("initContainer").className = 'initContainerSmall';
			parent.document.getElementById("settingUtilities").className = 'utilitiesBoxFixed';
			parent.document.getElementById("textUtilities").className = 'utilitiesBoxFixed';
			currentTheme = "smallLayout";			
		}
	}
	//status = currentTheme;
	return true;
}


function getBrowserWidth() {
	if (window.innerWidth) {
		return window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth != 0) {
		return document.documentElement.clientWidth;
	}
	else if (document.body) {
		return document.body.clientWidth;
	}	
	return 0;
}


function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

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 readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);




var dom1=(document.getElementById)?1:0;
var ie4plus=(document.all)?1:0;
var ns4=(document.layers)?1:0;

function getElementRef(id){
	if (dom1) return document.getElementById(id);
	else if (ie4plus) return document.all[id];
	//else if (ns4) return document.layers[id];
	else return null;
}
function textResizeLinks(){
	smallLink=getElementRef('decreaseFont');
	largeLink=getElementRef('increaseFont');
	currentStyle = getActiveStyleSheet();
	if(largeLink){
		if(!largeLink.style)return;
		if(currentStyle=="themeLayoutSS"){
			smallLink.style.color="#c8c8c8";
			smallLink.style.cursor="default";
			largeLink.style.color="#06518C";
			largeLink.style.cursor="pointer";
		}else if(currentStyle=="themeLayoutLL"){
			smallLink.style.color="#06518C";
			smallLink.style.cursor="pointer";
			largeLink.style.color="#c8c8c8";
			largeLink.style.cursor="default";
		}else{
			smallLink.style.color="#06518C";
			smallLink.style.cursor="pointer";
			largeLink.style.color="#06518C";
			largeLink.style.cursor="pointer";
		}
	}
}

function sizeTextUp() {
  active = getActiveStyleSheet();
  switch (active) {
    case 'themeLayoutSS' : 
      setActiveStyleSheet('themeLayoutS');
      break;
    case 'themeLayoutS' : 
      setActiveStyleSheet('themeLayout');
      break;
    case 'themeLayout' : 
      setActiveStyleSheet('themeLayoutL');
      break;
    case 'themeLayoutL' : 
      setActiveStyleSheet('themeLayoutLL');
      break;
    case 'themeLayoutLL' :
      break;
    default :
      setActiveStyleSheet('themeLayoutSS');
      break;
  }
	textResizeLinks();
}

function sizeTextDown() {
  active = getActiveStyleSheet();
  switch (active) {
    case 'themeLayoutLL' : 
      setActiveStyleSheet('themeLayoutL');
      break;
    case 'themeLayoutL' : 
      setActiveStyleSheet('themeLayout');
      break;
    case 'themeLayout' : 
      setActiveStyleSheet('themeLayoutS');
      break;
    case 'themeLayoutS' : 
      setActiveStyleSheet('themeLayoutSS');
      break;
    case 'themeLayoutSS' : 
       break;
    default :
      setActiveStyleSheet('themeLayoutSS');
      break;
  }
	textResizeLinks();
}