//<script language="javascript">

  //-----------------------------------------------
  // 
  //-----------------------------------------------
	function SetFocusToField(field) {
  	if (IsOpera) { field.focus(); field.select();}
  	else { setTimeout("document.forms[0]." + field.name + ".select();", 0); }
	}

  //-----------------------------------------------
  // 
  //-----------------------------------------------
	function SetHeight(obj,h) 
	{ 
		if (this.IsNetscape) 
		{
			if (obj.clip) obj.clip.bottom=h; 
		} else { 
		  obj.style.height=h; 
		}
	}

  //-----------------------------------------------
  // 
  //-----------------------------------------------
	function GetObject(id, doc) 
	{
		var i,x;  
		if (!doc) doc=document; 
		if (!(x=doc[id])&&doc.all) x=doc.all[id]; 
		if (!x && document.getElementById) x=document.getElementById(id); 
		return x;
	}

  //-----------------------------------------------
  // 
  //-----------------------------------------------
	function GetHeight(obj) 
	{ 
		var h=0; 
		if (this.IsNetscape) 
		{ 
			h=(obj.height)? obj.height:obj.clip.height; 
			return h; 
		} 
		h=obj.offsetHeight; 
		return h; 
	}

  //-----------------------------------------------
  // 
  //-----------------------------------------------
  function onMainPageLoad () {
  
  	var oLinkBox = GetObject('tblLinkBox', document);
  	var oMainBox = GetObject('tblMainBox', document);
  	
    if (oLinkBox && oMainBox){
    
      var hLnk = GetHeight(oLinkBox);
      var hMain = GetHeight(oMainBox);
      
      var hTmp = hMain;
      if ( hLnk > hMain ) { hTmp = hLnk; }
      SetHeight(oMainBox, hTmp);
      SetHeight(oLinkBox, hTmp);
      
      // table content on main page
      if (curPage.indexOf("customerhome.asp") > 0) {
        var hHead = GetHeight(GetObject('tblContUpperPart', document));
        SetHeight(GetObject('divSRListFrame', document), hTmp - hHead);
      }
    }

    // start action if passed to the page
    if (curPage.indexOf("srstatus.asp") > 0) {
      window.setTimeout('startDetailAction();', 300);
    }
    
  }
 
  //-----------------------------------------------
  // start detail action
  //-----------------------------------------------
  function startDetailAction() {
  
	  var mainform = window.document.forms[0];
	  if (document.all("reqid") == null) return false;	 // if not available - quit 
    var woid = mainform.reqid.value;	  
    
    if (g_actid == 'vercomp'){
	    g_actid = '';
      addNewRatingSelector(woid);  
    }
    
    if (g_actid == 'onapprove'){
	    g_actid = '';
	    
	    var statusid = mainform.statusid.value;
	    var EstimateAmount = mainform.hidEstimateAmount.value;
	    var apprNoBill = mainform.hidapprNoBill.value;
	    var accNTEValue = mainform.hidaccNTEValue.value;
      	    
      // allow to enter approval of WO if NTE < Max approval value or contact is allowed to for all
      if ( apprNoBill == '1' || apprNoBill == '0' && parseFloat(accNTEValue) > parseFloat(EstimateAmount)) {
        OnApproveWODialog(woid, statusid, EstimateAmount); 
      }
       
    }
    
  }
  
  //-----------------------------------------------
  // pageButtonLink - CN-36 - warning if service request wizard is going to be intterrupted by action
  //-----------------------------------------------
  function pageButtonLink(link) {
     var page = _lblPageBtnLnk_;
     var pages = "lineitem.asp emergency.asp srdetails.asp apptnew.asp";
     var pos = pages.indexOf(page);
     var woid = _req_WOID_; 
     if ( (pos >= 0 && page != 'apptnew.asp') || (pos >= 0 && page == 'apptnew.asp' && woid == '')) {
	    if (confirm(g_strAreYouSureCRCreate)) {
  	    window.location.href = link;
  	    return true;
	    } else {
	      return false;
	    }
     } else {
  	   window.location.href = link;
  	   return true;
  	 }
  }

//</script>
