// Support Script (604)
function subAwithBinC(a,b,c)
{

	var i = c.indexOf(a);
	var l = b.length;

	while (i != -1)	{
		c = c.substring(0,i) + b + c.substring(i + a.length,c.length);
  i += l
		i = c.indexOf(a,i);
	}
	return c;

}
// Support Script (589)
function Validate(stopOnFailure)
{
	var ErrorMsg = "";
	var i
	var msg
	var tofocus = true;
	var ErrorMsg = "";
	
	// Go through the Validate Array that may or may not exist
	// and call the Validate function for all elements that have one.
	if (document.ValidateArray)
	{
		for (i = 0; i < document.ValidateArray.length; i ++)
		{
			msg = eval( document.ValidateArray[i] + ".Validate()")
			if (msg != "")
			{
				ErrorMsg += "\n\n" + document.ValidateArray[i] + ":  " + msg;
				if (tofocus) 
				{
					eval(document.ValidateArray[i] + ".focus()")
					tofocus = false;
				}
				
				if (stopOnFailure == "1") return ErrorMsg;
			}
  	}
  }
	return ErrorMsg;
}

// Support Script (287)
function colorAsRGBHex(s)
{
	return swapRedBlue(colorAsHex(s));
}

function colorAsHex(s)
{
	lColor = parseColor(s);
	color = lColor.toString(16);
	while (color.length < 6)
		color = "0" + color;

	return color;
}

function swapRedBlue(s)
{
	retColor = s;
	if (s.length == 6 && !isNaN(parseInt("0x" + s)))
	{
			r = s.substr(4,2);
			g = s.substr(2,2);
			b = s.substr(0,2);
			retColor = r + g + b;
	}
	else alert("swapRedBlue: Illegal input " + s);

	return retColor;
}

function parseColor(s)
{
	sInit = s;
	retColor = 0x0F000000;  // illegal color value

	s = s.replace(/^\s+/, "");  // trim leading and trailing white space
	s = s.replace(/\s+$/, "");

	if (s.substr(0,3) == "rgb")     // rgb(rrr,ggg,bbb)
		s = s.substr(3, s.length);

	if (s.substr(0,1) == "(")       // (rrr,ggg,bbb)
	{
		s = s.substr(0, s.length -1);
		s = s.substr(1, s.length -1);
		rgb = s.split(",");
		retColor = parseInt(rgb[0])*0x10000 + parseInt(rgb[1])*0x100 + parseInt(rgb[2]);
	}
	else
	{
		if (s.charAt(0) == "#")                          // #rrggbb
		{
			s = s.substr(1,6);
			retColor = parseInt("0x" + s);
		}
		else
		{
			if (s.substr(0,2) == "0x" && s.length > 2)       // Oxrrggbb OR 0xHHH (not 6 digit hex)
			{
				s = s.substr(2, s.length);
				retColor = parseInt("0x" + s);
			}
			else
			{
				if (!isNaN(parseInt(s)))                       // ddddddd (decimal) OR 0xrrggbb (hex)
				{
					retColor = parseInt(s);
				}
			}
		}
	}

	if (isNaN(retColor) || retColor == 0x0F000000)
	{
		retColor = 0xC0C0C0;
		alert("parseColor: color value not parsed (using default gray) " + sInit);
	}

	return retColor;
}

function document_onLoad() {
var colorL = colorAsRGBHex("0");
var colorA = colorAsRGBHex("0");
var colorV = colorAsRGBHex("0");
colorL = '#'+colorL;
colorV = '#'+colorV;
colorA = '#'+colorA;
document.linkColor = colorL;
document.vlinkColor = colorV;
document.alinkColor = colorA;
 }
function ImageButton1_onClick() {
var addChar = "?" 
var j
var okToSubmit = false;


// execute the onSubmit() event handler and try to 
// determine if it already validated the form
Result = Form1.onSubmit();

//   If there is no onSubmithander the return value is null
//   If there is a validation handler it returns true to submit
//   or false to not submit
if (Result==null)  // there is no validation already defined
{
    if ("0" == "1")
    {
        Result = Validate("0"); // don't stop on first error
        if (Result == "") okToSubmit = true;
        else alert("The form could not be submitted:" + Result);
    }
    else okToSubmit = true;
}
else // there is a validation already defined
{
    if (Result==true)
        okToSubmit = true;
}

if (okToSubmit) 
{
    // We have to
    // put the source in the query string so the generic database contracts
    // still work.

    // NOTE: this only works if the method of the form is POST


    act = Form1.getAction();
    if (act.indexOf("?") != -1)
    {    
        addChar = "&"
    }

    act += addChar + "ImageButton1=1"
    Form1.setAction(act);


    Form1.submit();
}
 }
function _ImageButton1_onClick() { if (ImageButton1) return ImageButton1.onClick(); }

