var isNS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);
var HIDDEN = (isNS) ? 'hide' : 'hidden';
var VISIBLE = (isNS) ? 'show' : 'visible';

var mX, mY;


function selChangeLocation(obj) {
	location.href = obj.value;
}

/* Shows an object  */
function showIt(object) 
{
	eval("document.all." + object + ".style.visibility='" + VISIBLE + "'");
}

/* Hides an object */
function hideIt(object) 
{
	eval("document.all." + object + ".style.visibility='" + HIDDEN + "'");
}


function printWindow() {
	window.print();
}

function highlight(trId){ 
	if(document.getElementById(trId).style.backgroundColor != "#ffff99"){ 
		document.getElementById(trId).style.backgroundColor = "#ffff99"; 
	} else { 
		document.getElementById(trId).style.backgroundColor = "#ffffff"; 
	} 
} 


function goTo(link){
	location.href=link;
}

function menuClick(link, mnuid){
	parent.frames['fContent'].location=link;
	parent.frames['fMenu'].location="frame_menu.asp?mnuid=" + mnuid;
}

function double_link(content_link, submenu_link){
	parent.frames['content'].location=content_link;
	parent.frames['submenu'].location=submenu_link;
}

function recordmousecoordinates(evnt) {
	mX = evnt.pageX;
	mY = evnt.pageY;
}

//function to trim whitespace from a string
function trim(strIn){
  strOut = strIn;
  for (var t = 0; t < strIn.length; t++ ) {
	  if (  strIn.substring( t, t+1 ) != " " ) {
	    return (strOut);
	  } else { strOut = strIn.substring( t+1, strIn.length); }
	} return (strOut);
}

function dhtmlpopup()
{
	var args;
	args = dhtmlpopup.arguments;

	if (args[1] == 2)
	{
		if (navigator.appName == 'Netscape')
			document.layers[args[0]].visibility = 'show';
		else if (document.all)
			document.all[args[0]].style.visibility = 'visible';
		else if (document.getElementById)
			document.getElementById(args[0]).style.visibility = 'visible';
	}
	else if (args[1] == 1)
	{
		if (document.layers)
		{ // NS
			document.layers[args[0]].pageX = mX - (document.layers[args[0]].clip.width * args[2]) - args[4];
			document.layers[args[0]].pageY = mY - (document.layers[args[0]].clip.height * args[3]) - args[5];
			document.layers[args[0]].visibility = 'show';
		}
		else if (document.all)
		{ // IE
			document.all[args[0]].style.posLeft = window.event.x + document.body.scrollLeft - (document.all[args[0]].clientWidth * args[2]) - args[4];
			document.all[args[0]].style.posTop = window.event.y + document.body.scrollTop - (document.all[args[0]].clientHeight * args[3]) - args[5];
			document.all[args[0]].style.visibility = 'visible';
		}
		else if (document.getElementById)
		{ // MZ6
			//document.getElementById(args[0]).style.posLeft = window.event.x + document.body.scrollLeft - (document.getElementById(args[0]).clientWidth * args[2]) - args[4];
			//document.getElementById(args[0]).style.posTop = window.event.y + document.body.scrollTop - (document.getElementById(args[0]).clientHeight * args[3]) - args[5];
			//document.getElementById(args[0]).style.visibility = 'visible';
		}
	}
	else
	{
		if (document.layers)
			document.layers[args[0]].visibility = 'hide';
		else if (document.all)
			document.all[args[0]].style.visibility = 'hidden';
		else if (document.getElementById)
			document.getElementById(args[0]).style.visibility = 'hidden';
	}
}

function loginpopup()
{
	loginwin = window.open('/_a/loginlist.htm','loginwin','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=450,height=400,left=' + (window.screen.width-450)/2 + ',top=' + (window.screen.height-400)/2);
	loginwin.focus();
}

function newmsgpopup(id) {
	msgpop = window.open('/message_write.htm?idlogin='+id,'msgpopup','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=500,height=300,left=' + (window.screen.width-500)/2 + ',top=' + (window.screen.height-300)/2);
}

function s(p) { window.status=p; return true; }
function n() { window.status=''; return true; }

if (navigator.appName == 'Netscape')
{
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = recordmousecoordinates;
}



//document.all(obj.name).style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#4C4A47', EndColorStr='#FFA534')"; 

function menuHover(obj){
	identity=document.getElementById(obj.id);
	identity.className="menuHover";
}

function menuExit(obj){
	identity=document.getElementById(obj.id);
	identity.className="menu";
}

function menuItemHover(obj){
	identity=document.getElementById(obj.id);
	identity.className="menuItemHover";
}

function menuItemExit(obj){
	identity=document.getElementById(obj.id);
	identity.className="menuItem";
}

function BorderFadeOut(obj, opacity){
	alert("foo");
	document.all(obj.name).style.alpha.opacity = opacity;
	alert("bar");

	if (opacity != 0)	{
		setTimeout("BorderFadeOut(" + obj + ", " + opacity-1 + ")",10);
		alert("3");
	}
	
}


//documentation for this function at http://www.shawnolson.net/a/503/
function changecss(theClass,element,value) {
	//example changecss('.mainMenu','border-color','black')
	var cssRules;
	if (document.all) {
		cssRules = 'rules';
	} else if (document.getElementById) {
		cssRules = 'cssRules';
	}
	for (var S = 0; S < document.styleSheets.length; S++){
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
			if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
				document.styleSheets[S][cssRules][R].style[element] = value;
			}
		}
	}	
}



function fadeOut(obj) {
    obj.style.filter="blendTrans(duration=1)";
	// Make sure filter is not playing.
	//if ((obj.visibility != "hidden")) {
        obj.filters.blendTrans.Apply();
        obj.style.visibility="hidden";
				obj.filters.blendTrans.Play();
	//}
}
function fadeIn(obj) {
    obj.style.filter="blendTrans(duration=1)";
	// Make sure filter is not playing.
	//if ((obj.visibility != "visible")) {
      obj.filters.blendTrans.Apply();
      obj.style.visibility="visible";
			obj.filters.blendTrans.Play();
	//}
}


function overRow(row){
	row.bgColor="#ffff99";
}
function outRow(row){
	if ((parseInt(row.name)%2) == 1) {
		row.bgColor="#FFFFFF";
	} else {
		row.bgColor="#EEF0FF";
	}
}


function showGrad(el, start, end) { document.all(el).style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='"+start+"', EndColorStr='"+end+"')"; }
function showGray(el) { document.all(el).style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#CCCCCC', EndColorStr='#FFFFFF')"; }
function fOn(o) { o.style.filter = "progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#444444', EndColorStr='#886212')"; }
function fOff(o) { o.style.filter = ""; }
function eOn(o,c) { document.getElementById(o).bgcolor=c; }


// Java Script to Handle AutoSearch
function onSelectKeyDown()
{
	if(window.event.keyCode == 46)
		clr();
}
function selectKeyPress()
{
	// Notes:
	//	1) previous keys are cleared onBlur/onFocus and with Delete key
	//	2) if the search doesn't find a match, this returns to normal 1 key search
	//		setting returnValue = false below for ALL cases will prevent
	//		default behavior
	
	//TODO:
	//	1) add Netscape handling
	
	var sndr = window.event.srcElement;
	var pre = this.document.all["keys"].value;
	var key = window.event.keyCode;
	var char = String.fromCharCode(key);

	var re = new RegExp("^" + pre + char, "i"); // "i" -> ignoreCase
	for(var i=0; i<sndr.options.length; i++)
	{
		if(re.test(sndr.options[i].text))
		{
			sndr.options[i].selected=true;
			document.all["keys"].value += char;
			window.event.returnValue = false;
			break;
		}
	}
}
function clr()
{
	document.all["keys"].value = "";
}
// END Java Script to Handle AutoSearch

//pass in a decimal value, returns the hex value
function dectohex(decval) {
	decval = parseInt(decval);
	if ( (decval<=9) && (decval>=0) ) {
		return decval;
	} else { // decval must be in (10, 11, 12, 13, 14, 15, 16)
		if (decval==10){return "A";}
		if (decval==11){return "B";}
		if (decval==12){return "C";}
		if (decval==13){return "D";}
		if (decval==14){return "E";}
		if (decval==15){return "F";}
	} 
	return "dectohex error";
}

/*function hextodec(hexval) {
	if ((parseInt(hexval))<=9) && (parseInt(hexval)>=0)) {
		return parseInt(hexval);
	} else { // hexval must be in (A, B, C, D, E, F)
		if ((hexval=="A") || (hexval=="a")){return 10;}
		if ((hexval=="B") || (hexval=="b")){return 11;}
		if ((hexval=="C") || (hexval=="c")){return 12;}
		if ((hexval=="D") || (hexval=="d")){return 13;}
		if ((hexval=="E") || (hexval=="e")){return 14;}
		if ((hexval=="F") || (hexval=="f")){return 15;}
	} 
	return "hextodec error";
}*/

function incrementHexValue(val) {
	val=val+"";
	switch (val) {
		case "0": val="1";break;
		case "1": val="2";break;
		case "2": val="3";break;
		case "3": val="4";break;
		case "4": val="5";break;
		case "5": val="6";break;
		case "6": val="7";break;
		case "7": val="8";break;
		case "8": val="9";break;
		case "9": val="A";break;
		case "A": val="B";break;
		case "B": val="C";break;
		case "C": val="D";break;
		case "D": val="E";break;
		case "E": val="F";break;
		case "F": val="E";break;
		default	:	val="0";break;
	}
	return val;
}

function decrementHexValue(val) {
	val=val+"";
	switch (val) {
		case "0": val="1";break;
		case "1": val="0";break;
		case "2": val="1";break;
		case "3": val="2";break;
		case "4": val="3";break;
		case "5": val="4";break;
		case "6": val="5";break;
		case "7": val="6";break;
		case "8": val="7";break;
		case "9": val="8";break;
		case "A": val="9";break;
		case "B": val="A";break;
		case "C": val="B";break;
		case "D": val="C";break;
		case "E": val="D";break;
		case "F": val="E";break;
		default	:	val="0";break;
	}
	return val;
}

function incrementColorFull(colorn, red_tf, green_tf, blue_tf, red_flip_01, green_flip_01, blue_flip_01) {
	//check for strings that are less than 6 or more than 7 chars
	if (colorn.length>7 || colorn.length< 6 ) { //this is not a 6 or 7 char color
//		return "000000";
		return "error - not a 6 or 7 char color";
	}
	//check for the # sign in front of the color
	if (colorn.charCodeAt(0)==35 && colorn.length==7) {	//char is #
		colorn=colorn.substr(1,6);
		//alert("found #" + colorn + " " + colorn.length);
	}	
	colorn=colorn.toUpperCase();
//	alert(colorn);
	//get indivdual colors
//	var r = colorn.substr(0,2);
//	var g = colorn.substr(2,2);
//	var b = colorn.substr(4,2);
	var r1 = colorn.substr(0,1);
	var g1 = colorn.substr(2,1);
	var b1 = colorn.substr(4,1);
	var r2 = colorn.substr(1,1);
	var g2 = colorn.substr(3,1);
	var b2 = colorn.substr(5,1);

	if (red_yn==true) {
		if (red_flip_01==1) {
			r1=decrementColor(r1);
		} else {
			r1=incrementColor(r1);
		}
	}
	if (green_yn==true) {
		if (green_flip_01==1) {
			g1=decrementColor(g1);
		} else {
			g1=incrementColor(g1);
		}
	}
	if (blue_yn==true) {
		if (blue_flip_01==1) {
			b1=decrementColor(b1);
		} else {
			b1=incrementColor(b1);
		}
	}
	
	colorn=r1+r2+g1+g2+b1+b2;
//	alert(colorn);
	return colorn;
}






/*The following is from a script collection called fade.js from mini-itx.com*/

/*****************************************\
||       Fade Script Version 3.1         ||
||   http://anarchos.xs.mw/fade.phtml    ||
||            (c) July 2001              ||
|| _____________________________________ ||
|| Created by:                           ||
|| Anarchos    > anarchos.xs.mw          ||
|| _____________________________________ ||
|| auto-startColor by Mike West          ||
|| mike@westman.org                      ||
|| _____________________________________ ||
|| uniqueID upgrade by DubMatrix         ||
|| http://www.princefari.com             ||
|| _____________________________________ ||
|| Color conversion from decimal to      ||
|| hex (dehexize function) by:           ||
|| Litejet > litejet@hotmail.com         ||
|| _____________________________________ ||
|| Fade, hex, setColor functions by:     ||
|| Dak Phoenix > phoenix-archetypes.com  ||
|| _____________________________________ ||
|| domouseover/out based on scripts by   ||
|| The Shadow  > www.icon.co.za/~andrewk ||
||                                       ||
\*****************************************/

/*************
**** <config>
**/

fadeColor = "#0000AA";  // color to fade to
stepIn = 15; // delay when fading in
stepOut = 5; // delay when fading out

/* set to true or false; true will
** cause all links to fade automatically
** (you won't need to add class="fade")
***/
autoFade = true;  

/* set to true or false; true will cause all CSS
** classes with "fade" in them to fade onmouseover
***/
sloppyClass = true;

/* set to true or false; true will make the script
** work for Macs (IE 5+), but you will have to give
** a name (name="blah") to each link that you want
** to fade.
***/
macCompat = false;

/** 
**** </config>
**************/

hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

document.onmouseover = domouseover;
document.onmouseout = domouseout;

fadeColor = dehexize(fadeColor.toLowerCase());

var fadeId = new Array();

function dehexize(Color){
	var colorArr = new makearray(3);
	for (i=1; i<7; i++){
		for (j=0; j<16; j++){
			if (Color.charAt(i) == hexa[j]){
				if (i%2 !=0)
					colorArr[Math.floor((i-1)/2)]=eval(j)*16;
				else
					colorArr[Math.floor((i-1)/2)]+=eval(j);
			}
		}
	}
	return colorArr;
}

function domouseover() {
	if(document.all){
		var srcElement = event.srcElement;
		if ((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) {
				if (!srcElement.startColor) {
					srcElement.startColor = (srcElement.style.color)? srcElement.style.color: srcElement.currentStyle.color;
					srcElement.startColor = dehexize(srcElement.startColor.toLowerCase());
				}
				var link = (macCompat? srcElement.name: srcElement.uniqueID);
				if (link) fade(srcElement.startColor,fadeColor,link,stepIn);				
				else if (macCompat) alert("Error: Mac Compatility mode enabled, but link has no name.");
		}
	}
}

function domouseout() {
	if (document.all){
		var srcElement = event.srcElement;
		if ((srcElement.tagName == "A" && autoFade && srcElement.className != "nofade") || srcElement.className == "fade" || (sloppyClass && srcElement.className.indexOf("fade") != -1)) {
			var link = (macCompat? srcElement.name: srcElement.uniqueID);
			if (link) fade(fadeColor,srcElement.startColor,link,stepIn);
		}
	}
}

function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
       return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function setColor(r, g, b, element) {
      var hr = hex(r); var hg = hex(g); var hb = hex(b);
      element.style.color = "#"+hr+hg+hb;
}

function fade(s,e,element,step) {
	var sr = s[0]; var sg = s[1]; var sb = s[2];
	var er = e[0]; var eg = e[1]; var eb = e[2];
	
	if (fadeId[0] != null && fade[0] != element && eval(fadeId[0])) {
		var orig = eval(fadeId[0]);
		setColor(orig.startColor[0],orig.startColor[1],orig.startColor[2],orig);
		var i = 1;
		while(i < fadeId.length) {
			clearTimeout(fadeId[i]);
			i++;
		}
	}
		
	for(var i = 0; i <= step; i++) {
		fadeId[i+1] = setTimeout("setColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +
			step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+
			")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),"+element+");",i*step);
	}
	fadeId[0] = element;
}


/* end mini-itx.com fade.js script */








/* DRAG STUFF FROM BRAINJAR.COM */

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.
var dragObj = new Object();
dragObj.zIndex = 0;



function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }


// Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

 // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

// Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;


// Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }

}


function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

// Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left =
    (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  =
    (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

 if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();

}


function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}



/*** END DRAG STUFF ********/