/* this uses stylesheets.js now */

function detectFontSize( name ){
	var style_sheet = readCookie( name );
	if( style_sheet ){
		setFontSize( style_sheet );
	}
}

function storeFontSize( title, days, path ){
	setStyleSheet( title );
	createCookie( "fontsize-switch", title, setDays( days ), path, '' );
}

function setFontSize( title ){
	storeFontSize( title, 30, '/arriva/' );	
}

function setFontSizeLinks( img_path ){
	var link_holder = document.getElementById( "fontsize_switch" );
	var imgs = ['a.gif','aa.gif','aaa.gif'];
	var actions = ['fs_min','fs_default','fs_max'];
	var alts = ['Minimum font size','Medium font size','Maximum font size'];
	for( var i = 0 ; i < imgs.length ; i++ ){
		var action = actions[ i ];
		var img_src = img_path + imgs[ i ];
		var img_alt = alts[ i ];
		var link = document.createElement( "a" );
		link.setAttribute( "href", "#" );
		link.setAttribute( "name", action );
		link.onclick = function(){
			setFontSize( this.getAttribute( "name" ) );
			return false;
		};
		var img = document.createElement( "img" );
		img.setAttribute( "alt", img_alt );
		img.alt = img_alt;
		img.setAttribute( "src", img_src );
		link.appendChild( img );
		link_holder.appendChild( link );
	}
}

function initFontSize(){
	setFontSizeLinks( "/arriva/images/" );
	detectFontSize( "fontsize-switch" );
}	

