if (document.images) {
	var s_off = new Image(); s_off.src = 'http://img.4travel.jp/img/reserve/icon/btn_fontsize_small_off.gif';
	var s_on  = new Image(); s_on.src  = 'http://img.4travel.jp/img/reserve/icon/btn_fontsize_small_on.gif';
	var m_off = new Image(); m_off.src = 'http://img.4travel.jp/img/reserve/icon/btn_fontsize_medium_off.gif';
	var m_on  = new Image(); m_on.src  = 'http://img.4travel.jp/img/reserve/icon/btn_fontsize_medium_on.gif';
	var l_off = new Image(); l_off.src = 'http://img.4travel.jp/img/reserve/icon/btn_fontsize_large_off.gif';
	var l_on  = new Image(); l_on.src  = 'http://img.4travel.jp/img/reserve/icon/btn_fontsize_large_on.gif';
}

SizeList = new Array (87.5, 100, 130);

if(readCookie("TextSize") == "none"){
	key = 1;
}else{
	key = Number(readCookie("TextSize"));
}

/**** http://dev02/issues/show/2057 (2009/12/04) ****/
if (window.addEventListener){
	window.addEventListener("load", onload_setup, false);

}
else if (window.attachEvent){
	window.attachEvent("onload", onload_setup);
}
else {
	window.onload = onload_setup;
}

function onload_setup(){
	// set graphics for the buttons
	if(key == 0){
		document.images["s_img"].src = s_on.src;
		document.images["m_img"].src = m_off.src;
		document.images["l_img"].src = l_off.src;
	}else if(key == 2){
		document.images["s_img"].src = s_off.src;
		document.images["m_img"].src = m_off.src;
		document.images["l_img"].src = l_on.src;
	}else{
		document.images["s_img"].src = s_off.src;
		document.images["m_img"].src = m_on.src;
		document.images["l_img"].src = l_off.src;
	}
	// set on click event
	document.images["s_img"].onclick = delegate(setStyle, "s");
	document.images["m_img"].onclick = delegate(setStyle, "m");
	document.images["l_img"].onclick = delegate(setStyle, "l");
}

function delegate(func, args){
	return function (){return func(args);}
}

/* bad -> this can be over written any time
window.onload = function() {
	
	console.log("onload function is alive");
	
	if(key == "0"){
		document.images["s_img"].src = s_on.src;
		document.images["m_img"].src = m_off.src;
		document.images["l_img"].src = l_off.src;
	}else if(key == "2"){
		document.images["s_img"].src = s_off.src;
		document.images["m_img"].src = m_off.src;
		document.images["l_img"].src = l_on.src;
	}else{
		document.images["s_img"].src = s_off.src;
		document.images["m_img"].src = m_on.src;
		document.images["l_img"].src = l_off.src;
	}
}
*/


document.writeln('<style type="text/css"><!--');
document.writeln('#maincontent'+'{font-size: '+SizeList[key]+'%;}');
document.writeln('#rsv-header'+'{font-size: '+SizeList[key]+'%;}');
document.writeln('#des-wrap'+'{font-size: '+SizeList[key]+'%;}');
document.writeln('#current-wrap'+'{font-size: '+SizeList[key]+'%;}');
document.writeln('#footer-parent'+'{font-size: '+SizeList[key]+'%;}');
document.writeln('#footer-kakaku'+'{font-size: '+SizeList[key]+'%;}');
document.writeln('#footer'+'{font-size: '+SizeList[key]+'%;}');
document.writeln('//--></style>');


function setStyle(value){
	if(value == "s"){
	    if(document.images["s_img"]){
		    document.images["s_img"].src = s_on.src;
		}
		if(document.images["m_img"]){
		    document.images["m_img"].src = m_off.src;
        }		    
		if(document.images["l_img"]){
		    document.images["l_img"].src = l_off.src;
		}		
	}else if(value == "l"){
	    if(document.images["s_img"]){	
		    document.images["s_img"].src = s_off.src;
		}						
		if(document.images["m_img"]){
		    document.images["m_img"].src = m_off.src;
		}						
		if(document.images["l_img"]){		
		    document.images["l_img"].src = l_on.src;
		}						
	}else{
	    if(document.images["s_img"]){	
		    document.images["s_img"].src = s_off.src;
		}				
		if(document.images["m_img"]){
		    document.images["m_img"].src = m_on.src;
		}		
		if(document.images["l_img"]){		
		    document.images["l_img"].src = l_off.src;
		}				
	}

	if(value=="l"){
		key = 2;
	}else if(value=="s"){
		key = 0;
	}else if(value=="m"){
		key = 1;
	}
	size = SizeList[key] + "%";
	if(document.all){
		if(document.all("maincontent") ){
		    document.all("maincontent").style.fontSize = size;
		}						
		if(document.all("rsv-header") ){
		    document.all("rsv-header").style.fontSize = size;
		}						
		if(document.all("des-wrap") ){
		    document.all("des-wrap").style.fontSize = size;
		}						
		if(document.all("current-wrap") ){
		    document.all("current-wrap").style.fontSize = size;
		}						
	}
	if(document.getElementById){
		if(document.getElementById("maincontent") ){
		    document.getElementById("maincontent").style.fontSize = size;
		}		
		if(document.getElementById("rsv-header") ){
            document.getElementById("rsv-header").style.fontSize = size;
		}        
		if(document.getElementById("des-wrap") ){
		    document.getElementById("des-wrap").style.fontSize = size;
		}		
		if(document.getElementById("current-wrap")){
		    document.getElementById("current-wrap").style.fontSize = size;
		}
		if(document.getElementById("footer-parent") ){
		    document.getElementById("footer-parent").style.fontSize = size;
		}
		if(document.getElementById("footer-kakaku") ){
		    document.getElementById("footer-kakaku").style.fontSize = size;
		}		
		if(document.getElementById("footer") ){
		    document.getElementById("footer").style.fontSize = size;		
		}		
	}
	createCookie("TextSize",key)
}


function createCookie(name,value){
	tmp = name+"="+value+";";
	tmp += "expires=Fri, 31-Dec-2030 23:59:59;";
	tmp += "path=/;";
	document.cookie = tmp;
}

function readCookie(value){
	data = document.cookie+";";
	tmp = data.indexOf(value,0);
	if(tmp != -1){
		size = data.substring(tmp,data.length);
		start = size.indexOf("=",0);
		end = size.indexOf(";",start);
		return(unescape(size.substring(start+1,end)));
	}else{
		return "none";
	}
}


function ts_init() {
	if(key == "0"){
		document.images["s_img"].src = s_on.src;
		document.images["m_img"].src = m_off.src;
		document.images["l_img"].src = l_off.src;
	}else if(key == "2"){
		document.images["s_img"].src = s_off.src;
		document.images["m_img"].src = m_off.src;
		document.images["l_img"].src = l_on.src;
	}else{
		document.images["s_img"].src = s_off.src;
		document.images["m_img"].src = m_on.src;
		document.images["l_img"].src = l_off.src;
	}
}

