// <![CDATA[

var cookie;
var defaultFontSize;
var ratio;


/* Dreamweaver ---------------------------------------------------------------*/

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/*----------------------------------------------------------------------------*/


function addEvent (elm, listener, func) {
	try {
		elm.addEventListener(listener, func, false);
	}
	catch(e) {
		elm.attachEvent("on" + listener, func);
	}
}

function changeDisplay(prefix, targetNum, bgId, img) {
	var i;
	
	var divObj = document.getElementsByTagName('div');
	
	var divObjLen = divObj.length;
	var matchObj = new RegExp(prefix);

	var imgObj = document.getElementById(bgId);

	for (i = 0; i < divObjLen; i++) {
		var t = divObj[i];
		
		if (t.id.match(matchObj)) {
			if (t.id == prefix + targetNum) {
				t.style.display = 'block';
				
				if (imgObj) {
					imgObj.style.backgroundImage = 'url(' + img + ')';
				}
			}
			else {
				t.style.display = 'none';
			}
		}
	}
}

/* set cookie ----------------------------------------------------------------*/
function setCookie(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=/';
}

/* read cookie ---------------------------------------------------------------*/
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;
}

/* change fontSize ------------------------------------------------------------*/

function changeFontSize(ratio) {
	if (ratio == 100) {
		defaultFontSize = 80;
	}
	else {
		if (50 < parseInt(defaultFontSize) && parseInt(ratio) < 0 ) {
			defaultFontSize = parseInt(defaultFontSize) + parseInt(ratio);
		}
		if (0 < parseInt(ratio) && parseInt(defaultFontSize) < 110) {
			defaultFontSize = parseInt(defaultFontSize) + parseInt(ratio);
		}
	}
	
	document.body.style.fontSize = defaultFontSize + '%';
}

/* change font size when onload-----------------------------------------------*/
function changeFontSizeWhenOnload() {
	cookie = readCookie('fontSize');
	defaultFontSize = cookie ? cookie : 80;
	changeFontSize(0);
}

/* set font size cookie when onload ------------------------------------------*/
function setCookieWhenUnload() {
	setCookie('fontSize', defaultFontSize, 365);
}

/* event ----------------------------------------------------------------------*/

addEvent(window, 'load'   , changeFontSizeWhenOnload);
addEvent(window, 'unload' , setCookieWhenUnload);

// ]]>
