
function setPointer(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
}

function clickHandler(id)
{
	var targetId, srcElement, targetElement;
	var srcElement    = document.getElementById(id);
	var targetElement = document.getElementById("T" + id);
	
	if (targetElement.style.display == "none")
	{
		srcElement.src              = "../../images/minus.gif";
		targetElement.style.display = "";
	}
	else
	{
		srcElement.src              = "../../images/plus.gif";
		targetElement.style.display = "none";
	}
}

function mark(face,field_color,text_color){

	if (document.documentElement){//if browser is IE5+ or NS6+
		face.style.backgroundColor=field_color;
		face.style.color=text_color;
	}

}

function clickHandler(id)
{
	var targetId, srcElement, targetElement;
	var srcElement    = document.getElementById(id);
	var targetElement = document.getElementById("T" + id);
	
	if (targetElement.style.display == "none")
	{
		srcElement.src              = "../../images/minus.gif";
		targetElement.style.display = "";
	}
	else
	{
		srcElement.src              = "../../images/plus.gif";
		targetElement.style.display = "none";
	}
}

// Macromedia functions
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*
function popWin( url, name, width, height, scroller ) {
	var outStr = 'height=' + height + ',width=' + width;
	if (scroller != 'true') {
	outStr = outStr + ',menubar=yes,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes';
	}
	else {
	outStr = outStr + ',menubar=yes,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes';
	}
	window.open(url, name, outStr);
}
*/
// Pop-up Windows
function popWin( url, name, width, height, scroller )
{
	var outStr = 'height=' + height + ',width=' + width;
	outStr = outStr + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=' + scroller + ',resizable=no';
	window.open(url, name, outStr);
}

function showStuff(id, triggerFlag)
{
	var srcElement, targetElement;
	var srcElement    = document.getElementById(id);
	var targetElement = document.getElementById("T" + id);
	
	if (srcElement.value == triggerFlag)
		targetElement.style.display = "";
	else
		targetElement.style.display = "none";
}

function hideStuff(id, triggerFlag)
{
	var srcElement, targetElement;
	var srcElement    = document.getElementById(id);
	var targetElement = document.getElementById("T" + id);
	
	if (srcElement.value == triggerFlag)
		targetElement.style.display = "none";
	else
		targetElement.style.display = "";
}

function switchStuffAndHide(id, triggerFlag, hideothers)
{
	var srcElement, targetElement;
	var srcElement    = document.getElementById(id);
	var targetElement = document.getElementById("T" + id);
	var hideElement = document.getElementById("H" + id);
	
	if (srcElement.value == triggerFlag)
		targetElement.style.display = "";
	else
		targetElement.style.display = "none";
	
	if(hideothers == true)
	{
		if (srcElement.value == triggerFlag)
			hideElement.style.display = "none";
		else
			hideElement.style.display = "";
	}
}

function showHide(id){
	var targetElement = document.getElementById(id);
	if (targetElement.style.display == "none")
		targetElement.style.display = "";
	else
		targetElement.style.display = "none";

}

function switchText(id, triggerFlag, first, second)
{
	var srcElement, switchOne, switchTwo;
	var srcElement = document.getElementById(id);
	var switchOne  = document.getElementById(first);
	var switchTwo  = document.getElementById(second);
	
	if (srcElement.value == triggerFlag)
	{
		switchOne.style.display = "none";
		switchTwo.style.display = "";
	}
	else
	{
		switchOne.style.display = "";
		switchTwo.style.display = "none";
	}
}

/* For Div Confirmations */

//fades layer in
opac = 0;
var browser = (navigator.appName == "Microsoft Internet Explorer") ? "IE" : "MOZ";

function fadeIn(id, user_opac) {
	
	if(opac != user_opac)
	{
		if(opac == 0)
		{
			document.getElementById(id).style.display = '';
			if(browser == "IE") document.getElementById(id).style.filter = 'alpha(opacity=0)';
			if(browser == "MOZ") document.getElementById(id).style.opacity = 0;
		}
		opac+=1;
		
		if(browser == "IE") document.getElementById(id).style.filter = 'alpha(opacity=' + opac*10 + ')';
		if(browser == "MOZ") document.getElementById(id).style.opacity = opac/10;
		
		setTimeout("fadeIn('"+ id +"',"+ user_opac +")", 1);
	}
	else
	{
		opac = 0;
	}
}


function fadeInConfirm(id, confirmText) {
	
	if(opac != 10)
	{
		if(opac == 0)
		{
			document.getElementById('confirmText').innerHTML = confirmText;
			if(browser == "IE") document.getElementById('blanket').style.filter = 'alpha(opacity=0)';
			if(browser == "MOZ") document.getElementById('blanket').style.opacity = 0;
			document.getElementById('blanket').style.display = '';
			document.getElementById('confirm').style.display = '';
		}
		opac+=1;
		
		if(opac <= 5){
			if(browser == "IE") document.getElementById('blanket').style.filter = 'alpha(opacity=' + opac*10 + ')';
			if(browser == "MOZ") document.getElementById('blanket').style.opacity = opac/10;
		}
		
		if(browser == "IE") document.getElementById('confirm').style.filter = 'alpha(opacity=' + opac*10 + ')';
		if(browser == "MOZ") document.getElementById('confirm').style.opacity = opac/10;
		
		setTimeout("fadeInConfirm('"+ id +"','')", 1);
	}
	else
	{
		opac = 0;
	}
}

//fades layer out
opac2 = 10;

function fadeOut(id, start_opac) {
	
	if(start_opac > 0){
		start_opac-=1;
		
		if(browser == "IE") document.getElementById(id).style.filter = 'alpha(opacity=' + start_opac*10 + ')';
		if(browser == "MOZ") document.getElementById(id).style.opacity = start_opac/10;
		
		setTimeout("fadeOut('"+ id +"',"+ start_opac +")", 1);
	}
	else
	{
		document.getElementById(id).style.display = 'none';
		if(document.getElementById('confirmText')){
			document.getElementById('confirmText').innerHTML = '';
		}
	}
}

function fadeOutConfirm() {
	
	if(opac2 > 0){
		opac2-=1;
		
		if(opac2 <= 5){
			if(browser == "IE") document.getElementById('blanket').style.filter = 'alpha(opacity=' + opac2*10 + ')';
			if(browser == "MOZ") document.getElementById('blanket').style.opacity = opac2/10;
		}
		
		if(browser == "IE") document.getElementById('confirm').style.filter = 'alpha(opacity=' + opac2*10 + ')';
		if(browser == "MOZ") document.getElementById('confirm').style.opacity = opac2/10;
		
		setTimeout('fadeOutConfirm()', 1);
	}
	else
	{
		document.getElementById('blanket').style.display = 'none';
		document.getElementById('confirm').style.display = 'none';
		opac2 = 10;
	}
}

/* For Doing a color fade  */
function fadeColour( fromcol, tocol, fadePortion ) {
    //in the format fadeColour( 'ff0098', 'fe0934', 0.23 )
    var oF = [], oT = [], oP = [];
    var oH = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
    //get the red, green and blue substrings ...
    for( var x = 0; x < 3; x++ ) {
        //... and convert them from hex into decimal ...
        oF[x] = eval( '0x' + fromcol.substring( 2 * x, ( 2 * x ) + 2 ) );
        oT[x] = eval( '0x' + tocol.substring( 2 * x, ( 2 * x ) + 2 ) );
        //... add on the required portion of difference between the two ...
        oP[x] = Math.round( oF[x] + ( ( oT[x] - oF[x] ) * fadePortion ) );
        //... and convert it back into hex ...
        oP[x] = oH[ ( oP[x] - ( oP[x] % 16 ) ) / 16 ] + oH[ oP[x] % 16 ];
    }
    //... and put them back together again as a colour string
    return '#' + oP.join('');
}
/*
for( var y = 0; y < 10; y++ ) {
    //in 10 steps, fade the colour - also see the section on writing with script
    document.write( '<font color="' + fadeColour( 'd2cbff', '000099', y / 9 ) +
    '">Fade!</font> ' );
}

for( var y = 0; y < 12; y++ ) {
    //in 12 steps, fade the colour
    document.write( '<font color="' + fadeColour( 'ff0000', '000000', y / 11 ) +
    '">Fade!</font> ' );
}
*/

// bring up the blanket with a hour-glass cursor
function iAmThinking()
{
	if(browser == "IE") document.getElementById('blanket').style.filter = 'alpha(opacity=0)';
	if(browser == "MOZ") document.getElementById('blanket').style.opacity = 0;
	
	document.getElementById('blanket').style.display = '';
	document.getElementById('blanket').style.cursor = 'wait';
}

function iAmDoneThinking()
{
	document.getElementById('blanket').style.display = 'none';
	document.getElementById('blanket').style.cursor = '';
}