﻿
var i = 1;
var path = 'http://' + document.domain+ '/css/';

var css = get_cookie.call(this);

if(css){change_css.call(this,path,css,i);}


function write_form()
{
	
	// CSSファイル名
	var css_a = new Array('default','enlarged');
	
	// セレクトボックス表示
	var css_n = new Array('標準','拡大');
	
	var css = get_cookie.call(this);
	
	if(!css){css = css_a[0];}
	
	document.write('<form style="margin:5px 30px 5px;">');
	document.write('	<select name="css_ss" style="width:80px;"');
	document.write('onchange="set_cookie(this.options[this.selectedIndex].value);">');
	
	var css_v = '';
	var selected = '';
	
	for(i in css_a)
	{
		
		css_v = css_a[i];
		css_o = css_n[i];
		
		selected = (css_v == css) ? ' selected="selected"' : '';
		
		document.write('	<option value="' + css_v + '"' + selected + '>');
		document.write(css_o + '</option>');
		
	}
	
	document.write('	</select>');
	document.write('</form>');
	
}


function change_css(path,css,i)
{
	
	if(document.all)
	{
		
		document.all.tags('link').item(i).href = path + css + '.css';
		
	}
	else if(document.getElementsByTagName)
	{
		
		document.getElementsByTagName('link').item(i).href = path + css + '.css'; 
		
	}
	
}


function get_cookie()
{
	
	if(!document.cookie){return;}
	
	var css = '';
	var cookie = unescape(document.cookie).split(';');
	
	for(j in cookie)
	{
		
		if(!cookie[j].match(/css_ss=/)){continue;}
		
		c = cookie[j].replace(/css_ss=/g,"");
		
		v = c.split('=');
		
		css = v[1];
		
	}
	
	return css;
	
}


function set_cookie(css)
{
	
	cookie  = 'css_ss=css=' + escape(css) + '; ';
	cookie += "expires=Fri, 31-Dec-2030 23:59:59 GMT; path=/; ";
	
	document.cookie = cookie;
	
	location.reload();
	
}

