/*
	--------------------------------
	Last Updated: 2006.04.03
	--------------------------------
	- Table of Contents -

	1. CONFIGURATION

	2. FUNCTIONS
		- GetDH ( )
		- GetOS ( )
		- GetBrowser ( )
		- SetLetterSpacing ( )
		- SetImgs ( )
		- SwapImg ( )
		- WrtCopyYear ( )
	--------------------------------
*/



/* --------------------------------
	1. CONFIGURATION
-------------------------------- */

var _DH = GetDH ( );

var _OS = GetOS ( );

var Browser = GetBrowser ( );
var _WB = Browser[ 'name' ];
var _WB_Ver = Browser[ 'ver' ];

SetLetterSpacing ( );

var _SwapKey_Blur = '-a';
var _SwapKey_Focus = '-b';
var _SwapKey_Current = '-c';
var _Imgs = [ ];



/* --------------------------------
	2. FUNCTIONS
-------------------------------- */

function GetDH ( ) {
	// [ a ] IE 5.x+, Firefox, Safari, Netscape 6.x+, Opera 6.x+, Mosilla; [ b ] IE 4.x-; [ c ] NN 4.x-;
	return ( document.getElementById ) ? 'a' : ( document.all ) ? 'b' : ( document.layers ) ? 'c' : 'unknw';
}

function GetOS ( ) {
	var AV = navigator.appVersion;

	return ( AV.match ( 'Win' ) ) ? 'Win' : ( AV.match ( 'Mac' ) ) ? 'Mac' : 'unknw';
}

function GetBrowser ( ) {
	// arguments : ( [ string mode ] )

	var Args = GetBrowser.arguments;

	var WB = 'unknw';
	var WB_Ver = 'unknw';
	var UA = navigator.userAgent;
	var AP = 1;
	if ( UA.match ( /Opera\// ) ) { WB = 'Opera'; UA = UA.split ( '/' ); } // Opera 6.x+
	else if ( UA.match ( /Opera / ) ) { WB = 'Opera'; UA = UA.split ( 'Opera ' ); } // Opera 6.x+
	else if ( UA.match ( /MSIE/ ) ) { WB = 'IE'; UA = UA.split ( 'MSIE ' ); } // IE
	else if ( UA.match ( /Firebird|Firefox/ ) ) { WB = 'Firefox'; UA = UA.split ( '/' ); AP = 3; } // Firefox
	else if ( UA.match ( /Safari/ ) ) { WB = 'Safari'; UA = UA.split ( '/' ); AP = 3; } // Safari
	else if ( UA.match ( /Netscape/ ) ) { WB = 'Netscape'; UA = UA.split ( '/' ); AP = 3; } // Netscape 6.x+
	else if ( UA.match ( /^Mozilla\/[0-9\.]+ \[/ ) ) { WB = 'Netscape'; UA = UA.split ( '/' ); } // Netscape 4.x-
	else if ( UA.match ( /Gecko\/[0-9]{8}$/ ) ) { WB = 'Mozilla'; UA = UA.split ( 'rv:' ); } // Mozilla
	else if ( UA.match ( /Camino/ ) ) { WB = 'Camino'; UA = UA.split ( '/' ); AP = 3; } // Camino
	
	if ( WB != 'unknw' ) {
		var Temp = UA[ AP ].split ( '.' );
		WB_Ver = Temp[ 0 ] + '.' + Temp[ 1 ].substr ( 0, 1 );
	}

	var Val = [ WB, WB_Ver ];
	Val[ 'name' ] = WB;
	Val[ 'ver' ] = WB_Ver;

	return Val;
	return ( Args[ 0 ] == 'name' ) ? WB : ( Args[ 0 ] == 'ver' ) ? WB_Ver : Val;
}

function SetLetterSpacing ( ) {
	if ( _DH != 'a' ) { return false; }

	var LS = ( _OS == 'Mac' ) ? 0 : ( _WB == 'IE' ) ? 0.04 : 0.081;
	var Style = '<style type="text/css" media="screen, print">\n';
	Style += '.txt10 { letter-spacing: ' + LS + 'em; }\n';
	Style += '.txt12 { letter-spacing: ' + LS + 'em; }\n';
	Style += '.txt14 { letter-spacing: ' + LS + 'em; }\n';
	Style += '.txt16 { letter-spacing: ' + LS + 'em; }\n';
	Style += '.txt18 { letter-spacing: ' + LS + 'em; }\n';
	Style += '</style>\n';
	
	document.open ( );
	document.writeln ( Style );
	document.close ( );
	Style = null;
}

function SetImgs ( ) {
	// arguments : ( Keys, Path, Extension [, Mark ] )

	var Args = SetImgs.arguments;

	var Keys = Args[ 0 ];
	var Path = Args[ 1 ];
	var Extension = Args[ 2 ];
	var Mark = ( Args.length > 3 ) ? Args[ 3 ] : '';

	for ( var I = 0; I < Keys.length; I++ ) {
		if ( Keys[ I ] === false ) { continue; }
		var Key = Mark + Keys[ I ];
		var Name = Keys[ I ];
		_Imgs[ Key + _SwapKey_Blur ] = new Image ( );
		_Imgs[ Key + _SwapKey_Blur ].src = Path + Name + _SwapKey_Blur + Extension;
		_Imgs[ Key + _SwapKey_Focus ] = new Image ( );
		_Imgs[ Key + _SwapKey_Focus ].src = Path + Name + _SwapKey_Focus + Extension;
	}
}

function SwapImg ( ) {
	// arguments : ( ID, Key *[, ID, Key ], Mode )

	var Args = SwapImg.arguments;

	var Mode = Args[ Args.length - 1 ];
	Mode = ( Mode ) ? _SwapKey_Focus : _SwapKey_Blur;
	for ( var I = 0; I < Args.length - 1; I += 2 ) {
		var ID = Args[ I ];
		var Key = Args[ I + 1 ];
		document.getElementById( ID ).src = _Imgs[ Key + Mode ].src;
	}
}

function WrtCopyYear ( ) {
	var Since = false;

	var Time = new Date ( );
	var Year = Time.getYear ( );
	if ( Year < 1900 ) { Year += 1900; }
	var CopyYear = ( !Since || Year == Since ) ? Year : Since + '-' + Year;

	document.open ( );
	document.write ( CopyYear );
	document.close ( );
	CopyYear = null;
}
