// Glyph execute code:  parse 'vString' into Bajoran glyphs, per the suggested usage

function c2subMakeWindow( vString ) {
 var vgLoopInt,r,c,d,q;
if ( c2fvTallWide == 1 ) var newWin = window.open( "", "Bajoran", "scrollbars,resizable,width=100,height=500" );
if ( c2fvTallWide != 1 ) var newWin = window.open( "", "Bajoran", "scrollbars,resizable,width=600,height=100" );
 newWin.document.open( "text/html" );
 newWin.document.writeln( '\<head \>' );
 newWin.document.writeln( '\<title \>Bajoran Glyphs for "' + vString + '"\</title \>' );
 newWin.document.writeln( '\</head \>' );
 newWin.document.writeln( '\<BODY text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#800080" alink="#FF0000" \>' );
 newWin.document.writeln( '\<HR\>' );

// force lower case
 vString = vString.toLowerCase();
//-----------------------------------------------------
// loop through string vString, l is the pointer
      for ( vgLoopInt = 0; vgLoopInt < vString.length; vgLoopInt++ ) {
// slice out the sub-string, "rcdq", with "c" being the current pointed letter
         c = vString.charAt( vgLoopInt )
// d defaults to a space, or the next char in the line, with modifiers
         d=" "
         if ( (vgLoopInt+1) < vString.length) d = vString.charAt( vgLoopInt+1 )
         if ( d == "x") d = "z"
         if ( d == "u" && c == "q" ) d = "w"
         if ( c == "q") c = "k"
// q also defaults to a space, or the second from c
         q=" "
         if ( (vgLoopInt+2) < vString.length)q = vString.charAt( vgLoopInt+2 )
// r defaults to a space, then to the _prior_ char.. I don't use it yet
         r=" "
         if ( (vgLoopInt) > 1) r = vString.charAt( vgLoopInt-1 )

// filter non-supported, we don't need to filter d, q, or r because of the tests
         if ( "abcdefghijklmnoprstuvwxyz?' ".indexOf( c ) == -1 ) { c = " " }
// trap for a real "s"
        if ( c == "s" && d == "h") {
             vgLoopInt += 1
            c = c + d
	    d = q
            q=" "
            if ( (vgLoopInt+2) < vString.length) q = vString.charAt( vgLoopInt+2 )
          }
// Deal with "c" being sometimes an "s" and sometimes a "k"...
          if ( c == "c" ) {
		if ( "aeio".indexOf( d ) != -1 ) { c = "s" }
		if ( "aeio".indexOf( d ) == -1 ) { c = "k" }
	  }
//
        if ( c == "p" && d == "h") {
             vgLoopInt += 1
            c = "f"
	    d = q
            q=" "
            if ( (vgLoopInt+2) < vString.length)q = vString.charAt( vgLoopInt+2 )
	  }
// process the triples..
// if dq = ee, ye, or ie
         if ( "eyi".indexOf( d ) != -1 ) {
         if ( "e".indexOf( q ) != -1 ) {
             vgLoopInt += 1
            d = "x"
           }
           }
         if ( "kstrnhpbdxjl".indexOf( c ) != -1 ) {
// if dq = ey or ay
         if ( "ea".indexOf( d ) != -1 ) {
         if ( q == "y") {
             vgLoopInt += 2
            c = c + "y"
          }
          }
          }
// process double letter entities
         if ( "kstrnhpbdxjl".indexOf( c ) != -1 ) {
         if ( "eioax".indexOf( d ) != -1 ) {
             vgLoopInt += 1
            c = c + d
          }
          }
        if ( c == "e" && d == "y") {
             vgLoopInt += 1
            c = c + d
          }
        if ( c == "s" && d == "t") {
             vgLoopInt += 1
            c = c + d
          }
        if ( c == "t" && d == "h") {
             vgLoopInt += 1
            c = c + d
          }
        if ( c == "n" && d == "g") {
             vgLoopInt += 1
            c = c + d
	  }
         if ( c == "p" && d == "n") {
             vgLoopInt += 1
            c = d
         }
// process punctuation
	if ( c == " " ) { c = "space" }
	if ( c == "?" ) { c = "qu"    }
	if ( c == "'" ) { c = "ex"    }

//conversions complete, write the result
 if ( c2fvShowTransform == 1 && c != "space" ) newWin.document.writeln( c + '  \<IMG src="Char' + c + '.gif" border="0" width="25" height="20" align="middle" \>' );
 if ( c2fvShowTransform == 1 && c == "space" ) newWin.document.writeln( '\<IMG src="Char' + c + '.gif" border="0" width="25" height="20" align="middle" \>' );
 if ( c2fvShowTransform != 1 ) newWin.document.writeln( '\<IMG src="Char' + c + '.gif" border="0" width="25" height="20" align="middle" \>' );
 if ( c2fvTallWide == 1 )  newWin.document.writeln( '\<br\> ' );
// end the process loop
      }
//--------------------------------------------------------------------------------
// close out the function
 newWin.document.writeln( '\<HR\>' );
 newWin.document.writeln( "[ Close ]".link( 'javascript:close()' ) );
 newWin.document.close();
      }


