/* ORIGINAL ASP FUNCTION
function doURLname(byval name)
dim result, i, ch
If IsNull( Name ) Then Name = ""
Name = Replace( Replace( trim( lcase( ""&Name ) ), " ", "-" ), "/", "-" )

for i = 1 to len( name )
	ch = chr( Asc( mid( Name, i, 1 ) ) )
	if instr( "-0123456789abcdefghijklmnopqrstuvwxyz", ch ) then result = result & ch
	if ch = "æ" then result = result & "ae"
	if ch = "å" then result = result & "aa"
	if ch = "ø" then result = result & "oe"
	if ch = "ö" then result = result & "oe"
next
result = replace( replace( result, "--", "-" ), "--", "-" )
If result <> "" Then result = result & ".html"
doURLname = result
end function
*/



// javascript replica of doURLname (above)
// KBE23062008
function urlString( str ) {

	var i, ch;
	var result = "";

	if ( ! str ) {
		str == "";
		}

	str = trim( str.toLowerCase() );
	str = str.replace( /\s+/g, "-" );
	str = str.replace( /\\/g, "-" );

	for( i = 0; i < str.length; i++ ) {
		ch = str.substring( i, i + 1 )
		ch = String.fromCharCode( ch.charCodeAt( 0 ) )

		if( ch.match( /-|[a-z0-9]/ ) ) {
			result += ch;
			}

		if( ch == "æ" ) { result += "ae" }
		if( ch == "å" ) { result += "aa" }
		if( ch == "ø" ) { result += "oe" }
		if( ch == "ö" ) { result += "oe" }

		}

	result = result.replace( /-+/g, "-" );

	if( result ) {
		result += ".html"
	}

	return result;
	}


/* trim left spaces */
function lTrim( sString ) {
	while ( sString.substring( 0, 1 ) == ' ' ) {
		sString = sString.substring( 1, sString.length );
		}
	return sString;
	}

/* trim right spaces */
function rTrim( sString ) {
	while ( sString.substring( sString.length - 1, sString.length ) == ' ' ) {
		sString = sString.substring( 0, sString.length - 1 );
		}
	return sString;
	}

/* trim left and right spaces */
function trim( sString ) {
	sString = lTrim( sString );
	sString = rTrim( sString );
	return sString;
	}

