

/*-------------------------------------------------------------------------\
|                             Font Resize 1.0                              |
\-------------------------------------------------------------------------*/


function CookieGet( name, position ) {
    var current = document.cookie;
    var pos = current.indexOf( name + '=' );
    if (pos > 0) {
        var pos2 = current.indexOf( ';', pos );
        if (pos2 == -1) {
            pos2 = current.length;
        } else {
            pos2 = pos2 - pos;
        }
        current = current.substring( pos + 1 + name.length, pos2 );
    } else {
        current = '';
    }
    return( current.substring( position, 1 ) );
}

function CookieSet( name, position, value ) {
    var domain = document.domain;
    domain = domain.substr( domain.indexOf( 'meh' ) );
    var current = document.cookie;
    var pos = current.indexOf( name + '=' );
    if ( pos > 0 ) {
        var pos2 = current.indexOf( ';', pos );
        if (pos2 == -1) {
            pos2 = current.length;
        } else {
            pos2 = pos2 - pos;
        }
        current=current.substring( pos + 1 + name.length, pos2 );
    } else {
        current='';
    }
    current = current.substring( 0, position ) + value + current.substring( position + 1 );
    document.cookie=name + "=" + escape(current) +
        ";expires=Sun Dec 01 2019 12:00:00 GMT+0100;path=/;domain=" + domain;
}


// ---------------------------------------------------------------------- //


function StyleActivate( prefix, value ) {
	var i, lnk;
	for( i = 0; (lnk = document.getElementsByTagName("link")[i]); i++ ) {
		if ( lnk.getAttribute("rel").indexOf("style" ) != -1 && lnk.getAttribute("title") ) {
  		    lnk.disabled = true;
    		if ( lnk.getAttribute("title") == prefix+value ) {
    		    lnk.disabled = false;
    		}
		}
	}
}

function StyleActual( prefix ) {
	var i, lnk;
	for( i = 0; (lnk = document.getElementsByTagName("link")[i]); i++ ) {
        if ( lnk.getAttribute("rel").indexOf("style" ) != -1 && lnk.getAttribute("title") &&
             !lnk.disabled && lnk.getAttribute("title").substring(0,prefix.length) == prefix ) {
          return lnk.getAttribute("title").substring(prefix.length);
		}
	}
	return null;
}


// ---------------------------------------------------------------------- //


function FontResizeSet( name ) {
    var value = 0;
    if ( name == 'small' ) { value = 0; }
    if ( name == 'normal' ) { value = 1; }
    if ( name == 'large' ) { value = 2; }
    StyleActivate( 'font size: ', name );
}

function FontResizeLoad() {
    var name='small';
    var value=CookieGet('preferences', 0);
    if ( value == 0 ) { name = 'small'; }
    if ( value == 1 ) { name = 'normal'; }
    if ( value == 2 ) { name = 'large'; }
    setTimeout("StyleActivate( 'font size: ', '"+name+"' );",10);
}

function FontResizeSave() {
    var value = 0;
    var name = StyleActual( 'font size: ' );
    if ( name == 'small' ) { value = 0; }
    if ( name == 'normal' ) { value = 1; }
    if ( name == 'large' ) { value = 2; }
	CookieSet( 'preferences' ,0 , value );
}
