<SCRIPT LANGUAGE="JScript" RUNAT="Server">
/**
 * @package NOF_Framework
 *
 * @author Adrian Pascu <apascu@innovative.ro>
 */

function NOF_CaptchaBMP(){
	/**
	 * Image content
	 * @var string
	 */
	this.content = "";

	/**
	 * BMP header definition
	 * @var array
	 */
	this.bmpHeader   = new Array();

	/**
	 * Characters definition
	 * @var array
	 */
	this.charsMap    = new Array();

	/**
	 * Character width
	 * @var int
	 */
	this.charWidth   = 0;

	/**
	 * Caracter height
	 * @var int
	 */
	this.charHeight  = 0;

	/**
	 * Number of necesarly bytes to add to compleate a dword
	 * @var int
	 */
	this.$imageCorrection = 0;

	/**
	 * List with possible letters can apear in captcha image
	 * @var string
	 */
	this.chars       = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	/**
	 * Text what apear in captcha image
	 * @var string
	 */
	this.imageChars  = "ABCDE";

	/**
	 * Hex code for the background color
	 * @var string
	 */
	this.bgColor     = "000000";

	/**
	 * Hex code for the foreground colors
	 * @var array
	 */
	this.fgColors    = new Array("ffffff");

	/**
	 * Number of blank pixels(spaces) on the top of image
	 * @var int
	 */
	this.spaceTop    = 0;

	/**
	 * Number of blank pixels(spaces) on the bottom of image
	 * @var int
	 */
	this.spaceBottom = 0;

	/**
	 * Number of blank pixels(spaces) on the left of image
	 * @var int
	 */
	this.spaceLeft   = 0;

	/**
	 * Number of blank pixels(spaces) on the right of image
	 * @var int
	 */
	this.spaceRight  = 0;

	/**
	 * Number of blank pixels(spaces) between the image chars
	 * @var int
	 */
	this.spaceInner  = 0;

	/**
	 * Location path where the characters definion is
	 * @var string
	 */
	this.charFontDir = "../NOF_Data/charsMap/trebuchet";

	/**
	 * Flag what show if the font definition arrays exists and have the same dimensions
	 * @var boolean
	 */
	this.success = false;

      this.FileObj = Server.CreateObject("Scripting.FileSystemObject");

}

	/**
	 *
	 *
	 * @param string font	Location path where the characters definion is or empty for default definion.
	 */
	NOF_CaptchaBMP.prototype.Init = function(font){
		// BITMAPFILEHEADER
		this.bmpHeader["bfType"]          = "42 4D";       // *-42 4D
		this.bmpHeader["bfSize"]          = "56 0A 00 00"; // (width x height x color deep) + 54
		this.bmpHeader["bfReserved1"]     = "00 00";     	 // *-00 00
		this.bmpHeader["bfReserved2"]     = "00 00";       // *-00 00
		this.bmpHeader["bfOffBits"]       = "36 00 00 00"; // *-36 00 00 00
		// BITMAPINFOHEADER
		this.bmpHeader["biSize"]          = "28 00 00 00"; // *-28 00 00 00
		this.bmpHeader["biWidth"]         = "20 00 00 00"; //
		this.bmpHeader["biHeight"]        = "1B 00 00 00"; //
		this.bmpHeader["biPlanes"]        = "01 00";		 // *-01 00
		this.bmpHeader["biBitCount"]      = "18 00";       // *-18 00 (24)
		this.bmpHeader["biCompression"]   = "00 00 00 00"; // *-00 00 00 00
		this.bmpHeader["biSizeImage"]     = "20 0A 00 00"; // *-00 00 00 00(2592) = with x height x color deep(24)
		this.bmpHeader["biXPelsPerMeter"] = "12 0B 00 00"; //
		this.bmpHeader["biYPelsPerMeter"] = "12 0B 00 00"; //
		this.bmpHeader["biClrUsed"]       = "00 00 00 00"; //
		this.bmpHeader["biClrImportant"]  = "00 00 00 00"; // *-00 00 00 00

		if(font.length == 0){
			this.success = this.setFontDir(this.charFontDir);
		}else{
			this.success = this.setFontDir(font);
		}
	}


	/**
	 * Add characters definition for each letter.
	 * The letters sizes(height and width) must be the same between the chars.
	 *
	 * @param string fontDir	Location path where the characters definion is.
	 */
	NOF_CaptchaBMP.prototype.setFontDir = function(fontDir){
		this.charFontDir = fontDir;
		charWidth = 0;
		charHeight = 0;
		for(i=0; i<this.chars.length; i++){
			if(!this.FileObj.FileExists(Server.MapPath(this.charFontDir + "/charMap-" + this.chars.charAt(i) + ".txt"))){
				Response.Write("1|Could not find path charMap for letter\"" + this.chars.charAt(i) +"\"");
                        Response.End;
				return false;
			}
			this.loadChar(this.chars.charAt(i));
			if(!this.charCheck(this.charsMap[this.chars.charAt(i)], this.chars.charAt(i))){
				return false;
			}
		}
		this.charWidth = this.charsMap[this.chars.charAt(0)][0].length;
		return true;
	}


	/**
	 * Load the char map file into "charsMap" array
	 *
	 * @param string charName		Character name
	 */
	NOF_CaptchaBMP.prototype.loadChar = function(charName){
            var handle = this.FileObj.OpenTextFile(Server.MapPath(this.charFontDir + "/charMap-" + charName + ".txt"));
            var line;

            this.charsMap[charName] = new Array();
            while(!handle.AtEndOfStream) {
                  line = handle.ReadLine();
                  this.charsMap[charName].length++;
                  this.charsMap[charName][this.charsMap[charName].length-1] = this.trim(line);
		}
            handle.Close();
	}


	/**
	 * Characters Map verification
	 *
	 * @param  array   character		Character definition
	 * @param  string  charName	Character name
	 * @return boolean
	 */
	NOF_CaptchaBMP.prototype.charCheck = function(character, charName){
		//if(!isset(character)){
		//	Response.Write(("1|CharMap not defined for letter\"" + charName + "\".");
		//	return false;
		//}
		if(typeof(character) != "object"){
			Response.Write("1|CharMap not defined properly for letter\"" + charName +"\", is not an array.");
                  Response.End;
			return false;
		}
		if(character.length == 0){
			Response.Write("1|CharMap not defined properly for letter\"" + charName +"\", array is empty.");
                  Response.End;
			return false;
		}
		if(this.charHeight == 0){
			this.charHeight = character.length;
		}
		if(this.charHeight != character.length){
			Response.Write("1|CharMap not defined properly for letter\"" + charName +"\", diferent height.");
                  Response.End;
			return false;
		}
		if(typeof(character[0]) != "string"){
			Response.Write("1|CharMap not defined properly for letter\"" + charName +"\", is not an array of strings.");
                  Response.End;
			return false;
		}
		if(character[0].length == 0){
			Response.Write("1|CharMap not defined properly for letter\"" + charName +"\", string is empty.");
                  Response.End;
			return false;
		}
		if(this.charWidth == 0){
			this.charWidth = character[0].length;
		}
		charTotalLength = character.join("").length;
		if((charTotalLength/this.charHeight != this.charWidth) || (charTotalLength%this.charHeight != 0)){
			Response.Write("1|CharMap not defined properly for letter\"" + charName +"\", diferent width.");
                  Response.End;
			return false;
		}

		return true;
	}


	/**
	 * Add a hex code foreground color
	 *
	 * @param  string color	Color to add
	 * @return boolean			Operation success
	 */
	NOF_CaptchaBMP.prototype.addFgColor = function(color){
            var t;
		if(color.length == 0){
			return false;
		}else{
			if(this.in_array(color, this.fgColors)){
				return false;
			}else{
                        this.fgColors.length++;
                        this.fgColors[this.fgColors.length-1] = color;
				return true;
			}
		}
	}


	/**
	 * Remove a color from foreground list
	 *
	 * @param  string color	Color to remove
	 * @return boolean			Operation success
	 */
	NOF_CaptchaBMP.prototype.remFgColor = function(color){
		if(color.length == 0){
			return false;
		}else{
			if(this.fgColors.length == 1){
				return false;
			}else{
				colorPos = this.array_search(color, this.fgColors);
				if(colorPos > -1){
					return false;
				}else{
					this.fgColors[colorPos] = null;
					this.fgColors = this.fgColors.reverse();	// reindex the array
					return true;
				}
			}
		}
	}


	/**
	 * Return converted to a 'Big Indian' string the 'Little Indian' longint value
	 *
	 * @param  longint decNr	'Little Indian'	value
	 * @return string			'Big Indian' string
	 */
	NOF_CaptchaBMP.prototype.hexStrLongBigIndian = function(decNr){
            try{
		//littleIndian = pack("L", decNr);
		//bigIndian = strtoupper(dechex(implode("", unpack("N*", littleIndian))));
		var b = new Array();
		b[0] = this.dechex((decNr & 0x000000FF) >> 0);
            b[0] = b[0].toUpperCase();
		b[1] = this.dechex((decNr & 0x0000FF00) >> 8);
            b[1] = b[1].toUpperCase();
		b[2] = this.dechex((decNr & 0x00FF0000) >> 16);
            b[2] = b[2].toUpperCase();
            //b3s = this.dechex((decNr & 0xFF000000) >> 24);
		//b[3] = substr(this.dechex((decNr & 0xFF000000) >> 24), -2);
            b[3] = this.dechex((decNr & 0xFF000000) >> 24);
            b[3] = b[3].toUpperCase();
		for(i=0; i<b.length; i++){
			if(b[i].length == 1){
				b[i] = "0" + b[i];
			}
		}

		return b.join(" ");
            }catch(e){
                  Response.write("<b>function hexStrLongBigIndian:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Return the 'Little Indian' longint value of a 'Big Indian' string
	 *
	 * @param  string	strLongBigIndian	'Big Indian' string
	 * @return longint						'Little Indian' value
	 */
	NOF_CaptchaBMP.prototype.getLongLittleIndian = function(strLongBigIndian){
            try{
		l = strLongBigIndian.split(" ");
		result = 0;
		for(i=0; i<l.length; i++){
			result = result + (this.hexdec(l[i]) * Math.pow(256, i));
		}
		return result;
            }catch(e){
                  Response.write("<b>function getLongLittleIndian:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Set the image file size in BMP header
	 *
	 * @param longint size		The image file size reprezented on 4 bytes
	 */
	NOF_CaptchaBMP.prototype.setBmpFileSize = function(size){	// 4 byte
            try{
		if(size == 0){
			app = 2 * this.getLongLittleIndian(this.bmpHeader["biHeight"]) + 2;
			app=0;
			this.bmpHeader["bfSize"] = this.hexStrLongBigIndian(this.getLongLittleIndian(this.bmpHeader["biWidth"]) * this.getLongLittleIndian(this.bmpHeader["biHeight"]) * 3 + 54 + app);
		}else{
			this.bmpHeader["bfSize"] = this.hexStrLongBigIndian(size);
		}
            }catch(e){
                  Response.write("<b>function setBmpFileSize:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Set the image width in BMP header
	 *
	 * @param longint width	The image width reprezented on 4 bytes
	 */
	NOF_CaptchaBMP.prototype.setBmpWidth = function(width){
            try{
		this.bmpHeader["biWidth"] = this.hexStrLongBigIndian(width);
            }catch(e){
                  Response.write("<b>function setBmpWidth:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Set the image height in BMP header
	 *
	 * @param longint height	The image height reprezented on 4 bytes
	 */
	NOF_CaptchaBMP.prototype.setBmpHeight = function(height){
            try{
		this.bmpHeader["biHeight"] = this.hexStrLongBigIndian(height);
            }catch(e){
                  Response.write("<b>function setBmpHeight:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Set the image size in BMP header
	 *
	 * @param longint size		The image size reprezented on 4 bytes
	 */
	NOF_CaptchaBMP.prototype.setBmpSizeImage = function(size){	// 4 byte
            try{
		if(size == 0){
			//app = 2 * this.getLongLittleIndian(this.bmpHeader["biHeight"]) + 2;
			//app = this.imageCorrection * this.imageHeight;
			app=0;

			this.bmpHeader["biSizeImage"] = this.hexStrLongBigIndian(this.getLongLittleIndian(this.bmpHeader["biWidth"]) * this.getLongLittleIndian(this.bmpHeader["biHeight"]) * 3 + app);
		}else{
			this.bmpHeader["biSizeImage"] = this.hexStrLongBigIndian(size);
		}
            }catch(e){
                  Response.write("<b>function setBmpSizeImage:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Construct the BMP image header ready to be used.
	 *
	 * @return string
	 */
	NOF_CaptchaBMP.prototype.makeBmpHeader = function(){
            try{
            var i;
		var result = "&H";

		result += this.bmpHeader["bfType"]          + " ";
		result += this.bmpHeader["bfSize"]          + " ";
		result += this.bmpHeader["bfReserved1"]     + " ";
		result += this.bmpHeader["bfReserved2"]     + " ";
		result += this.bmpHeader["bfOffBits"]       + " ";
		result += this.bmpHeader["biSize"]          + " ";
		result += this.bmpHeader["biWidth"]         + " ";
		result += this.bmpHeader["biHeight"]        + " ";
		result += this.bmpHeader["biPlanes"]        + " ";
		result += this.bmpHeader["biBitCount"]      + " ";
		result += this.bmpHeader["biCompression"]   + " ";
		result += this.bmpHeader["biSizeImage"]     + " ";
		result += this.bmpHeader["biXPelsPerMeter"] + " ";
		result += this.bmpHeader["biYPelsPerMeter"] + " ";
		result += this.bmpHeader["biClrUsed"]       + " ";
		result += this.bmpHeader["biClrImportant"];
            /*
		arrayHeader = result.split(" ");
		result = "";
            for(i=0; i<arrayHeader.length; i++){
			//result += String.fromCharCode(this.hexdec(arrayHeader[i]));
                 result += this.hexdec(arrayHeader[i]);
		}
            */

		return result;
            }catch(e){
                  Response.write("<b>function makeBmpHeader:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Construct the BMP image content ready to be used.
	 *
	 * @return string
	 */
	NOF_CaptchaBMP.prototype.makeBmpContent = function(){
            try{
		if(!this.success){
			return false;
		}

		var result = "";
		var imageArray = new Array();
            var bgColorReady = " " + (this.bgColor.substr(4, 2)) + " " + (this.bgColor.substr(2, 2)) + " " + (this.bgColor.substr(0, 2));

		// insert left spaces
		arrayLeft = new Array();
		if(this.spaceLeft > 0){
			leftChars = "";
			for(i=0; i<this.spaceLeft; i++){
				leftChars += bgColorReady;
			}
			arrayLeft = this.array_fill(0, this.charHeight, leftChars);
                  imageArray = arrayLeft;
		}

		// insert inner spaces
		var arrayInner = new Array();
		if(this.spaceInner > 0){
			innerChars = "";
			for(i=0; i<this.spaceInner; i++){
				innerChars += bgColorReady;
			}
			arrayInner = this.array_fill(0, this.charHeight, innerChars);
		}

		// insert chars
		for(ia=0; ia<this.imageChars.length; ia++){
			fgColor = this.getRandColor();

			if(this.spaceInner > 0 && ia > 0){
				for(j=0; j<this.charHeight; j++){
					imageArray[j] += arrayInner[j];
				}
			}

			if(imageArray.length == 0){
				imageArray = this.applyColors(this.charsMap[this.imageChars.charAt(ia)], fgColor);
			}else{
				for(ja=0; ja<this.charHeight; ja++){
					imageArray[ja] += this.applyColors(this.charsMap[this.imageChars.charAt(ia)][ja], fgColor);
				}
			}
		}

		// insert right spaces
		var arrayRight = new Array();
		if(this.spaceRight > 0){
			rightChars = "";
			for(i=0; i<this.spaceRight; i++){
				rightChars += bgColorReady;
			}
			arrayRight = this.array_fill(0, this.charHeight, rightChars);

			for(j=0; j<this.charHeight; j++){
				imageArray[j] += arrayRight[j];
			}
		}

		// insert top/bottom spaces
		var tbChars = "";
		for(i=0; i<(imageArray[0].length/9); i++){
			tbChars += bgColorReady;
		}
		var arrayTop = new Array();
		if(this.spaceTop > 0){
			arrayTop = this.array_fill(0, this.spaceTop, tbChars);
			imageArray = arrayTop.concat(imageArray);
		}

		var arrayBottom = new Array();
		if(this.spaceBottom > 0){
			arrayBottom = this.array_fill(0, this.spaceBottom, tbChars);
			imageArray = imageArray.concat(arrayBottom);
		}

		imageArray = imageArray.reverse();

		// verify if image need correction
		this.imageCorrection = (imageArray[0].length) % 4;
//		this.imageCorrection == 0 ? this.imageCorrection = 0 : this.imageCorrection = 4 - this.imageCorrection;
		endLine = "";
		for(i=0; i<this.imageCorrection; i++){
                 endLine += " 00";
		}
		result = imageArray.join(endLine);

		return result + endLine;
            }catch(e){
                  Response.write("<b>function makeBmpContent:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Code the image colors for the background ('0') and foreground ('1') pixels
	 *
	 * @param  array|string charElement
	 * @param  string 		fgColor
	 * @return array|string
	 */
	NOF_CaptchaBMP.prototype.applyColors = function(charElement, fgColor){
            try{
		if(typeof(charElement) == "object"){
			var result = new Array();
			for(i=0; i<charElement.length; i++){
				line = "";
				for(j=0; j<charElement[i].length; j++){
					if(charElement[i].charAt(j) == "0"){
                                   line += " " + (this.bgColor.substr(4, 2)) + " " + (this.bgColor.substr(2, 2)) + " " + (this.bgColor.substr(0, 2));
					}else{
                                   line += " " + (fgColor.substr(4, 2)) + " " + (fgColor.substr(2, 2)) + " " + (fgColor.substr(0, 2));
					}
				}
                        result.length++;
                        result[result.length-1] = line;
			}
			return result;
		}else{
			var result = "";
			for(i=0; i<charElement.length; i++){
				if(charElement.charAt(i) == "0"){
                              result += " " + (this.bgColor.substr(4, 2)) + " " + (this.bgColor.substr(2, 2)) + " " + (this.bgColor.substr(0, 2));
				}else{
                              result += " " + (fgColor.substr(4, 2)) + " " + (fgColor.substr(2, 2)) + " " + (fgColor.substr(0, 2));
				}
			}
			return result;
		}
            }catch(e){
                  Response.write("<b>function applyColors:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Get a random hex color code from foreground color list
	 *
	 * @return string|false
	 */
	NOF_CaptchaBMP.prototype.getRandColor = function(){
            try{
		if(this.fgColors.length == 0){
			return false;
		}
		colorPos = Math.floor(Math.random() * this.fgColors.length);
		return this.fgColors[colorPos];
            }catch(e){
                  Response.write("<b>function getRandColor:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Create a random string based on the character set with desired length.
	 *
	 * @param  string chars
	 * @param  int 	  numberOfChars
	 * @return string
	 */
	NOF_CaptchaBMP.prototype.randomChars = function(chars, numberOfChars){
		var result = "";
		for(i=0; i<numberOfChars; i++){
			pos = Math.floor(Math.random() * chars.length);
			result += chars.charAt(pos);
		}
		return result;
	}


	/**
	 * Calculate the image width, height, size and file size.
	 * Put together the header and image content to be ready for use.
	 *
	 */
	NOF_CaptchaBMP.prototype.createImage = function(){
            try{
		if(!this.success){
			return false;
		}

		var imgWidth  = this.spaceLeft + this.spaceRight + (this.imageChars.length * this.charWidth) + ((this.imageChars.length - 1) * this.spaceInner);
		var imgHeight = this.spaceTop + this.spaceBottom + this.charHeight;

		this.setBmpWidth(imgWidth);
		this.setBmpHeight(imgHeight);
		this.setBmpSizeImage(0);
		this.setBmpFileSize(0);

		this.content += this.makeBmpHeader();
		this.content += this.makeBmpContent();
            }catch(e){
                  Response.write("<b>function createImage:</b><br>" + e.message + "<br>" + e.description);
                  Response.end;
            }
	}


	/**
	 * Write the generated image to disk
	 *
	 * @param string fileName	file path and name
	 */
	NOF_CaptchaBMP.prototype.writeImage = function(fileName){
            try{
            var handle = this.FileObj.CreateTextFile(Server.MapPath(fileName), true);

            /*
            var handle = Server.CreateObject("ADODB.Stream");
            handle.Open();
            //handle.Type = 1; // adTypeBinary
            handle.WriteText(this.content);
            handle.SaveToFile(Server.MapPath(fileName), 2); // adSaveCreateOverWrite
            */
            handle.Write(this.content);
            handle.Close();
           }catch(e){
                  Response.write("<b>function writeImage:</b><br>" + e.message + "<br>" + e.description);
              //    handle.Write("*** BMP content length:" + this.content.length);
                //  handle.Close();
                  Response.end;
            }
	}

// ************************************************************************

      NOF_CaptchaBMP.prototype.dechex = function(dec){
            var hexChars = "0123456789ABCDEF";
            var a = dec % 16;
            var b = (dec - a)/16;
            hexNr = "" + hexChars.charAt(b) + hexChars.charAt(a);
            return hexNr;
      }


      NOF_CaptchaBMP.prototype.hexdec = function(hexNr){
            return parseInt(hexNr, 16);
      }


      NOF_CaptchaBMP.prototype.array_fill = function(start_index, num, value){
            var res = new Array(start_index + num);
            var i;
            for(i=start_index; i<(start_index + num); i++){
                  res[i] = value;
            }

            return res;
	}


      NOF_CaptchaBMP.prototype.array_search = function(needle, haystack){
            var i;
            for(i=0; i<haystack.length; i++){
                  if(haystack[i] == needle){
                        return i;
                  }
            }
            return -1;
	}


      NOF_CaptchaBMP.prototype.in_array = function(needle, haystack){
            var i;
            for(i=0; i<haystack.length; i++){
                  if(haystack[i] == needle){
                        return true;
                  }
            }
            return false;
	}


      NOF_CaptchaBMP.prototype.trim = function(str){
            return str.replace(/^\s*|\s*$/g,"");
      }

// **************************************************************************

      bContent = new Array();

      function initNOF_CaptchaBMP(font, imageChars, bgColor, fgColors, spaceTop, spaceBottom, spaceLeft, spaceRight, spaceInner){
            // create image
            var img = new  NOF_CaptchaBMP();

            img.Init(font);
            img.imageChars  = imageChars;
            img.bgColor     = bgColor;
            img.fgColors    = fgColors.split(",");

            img.spaceTop    = spaceTop;
            img.spaceBottom = spaceBottom;
            img.spaceLeft   = spaceLeft;
            img.spaceRight  = spaceRight;
            img.spaceInner  = spaceInner;

            img.createImage();

            bContent = img.content.split(" ");
      }

      function JinitNOF_CaptchaBMP(settings){
            // create image
            var img = new  NOF_CaptchaBMP();
            var arrSettings = new Array()
            arrSettings = settings.split("|");

            img.Init(arrSettings[8]);
            img.imageChars  = arrSettings[0];

            img.bgColor     = arrSettings[2];
            img.fgColors    = arrSettings[3].split(",");

            img.spaceTop    = parseInt(arrSettings[4]);
            img.spaceBottom = parseInt(arrSettings[5]);
            img.spaceLeft   = parseInt(arrSettings[6]);
            img.spaceRight  = parseInt(arrSettings[7]);
            img.spaceInner  = parseInt(arrSettings[1]);

            img.createImage();
            bContent = img.content.split(" ");
      }
</SCRIPT>

<%
Dim CaptchaBMP_Temp
Dim CaptchaBMP_myVBArray

'Call initNOF_CaptchaBMP(Session("Captcha_charFontDir"), Session("Captcha_imageChars"), Session("Captcha_bgColor"), Session("Captcha_fgColors"), Session("Captcha_spaceTop"), Session("Captcha_spaceBottom"), Session("Captcha_spaceLeft"), Session("Captcha_spaceRight"), Session("Captcha_spaceInner"))

If Request.QueryString("cid") <> "" Then

      Call JinitNOF_CaptchaBMP(Session("nof_" & Request.QueryString("cid") & "_CaptchSettings"))

      CaptchaBMP_Temp = bContent.join(" &H")
      CaptchaBMP_myVBArray = Split(CaptchaBMP_Temp, " ")
End If

Sub CaptchaBMP_generateSrc
      Dim i
      Dim b
      Response.Buffer = True
      Response.ContentType = "image/bmp"
      Response.CacheControl = "no-cache"
      Response.AddHeader "Pragma", "no-cache"
      Response.Expires = -1

      for i=0 to UBound(CaptchaBMP_myVBArray)
            b = CInt(CaptchaBMP_myVBArray(i))
            Response.BinaryWrite ChrB(b)
      next
      Response.End
End Sub

If Request.QueryString("cid") <> "" Then
      CaptchaBMP_generateSrc
End If



%>
