//HighLight Tabs - Menu functions
function reportmenu()
{
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_on_separator.gif';
    document.getElementById('img5').src='images/menu0_on_off_separator.gif';
    document.getElementById('img7').src='images/menu0_off_end.gif';
    
    window.img2.background='images/menu0_off_bg.gif';
    window.img4.background='images/menu0_on_bg.gif';
    window.img6.background='images/menu0_off_bg.gif';
    
    document.getElementById('lnk1').className = "menuoff";
    document.getElementById('lnk2').className = "menuon";
    document.getElementById('lnk3').className = "menuoff";
}

function utilitymenu()
{
   
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_off_separator.gif';
    document.getElementById('img5').src='images/menu0_off_on_separator.gif';
    document.getElementById('img7').src='images/menu0_on_end.gif';
    
    window.img2.background='images/menu0_off_bg.gif';
    window.img4.background='images/menu0_off_bg.gif';
    window.img6.background='images/menu0_on_bg.gif'
    
    document.getElementById('lnk1').className = "menuoff";
    document.getElementById('lnk2').className = "menuoff";
    document.getElementById('lnk3').className = "menuon";
}

function cpahomemenu()
{
}

function cpataskmenu(id)
{
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_on_separator.gif';
    document.getElementById('img5').src='images/menu0_on_off_separator.gif';
    document.getElementById('img7').src='images/menu0_off_off_separator.gif';
    document.getElementById('img9').src='images/menu0_off_off_separator.gif';
    document.getElementById('img11').src='images/menu0_off_end.gif';
    
    document.getElementById('img2').background='images/menu0_off_bg.gif';
    window.ctl00_img4.background='images/menu0_on_bg.gif';
    window.ctl00_img6.background='images/menu0_off_bg.gif';
    window.ctl00_img8.background='images/menu0_off_bg.gif';
    window.ctl00_img10.background='images/menu0_off_bg.gif';
    
    document.getElementById('ctl00_lnk1').className = "menuoff";
    document.getElementById('ctl00_lnk2').className = "menuon";
    document.getElementById('ctl00_lnk3').className = "menuoff";
    document.getElementById('ctl00_lnk4').className = "menuoff";
    document.getElementById('ctl00_lnk5').className = "menuoff";
    
}

function cpasearchsmenu()
{
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_off_separator.gif';
    document.getElementById('img5').src='images/menu0_off_on_separator.gif';
    document.getElementById('img7').src='images/menu0_on_off_separator.gif';
    document.getElementById('img9').src='images/menu0_off_off_separator.gif';
    document.getElementById('img11').src='images/menu0_off_end.gif';
    
    window.img2.background='images/menu0_off_bg.gif';
    window.ctl00_img4.background='images/menu0_off_bg.gif';
    window.ctl00_img6.background='images/menu0_on_bg.gif';
    window.ctl00_img8.background='images/menu0_off_bg.gif';
    window.ctl00_img10.background='images/menu0_off_bg.gif';
    
    document.getElementById('ctl00_lnk1').className = "menuoff";
    document.getElementById('ctl00_lnk2').className = "menuoff";
    document.getElementById('ctl00_lnk3').className = "menuon";
    document.getElementById('ctl00_lnk4').className = "menuoff";
    document.getElementById('ctl00_lnk5').className = "menuoff";
}

function cpareportmenu()
{
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_off_separator.gif';
    document.getElementById('img5').src='images/menu0_off_off_separator.gif';
    document.getElementById('img7').src='images/menu0_off_on_separator.gif';
    document.getElementById('img9').src='images/menu0_on_off_separator.gif';
    document.getElementById('img11').src='images/menu0_off_end.gif';
    if(document.getElementById('ctl00_img10').style.display == "none")
    {
        document.getElementById('img11').src='images/menu0_on_end.gif';
    }
    
    window.img2.background='images/menu0_off_bg.gif';
    window.ctl00_img4.background='images/menu0_off_bg.gif';
    window.ctl00_img6.background='images/menu0_off_bg.gif';
    window.ctl00_img8.background='images/menu0_on_bg.gif';
    window.ctl00_img10.background='images/menu0_off_bg.gif';
    
    document.getElementById('ctl00_lnk1').className = "menuoff";
    document.getElementById('ctl00_lnk2').className = "menuoff";
    document.getElementById('ctl00_lnk3').className = "menuoff";
    document.getElementById('ctl00_lnk4').className = "menuon";
    document.getElementById('ctl00_lnk5').className = "menuoff";
}

function cpautilitymenu()
{
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_off_separator.gif';
    document.getElementById('img5').src='images/menu0_off_off_separator.gif';
    document.getElementById('img7').src='images/menu0_off_off_separator.gif';
    document.getElementById('img9').src='images/menu0_off_on_separator.gif';
    document.getElementById('img11').src='images/menu0_on_end.gif';
    
    window.img2.background='images/menu0_off_bg.gif';
    window.ctl00_img4.background='images/menu0_off_bg.gif';
    window.ctl00_img6.background='images/menu0_off_bg.gif';
    window.ctl00_img8.background='images/menu0_off_bg.gif';
    window.ctl00_img10.background='images/menu0_on_bg.gif';
    
    document.getElementById('ctl00_lnk1').className = "menuoff";
    document.getElementById('ctl00_lnk2').className = "menuoff";
    document.getElementById('ctl00_lnk3').className = "menuoff";
    document.getElementById('ctl00_lnk4').className = "menuoff";
    document.getElementById('ctl00_lnk5').className = "menuon";
}

   function cpautilitychangepwd()
   { 
    document.getElementById('ctl00_lnk1').setAttribute('disabled',true);  
    document.getElementById('ctl00_lnk1').removeAttribute('href',false);
    document.getElementById('ctl00_lnk2').setAttribute('disabled',true);  
    document.getElementById('ctl00_lnk2').removeAttribute('href',false);
    document.getElementById('ctl00_lnk3').setAttribute('disabled',true);  
    document.getElementById('ctl00_lnk3').removeAttribute('href',false);
    document.getElementById('ctl00_lnk4').setAttribute('disabled',true);  
    document.getElementById('ctl00_lnk4').removeAttribute('href',false);
    document.getElementById('ctl00_lnk5').setAttribute('disabled',true);  
    document.getElementById('ctl00_lnk5').removeAttribute('href',false);
   }
   
function opnpntsMenuQes()
{
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_on_separator.gif';
    document.getElementById('img5').src='images/menu0_on_off_separator.gif';
    document.getElementById('img7').src='images/menu0_off_off_separator.gif';
    document.getElementById('img9').src='images/menu0_off_off_separator.gif';
    document.getElementById('img11').src='images/menu0_off_end.gif';
    window.img2.background='images/menu0_off_bg.gif';
    window.img4.background='images/menu0_on_bg.gif';
    window.img6.background='images/menu0_off_bg.gif';
    window.img8.background='images/menu0_off_bg.gif';
    window.ctl00_img10.background='images/menu0_off_bg.gif';
    
    document.getElementById('lnk1').className = "menuoff";
    document.getElementById('lnk2').className = "menuon";
    document.getElementById('lnk3').className = "menuoff";
    document.getElementById('lnk4').className = "menuoff";
    document.getElementById('lnk5').className = "menuoff";
    
}

function opnpntsMenuRvPnts()
{
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_off_separator.gif';
    document.getElementById('img5').src='images/menu0_off_on_separator.gif';
    document.getElementById('img7').src='images/menu0_on_off_separator.gif';
    document.getElementById('img9').src='images/menu0_off_off_separator.gif';
    document.getElementById('img11').src='images/menu0_off_end.gif';
    window.img2.background='images/menu0_off_bg.gif';
    window.img4.background='images/menu0_off_bg.gif';
    window.img6.background='images/menu0_on_bg.gif';
    window.img8.background='images/menu0_off_bg.gif';
    window.ctl00_img10.background='images/menu0_off_bg.gif';
    
    document.getElementById('lnk1').className = "menuoff";
    document.getElementById('lnk2').className = "menuoff";
    document.getElementById('lnk3').className = "menuon";
    document.getElementById('lnk4').className = "menuoff";
    document.getElementById('lnk5').className = "menuoff";
    
}

function opnpntsMenuAll()
{
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_off_separator.gif';
    document.getElementById('img5').src='images/menu0_off_off_separator.gif';
    document.getElementById('img7').src='images/menu0_off_on_separator.gif';
    document.getElementById('img9').src='images/menu0_on_off_separator.gif';
    document.getElementById('img11').src='images/menu0_off_end.gif';
    if(document.getElementById('ctl00_img10').style.display == "none")
    {
        document.getElementById('img11').src='images/menu0_on_end.gif';
    }
    window.img2.background='images/menu0_off_bg.gif';
    window.img4.background='images/menu0_off_bg.gif';
    window.img6.background='images/menu0_off_bg.gif';
    window.img8.background='images/menu0_on_bg.gif';
    window.ctl00_img10.background='images/menu0_off_bg.gif';
    
    document.getElementById('lnk1').className = "menuoff";
    document.getElementById('lnk2').className = "menuoff";
    document.getElementById('lnk3').className = "menuoff";
    document.getElementById('lnk4').className = "menuon";
    document.getElementById('lnk5').className = "menuoff";
    
}

function opnpntsMenuIntPnts()
{
    document.getElementById('img1').src='images/start_off.gif';
    document.getElementById('img3').src='images/menu0_off_off_separator.gif';
    document.getElementById('img5').src='images/menu0_off_off_separator.gif';
    document.getElementById('img7').src='images/menu0_off_off_separator.gif';
    document.getElementById('img9').src='images/menu0_off_on_separator.gif';
    document.getElementById('img11').src='images/menu0_on_end.gif';
    window.img2.background='images/menu0_off_bg.gif';
    window.img4.background='images/menu0_off_bg.gif';
    window.img6.background='images/menu0_off_bg.gif';
    window.img8.background='images/menu0_off_bg.gif';
    window.ctl00_img10.background='images/menu0_on_bg.gif';
    
    document.getElementById('lnk1').className = "menuoff";
    document.getElementById('lnk2').className = "menuoff";
    document.getElementById('lnk3').className = "menuoff";
    document.getElementById('lnk4').className = "menuoff";
    document.getElementById('lnk5').className = "menuon";
    
}

//------------ End ------------------



// JScript File
function showdiv(type)
{
    if(type==0)
    {
        window.locdiv.style.visibility='visible';
        window.detdiv.style.visibility='hidden';
    }
    else if(type==1)
    {
        window.locdiv.style.visibility='hidden';
        window.detdiv.style.visibility='visible';
    }
}

function openLocwindow(url)
{
    window.open(url, 'location', 'height=500,width=600');
    return false;
}

function openTaskTierwindow(url)
{
    window.open(url, 'location', 'height=200,width=600');
    return false;
}

function openCalwindow(url)
{
    window.open(url, 'location', 'height=200,width=300,Top=10,left=100');
    return false;
}

function changeColor()
{
    window.event.srcElement.style.color = '#FFFFEC';
}

function resetColor()
{
    window.event.srcElement.style.color = '#330066';
}

function menuColor()
{
    window.event.srcElement.style.color = '#FF9933';
}



var pcnt=0;
var page=0;

//set the value for Allow Updates from Creditors that charge fee
function setValue(element)
{
  if (element.checked==true)
    element.value="y";
  else if(element.checked==false)
    element.value="n";
}   

//setStle to the rows on mouseover
function setStyle(row,style)
{
	for(var i=0;i<row.cells.length;i++)
	{
		row.cells(i).className=style;
	}
}

//Highlight the SelectedRow
function highlightRow(row)
{
row=event.srcElement;
while(row.tagName!='TR')
	row=row.parentElement;
if(row.cells(0).className!="selectedLineItem")
 {		
  	setStyle(row,"highlightLineItem");    
 }
 	row.style.cursor="hand"	
}

//set the Selected Row
function setSelectedRow(row)
{
	var tabObject=row;
	if(row!=null)
	{
		while(tabObject.tagName!='TABLE')
			tabObject=tabObject.parentElement;
		tabObject.selectedRow=row;
	}
}

//Normalise all the rows
function normaliseRow(row)
{
row=event.srcElement; 
while(row.tagName!='TR')
	row=row.parentElement;
if(row.cells(0).className!='selectedLineItem')
	   normaliseSelectedRow(row);
}

//Normalise the selected row
function normaliseSelectedRow(row)
{
        setStyle(row,'searchLineItem');

}

function selectRow(row, type)
{
	
	var element=row;
	while(element.tagName!='TABLE')
		element=element.parentElement;
	if(element.selectedRow!=null)
	{
		normaliseSelectedRow(element.selectedRow);
	}
	while(row.tagName!='TR')
			row=row.parentElement;
	setStyle(row,'selectedLineItem');

    if(type=='staff')
    {
        document.getElementById('SelectedName').value = row.cells(1).innerText;
	    document.getElementById('SelectedID').value = row.cells(3).innerText;
	}
	else if(type=="group")
	{
	    document.getElementById('SelectedName').value = row.cells(0).innerText;
	    document.getElementById('SelectedID').value = row.cells(1).innerText;
	}

	element.selectedRow=row;
}


function sameaddressclick()
{
    if(document.getElementById("sameaddr").checked == true)
    {
        document.getElementById("Address12").value=document.getElementById("Address1").value;
        document.getElementById("Address22").value=document.getElementById("Address2").value;
        document.getElementById("City2").value=document.getElementById("City").value;
        document.getElementById("State2").value=document.getElementById("State").value;
        document.getElementById("Zip2").value=document.getElementById("Zip").value;
    }
    else
    {
        document.getElementById("Address12").value="";
        document.getElementById("Address22").value="";
        document.getElementById("City2").value="";
        document.getElementById("State2").value="";
        document.getElementById("Zip2").value="";
    }
    
}

var secs=0;
var popup=0;
var timerID = null;
var delay = 1000;
var seruri = null;

function InitializeTimer(ltime,popupDelay,suri)
{        
    secs = ltime * 60;
    self.status = ltime + ' minutes to automatic logout. Thank you for using XPITAX!';
    popup = popupDelay * 60;
    
    seruri=suri;
    StartTheTimer(seruri);
}

function resetTime(ltime){
    secs = ltime * 60;
}

function StartTheTimer(seruri)
{  
    if (secs==popup)
    {        
        document.getElementById("transparentDiv").style.display="block";
        secs = secs - 1;
        timerRunning = true;
        self.setTimeout("StartTheTimer(seruri)", delay);
    } 
    else if (secs<1)
    {          
        window.location.href="_Login.aspx?message='Session Expired'&ruri="+seruri;
    }
    else
    {
        if(secs % 60 == 0)
        {
            self.status = (secs/60) + ' minutes to automatic logout. Thank you for using XCM!';            
        }
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer(seruri)", delay);
    }
}

var secsp=0;
var timerIDP = null;
var delayP = 1000;

function InitializeTimerPopup(ltime)
{    
    secsp = (ltime-1) * 60;
    self.status = ltime + ' minutes to automatic logout. Thank you for using XPITAX!';
    StartTheTimerPopup();
}

function StartTheTimerPopup()
{
    if (secsp<1)
    {        
        self.close();
    } 
    else
    {
        if(secsp % 60 == 0)
            self.status = (secsp/60) + ' minutes to automatic logout. Thank you for using XCM!';
        secsp = secsp - 1;
        timerIDp = self.setTimeout("StartTheTimerPopup()", delayP);
    }
}

function button_over(eButton)
{
	eButton.style.backgroundColor = "#cd853f";
	eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
}

function button_out(eButton)
{
	eButton.style.backgroundColor = "#deb887";
	eButton.style.borderColor = "#deb887";
}

function button_down(eButton)
{
	eButton.style.backgroundColor = "#8494B5";
	eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
}

function button_up(eButton)
{
    eButton.style.backgroundColor = "#cd853f";
    eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
    eButton = null; 
}

function hideTransparent()
{
    document.getElementById("transparentDiv").style.display="none";
}

var isIE = document.all?true:false;
var isNS = document.layers?true:false;
function onlyDigits(e) 
{
    var _ret = true;
    if (isIE) {
    if (window.event.keyCode < 47 || window.event.keyCode > 57) {
    window.event.keyCode = 0;
    _ret = false;
    }
    }
    if (isNS) {
    if (e.which < 47 || e.which > 57) {
    e.which = 0;
    _ret = false;
    }
    }
    return (_ret); 
}
//var isIE = document.all?true:false;
//var isNS = document.layers?true:false;
function onlyspecar(e) 
{
    var _ret = true;
    if (isIE) {
    if (window.event.keyCode == 60 || window.event.keyCode == 62) {
    window.event.keyCode = 0;
    _ret = false;
    }
    }
    if (isNS) {
    if (e.which == 60 || e.which == 62) {
    e.which = 0;
    _ret = false;
    }
    }
    return (_ret); 
}
function onlyFloat(e)
{
	var floatPoint = false;
    var _ret = true;
	for(var i=0; i<=e.value.length; i++)
	{
		var c = e.value.charAt(i);
		if(c == ".")
		{
			floatPoint = true;
			break;
		}
	}

    if (isIE) 
	{
		if(window.event.keyCode == 46)
		{
			if(floatPoint == false)
			{
				_ret = true;
			}
			else
			{
				window.event.keyCode = 0;
				_ret = false
			}
		}
		else
		{
			if (window.event.keyCode < 47 || window.event.keyCode > 57) 
			{
				window.event.keyCode = 0;
				_ret = false;
			}
		}
    }

    if (isNS) 
	{
		if(e.which == 46)
		{
			if(floatPoint == false)
			{
				_ret = true;
			}
			else
			{
				window.event.keyCode = 0;
				_ret = false
			}
		}
		else
		{
			if (e.which < 47 || e.which > 57) 
			{
				e.which = 0;
				_ret = false;
			}
		}
    }
    return (_ret); 
}

function formatUSPhone(ele)
{   
	p = new String(ele.value);

	if(p.length==3)
	{
		if(p.charAt(0) != '(')
		p = "(" + p + ")";
		ele.value = p;
	}
	if(p.length == 8)
	{
		if(p.charAt(8) != '-')
		p = p + "-";
		ele.value = p;
	}
}

function convertPhone(ele)
{
	p1 = new String(ele.value);
	if(p1.length >= 10)
	{
		if(p1.charAt(0) != '(')
		{
			p1 = "(" + p1;
			ele.value = p1;
		}
		if(p1.charAt(4) != ')')
		{
			p1 = p1.substr(0,4)+')'+p1.substr(4, 7);
			ele.value = p1;
		}
		if(p1.charAt(8) != '-')
		{
			p1 = p1.substr(0,8)+'-'+p1.substr(8, 4);
			ele.value = p1;
		}
	}	
}

function NoSpecialChar()
{ 
  /*  if((event.keyCode>31 && event.keyCode<48) || (event.keyCode>57 && event.keyCode<65) || (event.keyCode>90 && event.keyCode<97) || (event.keyCode>122))
    { 
        event.keyCode=0;
        return false;
    } */
    
    if((event.keyCode== 32))
    { 
        event.keyCode=0;
        return false;
    }
} 

function onlyclintspecar(e) 
{
    var _ret = true;
    if (isIE) {
    if (window.event.keyCode == 60 || window.event.keyCode == 62 || window.event.keyCode == 91 || window.event.keyCode == 93) {
    window.event.keyCode = 0;
    _ret = false;
    }
    }
    if (isNS) {
    if (e.which == 60 || e.which == 62 || e.which == 91 || e.which == 93) {
    e.which = 0;
    _ret = false;
    }
    }
    return (_ret); 
}
