/**********************************************************************
*
* Title:       Main Processing -- JavaScript -- TDScode.com
* Author:      Tom Smith - TDS Web Development
* Date:        5/10/2002
* Version:     1.0.0
* Description: The main processing javascript contains all of the 
*              common procedures used within tdscode.com.  Any comments
*              and/or questions should be sent to support@tdscode.com.
*
**********************************************************************/

//Variables used within some fuctions below.
NS4 = (document.layers);
IE4 = (document.all);
ver4 = (NS4 || IE4);   
isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = ((NS4 && !isMac) || (IE4 && !isMac));


//Changes the background color on a mouseover event
function bgOvr(src,clrOver)
{ 
	if (IE4)
		src.style.cursor = 'hand'; 
	
	src.bgColor = clrOver;
}

//Changes the background color on a mouseout event
function bgOut(src,clrIn)
{ 
	if (IE4)
		src.style.cursor = 'default'; 
	
	src.bgColor = clrIn;
}

//Changes the background color
function chgBG(src,color)
{
	src.bgColor = color;
}

function chgBtn(src,style)
{
	if (style == 'cBtnOvr')
		src.style.cursor = 'hand';
	else
		src.style.cursor = 'default';

	src.className = style;
}

//Changes the class on a mouseover event
function clsOvr(src,style)
{ 
	if (IE4)
		src.style.cursor = 'hand';
	
	src.className = style;
}

//Changes the class on a mouseout event
function clsOut(src,style)
{ 
	if (document.all)
		src.style.cursor = 'default';

	src.className = style;
}

//Change the class name
function chgClass(src,style)
{
	src.className = style;
}

//Replace Substring function.
function replace(string,text,by) 
{
    var strLength = string.length;
    var txtLength = text.length;
    
    if ((strLength == 0) || (txtLength == 0)) 
    	return string;

    var i = string.indexOf(text);
    
    if ((!i) && (text != string.substring(0,txtLength))) 
    	return string;
    	
    if (i == -1) 
    	return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

//Displays message box. Calls VB function makeMsgBox.  IE only....
function newConfirm(title,mess,icon,defbut,mods) 
{
	if (IE4) 
	{
		icon = (icon==0) ? 0 : 2;
		defbut = (defbut==0) ? 0 : 1;
		retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
		retVal = (retVal==6);
	}
	else 
	{ 
		retVal = confirm(mess); 
	}

	return retVal;
}


//Refreshes the current location.
function RefreshDoc()
{
	location.reload();
}

//Select or Deselect all check boxes
function chgChk(obj)
{
	for (var i=0;i < document.forms[0].length;i++)
	{
		objCur = document.forms[0].elements[i];
		
		if (objCur.type == "checkbox")
		{
			if (obj.checked)
				objCur.checked = true;
			else
				objCur.checked = false;
		}
	}
}

//Print the current page
function prtWin(page)
{
	var wParam = "width=500,height=400,resizable,scrollbars";
	var wPath = "prtWindow.jsp?page=" + page;
	var wWin = open(wPath,'_blank',wParam);
}

//Print the current page
function prtWinEx(page)
{
	var wParam = "width=500,height=400,resizable,scrollbars";
	var wPath = "printEx.jsp?exp=" + page;
	var wWin = open(wPath,'_blank',wParam);
}
//Print the current page
function prtWinAp(page)
{
	var wParam = "width=500,height=400,resizable,scrollbars";
	var wPath = "printAp.jsp?exp=" + page;
	var wWin = open(wPath,'_blank',wParam);
}

function dwnWinAp(page)
{
	var wParam = "width=500,height=400,resizable,scrollbars";
	var wPath = "dwnAp.jsp?page=" + page;
	var wWin = open(wPath,'_blank',wParam);
}

function openWin(page)
{
	var wParam = "width=500,height=400,resizable,scrollbars";
	var wWin = open(page,'_blank',wParam);
}

//Change the page to the page being passed
function chgPage(page,menu)
{
	window.top.location.href = "/main.jsp?page=" + page + "&menu=" + menu;
}
//Change the background color
function chgRowBG(src,color)
{
	src.bgColor = color;
}