﻿
function toggle(element) {
    
    if (document.getElementById) {
        xmain = document.getElementById(element);
    } else {
        xmain = eval('document.all.' + element);
    }
  
  var mainStyle;

  mainStyle = xmain.style.display;

  if (mainStyle == "none") {
     xmain.style.display = "block";
  } else {
     xmain.style.display = "none";
  }
}

function changeDiv(element, disp) {

    var xmain;

    if (document.getElementById) {
        xmain = document.getElementById(element);
    } else {
        xmain = eval('document.all.' + element);
    }
  
  var mainStyle;

  mainStyle = xmain.style.display;

  xmain.style.display = disp;
}

function findDocElement(ElementName) {
    var newObj;
    
   var elem = document.forms[0].elements;
   for (var i = 0; i < elem.length; i++) {
     if (elem[i].id.indexOf(ElementName)>0) {
       newObj = elem[i];
     }
  }
  return newObj;
   

}

function FormatDecimal(num,dec)
{
     dec=Math.pow(10,dec);
     var num=(Math.round(num*dec)/dec) + "";
     var first=num.split(".");
     var tmp=new Array;
     var cnt=0;
     var start=first[0].length % 3;
     if (start) tmp[cnt++]=first[0].substr(0,start);
     for(var i=start;i<first[0].length;i+=3) tmp[cnt++]=first[0].substr(i,3);
     first[0]=tmp.join(",");
     return first.join(".");
}


function openHelp(Path2File) {
    var url;
    var win;
    var pageType
    var height = 500
    var width = 650
    var winl = (screen.width - width) / 2;
    var wint = (screen.height - height) / 2;
    var name = 'HelpSection';
    var windowprops = 'width='+width+',height='+height+',top='+wint+',left='+winl+',toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes';
   
    url = Path2File;
          
    win = window.open(url, name, windowprops);
    win.focus();

}

function ShowInvoice(OrderID) {
    
    var url;
    var win;
    var pageType
    var height = 600
    var width = 650
    var winl = (screen.width - width) / 2;
    var wint = (screen.height - height) / 2;
    var name = 'UserInvoice';
    var windowprops = 'width=' + width + ',height=' + height + ',top=' + wint + ',left=' + winl + ',toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes';

    url = 'Invoice.aspx?order=' + OrderID;

    win = window.open(url, name, windowprops);
    win.focus();

}

function openTermsConditions() {
    var url;
    var win;
    var pageType
    var height = 600
    var width = 650
    var winl = (screen.width - width) / 2;
    var wint = (screen.height - height) / 2;
    var name = 'TermsSection';
    var windowprops = 'width='+width+',height='+height+',top='+wint+',left='+winl+',toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes';
   
    url = 'AgreeToTerms.aspx';
          
    win = window.open(url, name, windowprops);
    win.focus();
  
}