var isNS4 = (navigator.appName=="Netscape")?1:0;
// Dynamic Digital Clock
function dummy24() {
    // A 'Do Nothing' subroutine.
};

var timeId24 = 0;
var NewMovementID=0;

function updateWatch24() { // update the watch
  var tid = new Date();    // get a time object

  var h = tid.getHours();
  hrs = (h>=10)?(""+h):("0"+h);  // hours

  m=tid.getMinutes();
  mns = (m>=10)?(":"+m):(":0"+m); // minutes

  s=tid.getSeconds();
  scs = (s>=10)?(":"+s):(":0"+s); // seconds

  document.getElementById("DIVDateTime").innerHTML = document.getElementById("lblDateTime").value + " - " + hrs+mns+scs;
          // write the new time in the textfield

  timeId24 = setTimeout('updateWatch24()',1000);
          // repeat every 500 milliseconds
}; // updateWatch24
//End of Dynamic Clock
function ShowAPTLogin(imgName)
{
	
	
	//alert(imgName);
	//document[imgName].src="images\\Login_APT_HD.jpg";
	//window.document[imgName].src="images\\Login_APT_HD.jpg";
	//window.document[imgName].src="images\\Login_Teacher_Dark.gif";
	//window.document['ImgLoginHD1'].src="images\\Login_Office_Light.gif";
	//alert(window.document[imgName].src);
	document.getElementById(imgName).background="images\\Login_Teacher_Dark.gif";
	document.getElementById('tblOffice').background="images\\Login_Office_Light.gif";
	document.getElementById("DIVAPTPANEL").style.display="";
	document.getElementById("DIVAPOPANEL").style.display="None";
	document.getElementById("DivPopupAPO").innerHTML="";
	if (document.getElementById("txtAPTUserName").value=="")
	{
		document.getElementById("txtAPTUserName").focus();
	}
	else
	{
		document.getElementById("txtAPTPassword").focus();
	}
	
	var lsMessages;
	var lsaMessages;
	
	//alert(document.getElementById('lblTeacherMsg').innerHTML);
	lsMessages=document.getElementById('lblTeacherMsg').innerHTML;
	
	//alert(lsMessages);
	//Mesages 
	lsaMessages=lsMessages.split(String.fromCharCode(251));
	
	//alert(lsaMessages.length);
	if(lsaMessages.length>0)
	{	
		//Mission Header
		if(lsaMessages[0]!="")
			document.getElementById("lblMissionHeader").innerHTML=lsaMessages[0];
		else
			document.getElementById("lblMissionHeader").innerHTML="";
		
		//Mission Test
		if(lsaMessages[1]!="")
			document.getElementById("lblMissionText").innerHTML=lsaMessages[1];
		else
			document.getElementById("lblMissionText").innerHTML="";
			
		//News & Events
		if(lsaMessages[2]!="")
			document.getElementById("lblNewsText").innerHTML=lsaMessages[2];
		else
			document.getElementById("lblNewsText").innerHTML="";
		
	}
	//document.getElementById('hdApplicationType').value="TEACHER";
	return false;
}
function ShowAPOLogin(imgName)
{
	//document[imgName].src="images\\Login_APO_HD.jpg";
	//window.document[imgName].src="images\\Login_APO_HD.jpg";
	//window.document[imgName].src="images\\Login_Office_Dark.gif";
	//window.document['tblTeacher'].src="images\\Login_Teacher_Light.gif";
	//alert(imgName);
	document.getElementById(imgName).background="images\\Login_Office_Dark.gif";
	document.getElementById('tblTeacher').background="images\\Login_Teacher_Light.gif";
	document.getElementById("DIVAPTPANEL").style.display="None";
	document.getElementById("DIVAPOPANEL").style.display="";
	document.getElementById("DivPopupAPT").innerHTML="";	
	
	//alert(document.getElementById("txtAPOUserName").value);
	//ADP4650 on 1-Dec-2008,
	if(document.getElementById("txtAPOUserName").value=="")
		document.getElementById("txtAPOUserName").focus();//document.getElementById("txtAPOPassword").focus();
	else
		document.getElementById("txtAPOPassword").focus();  
		
		
	
	//Msg.
	var lsMessages;
	var lsaMessages;
	
	//alert(document.getElementById('lblOfficeMsg').innerHTML);
	lsMessages=document.getElementById('lblOfficeMsg').innerHTML;
	
	//alert(lsMessages);
	//Mesages 
	lsaMessages=lsMessages.split(String.fromCharCode(251));
	
	//alert(lsaMessages.length);
	if(lsaMessages.length>0)
	{	
		//Mission Header
		if(lsaMessages[0]!="")
			document.getElementById("lblMissionHeader").innerHTML=lsaMessages[0];
		else
			document.getElementById("lblMissionHeader").innerHTML="";
		
		//Mission Test
		if(lsaMessages[1]!="")
			document.getElementById("lblMissionText").innerHTML=lsaMessages[1];
		else
			document.getElementById("lblMissionText").innerHTML="";
			
		//News & Events
		if(lsaMessages[2]!="")
			document.getElementById("lblNewsText").innerHTML=lsaMessages[2];
		else
			document.getElementById("lblNewsText").innerHTML="";
		
	}
	
	//document.getElementById("lblMissionHeader").innerHTML=document.getElementById("hdOfficeMissionHeader").value.replace(/String.fromCharCode(251)/g,'<br>');
	//document.getElementById("lblMissionText").innerHTML=document.getElementById("hdOfficeMission").value.replace(/String.fromCharCode(251)/g,'<br>');
	///document.getElementById("lblNewsText").innerHTML=document.getElementById("hdOfficeNewsEvents").value.replace(/String.fromCharCode(251)/g,'<br>');
	
	//document.getElementById('hdApplicationType').value="OFFICE";
	return false;	
}

function SetFocusTeacherLogin()
{
	//window.document[imgName].src="images\\Login_Teacher_Dark.gif";
	//window.document['ImgLoginHD1'].src="images\\Login_Office_Light.gif";
	//document.getElementById("DIVAPTPANEL").style.display="";
	//document.getElementById("DIVAPOPANEL").style.display="None";
	//document.getElementById("DivPopupAPO").innerHTML="";
	if (document.getElementById("txtAPTUserName").value=="")
	{
		document.getElementById("txtAPTUserName").focus();
	}
	else
	{
		document.getElementById("txtAPTPassword").focus();
	}
	return false;
}

function SetFocusOfficeLogin()
{
	//window.document[imgName].src="images\\Login_Teacher_Dark.gif";
	//window.document['ImgLoginHD1'].src="images\\Login_Office_Light.gif";
	//document.getElementById("DIVAPTPANEL").style.display="";
	//document.getElementById("DIVAPOPANEL").style.display="None";
	//document.getElementById("DivPopupAPO").innerHTML="";
	if (document.getElementById("txtAPOUserName").value=="")
	{
		document.getElementById("txtAPOUserName").focus();
	}
	else
	{
		document.getElementById("txtAPOPassword").focus();
		return true;
	}
	return false;
}


//Dynamic Movement of News DIV
IE4 = navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4;        
NS4 = navigator.appName.substring(0,8) == "Netscape" && parseInt(navigator.appVersion) >= 4;
        
// checkBrowser() -- Checks whether the browser is new enough for some DynamicMovement ...

function checkBrowser()
{
	if(IE4 || NS4)
	{
		return true;
	}
    return false;
}
// setPos() -- sets the end position accurately when doDynamicMovement has done its job
function setPos(x, y, ref)
{
        ref.left = x;
        ref.top = y;
}

// doDynamicMovement() -- does the Dynamic Movement
function doDynamicMovement(curX, curY, eX, eY, sp, xS, yS, ref, speed, hS)
{
        if(Math.floor(hS - 1) != 0)
        {
                hS--;
                curX += xS * speed;
                curY += yS * speed; 
                ref.left = Math.round(curX);
                ref.top = Math.round(curY);
                setTimeout("doDynamicMovement(" + curX + ", " + curY + ", " + eX + ", " + eY + ", " + sp + ", " + xS + ", " + yS + ", ref, " + speed + ", " + hS + ")", sp);
        }
        else
        {
                setPos(eX, eY, ref);    
        }
}

// startMovement() -- starts the movement

function startMovement()
{
	if(checkBrowser())
	{
		if(IE4)
		{
			ref = document.all(this.ref).style;
        }
        else
        {
			ref = document[this.ref];
		}
        doDynamicMovement(this.sX, this.sY, this.eX, this.eY, this.de, this.xS, this.yS, ref, this.sp, this.howManySteps);
	}
}

// movableObj() -- Creates a new movable object

function movableObj(startX, startY, endX, endY, delay, speed, refId)
{
	this.sX = startX;
	this.sY = startY;
	this.eX = endX;
    this.eY = endY;
    this.de = delay;
    this.sp = speed;
    this.ref = refId;
    
    xL = endX - startX;
    yL = endY - startY;
    //alert(xL);
    
    with (Math)
    {
        if(abs(xL) > abs(yL))
        {
                this.xS = (xL > 0)?1:-1;
                this.yS = (yL > 0)?abs(yL / xL):-abs(yL / xL);
                this.howManySteps = abs(xL / speed);
        }
        else if(abs(yL) > abs(xL))
        {
                this.yS = (yL > 0)?1:-1;
                this.xS = (xL > 0)?abs(xL / yL):-abs(xL / yL);
                this.howManySteps = abs(yL / speed);
        }
        else
        {
                this.yS = (yL > 0)?1:-1;
                this.xS = (xL > 0)?1:-1;
                this.howManySteps = abs(xL / speed);
        }
    }
    this.startMovement = startMovement;
}

function LoadApplication(e,APP)
{
	var keynum;
	if(window.event) // IE
	{
		keynum = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which
	}
	if (keynum==13)
	{
		if(APP=="APT") 
		{
			document.getElementById('imgbtAPTLogin').click();
		}
		if(APP=="APO")
		{
			document.getElementById('imgbtAPOLogin').click();
		}
		
	}
}


function NewUserActivation()
{
	document.location="UserActivation.aspx";
}

function OpenAPWebOfficeWindow(psTheme,Time)
{

	var lsPage="";
	if(psTheme!="7")
	{
		lsPage="Forms\\frmAPOMain.aspx";
	}
	else
	{
		//New Theme Starts from  7
		lsPage="Forms\\APWebMain.aspx"
	}	
	if (!isNS4)
	{
		//In IE open in Another Window
		//window.open(lsPage, 'APWebOfficeWindow'+Time,'width=1012, height=640, left=1, top=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=no');	
		//window.opener='x';
		//window.close();
		window.location.href
	}
}

function SetBrowser()
{
	document.getElementById("hdNS4Browser").value=isNS4;
	//alert(document.getElementById("hdNS4Browser").value);
}