/*
  Specialized overlib functions for the SCSG-web.
  Author Sveinn S. Erlendsson - Habilis ehf
*/

/*Collect window sizes for popup windows*/ 
var skwidth   = screen.width;
var skheight  = screen.height;
var winheight = skheight - 96;
var winwidth  = skwidth;
var winwidthw = skwidth;
var winwidthv = skwidth;
 if (winwidth >= 850)
   winwidth = 850;
 if (winwidthw >= 950)
   winwidthw = 950;
 if (winheight >= 900)
   winheight = 900;
 if (winwidthv >= 1050)
   winwidthv = 1050;
var wintop  = (skheight - 96 - winheight) / 2;    
var winleft = (skwidth - winwidth) / 2;
var winleftw = (skwidth - winwidthw) / 2;
var winlefth = (skwidth - winwidthv) / 2;

/*overlib defaults*/
var SCSG_overDIV = 'overlibDIV';
var SCSG_overheader = '<div id="'+SCSG_overDIV+'" style="font-size:12px;">';
var SCSG_overfooter = '</div>';

var SCSG_txtWait = '<h2>Please wait..</h2>'
/*var SCSG_txtWait = document.aspnetForm.ctl00_plswait.value;*/
var SCSG_iheader = SCSG_overheader+'<iframe src=';
var SCSG_ifooter = '</iframe>'+SCSG_overfooter;
 var cntlist = ''; /* global variable for buildselectionvaluelist_cnt */

function loadPlsWait(loadText){
SCSG_txtWait=loadText;
}

/*Selection functions*/
function BuildSelectionValueList(formname,fldname){
  var selectionlist = '';
  var selectioncnt = 0;
  frmname = eval('document.'+formname);
  fldlen = fldname.length; 
  for (var i = 0; i < frmname.elements.length; i++) {
    if((frmname.elements[i].type == 'checkbox') && (frmname.elements[i].name.substring(0,fldlen) == fldname)){
      if (frmname.elements[i].checked) {
        if (selectioncnt > 0) {
          selectionlist = selectionlist+',';
        }
        selectionlist = selectionlist+frmname.elements[i].value;
        selectioncnt = selectioncnt+1;
      }  
    }
  }
  return selectionlist;
}
function BuildSelectionValueList_Cnt(formname,fldname){
  
  var selectionlist = '';
  cntlist = '';
  var selectioncnt = 0;
  frmname = eval('document.'+formname);
  fldlen = fldname.length; 
  for (var i = 0; i < frmname.elements.length; i++) {
    if((frmname.elements[i].type == 'checkbox') && (frmname.elements[i].name.substring(0,fldlen) == fldname)){
      if (frmname.elements[i].checked) {
        if (selectioncnt > 0) {
          selectionlist = selectionlist+',';
          cntlist = cntlist+','; 
        }
        pos = frmname.elements[i].value.indexOf(";");
       
        cntlist = cntlist +frmname.elements[i].value.substr(pos+1);
        selectionlist = selectionlist+frmname.elements[i].value.substr(0,pos);
        selectioncnt = selectioncnt+1;
      }  
    }
  }
  return selectionlist;
}
/* Toggle all checkboxes in form with name beginning with fieldname */
function ToggleSelection(formname,fldname){
  frmname = eval('document.'+formname);
  fldlen = fldname.length; 
  for (var i = 0; i < frmname.elements.length; i++) {
    if((frmname.elements[i].type == 'checkbox') && (frmname.elements[i].name.substring(0,fldlen) == fldname)){
      frmname.elements[i].checked = !(frmname.elements[i].checked);
    }
  }
  return true;
}
/*Check if at least one checkbox in form beginning with fldname is checked or not*/
function CheckBoxSelected(formname,fldname){
  frmname = eval('document.'+formname);
  fldlen = fldname.length; 
  isChecked = false;
  for (var i = 0; i < frmname.elements.length; i++) {
    if((frmname.elements[i].type == 'checkbox') && (frmname.elements[i].name.substring(0,fldlen) == fldname)){
      if (frmname.elements[i].checked){
        isChecked = true;
      }
    }
  }
  return isChecked;
}

/*Popup Windows general:*/
function PopupGetCustomer(){
   window.open('SelectCustomerUser.aspx','PopupCustGet','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 10 + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupGetCustomerMulti(UserId){
   window.open('SelectCustomerUser.aspx?MultiUser='+UserId,'PopupCustGetMulti','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 10 + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupGetConDebtor(custId){
   window.open('SelectConDebtor.aspx?CustId='+custId,'PopupCustGet','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 10 + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupGetEmployee(retFunction){
   functionret = '';
   if (retFunction){
     functionret = 'refFunction='+retFunction;
   }  
   window.open('EmployeeSearch.aspx?'+functionret,'PopupEmpGet','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 10 + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupReceiveOriginals(BookNo,retFunction){
   functionret = '';
   if (retFunction){
     functionret = '&refFunction='+retFunction;
   }  
   window.open('ReceiveOriginals.aspx?Popup=1&BookNo='+BookNo+functionret,'PopupROriginals','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupSetBookDeliveryDate(BookNo,retFunction){
   functionret = '';
   if (retFunction){
     functionret = '&refFunction='+retFunction;
   }  
   window.open('ReceiveOriginals.aspx?Popup=1&BookNo='+BookNo+'&CustClr=ShipDelDate'+functionret,'PopupSetDeliveryDate'+BookNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupSetRequestDeliveryDate(RequestNo,retFunction){
   functionret = '';
   if (retFunction){
     functionret = '&refFunction='+retFunction;
   }  
   window.open('ReceiveOriginals.aspx?Popup=1&ReqNo='+RequestNo+'&CustClr=ReqDelDate'+functionret,'PopupSetDeliveryDate'+RequestNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupCloseTrkMan(RequestNo,retFunction){
   functionret = '';
   if (retFunction){
     functionret = '&refFunction='+retFunction;
   }  
   window.open('ReceiveOriginals.aspx?Popup=1&ReqNo='+RequestNo+'&CustClr=CloseTrkMan'+functionret,'PopupCloseTrkMan'+RequestNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupCustClear(BookNo,retFunction){
   functionret = '';
   if (retFunction){
     functionret = '&refFunction='+retFunction;
   }  
   window.open('ReceiveOriginals.aspx?Popup=1&CustClr=1&BookNo='+BookNo+functionret,'PopupCuClr','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupChangeCustClear(BookNo,retFunction)
{
   functionret = '';
   if (retFunction){
     functionret = '&refFunction='+retFunction;
   }  
   window.open('ReceiveOriginals.aspx?Popup=1&CustClr=2&BookNo='+BookNo+functionret,'PopupCuClr','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupShowSfsInvoice(invRecid,lineId,parentPage){
      xurlstr = 'SFeesViewEdit.aspx?popup=1&InvoiceRecId=' + invRecid + '&ParentPage='+parentPage+'&LineId='+lineId;
      window.open(xurlstr,'inv_'+invRecid,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth  + ',height=' + winheight);
}
function PopupShowSfsInvoiceByNo(invNo){
      xurlstr = 'SFeesViewEdit.aspx?popup=1&InvoiceNo=' + invNo + '&ParentPage=&LineId=0';
      window.open(xurlstr,'invno_'+invNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth  + ',height=' + winheight);
}
function PopupPayment(BookNo,retFunction){
   functionret = '';
   if (retFunction){
     functionret = '&refFunction='+retFunction;
   }  
   window.open('BookingPayment.aspx?Popup=1&BookNo='+BookNo+functionret,'Popuppaym'+BookNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 10 + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupGetPort(retFunction,retFld,countryCode){
   functionret = '';
   fieldret = '';
   countryCoderet = '';
   if (retFunction){
     functionret = 'refFunction='+retFunction;
   }  
   if (retFld){
      fieldret = '&refParm='+retFld;
   }
   
   if(countryCode){
   countryCoderet = '&countryCode='+countryCode;
   }
   window.open('PortSearch.aspx?'+functionret+fieldret+countryCoderet,'PopupPortGet','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 10 + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
} 

function PopupClaimView(damageId){
   window.open('ClaimInfo.aspx?DamageId='+damageId,'PopupViewClaim'+damageId,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 10 + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}

function PopupClaimCreate(BookNo){
   window.open('ClaimCreate.aspx?Popup=1&BookingNo='+BookNo,'PopupNewClaim'+BookNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 10 + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupDomCollection(collectionId){
   window.open('DomForwardReciept.aspx?collectionid='+collectionId,collectionId,'width=980,height=900,toolbar=0,menubar=0,scrollbars=yes','_blank');
   return false;
}
function GoConInv(invNo,invDayStr,SCSG,CustId){
   window.open('http://jokull.samskip.is/php/con.php?DebOneInvoice.jsp?'+invNo+'&'+invDayStr+'&SCSG='+SCSG+'&SCSGCustId='+CustId,'ConInv_'+invNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=700,innerwidth=700,height=' + winheight + ',innerheight=' + winheight);
   return false;
}
/* Popup windows for bookings */
function MultiBookPrint(booklist,action){
   window.open('MultiBookPrint.aspx?BookNos='+booklist+'&BookAction='+action,'MultiBookPrint','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + '+20,width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function Book_Invoices(BookNo){
   window.open('BookingInvoices.aspx?BookNo='+BookNo,'PrInv'+BookNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + '+10,width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function MultiBookRequestCreate(booklist,action){
   window.open('AddBookingInQuiry.aspx?BookNos='+booklist+'&RequestType='+action,'MultiBookRequestCreate','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}

function MultiBookRequestCreateForward(booklist, action){
    
   window.open('AddBookingInQuiry.aspx?BookNos='+booklist+'&CntNo='+ cntlist + '&RequestType='+action,'MultiBookRequestCreate','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 10 + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function BookRequestCreate(bookno,action){
   window.open('AddBookingInQuiry.aspx?BookNo='+bookno+'&RequestType='+action,'SingleBookRequestCreate','toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 5 + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function booking(booking){
   window.open('BookingInfo.aspx?BookNo='+booking,'Book_'+booking,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + 5 + ',left=' + winleftw + ',width=' + winwidthw + ',innerwidth=' + winwidthw + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function booking_con_shm(bookno,SCSG,CustId){
   window.open('http://jokull.samskip.is/php/con.php?ShowBookings.jsp?BookNo='+bookno+'&Pop=1&SCSG='+SCSG+'&SCSGCustId='+CustId,'CBo_'+bookno,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=700,innerwidth=700,height=' + winheight + ',innerheight=' + winheight);
   return false;
}

function CrtReqUrlXal(cntno,dfrom,dto,SCSG,CustId){
   window.open('http://jokull.samskip.is/php/con.php?ContEmptyRetrive2.jsp?CntNo='+cntno+ '&DFrom=' +dto  + '&DTo=' + dfrom  + '&Pop=1&SCSG='+SCSG+'&SCSGCustId='+CustId,'CBr_'+ dfrom ,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=700,innerwidth=700,height=' + winheight + ',innerheight=' + winheight);
   return false;
}

function GoConDomShm(bookno,SCSG,CustId){
   window.open('http://jokull.samskip.is/php/con.php?DomShmView.jsp?'+bookno+'&Pop=1&SCSG='+SCSG+'&SCSGCustId='+CustId,'CDs_'+bookno,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=700,innerwidth=700,height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function GoConAction(bookno,SCSG,CustId){
   window.open('http://jokull.samskip.is/php/con.php?InsShipmentsActions.jsp?'+bookno+'&Pop=1&SCSG='+SCSG+'&SCSGCustId='+CustId,'CDs_'+bookno,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=700,innerwidth=700,height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function GoConBL(bookno,SCSG,CustId){
   window.open('http://jokull.samskip.is/php/con.php?InsShmBillOfLading.jsp?'+bookno+'&Pop=1&SCSG='+SCSG+'&SCSGCustId='+CustId,'CDs_'+bookno,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=700,innerwidth=700,height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function GoConDrvReq(bookno,SCSG,CustId){
   window.open('http://jokull.samskip.is/php/con.php?ShowDriveReq.jsp?'+bookno+'&Pop=1&SCSG='+SCSG+'&SCSGCustId='+CustId,'CDs_'+bookno,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=700,innerwidth=700,height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function invoice(invrecid){
   //window.open('InvDispService.aspx?InvRecId='+invrecid,'Inv_'+invrecid,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   window.open('MultiBookPrint.aspx?BookNos='+invrecid+'&BookAction='+'Invoices','MultiBookPrint_'+invrecid,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + '+20,width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function invoiceNo(invno){
   window.open('InvDispService.aspx?InvId='+invno,'Inv_'+invno,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PopupRequest(requestNo){
   window.open('DisplayBookingInquiry.aspx?ReqNo='+requestNo,'Req_'+requestNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth  + ',height=' + winheight);
   return false;
}

function PopupPartialPickUp(BookingNo, cl_position){
   window.open('PartialPickUp.aspx?BookingNo=' + BookingNo + '&cl_position=' + cl_position ,'Book_'+BookingNo,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth  + ',height=' + winheight);
   return false;
}
function PopupReceipt(ReceiptRecId){
   window.open('Receipe.aspx?RecId='+ReceiptRecId,'Rec_'+ReceiptRecId,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth  + ',height=' + winheight);
   return false;
}

function HelpPopup(helpid,helploc){
   window.open('http://www.habil.is/lix/adjalta?PageDisp='+helpid+'&sysl&'+helploc,'hlp_'+helpid,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth  + ',height=' + winheight);
   return false;
}
function container(cntno){
   window.open('CntSrcByNo.aspx?CntNo='+cntno,'Cnt_'+cntno,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winlefth + ',width=' + winwidthv + ',innerwidth=' + winwidthv + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function ArrivalNotice(booking){
   window.open('BookingInfo.aspx?BookNo='+booking,'AR_'+booking,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function DepartureNotice(booking){
   window.open('BookingInfo.aspx?BookNo='+booking,'DP_'+booking,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function BillOfLading(booking){
   window.open('BookingInfo.aspx?BookNo='+booking,'BL_'+booking,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PDFPrint_Book(pType,booking){
   winid = booking;
   if (winid.indexOf(',') >= 0)
     winid = '';
   window.open('DorisDispBookPDF.aspx?PrintAction='+pType+'&BookNos='+(booking),pType+'_'+winid,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function PDFPrint_Invoice(pType,invoice){
   winid = invoice;
   //if (invoice.indexOf(',') >= 0)
   //  winid = '';
   window.open('DispInvoicePDF.aspx?PrintAction='+pType+'&InvNos='+(invoice),pType+'_'+winid,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function MultiAccSetup(userid) {
   window.open('MultiAccSetup.aspx?UserId='+userid,'MAS_'+userid,'toolbar=no,scrollbars=1,status=1,menubar=1,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
   return false;
}
function svarboxOpen() {
   window.open('http://svarbox.teljari.is/?c=1041','svarbox','toolbar=no,scrollbars=0,status=1,menubar=0,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + 580 + ',innerwidth=' + 580 + ',height=' + 555 + ',innerheight=' + 555);
}

function applyAccount() {
   window.open('http://www.samskip.is/media/annad/notendasamningur.pdf ','applySamskip','toolbar=no,scrollbars=0,status=1,menubar=0,resizable=1,top=' + wintop + ',left=' + winleft + ',width=' + winwidth + ',innerwidth=' + winwidth + ',height=' + winheight + ',innerheight=' + winheight);
}

/* Popup divs for booking info (Iframe/Ajax)*/
function OVIExchange(amt,code){
  popupPath = 'ExchRatePopup.aspx?ExchCode='+code+'&ExchAmt='+amt;
  OVA(popupPath,200,360);
  return true;
}
function OVIVoyage(voyno){
  popupPath = 'VoyagePopUp.aspx?VoyNo='+voyno;
  OVA(popupPath,240,475);
  return true;
}
function OVIBookPortsI(bookingno){
  popupPath = 'BookingLocPopup.aspx?BookNo='+bookingno;
  OVA(popupPath,110,240);
  return true;
}
function OVIBookPorts(bookingno){
  popupPath = 'BookingLocPopup.aspx?BookNo='+bookingno;
  OVA(popupPath,140,320);
  return true;
}
function OVIBookAddr(bookingno){
  popupPath = 'BookingAddrPopup.aspx?BookNo='+bookingno;
  OVA(popupPath,280,320);
  return true;
}
function OVIBookGoods(bookingno){
  popupPath = 'BookingGoodsPopup.aspx?BookNo='+bookingno;
  OVA(popupPath,280,300);
  return true;
}
function OVIBookLineUnits(bookingno,lineno){
  popupPath = 'BookingDimPopup.aspx?BookNo='+bookingno+'&LineNo='+lineno;
  OVA(popupPath,70,300);
  return true;
}

function OVIPrintMenu(bookingno){
  popupPath = 'BookingPrintmenuPopup.aspx?BookNo='+bookingno;
  OVA_ST(popupPath,100,200);
  return true;
}
function OVIActionMenu(bookingno){
  popupPath = 'BookingActionmenuPopup.aspx?BookNo='+bookingno;
  OVA_ST(popupPath,100,224);
  return true;
}
function OVIActionMenuEmp(bookingno){
  popupPath = 'BookingActionmenuPopup.aspx?BookNo='+bookingno;
  OVA_ST(popupPath,165,224);
  return true;
}
function OVIDomActionMenu(collectionId){
  popupPath = 'BookingActionmenuPopup.aspx?CollId='+collectionId;
  OVA_ST(popupPath,100,224);
  return true;
}
function OVIHistMemo(recid){
  popupPath = 'MemoPopup.aspx?DataId=HMemo&RecId='+recid;
  OVA_ST(popupPath,250,250);
  return true;
}
function OVIRquestMemo(recid){
  popupPath = 'MemoPopup.aspx?DataId=RMemo&RecId='+recid;
  OVA_ST(popupPath,250,250);
  return true;
}
function OVIUserInfo(userid){
  popupPath = 'UserInfoPopUp.aspx?UserId='+userid;
  OVA_ST(popupPath,180,320);
  return true;
}
function OVISSNInfo(SSN,AltTitle){
  popupPath = 'SSNInfoPopUp.aspx?SSN='+SSN+'&SSNTitle='+AltTitle;
  OVA_ST(popupPath,180,80);
  return true;
}

function OVIPartialDelivery(Booknr, cl_position){
  popupPath = 'PartialPickUp.aspx?BookingNo=' + Booknr +'&cl_position='+cl_position;
  OVA_ST(popupPath,250,250);
  return true;
}



/*General overlib setup functions:*/
function OVT(txt){
  ot = SCSG_overheader+txt+SCSG_overfooter;
  overlib(ot,HAUTO,VAUTO,HIDESELECTBOXES,WIDTH,50,FGCOLOR,'#FFFFEE',BASE,2,SHADOW,SHADOWX,3,SHADOWY,3);
}

/*Iframe popup*/
function OVI(src,ht,wt){
  ot = SCSG_iheader+'"'+src+'" id="ioverFrame" WIDTH="'+wt+'" HEIGHT="'+ht+'" scrolling="no" frameBorder="0" border="0" marginwidth="0" marginheight="0">'+SCSG_ifooter;
  overlib(ot,HAUTO,VAUTO,HIDESELECTBOXES,WIDTH,wt,HEIGHT,ht,FGCOLOR,'#FFFFEE',BASE,2,SHADOW,SHADOWX,3,SHADOWY,3,DELAY,700);
}
function OVI_ST(src,ht,wt){
  ot = SCSG_iheader+'"'+src+'" id="ioverFrame" WIDTH="'+wt+'" HEIGHT="'+ht+'" scrolling="no" frameBorder="0" border="0" marginwidth="0" marginheight="0">'+SCSG_ifooter;
  overlib(ot,HAUTO,VAUTO,HIDESELECTBOXES,WIDTH,wt,HEIGHT,ht,FGCOLOR,'#FFFFEE',BASE,2,SHADOW,SHADOWX,3,SHADOWY,3,DELAY,700,STICKY,MOUSEOFF,TIMEOUT,2000);
}
function OVIOut(){
  frameid = document.getElementById('ioverFrame');
  if (frameid){
    //frameid.style.visibility="hidden";
    frameid.style.display = "none";
  }
  nd();
  return true;
} 

/*Popup - Ajax handling functions */
var SCSG_PopupModeNotifyUrl = '&DispMode=DIV';
var SCSG_PopupDivCnt = 0;
var SCSG_dispfunction = function(){};
var SCSG_ServerErrorsToMaster = true;

    function SCSG_PopupDivcontentStripper_Pure(html){
      startertxt = '<div id="starter"></div>';
      stoppertxt = '<div id="stopper"></div>';
       startpos = html.indexOf(startertxt);
       if (startpos >= 0){
         startpos+=startertxt.length;
       }else{
         startpos = 0;
       }  
       stoppos = html.indexOf(stoppertxt)+0;
       if (stoppos <= 0){
         stoppos = html.length;
       }
       //Debug routine to display errors on master page bottom
       if (SCSG_ServerErrorsToMaster && html.indexOf('Server Error') > 0){
          //alert(html.substring(startpos,stoppos));
          errordivid = document.getElementById('masterErrorDiv');
          if (errordivid) {
           errordivid.innerHTML = html.substring(startpos,stoppos);
          }
       }
       return html.substring(startpos,stoppos);
    }
    function SCSG_PopupDivcontentStripper(html){
       return '<div class="ccPopupDivOutline">'+SCSG_PopupDivcontentStripper_Pure(html)+'</div>';
    }
    
    function SCSG_PopupAjaxLoader(url,divname){
          var xmlhttp=false;
          try {
            xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
          } catch (e) {
            try { xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); } catch (E) { xmlhttp = false; }
          }
          if(!xmlhttp) {xmlhttp=new XMLHttpRequest(); }
       xmlhttp.open('GET',url, true);
       evaltxt = 'xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState==4) { divid = document.getElementById(\''+divname+'\'); if (divid){divid.innerHTML = SCSG_PopupDivcontentStripper(xmlhttp.responseText);}else{nd();}}}';
       eval(evaltxt);
       xmlhttp.send(null);
    }

/*Default Ajax driven layer popup function*/
function OVA(src,ht,wt){
  SCSG_PopupDivCnt = SCSG_PopupDivCnt+1;
  nowDiv = SCSG_overDIV+SCSG_PopupDivCnt;
  ot = '<div id="'+nowDiv+'" class="ccPopupDivOutline">'+SCSG_txtWait+'</div>';
  eval('SCSG_dispfunction = function(){SCSG_PopupAjaxLoader(\''+src+SCSG_PopupModeNotifyUrl+'\',\''+nowDiv+'\');};');
  eval('OL_OnLoadFunction = SCSG_dispfunction;');
  overlib(ot,HAUTO,VAUTO,HIDESELECTBOXES,WIDTH,wt,HEIGHT,ht,FGCOLOR,'#FFFFEE',BASE,2,SHADOW,SHADOWX,3,SHADOWY,3,DELAY,700);
}
function OVA_ST(src,ht,wt){
  SCSG_PopupDivCnt = SCSG_PopupDivCnt+1;
  nowDiv = SCSG_overDIV+SCSG_PopupDivCnt;
  ot = '<div id="'+nowDiv+'" class="ccPopupDivOutline">'+SCSG_txtWait+'</div>';
  eval('SCSG_dispfunction = function(){SCSG_PopupAjaxLoader(\''+src+SCSG_PopupModeNotifyUrl+'\',\''+nowDiv+'\');};');
  eval('OL_OnLoadFunction = SCSG_dispfunction;');
  overlib(ot,HAUTO,VAUTO,HIDESELECTBOXES,WIDTH,wt,HEIGHT,ht,FGCOLOR,'#FFFFEE',BASE,2,SHADOW,SHADOWX,3,SHADOWY,3,DELAY,700,STICKY,MOUSEOFF,TIMEOUT,3000);
}

function OVAOut(){
  nd();
  return true;
}
//alert('OK?');

function roundedPanels(){
 var isIE     = navigator.userAgent.toLowerCase().indexOf("msie") > -1;
 if(isIE)
 {
   legendRoundSettings = {
      tl: { radius: 3 },
      tr: { radius: 3 },
      bl: { radius: 3 },
      br: { radius: 3 },
      antiAlias: true,
      autoPad: false,
      validTags: ["legend"]
    } 
    
     fieldsetRoundSettings = {
      tl: { radius: 10 },
      tr: { radius: 10 },
      bl: { radius: 10 },
      br: { radius: 10 },
      antiAlias: true,
      autoPad: true,
      validTags: ["fieldset","div"]
    } 
   node = document;
   var els = node.getElementsByTagName("LEGEND");
   var elsLen = els.length;
   
   for (i = 0; i < elsLen; i++)
   {
   els[i].className ="legend";
   } 
   
   var els = node.getElementsByTagName("FIELDSET");
   var elsLen = els.length;
   
   for (i = 0; i < elsLen; i++)
   {
   els[i].className ="fieldset";
   }
   
   var cornersObj = new curvyCorners(legendRoundSettings, "legend"); 
   cornersObj.applyCornersToAll();
   
   var cornersObjFD = new curvyCorners(fieldsetRoundSettings, "fieldset"); 
   cornersObjFD.applyCornersToAll();
   
   //var cornersObjPanel = new curvyCorners(fieldsetRoundSettings, "panel"); 
   //cornersObjPanel.applyCornersToAll();
 }
}

function rounddiv()
{
var isIE     = navigator.userAgent.toLowerCase().indexOf("msie") > -1;
 if(isIE)
 {
    fieldsetDivSettings = {
      tl: { radius: 10 },
      tr: { radius: 10 },
      bl: { radius: 10 },
      br: { radius: 10 },
      antiAlias: true,
      autoPad: true,
      validTags: ["div"]
    } 

   var cornersObjDiv = new curvyCorners(fieldsetRoundSettings, "ccBigPopupOutline"); 
   cornersObjDiv.applyCornersToAll();

}
}



/*Resizer-function from Eiki */		
		function Is() {
    	var agent   = navigator.userAgent.toLowerCase();
    	this.major  = parseInt(navigator.appVersion);
    	this.minor  = parseFloat(navigator.appVersion);
    	this.ns     = ((agent.indexOf('mozilla')   != -1) &&
              	    (agent.indexOf('spoofer')    == -1) &&
            	      (agent.indexOf('compatible') == -1) &&
          	        (agent.indexOf('opera')      == -1) &&
        	          (agent.indexOf('webtv')      == -1));
    	this.ns4    = (this.ns && (this.major      ==  4));
    	this.ns6    = (this.ns && (this.major      >=  5));
    	this.ie     = (agent.indexOf("msie")       != -1);
    	this.ie3    = (this.ie && (this.major      <   4));
    	this.ie4  	= (this.ie && (this.major >= 4));
    	this.ie5    = (this.ie && (this.major      ==  4) &&
      	            (agent.indexOf("msie 5.0")   != -1));
    	this.ieX    = (this.ie && !this.ie3 && !this.ie4);
		}		
		
		
		var is = new Is();
		
		/* ****  Þegar síðan er stækkuð og cssið passar upp á að web_wrapperinn fari ekki yfir ákveðin stærð þá verður að, centera web_wrapperinn upp á nýtt *****/
  	function Resize() {	
  	    obj = null;
  	    sobj = null;
  		/* SKIP FOR IIS does not handle to well...
		if (is.ie5){
			obj = document.getElementById('web_wrapper');  					
			sobj = document.getElementById('web_wrapper').style;	
		} else 
		if(is.ie4) {
			obj = document.all['web_wrapper'];
			sobj = document.all['web_wrapper'].style;
		} else 
					*/	
				
		if (is.ns6){
			obj = document.getElementById('web_wrapper');  					
			sobj = document.getElementById('web_wrapper').style;	
		}else if(is.ns4) {
			obj = document.layers['web_wrapper'];
			sobj = document.layers['web_wrapper'];
		}
		if ((obj != null) && (sobj != null))  {			
			sobj.marginLeft=parseInt((document.body.clientWidth/2)-(obj.scrollWidth/2))+'px';  		

	    }
   } 
   /* ********************************************/
   /* Some Div manipulation and stripper classes */
   /* ********************************************/
   function showhideDiv(refID,show) {
    //get a reference as above ...
    if( !refID ) {
        return false; //don't go any further
    }
    if( refID.style ) { //DOM & proprietary DOM
        if (show) {
          refID.style.visibility = 'visible';
          refID.style.display = 'block';
        }else{
          refID.style.visibility = 'hidden';
          refID.style.display = 'none';
        }  
    } else {
        if( refID.visibility ) { //Netscape
            if (show) {
              refID.visibility = 'show';
            }else{
              refID.visibility = 'hide';
            }  
        } else {
            return false; //don't go any further
        }
    }
    return true;
   }
   function resizetoDiv(refId,width,height){
    var noPx = document.childNodes ? 'px' : 0;
     refStyle = refId.style ? refId.style : refId;
     if( refStyle.resizeTo ) {
      refStyle.resizeTo( width, height ); 
     }
     refStyle.width = width + noPx; refStyle.pixelWidth = width;
     refStyle.height = height + noPx; refStyle.pixelHeight = height;
     return true;
   }
   function autosizeDiv(refId){
     refStyle = refId.style ? refId.style : null;
     if (refStyle){
       refStyle.widht = 'auto';
       refStyle.height = 'auto';
     }
   }
   function rewriteDiv(refId,txt){
    if( typeof( refId.innerHTML ) != 'undefined' ) {
      refId.innerHTML = txt;
    } else {
      if( refId.document && refId.document != window.document ) {
        refId.document.open();
        refId.document.write(txt);
        refId.document.close();
      } else {
        if( window.frames && window.frames.length && window.frames['nameOfIframe'] ) {
          refId = window.frames['nameOfIframe'].window;
          refId.document.open();
          refId.document.write(txt);
          refId.document.close();
        }
      }
    }
    return true;
  }
  function movetoDiv(refId,left,top){
    var noPx = document.childNodes ? 'px' : 0;
    refStyle = refId.style ? refId.style : refId;
    refStyle.left = ( parseInt(left) ) + noPx;
    refStyle.top = ( parseInt(top)) + noPx;
    return true;
  }

  function getleftDiv(refId){
    refStyle = refId.style ? refId.style : refId;
    return refStyle.left;
  }

  function gettopDiv(refId){
    refStyle = refId.style ? refId.style : refId;
    return refStyle.top;
  } 
  
  function getRefToDiv(divID,oDoc) {
    if( !oDoc ) { oDoc = document; }
    if( document.layers ) {
        if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
            //repeatedly run through all child layers
            for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
                //on success, return that layer, else return nothing
                y = getRefToDiv(divID,oDoc.layers[x].document); }
            return y; } }
    if( document.getElementById ) {
        return document.getElementById(divID); }
    if( document.all ) {
        return document.all[divID]; }
    return false;
  }
  
  //Habil extended
  function hab_hidelayer(lid){
    lay = getRefToDiv(lid);
    if (lay)
      showhideDiv(lay,false);
  }
  function hab_showlayer(lid){
    lay = getRefToDiv(lid);
    if (lay)
      showhideDiv(lay,true);
  }

 /**********************************************/
 /* Handling AJAX provided content using native routines*/
 /* ********************************************/
   
   /*Stripping headers and footers from scsg-like popup content*/
   function scsg_contentStripper(html){
      startertxt = '<div id="starter"></div>';
      stoppertxt = '<div id="stopper"></div>';
      //alert('my html: '+html);
       startpos = html.indexOf(startertxt);
       if (startpos >= 0){
         startpos+=startertxt.length;
       }else{
         startpos = 0;
       }  
       if (startpos > 0) {
         stoppos = html.indexOf(stoppertxt)+0;
         if (stoppos <= 0){
           stoppos = html.length;
         }
         return html.substring(startpos,stoppos);
       }else{
          return 'Error retreiving AJAX !';  
       }   
    }


 /**********************************************/
 /* Create Export bookings infragistics Ultra gridview functions*/
 /* ********************************************/

    /* function for onchange in infragistics grid*/
    
/**********************************************/
/* Shipment Search cheks */
/* ********************************************/

// shipment search


function parseFloatLang(value)
{

}

/**********************************************/
/* Scripts provided by Jeff Gordon for disabeling buttons in forms */
/* ********************************************/
// Keys to be disabled can be added to the lists below.
// The number is the key code for the particular key
// and the text is the description displayed in the
// status window if the key [combination] is pressed.

var badKeys = new Object();
badKeys.single = new Object();
badKeys.single['8'] = 'Backspace outside text fields';
badKeys.single['13'] = 'Enter';
//badKeys.single['116'] = 'F5 (Refresh)';
badKeys.single['122'] = 'F11 (Full Screen)';

badKeys.alt = new Object();
badKeys.alt['37'] = 'Alt+Left Cursor';
badKeys.alt['39'] = 'Alt+Right Cursor';

badKeys.ctrl = new Object();
badKeys.ctrl['78'] = 'Ctrl+N';
badKeys.ctrl['79'] = 'Ctrl+O';

var badKeysAllowUndefined = false; //if undefined position enter will be blocked (set to true if page contains webhtmleditor)

function bK_checkKeyCode(type, code) {
if (badKeys[type][code]) {
return true;
} else {
return false;
}
}
function bK_getKeyText(type, code) {
return badKeys[type][code];
}

var bK_ie=document.all;
var bK_w3c=document.getElementById&&!document.all;

function bK_keyEventHandler(evt) {
this.target = evt.target || evt.srcElement;
this.keyCode = evt.keyCode || evt.which;
var targtype = this.target.type;
if (bK_w3c) {
if (document.layers) {
this.altKey = ((evt.modifiers & Event.ALT_MASK) > 0);
this.ctrlKey = ((evt.modifiers & Event.CONTROL_MASK) > 0);
this.shiftKey = ((evt.modifiers & Event.SHIFT_MASK) > 0);
} else {
this.altKey = evt.altKey;
this.ctrlKey = evt.ctrlKey;
}
// Internet Explorer
} else {
this.altKey = evt.altKey;
this.ctrlKey = evt.ctrlKey;
}
// Find out if we need to disable this key combination
var badKeyType = 'single';
if (this.ctrlKey) {
badKeyType = 'ctrl';
} else if (this.altKey) {
badKeyType = 'alt';
}
if (bK_checkKeyCode(badKeyType, this.keyCode)) {
return bK_cancelKey(evt, this.keyCode, this.target, bK_getKeyText(badKeyType, this.keyCode));
}
}

function bK_cancelKey(evt, keyCode, target, keyText) {
if (keyCode==8 || keyCode==13) {
  // Don’t want to disable Backspace or Enter in text fields
  // Svaki: actually we do for text-fields:
  //alert(target.type);
  //alert(target.keyText);
  if ((target.type == null && badKeysAllowUndefined) ||
      (target.type == 'password') ||
      (keyCode==8 && (target.type == 'text' || target.type == 'textarea')) ||
      (keyCode==13 && (target.type == 'textarea' || target.type == 'submit' )) 
     ){
    window.status = '';
    return true;
  }  
}
if (evt.preventDefault) {
evt.preventDefault();
evt.stopPropagation();
} else {
evt.keyCode = 0;
evt.returnValue = false;
}
window.status = keyText+' is disabled';
return false;
}

function bK_addEvent(obj, evType, fn, useCapture) {
// General function for adding an event listener
if (obj.addEventListener) {
obj.addEventListener(evType, fn, useCapture);
return true;
} else if (obj.attachEvent) {
var r = obj.attachEvent('on' + evType, fn);
return r;
} else {
alert(evType+' handler could not be attached');
}
}

function bk_addKeyEvent() {
// Specific function for this particular browser
//var e = 'keydown';
//addEvent(document,e,bK_keyEventHandler,false);
}

//Test if we can set this as general event for all pages:
//bk_addKeyEvent();

function getClientLocalTimeOffset() {
  var now = new Date();
  return now.getTimezoneOffset();
}