﻿function BeforeClickHandler(node)
{
   if (node.Parent == null) 
   {
      if ( node.Expanded ) node.Collapse();
      else node.Expand();
      return false;
   }    
}
function KeyDownHandler(btn)
{
   // process only the Enter key
   if (event.keyCode == 13)
   {
	   // cancel the default submit
	   event.returnValue=false;
	   event.cancel = true;
	   // submit the form by programmatically clicking the specified button
	   __doPostBack(btn, '');
   }
}
function WindowHeight()
{
  if( typeof( window.innerHeight ) == 'number' ) 
     return( window.innerHeight ); //Non-IE
  else if( document.documentElement && ( document.documentElement.clientHeight ) ) 
     return( document.documentElement.clientHeight );
  else
     return( document.body.clientHeight );
}
function WindowWidth()
{
  if( typeof( window.innerWidth ) == 'number' ) 
     return( window.innerWidth ); //Non-IE
  else if( document.documentElement && ( document.documentElement.clientWidth ) ) 
     return( document.documentElement.clientWidth );
  else
     return( document.body.clientWidth );
}
function FindStyle( stylename )
{
   if ( document.styleSheets[0].cssRules != undefined )
   {
      for( var i=0; i<document.styleSheets.length; i++ )
      {
         for( var j=0; j<document.styleSheets[i].cssRules.length; j++ )
            if ( document.styleSheets[i].cssRules[j].selectorText == stylename )
               return( document.styleSheets[i].cssRules[j] );
      }
   }
   else
   {
      for( var i=0; i<document.styleSheets.length; i++ )
      {
         for( var j=0; j<document.styleSheets[i].rules.length; j++ )
            if ( document.styleSheets[i].rules[j].selectorText == stylename )
               return( document.styleSheets[i].rules[j] );
      }
   }
   return( null );
}
function OnResize() {
   if (document.getElementById("PageHeader") == null)
      return;

   var nContentHeight = WindowHeight() - (document.getElementById("CompanyHeader").offsetHeight + document.getElementById("PageHeader").offsetHeight + document.getElementById("SpeediARMS").offsetHeight + 20);

   var nWidth    = WindowWidth();
   var styleBody = FindStyle( ".StyleBody" );
   var styleContainer = null;
   
   if ( navigator.appVersion.indexOf("Safari") == -1 )
      styleContainer = FindStyle( "#ContentContainer" );
   else
      styleContainer = FindStyle( '*[ID"ContentContainer"]' );
   
   // Fix for IE Bug, Non-IE works fine so no need for value
   if ( navigator.appVersion.indexOf("MSIE") == -1 && styleContainer != null )
      styleContainer.style.marginTop = "0px";
   
   if( styleBody != null )             
      nWidth = parseInt(styleBody.style.width);
   
   if ( window.uc_JobBrowser_splitMain  )
   {
      if ( !uc_JobBrowser_splitMain.Loaded )
      {
         setTimeout('OnResize()', 50);
         return;
      }

      uc_JobBrowser_splitMain.Height = nContentHeight;
      uc_JobBrowser_splitMain.Width = nWidth;
      
      if ( uc_JobBrowser_splitMain.Height < 0 )
         uc_JobBrowser_splitMain.Height = 1;
      uc_JobBrowser_splitMain.OuterDomObj.style.width = uc_JobBrowser_splitMain.Width + "px";
      uc_JobBrowser_splitMain.OuterDomObj.style.height = uc_JobBrowser_splitMain.Height + "px";
      uc_JobBrowser_splitMain.AssignPaneHeights(uc_JobBrowser_splitMain.Panes, uc_JobBrowser_splitMain.Height, true);
      uc_JobBrowser_splitMain.SetWidth( uc_JobBrowser_splitMain.Panes[1], nWidth - (uc_JobBrowser_splitMain.Panes[0].Width+uc_JobBrowser_splitMain.Panes.SplitterBarWidth), true);
      
      var divJob = document.getElementById('divJobDesc');
      if ( divJob != null  && uc_JobBrowser_splitMain.Height > 36 )
      {
         divJob.style.height = (uc_JobBrowser_splitMain.Height-36) + "px";
      }
   }
   else if( document.getElementById('divCandidateInfo') != null )
   {
      if ( nContentHeight > 36 )
          document.getElementById('divCandidateInfo').style.height = (nContentHeight-30) + "px";
      document.getElementById('divCandidateInfo').style.width = (nWidth-15) + "px";
   }
}

function CheckboxSelected(EditID, ChkID)
{
   var dtedit = igedit_getById(EditID);
   var bchecked = document.getElementById(ChkID).checked;

   if ( dtedit )        
      dtedit.setVisible( !bchecked );
}

function SetCheckbox(EditID, ChkID)
{
   document.getElementById(ChkID).status = true;
   CheckboxSelected(EditID, ChkID);
}



