function showhide(id,val)
{
if (val==0) document.getElementById(id).style.display = 'none';
    var browser=navigator.appName
    version=parseFloat(navigator.appVersion);
    if (browser == "Microsoft Internet Explorer"){
        if (val==1) document.getElementById(id).style.display = 'block';
    }else if(browser == "Netscape" && (version >=4.7)){
       if (val==1) document.getElementById(id).style.display = 'table-row';
    }
}

// ADDED FOR SETTING FOCUS ON CLOSE OF POPUP
document.write("<input id='hdnControlToFocus' type='hidden' />");

//added by Veena - for PopUp enable/disable :04/03/2009
//Begin
function toggleAlert(popupdiv,val,controlToFocus) 
    {
        //debugger;
//        document.body.style.overflow=document.body.style.overflow=='hidden'?'':'hidden'
//        document.body.scroll=document.body.scroll=='no'?'auto':'no';
//        var pageheight=window.screen.availHeight;

//height of grey
    
        var browser=navigator.appName;
        var version=navigator.appVersion;
//        
        var innerheight=window.innerHeight;
        var pageHeight=document.body.clientHeight;
        var screenHeight=window.screen.height;
        var hx;
        if(pageHeight>screenHeight)hx=pageHeight+"px";
        else hx=screenHeight+"px";
        if(innerheight>hx)hx=innerheight+"px";
        
        
        
        //width of grey
        var innerwidth=window.innerWidth;
        var pageWidth=document.body.clientWidth;
        var screenWidth=window.screen.width;
        var wx;
        if(pageWidth>screenWidth)wx=pageWidth+"px";
        else wx=screenWidth+"px";
        if(innerwidth>wx)wx=innerwidth+"px";
        
        document.getElementById("BackDrop").style.width=wx;
        
        //if browser is ie6:
        var is_ie6 = (
	        browser=="Microsoft Internet Explorer" && parseFloat(version)<"7"
        );

        if(is_ie6)
        {
            document.getElementById(popupdiv).style.position="absolute";
            document.getElementById(popupdiv).style.zIndex="1200";
            document.getElementById(popupdiv).style.left="50%";
            document.getElementById(popupdiv).style.marginLeft="-30px";
            
            document.getElementById("BackDrop").style.position="absolute";
            document.getElementById("BackDrop").style.height=window.screen.height;
        }
        else
        {
            document.getElementById(popupdiv).style.position="fixed";
            document.getElementById(popupdiv).style.top="50%";
            document.getElementById(popupdiv).style.left="50%";
            document.getElementById(popupdiv).style.marginLeft="-200px";
            document.getElementById(popupdiv).style.marginTop="-75px";
            document.getElementById("BackDrop").style.position="fixed";
            document.getElementById("BackDrop").style.height="100%";
        }
        
        //setfocus height n width of popup
        document.getElementById(popupdiv).style.top=window.screen.height/2-75;
        document.getElementById(popupdiv).style.left=window.screen.width/2;
        showhide("BackDrop",val);
        showhide(popupdiv ,val);
        
        toggleDisabled(document.body,val);
        
        var el=document.getElementById(popupdiv);
        //setfocus and stop tabbing
        if(val=="1")
        {
            setTimeout(function(){setfocus(el,1)},10);
            if (document.getElementById("tab") != null)
            {            
                document.getElementById("tab").value="no";
            }            
        }
        else
        {
            if (document.getElementById("tab") != null)
            { 
                document.getElementById("tab").value="yes";
            }            
        }
        
        if(val=="1" && controlToFocus!=null)
        {
            document.getElementById("hdnControlToFocus").value=controlToFocus;
        }
        if(val=="0" && document.getElementById("hdnControlToFocus").value!="")
        {
            var cntrltohide=document.getElementById("hdnControlToFocus").value;
            document.getElementById(cntrltohide).focus();
            document.getElementById("hdnControlToFocus").value="";
        }
}
    
function NoTab(event)
{
   if (event.keyCode==9 && document.getElementById("tab").value=="no") {
		return false;
	}
}
function setfocus(el)
{
    if(el.tagName=="INPUT")
    {
        el.focus();
    }
    if(el.childNodes && el.childNodes.length>0)
    {
        for (var x = 0; x < el.childNodes.length; x++) 
        {
            setfocus(el.childNodes[x]);
        }
    }
}
    function toggleDisabled(el,val) 
    {
        if(el.tagName=="SELECT")
        {
            try {
                  if(val==0)showhide(el.id,1);
                  else showhide(el.id,0);
                  
                  el.disabled = el.disabled ? false : true;
//                el.disabled? el.style.backgroundColor="Gray" : el.style.backgroundColor="White";
            }
            catch(E){}
        }
        if (el.childNodes && el.childNodes.length > 0) 
        {
            for (var x = 0; x < el.childNodes.length; x++) 
                {
                toggleDisabled(el.childNodes[x],val);
                }
        }

    }

//End

