var popupWin; // Used ty OpenWin and other pages to detect if a pop-up blocking is on.
    
//----------- Set HR Menu Functions to Null	 
	var HM_Height_offset= 0;
    HM_IE = (document.all) ? true : false;
	if(window.event + "" == "undefined") event = null;
	function HM_f_PopUp(){return false};
	function HM_f_PopDown(){return false};
	function HM_f_HideAll(){return false};
	popUp = HM_f_PopUp;
	popDown = HM_f_PopDown;
	
	function DisplayFeatureExercises(){return false}; // used for feature Exercise on home page

//---------------------------- END HR Menu ---------------------------- //
function checkOpener(){
	var defaultURL = 'http://tbar2.dev/';
	if (window.opener && !window.opener.closed ) // Is the opener still open
		if (checkOpener.arguments[0])
			window.location.href = checkOpener.arguments[0];
		else
			window.location.href = defaultURL;
}
//---------------------------- Begin Window Open Template ---------------------------- //
// Open a pop-up window
function OpenWin()
{
	// Set default values
	var winName = "newWin";
	var intHt = 500;
	var intWd = 500;
	var intXPos = -1;
	var intYpos = -1;

	var bTool = 'no';
	var	bLoc = 'no';
	var bStatus = 'no';
	var bMenu = 'no';
	var bScroll = 'yes';
	var bResize = 'yes';
	var bHist = 'no';
	
	var strProp = "";  // Properties of the opened window
	
	// If there are no arguaments passed to the function then use the above defaults.
	
	if (OpenWin.arguments[0]){
		var url = OpenWin.arguments[0];
	
		if (OpenWin.arguments[1])
			winName = OpenWin.arguments[1];
		
		if (OpenWin.arguments[2])
			intHt = OpenWin.arguments[2];
	
		if (OpenWin.arguments[3])
			intWd = OpenWin.arguments[3];
			
		if (OpenWin.arguments[4])
			intXPos = OpenWin.arguments[4];
			
		if (OpenWin.arguments[5])
			intYpos = OpenWin.arguments[5];
			
		if (OpenWin.arguments[6])
			bTool = OpenWin.arguments[6];
			
		if (OpenWin.arguments[7])
			bLoc = OpenWin.arguments[7];
			
		if (OpenWin.arguments[8])
			bStatus = OpenWin.arguments[8];
			
		if (OpenWin.arguments[9])
			bMenu = OpenWin.arguments[9];
			
		if (OpenWin.arguments[10])
			bScroll = OpenWin.arguments[10];
			
		if (OpenWin.arguments[11])
			bResize = OpenWin.arguments[11];
			
		if (OpenWin.arguments[12])
			bHist = OpenWin.arguments[12];
			
		if (intXPos < 1 ) 
			intXPos = window.screenLeft + 10;

		if (intYpos < 1) 
			intYpos = window.screenTop - 20;		
		strProp = '';
		strProp	= strProp + "toolbar=" + bTool + ",location=" + bLoc + ",status=" + bStatus + ",menubar=" + bMenu + ","
		strProp	= strProp + "scrollbars=" + bScroll + ",resizable=" + bResize + ",copyhistory=" + bHist + ",";
		strProp	= strProp + "width=" + intWd + ",height=" + intHt + ",left=" + intXPos + ",top=" + intYpos + "";

		popupWin = window.open(url, winName,strProp);
	}
	else
	{
		alert("Please provide the URL.")
	}
}
//---------------------------- End Window Open Template ---------------------------- //

function resourceWin(url)
{
	OpenWin(url, "rscWin",540,700,window.screenLeft + 10,window.screenTop - 20);
}

function ExSavePrintWin(url)
{
	OpenWin(url, "rscWin",540,780,window.screenLeft + 10,window.screenTop - 20);
}

function SemEditWin(url)
{
	OpenWin(url, "SemEditWin",720,620, -1, -1);
}

//---------------------------- BEGIN Form Basics ---------------------------- //
function disableForm(theform) { // Disable form submit buttons
	if (document.all || document.getElementById) {
		for (i = 0; i < theform.length; i++) {
			var tempobj = theform.elements[i];
			if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
				tempobj.disabled = true;
		}
//		setTimeout('alert("Your form has been submitted.  Notice how the submit and reset buttons were disabled upon submission.")', 2000);
		return true;
	}
}  


function placeFocus() {
	if (document.forms.length > 0) {
		var field = document.forms[0];
		for (i = 0; i < field.length; i++) {
			if ((field.elements[i].type == "checkbox" || field.elements[i].type == "text") || (field.elements[i].type == "textarea") ) {
				document.forms[0].elements[i].focus();
				break;
         }
      }
   }
}

function strTrim(str) {
	//Match spaces at beginning and end of text and replace
	//with null strings
	return str.replace(/^\s+/,'').replace(/\s+$/,'');
	}


//-----------------------------------------------------------------------------
// Standard Rollover

function ChangeImages()
{
	if (document.images)
	{
   		for (var i=0; i<ChangeImages.arguments.length; i+=2)
   		{
			document[ChangeImages.arguments[i]].src = eval(ChangeImages.arguments[i+1] + ".src");
   		}
	}
}

var TopNavTimeID;
var arg1;
var arg2;
var arg3;
//-----------------------------------------------------------------------------
function ShowTopNav()
{
	var i=0;
	HideAllTopNav();
	clearTimeout(TopNavTimeID);
	if(document.images)
	{
		document[ShowTopNav.arguments[i]].src = eval(ShowTopNav.arguments[i+1] + ".src");
		ShowTopSubNav(arguments[i+2]);
	}
}
//-----------------------------------------------------------------------------
function SetHideTimeTopNav()
{
	var i=0;
	arg1 = SetHideTimeTopNav.arguments[0];
	arg2 = SetHideTimeTopNav.arguments[1];
	arg3 = SetHideTimeTopNav.arguments[2];
	TopNavTimeID = setTimeout("HideTopNav()", 1000);
}
//-----------------------------------------------------------------------------
function HideTopNav()
{
	var i=0;
	if(document.images)
	{
		if(HideTopNav.arguments.length > 0)
		{
			arg1 = HideTopNav.arguments[0];
			arg2 = HideTopNav.arguments[1];
			arg3 = HideTopNav.arguments[2];
		}
		document[arg1].src = eval(arg2 + ".src");
		HideTopSubNav(arg3);
	}
}
//-----------------------------------------------------------------------------
function HideAllTopNav()
{
   		for(var i=1; i<6; i++)
   		{
   			if(i!=3)
			{
				document['image' + i].src = eval('image' + i + 'off' + '.src');
				HideTopSubNav('topsubnav_' + i);
			}
   		}
}


//-----------------------------------------------------------------------------
// TopSubNav
function ShowTopSubNav(whichsub)
{
	var TopSubNav
	if(document.getElementById(whichsub))
	{
		TopSubNav = document.getElementById(whichsub)
		TopSubNav.style.visibility= 'visible';
	}
}
function HideTopSubNav(whichsub)
{
	var TopSubNav;
	if(document.getElementById(whichsub))
	{
		TopSubNav = document.getElementById(whichsub)
		TopSubNav.style.visibility= 'hidden';
	}
}


//-----------------------------------------------------------------------------
// Leftnav Rollover
var whaton;
function SelectNav(elem)
{
	if (document.all)
	{
		elem.parentElement.style.backgroundColor='#660099';
		elem.style.color="#ffffff"
	}
}

//-----------------------------------------------------------------------------
function UnSelectNav(elem)
{
	if (document.all)
	{
		if(elem.id != whaton)
		{
			elem.parentElement.style.backgroundColor='#ffffff';
			elem.style.color="#000000"
		}
	}
}

//-----------------------------------------------------------------------------
// Site topnav rollover
if(document.images)
{
	// on images
	image1on = new Image();
	image1on.src = "../elementsRed/topnav_1_on.gif";
	image2on = new Image();
	image2on.src = "../elementsRed/topnav_2_on.gif";
	image3on = new Image();
	image3on.src = "../elementsRed/topnav_3_on.gif";
	image4on = new Image();
	image4on.src = "../elementsRed/topnav_4_on.gif";	
	image5on = new Image();
	image5on.src = "../elementsRed/topnav_5_on.gif";

	// off images
	image1off = new Image();
	image1off.src = "../elementsRed/topnav_1_off.gif";
	image2off = new Image();
	image2off.src = "../elementsRed/topnav_2_off.gif";
	image3off = new Image();
	image3off.src = "../elementsRed/topnav_3_off.gif";
	image4off = new Image();
	image4off.src = "../elementsRed/topnav_4_off.gif";
	image5off = new Image();
	image5off.src = "../elementsRed/topnav_5_off.gif";
}

function wStatus(str)
{ 
	window.status = str;
	return true;
}

function xStatus()
{
	window.status = '';
//	return true;
}