/*****************************************
				Cookie
******************************************/
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;
}
/*****************************************
				End Cookie
******************************************/


/*****************************************
				Font changer
******************************************/
function revertStyles(){

	currentFontSize = defaultFontSize;
	changeFontSize(0);

}

function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);

	if(currentFontSize > 100){
		currentFontSize = 100;
	}else if(currentFontSize < 60){
		currentFontSize = 60;
	}
	setFontSize(currentFontSize);
};

function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('content_area') : document.all('content_area');
	document.body.style.fontSize = fontSize + '%';
	
	//alert (document.body.style.fontSize);
};

/*******************************************************
				End font changer
*******************************************************/

/*******************************************************
				Show Hide Right Panel
*******************************************************/
function showhide(){
	if(browser=='Opera') return true;
	currentShowHide *= -1;
	fadeSize.toggle('width');
	rightmargin.toggle('width');
}

function showhide3(){
	if(browser=='Opera') return true;
	currentShowHide3 *= -1;
	fadeSize3.toggle('width');
//	leftmargin.toggle('width');
}


function showhide2(){
	if(browser=='Opera') return true;
	if(browser=='IE') return true;
	currentShowHide2 *= -1;
	fadeSize2.toggle('height');
//	topmargin.toggle('height');
}

function zoomme(){
	if(zoomin == -1) {
		if(currentShowHide==-1)
			showhide();
		if(currentShowHide2==-1)
			showhide2();
		if(currentShowHide3==-1)
			showhide3();	
	} else {
		if(currentShowHide==1)
			showhide();
		if(currentShowHide2==1)
			showhide2();
		if(currentShowHide3==1)
			showhide3();	
	}
	zoomin *= -1;
}


/*******************************************************
				End Show Hide
*******************************************************/


var prefsLoaded = false;
var defaultFontSize = 76;
var currentFontSize = defaultFontSize;
var fadeSize = null;
var rightmargin = null;
var zoomin = -1;
var fadeSize2 = null;
var topmargin = null;
var fadeSize3 = null;
var leftmargin = null;
var currentShowHide2 = 1;
var currentShowHide3 = 1;
var currentShowHide = 1;
var browser     = '';
var version     = '';
var entrance    = '';
var cond        = '';
// BROWSER?
if (browser == ''){
if (navigator.appName.indexOf('Microsoft') != -1)
browser = 'IE'
else if (navigator.appName.indexOf('Netscape') != -1)
browser = 'Netscape'
else browser = 'IE';
}
if(navigator.userAgent.indexOf("Opera")!=-1){
var versionindex=navigator.userAgent.indexOf("Opera")+6
if (parseInt(navigator.userAgent.charAt(versionindex))>=8)
browser = 'Opera';
}
if (version == ''){
version= navigator.appVersion;
paren = version.indexOf('(');
whole_version = navigator.appVersion.substring(0,paren-1);
version         = parseInt(whole_version);
}

function setUserOptions(){
	fadeSize = new fx.FadeSize('rightside', {duration: 1000});
	rightmargin = new fx.FadeSize('rightmargin', {duration: 1000});
	fadeSize2 = new fx.FadeSize('topside', {duration: 1000});
	topmargin = new fx.FadeSize('topmargin', {duration: 1000});
	fadeSize3 = new fx.FadeSize('leftside', {duration: 1000});
	leftmargin = new fx.FadeSize('leftmargin', {duration: 1000});


	if(!prefsLoaded){

		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);		
		prefsLoaded = true;
		

	}
}

function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
}

window.onload = setUserOptions;
window.onunload = saveSettings;
