

//--------------------------------------------//
// Essential HTML version 1.0
//
// Author : Hoi-Hung Tsang (hoi@tsang.cc)
// Lastupd: 4/30/2001
// About  : this module combines of various
//          basic javascript functions to 
//				  generate some basic HTML tag
//          hope it helps you.
//--------------------------------------------//
// function sequence:
// public:
// 	[1] makeImage
// 	[2] makeColorText
// 	[3] makeSpacer
// 	[4] makeInput
// 	[5] makeTable
// 	[6] makeRow
// 	[7] makeCell
// 	[8] swapImage






//--------------------------------------------//
// 						Image Maker
//--------------------------------------------//
// input: [path] -- image path
// 			  [width] -- image width
//				[height] -- image height
//				[border] -- image border
// output: HTML tag string for an image
//--------------------------------------------//
function makeImage(path, width, height, border, name, map, actions, alt)
{
	var str = "<IMG src=\"" + path + "\" ";
	if (width != null)   str += " width="    + width;
	if (height != null)  str += " height="   + height;
	if (border != null)  str += " border="   + border;
	if (name != null)    str += " name=\""   + name + "\"";
	if (map != null)     str += " usemap=\"" + map + "\"";
	if (actions != null) str += " " + actions;
	if (alt != null)     str += " alt=\"" + alt + "\"";
	return str += ">";
}


//--------------------------------------------//
// 						Color Text Maker
//--------------------------------------------//
// input: [face] -- font face or type
// 			  [size] -- font size
//				[color] -- hex value of font color
//				[content] -- text message within this font tag
// output: HTML tag string of a font tag 
//--------------------------------------------//
function makeColorText(face, size, color, content)
{
	var str = "<FONT";
	if (face != null) str += " face=\"" + face + "\"";
	if (size != null) str += " size=" + size;
	if (color != null) str += " color=" + color;
	str += ">" + content + "</FONT>";
	return str;
}


//--------------------------------------------//
// 						Spacer Image Maker
//--------------------------------------------//
// input: [width] -- spacer image width
// 			  [height] -- spacer image height
// output: HTML tag string of a spacer img tag 
//--------------------------------------------//
function makeSpacer(width, height)
{
	return makeImage("images/spacer.gif", width, height, 0);
}


//--------------------------------------------//
// 						Input tag Maker
//--------------------------------------------//
// input: [name] -- name of the input tag
// 			  [propeties] -- properties of the 
//											 input tag (e.g. size...)
// output: HTML tag string of an input tag
//--------------------------------------------//
function makeInput(name, properties)
{
	var str = "<INPUT";
	if (name != null) 	str += " name\"" + name + "\"";
	if (properties != null) str += properties;
	return str + ">";
}


//--------------------------------------------//
// 						link Maker
//--------------------------------------------//
// input: [link] -- URL of the link
// 			  [target] -- link target (frame)
//				[text] -- click over text for the link
// output: HTML tag string of a link tag 
//--------------------------------------------//
function makeLink(link, text, properties)
{
	var str = "<A href=\"" + link + "\"";
	if (properties != null) str += " " + properties;
	return str + ">" + text + "</A>";
}


//--------------------------------------------//
// 						Table Tag Maker
//--------------------------------------------//
// input: [rows] -- array of row content
//        [properties] -- table properties
// output: HTML string of a table with 
//				 [properties] as properties and 
//				 [rows] as content.
//--------------------------------------------//
function makeTable(rows, properties)
{
	var str = "<TABLE " + properties + ">\n";
	for (i=0; i<rows.length; i++)
	{
		str += rows[i] + "\n";
	}
	str += "</TABLE>";
	return str;
}


//--------------------------------------------//
// 						Table Row Tag Maker
//--------------------------------------------//
// input: [content] -- content of the row
// process: HTML string of a table row with 
//   				[content]
//--------------------------------------------//
function makeRow(content)
{
	return "<TR>" + content + "\n" + "</TR>";
}


//--------------------------------------------//
// 						Table Cell Tag Maker
//--------------------------------------------//
// input: [content] -- content of the cell
//        [properties] -- the properties of a cell
// output: HTML string of a table cell with 
//				[properties] as properties, 
//				and [content] as content.
//--------------------------------------------//
function makeCell(content, properties)
{
	return "<TD " + properties + ">" + content + "</TD>";
}


//---------------------------------------------//
//             Image Swapper     
//---------------------------------------------//
// input: [imgName] -- image name
//        [path] -- new image path
// output: none
function swapImg(imgName, path)
{
	if (document.images)
	{
//		alert(imgName + "=" + path);
		document.images[imgName].src = path;
	}
}




//---------------------------------------------//
//            Random Integer Generator
//---------------------------------------------//
function getRandomInt(from, to)
{
	var range = to - from;
	var randNum = Math.floor(Math.random() * range);
	return randNum + from;
}



function doNothing()
{ }



function loadImage(imgSrc)
{
	var imgObject = new Image();
	imgObject.src = imgSrc;
	return imgObject;	
}

