// JavaScript Document
// tas.js
// Author: Janice Carrell 
// Date Created:  01-28-2008
// Copyright 2008 Acellus Labs
//
// REVISION HISTORY
// 01-30-2008 - added ChaLimiter2 and CharLimiter3 functions (copied from Scripts/TL.js, not modified)


function openDemo()
{
	window.open('/Demo/Demo.php', 'AcellusWin');	
}

function openCurr()
{
	window.open('/Curriculum/Curriculum.php', 'AcellusWin');	
}

function openWho()
{
	window.open('/WhoIsUsing/WhoIsUsing.php', 'AcellusWin');	
}

function LinkOn(anch)
{
	document.getElementById(anch).style.color='#ffffff';
}

function LinkOff(anch)
{
	document.getElementById(anch).style.color='#000077';
}

function openPage(P)
{
	window.open(P, 'AcellusWin');
}


var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring;
var version = 0;


if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('firefox')) browser = "Firefox"
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
			version = detect.slice(-4);
//	version = ender.charAt(0);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}


function getDemo(here)
{
	newWin=window.open(here, 'DemoWin')
}


function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


function CharLimiter2(theField, FieldName, V1, N1, V2, N2)
{
	var myField = document.getElementById(theField).value
	var theV;
	var theN;
	for(x=1; x<3; x++)
	{
		theN = eval('N' + x);
		theV = eval('V' + x);
		checkID=myField.indexOf(theV)
		if(checkID > -1)
		{
			alert('You may not use the ' + theN + ' character in the ' + FieldName + '.');
			var newLssn =myField.slice(0,-1);
			document.getElementById(theField).value=newLssn;
		}
	}
}

function CharLimiter3(theField, FieldName, V1, N1, V2, N2, V3, N3)
{
	var myField = document.getElementById(theField).value;
	var theV;
	var theN;
	for(x=1; x<4; x++)
	{
		theN = eval('N' + x);
		theV = eval('V' + x);
		checkID=myField.indexOf(theV)
		if(checkID > -1)
		{
			alert('You may not use the ' + theN + ' character in the ' + FieldName + '.');
			var newLssn =myField.slice(0,-1);
			document.getElementById(theField).value=newLssn;
		}
	}



}


var T;
function showButtns(x)
{
//	alert('in showButtns');
	var myBtns = 'Sub' + x;
	var ParentBtn = 'MenuBtn' + x;
	x++;
	var NeighborBtn = 'MenuBtn' + x;
//	alert('x=' + x + ', ParentBtn=' + ParentBtn + ', NeighborBtn=' + NeighborBtn);
	var theLeft = findPosX(ParentBtn);
	var theRight = findPosX(NeighborBtn);
	var newWidth=(theRight-theLeft);
//	var theTop = findPosY(ParentBtn);
//	alert('theTop=' + theTop);
	theLeft = theLeft + 'px';
	if(browser=='Internet Explorer')
	{
		theTop = '76px';	
	}
	else
	{
		theTop=	'74px';
	}
//	theTop = eval(theTop-10) + 'px';
//	alert('theLeft= ' + theLeft + ', theRight = ' + theRight + ', newWidth=' + newWidth );
	document.getElementById(myBtns).style.left = theLeft;
	document.getElementById(myBtns).style.top = theTop;
	document.getElementById(myBtns).width = newWidth;
	document.getElementById(myBtns).style.visibility='visible';
	T=1;
}

function showSubButtns(x)
{
//	alert('in showButtns');
	var myBtns = 'Sub' + x;
	var theObj = document.getElementById(myBtns);
	var ParentBtn = 'MenuBtn' + x;
	x++;
//	alert('x=' + x + ', ParentBtn=' + ParentBtn);
	var theLeft = findPosX(ParentBtn);
	var ParentWidth = document.getElementById(ParentBtn).offsetParent.offsetWidth;
	var theLeft = theLeft + ParentWidth;
	var theTop = findPosY(ParentBtn);
	theLeft=theLeft+'px';
//	alert('theTop= ' + theTop);
	theTop = theTop + 'px';
	theObj.style.left = theLeft;
	theObj.style.top = theTop;
	theObj.width = ParentWidth;
	theObj.style.visibility='visible';
	T=1;
}


var hideTimer;

function hideButtns()
{	
	for(x=1;x<3;x++) //x<n, where n is 1 more than the number of sub-menus
	{
		var myMenu = 'Sub' + x;
		if(!T || T == 0)
		{
		}
		else if(T==1)
		{
		this.document.getElementById(myMenu).style.visibility='hidden';
		}
	}
}
	
function hideSubButtns()	
{
	for(x=11;x<16;x++)
	{
		var myMenu = 'Sub' + x;
		if(!T || T == 0)
		{
		}
		else if(T==1)
		{
		this.document.getElementById(myMenu).style.visibility='hidden';
		}
	}
	for(x=22;x<24;x++)
	{
		var myMenu = 'Sub' + x;
		if(!T || T == 0)
		{
		}
		else if(T==1)
		{
		this.document.getElementById(myMenu).style.visibility='hidden';
		}
	}
	
}


function getLeft(x)
{
//	alert('in getLeft');
	var myLeft;
	switch(x)
	{
		case 1:
			myLeft = findPosX('btnSMBC');
			break; 
		case 2:
			myLeft = findPosX('btnHTTP');
			break;
		case 3:
			myLeft = findPosX('btnUpdate');
			break; 
	}
	return myLeft;
}


function findPosX(obj)
{
	obj=eval('document.getElementById(obj)');
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
} 

function findPosY(obj)
{
	obj=eval('document.getElementById(obj)');
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
} 
function setCopy()
{
	document.write('<span style="color:gray; font-family:arial,helvetica,sans-serif; font-size:7pt;"> Copyright &copy; 2003-2009 Acellus Labs.  All Rights Reserved.</span>')
}


function setBanner()
{
	var LEdge = findPosX('WhiteTbl');
	var WT = document.getElementById('WhiteTbl');
//	alert('LEdge=' + LEdge);
	var BWid = WT.style.width;
	BWid = BWid.slice(0,-2);
	BWid = BWid * 1;
//	alert('BWid=' + BWid);
	var NEdge = Math.abs(LEdge + BWid) - 954;
	NEdge = NEdge + 'px'
//	alert('NEdge= ' + NEdge);
	document.getElementById('GetBanner').style.left = NEdge;
}
