// ©Copyright IBM Corp. 1997-2003. ALL RIGHTS RESERVED
// Rational Rapid Developer 5.01-0061
//--------------------------------------------------------
//------- Global Variables
//--------------------------------------------------------



var whofirst=0; //1-mouseover first; 2-click first
var initialize = 0 ;
var currselection = "" ;
var currselectionNImage = "" ;
var buddycurrentselection = "" ;
var MouseOverNImage ="" ;

//////// -- code for regular button
var currselectionButton = "" ;
var currselectionButtonNImage = "" ;
var MouseOverButtonNImage ="" ;
var clicked= false;
var rrdMenus = new Array();
var menusLoaded = false;

function rrdWriteMenu()
 {
 if(!menusLoaded && rrdMenus.length>0 )
  {
    rrdMenus[0].writeMenus();
    menusLoaded = true;
    }
 } 
 function addRRDMenue(menu)
 {
  rrdMenus[rrdMenus.length] = menu;
 
 }


// 
function onButtonMouseDown(control, img)
{  
    // release the image if it is already selected
    if (currselectionButton != ""){
		currselectionButton.src = currselectionButtonNImage;
		currselectionButton = ""; 
		currselectionButtonNImage = "";
    }
   // capture the normal image
   if (MouseOverButtonNImage != "")
     currselectionButtonNImage =  MouseOverButtonNImage ;
   else
	 currselectionButtonNImage =  control.src ;
	 
    control.src = img;
    
    clicked = true;
   
}

function onButtonMouseUp(control,img)
{
   // reset on mouse up
   currselectionButtonNImage = "";
   control.src = img ;
   
   clicked = false;
}

function onButtonMouseOver(control,img)
{
 
   if (currselectionButton != control) {
	 MouseOverButtonNImage = control.src;
     control.src = img ;
   }
}

function onButtonMouseOut(control,img)
{
   if (currselectionButton != control)
    control.src = img ;
   MouseOverButtonNImage = "";
}

function onButtonMouseSelected(control,img)
{
   // selection is made
   if (clicked){
	currselectionButton = control ;
	control.src = img ;
	clicked = false;
   }
} 



/// -- end for button
function flipImage(control,img)
{
	if(control == currselection){
		return ;
	}
	if(whofirst==0) {MouseOverNImage=control.src;}
	whofirst=2;
	control.src = img ;
}


function OnMenuAUp(control,cimg,buddy,bimg)
{
	if(initialize > 0 && currselection != "")
		{
		currselection.src = currselectionNImage ;
		}
	currselection = control ;
	initialize = 1 ;
	whofirst=0;
	currselectionNImage = MouseOverNImage ;
	control.src = cimg ;
	buddy.src = bimg ;
	buddycurrentselection = bimg ;
}

function OnMenuAOver(control,cimg,buddy,bimg)
{
	if(control == currselection)
		{
		return ;
		}
	if(whofirst==0) {MouseOverNImage = control.src ;}
	whofirst=1;
	control.src = cimg ;
	buddycurrentselection = buddy.src ;
	buddy.src = bimg ;
}

function OnMenuAOut(control,cimg,buddy)
{
	if(control == currselection)
		{
		return ;
		}
	whofirst=0;
	control.src = cimg ;
	buddy.src = buddycurrentselection ;
}

function OnMenuBUp(control,img)
{
	if(initialize >0 && currselection != "")
		{
		currselection.src = currselectionNImage ;
		}
	currselection = control ;
	initialize = 1 ;
	whofirst=0;
	currselectionNImage = MouseOverNImage ;
	control.src = img ;
}

function OnMenuBOver(control,img)
{
	if(control == currselection)
		{
		return ;
		}
	if(whofirst==0) {MouseOverNImage=control.src;}
	whofirst=1;
	control.src = img ;
}

function OnMenuBOut(control,img)
{
	if(control == currselection)
		{
		return ;
		}
	whofirst=0;
	control.src = img ;
}



function domenustyle(object)
	{
	if (currselection != null)
	  currselection.className= 'side';
	currselection=object ;
	object.className= 'sidesel';
	}

function domouseon(object)
	{
	if (object == currselection)
	  object.className= 'sidesel';
	else
	  object.className= 'sidehi';
	}

function domouseoff(object)
	{
	if (object == currselection)
	  object.className= 'sidesel';
	else
	  object.className= 'side';
	}

function domouseon2(img,ref)
        {
		document.images[img].src = ref;
        }

function domouseoff2(img,ref)
        {
		document.images[img].src = ref;
        }


function SubmitButton(form,Element)
{
	var Errors = "" ;
	var Result = CheckForRequiredFields(form) ;	
	if (  Result == true)
	{
	form.SubmitBy.value = form.name ;
	form.SubmitControl.value = Element.name ;
	form.submit() ;
	}

}

function SubmitButtonPortal(form,Element)
{
	var Errors = "" ;
	var uniqueId = form.uniqueID.value ;
	var Result = eval ( "CheckForRequiredFields" + uniqueId +  "(form)" ) ;
	if (  Result == true){
		form.SubmitControl.value = Element.name ;
		form.submit() ;
	}

}

var defaultSubmitButton = null;
var defaultForm = null;
var isDefaultSet = false;
var isPortalForm = false;		
function setDefaultSubmitButton(form,submitButton,isPortal) {
	if (isDefaultSet) return ; 

    if (isPortal)
	{
	  isPortalForm = true;
	}
	defaultForm = form;
	defaultSubmitButton = submitButton;
	isDefaultSet = true ;

	var nav = window.Event ? true : false;
	if (nav) {
	   window.captureEvents(Event.KEYDOWN);
	   window.onkeydown = NetscapeEventHandler_KeyDown;
	} else {
	   document.onkeydown = MicrosoftEventHandler_KeyDown;
	}
}
		
function NetscapeEventHandler_KeyDown(e) {
  if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') {
    if (isPortalForm)
		SubmitButtonPortal(defaultForm,defaultSubmitButton);
	else
		SubmitButton(defaultForm,defaultSubmitButton);
	return false;
  }
  return true;
}

function MicrosoftEventHandler_KeyDown() {
  if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit')
  {
    if (isPortalForm)
		SubmitButtonPortal(defaultForm,defaultSubmitButton);
	else
		SubmitButton(defaultForm,defaultSubmitButton);
    
    return false;
  }
  return true;
}


function OpenNewWin(URL,Name,features) { 
  window.open(URL,Name,features);
}





function ChangeCase(CharCase,Control)
{
	var ControlValue="";
	ControlValue=Control.value+"";
	if(CharCase=='lower')
		ControlValue=ControlValue.toLowerCase( );
	else if(CharCase=='upper')
		ControlValue=ControlValue.toUpperCase( );
	Control.value=ControlValue;

}
 
 
   function sendTimeRequestTimeOut(value) { 
	var url="/tmalive/MemberTimeTrack_CDA?sessionvalue="+value;
	var xmlHttpObject=getTimeXMLHTTPObject(); 
	if(xmlHttpObject)  	{
	xmlHttpObject.open("GET",url,true);	
		xmlHttpObject.onreadystatechange=function()
		{
			if(xmlHttpObject.readyState==4 && xmlHttpObject.status == 200) 
			{
				var response = xmlHttpObject.responseText;
				if(response!='')
				{
			//	alert(response);
			 	window.top.parent.frmTop.location=window.top.parent.frmTop.location;
	            location.href='/tmalive/FrmTopNew';
	            location.reload(true);
	         	}
			}
		}
	
	xmlHttpObject.send(null);  
	}
	 
	}
	
	function getTimeXMLHTTPObject(
	){  	var A=null;  	try  	{    
	A=new ActiveXObject("Msxml2.XMLHTTP") 
	}  
	catch(e)  
	{    
	try    
	{      
	A=new ActiveXObject("Microsoft.XMLHTTP")  
	}   
	catch(oc) 
	{     		
	A=null   
	}  	
	} 
	
	if(!A && typeof XMLHttpRequest != "undefined") {    
		A=new XMLHttpRequest()  
	}
	return A
	}



 



var xScroll, yScroll, timerPoll, timerRedirect, timerClock;

function initRedirect(){
  if (typeof document.body.scrollTop != "undefined"){ //IE,NS7,Moz
    xScroll = document.body.scrollLeft;
    yScroll = document.body.scrollTop;
    clearInterval(timerPoll); //stop polling scroll move
    clearInterval(timerRedirect); //stop timed redirect
    timerPoll = setInterval("pollActivity()",1); //poll scrolling
  timerRedirect = setInterval("sendTimeRequestTimeOut('C');",1800000);  //set timed redirect
    clearInterval(timerClock);
   // document.getElementById("clock").innerHTML="0";
   // timerClock=setInterval("document.getElementById('clock').innerHTML=parseInt(document.getElementById('clock').innerHTML,10)+1",1000);
  }
  else if (typeof window.pageYOffset != "undefined"){ //other browsers that support pageYOffset/pageXOffset instead
    xScroll = window.pageXOffset;
    yScroll = window.pageYOffset;
    clearInterval(timerPoll); //stop polling scroll move
    clearInterval(timerRedirect); //stop timed redirect
    timerPoll = setInterval("pollActivity()",1); //poll scrolling
  timerRedirect = setInterval("sendTimeRequestTimeOut('C');",1800000);  //set timed redirect
    clearInterval(timerClock);
//document.getElementById("clock").innerHTML="0";
   // timerClock=setInterval("document.getElementById('clock').innerHTML=parseInt(document.getElementById('clock').innerHTML,10)+1",1000);
  }
}

function pollActivity(){
  if ((typeof document.body.scrollTop != "undefined" && (xScroll!=document.body.scrollLeft || yScroll!=document.body.scrollTop)) //IE/NS7/Moz
   ||
   (typeof window.pageYOffset != "undefined" && (xScroll!=window.pageXOffset || yScroll!=window.pageYOffset))) { //other browsers
      initRedirect(); 
  }
}

 
document.onmousemove=initRedirect;
document.onclick=initRedirect;
document.onkeydown=initRedirect;
window.onload=initRedirect;
window.onresize=initRedirect;

 









    
   
          		
          		


