/*
 * Creates and returns a new ARRAY with Length n
**/
function makeArray(n)
{
	this.length=n;
	for(var i=1;i<=n;i++)
		this[i]=0;
	return this;
}

/*
 * Global ARRAY of
**/
ARR_HEX=new makeArray(16);
for(var i=0;i<10;i++)
	ARR_HEX[i]=i;
ARR_HEX[10]="A";
ARR_HEX[11]="B";
ARR_HEX[12]="C";
ARR_HEX[13]="D";
ARR_HEX[14]="E";
ARR_HEX[15]="F";

/*
 * Returns the HEX-Code of the ParamValue i
**/
function getHEX(i)
{
	if (i < 0)
		return "00";
	else
		if(i>255)
			return "FF";
		else
			return ""+ARR_HEX[Math.floor(i/16)]+ARR_HEX[i%16];
}

/*
 * Prints the TextString out
**/
function doTxt(txtStr)
{
	document.write(txtStr);
}

/*
 * Converts and returns a RGB-Color-String (RRGGBB)
**/
function makeRGB(r,g,b)
{
	return getHEX(r)+getHEX(g)+getHEX(b);
}

/*
 * Returns the index-number of the picture with Name in the document
**/
function getPicNb(strName)
{
	var i=0;			// Index
	var f=false;	// Found?
	while (i<document.images.length)
	{
		var s=document.images[i].name;
		if (s==strName)
			f=true;
		if (!f)
			i++;
		else
			break;
	}
	if (f)
		return i;
	else
		return -1;
}

/*
 * Changes the Source of the Picture with ID Number in the document
**/
function chgPic(strName,imgSource)
{
	var nb=getPicNb(strName);
	if (nb==-1)
		alert("PictureIndexNumber in document.images[Name] = \""+strName+"\" could not found!");
	else
		document.images[nb].src = imgSource.src;
}

/*
 * Writes in the document the link with lots of special data
**/
function setPicLink(strName,Location,Source,AltTxt,StatusTxt,DX,DY,sOptions)
{
	var strNameO=strName.concat("_o");
	var strNameC=strName.concat("_c");
	var strNameN=strName.concat("_n");
	strName="\""+strName.concat("\"");
	var strStatus=status;
	if (sOptions != "")
		sOptions = " " + sOptions + " ";
	var strTmp=
		"<A HRef=\""+Location+"\" "+
		sOptions +
		"onMouseOver='status=\""+StatusTxt+"\"; chgPic( "+strName+", "+strNameO+");return true;' "+
		"onMouseDown='chgPic( "+strName+", "+strNameC+");return true;' "+
		"onMouseOut ='status=\""+strStatus+"\"; chgPic( "+strName+", "+strNameN+");return true;'>"+
		"<IMG Name="+strName+" Src=\""+Source+"\" Width="+DX+" Height="+DY+" Alt=\""+AltTxt+"\" Border=0>"+
		"</A>";
//	alert(strTmp);
	doTxt(strTmp);
}

/*
 * Writes in the document the link with lots of special data
**/
function setTxtLink(strName,Location,StatusTxt)
{
	//strName="\""+strName.concat("\"");
	var strStatus=status;
	doTxt(
		" <A HRef=\""+Location+"\" "+
		"onMouseOver='status=\""+StatusTxt+"\";return true;' "+
		"onMouseOut='status=\""+strStatus+"\";return true;'>"+
		strName+"</A> ");
}
